diff options
author | George Hazan <ghazan@miranda.im> | 2022-09-16 13:18:27 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-09-16 13:18:27 +0300 |
commit | b3dcfac0936aa764ecf0b98b8bfd0112d0c05fe5 (patch) | |
tree | 605afdd77a2dfc06119cca5f7e11bb508d0ff34a /include/google/protobuf/compiler | |
parent | 310e0602b8c4b709d18e93419f9bf5f77c2ffe59 (diff) |
we'd better use vcpkg instead of adding shit to our repo....
Diffstat (limited to 'include/google/protobuf/compiler')
27 files changed, 0 insertions, 6744 deletions
diff --git a/include/google/protobuf/compiler/code_generator.h b/include/google/protobuf/compiler/code_generator.h deleted file mode 100644 index 9c0b115cf1..0000000000 --- a/include/google/protobuf/compiler/code_generator.h +++ /dev/null @@ -1,207 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Defines the abstract interface implemented by each of the language-specific -// code generators. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ - -#include <string> -#include <utility> -#include <vector> -#include <google/protobuf/stubs/common.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -namespace io { -class ZeroCopyOutputStream; -} -class FileDescriptor; -class GeneratedCodeInfo; - -namespace compiler { -class AccessInfoMap; - -class Version; - -// Defined in this file. -class CodeGenerator; -class GeneratorContext; - -// The abstract interface to a class which generates code implementing a -// particular proto file in a particular language. A number of these may -// be registered with CommandLineInterface to support various languages. -class PROTOC_EXPORT CodeGenerator { - public: - inline CodeGenerator() {} - virtual ~CodeGenerator(); - - // Generates code for the given proto file, generating one or more files in - // the given output directory. - // - // A parameter to be passed to the generator can be specified on the command - // line. This is intended to be used to pass generator specific parameters. - // It is empty if no parameter was given. ParseGeneratorParameter (below), - // can be used to accept multiple parameters within the single parameter - // command line flag. - // - // Returns true if successful. Otherwise, sets *error to a description of - // the problem (e.g. "invalid parameter") and returns false. - virtual bool Generate(const FileDescriptor* file, - const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const = 0; - - // Generates code for all given proto files. - // - // WARNING: The canonical code generator design produces one or two output - // files per input .proto file, and we do not wish to encourage alternate - // designs. - // - // A parameter is given as passed on the command line, as in |Generate()| - // above. - // - // Returns true if successful. Otherwise, sets *error to a description of - // the problem (e.g. "invalid parameter") and returns false. - virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const; - - // This must be kept in sync with plugin.proto. See that file for - // documentation on each value. - enum Feature { - FEATURE_PROTO3_OPTIONAL = 1, - }; - - // Implement this to indicate what features this code generator supports. - // - // This must be a bitwise OR of values from the Feature enum above (or zero). - virtual uint64_t GetSupportedFeatures() const { return 0; } - - // This is no longer used, but this class is part of the opensource protobuf - // library, so it has to remain to keep vtables the same for the current - // version of the library. When protobufs does a api breaking change, the - // method can be removed. - virtual bool HasGenerateAll() const { return true; } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator); -}; - -// CodeGenerators generate one or more files in a given directory. This -// abstract interface represents the directory to which the CodeGenerator is -// to write and other information about the context in which the Generator -// runs. -class PROTOC_EXPORT GeneratorContext { - public: - inline GeneratorContext() { - } - virtual ~GeneratorContext(); - - // Opens the given file, truncating it if it exists, and returns a - // ZeroCopyOutputStream that writes to the file. The caller takes ownership - // of the returned object. This method never fails (a dummy stream will be - // returned instead). - // - // The filename given should be relative to the root of the source tree. - // E.g. the C++ generator, when generating code for "foo/bar.proto", will - // generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that - // "foo/" is included in these filenames. The filename is not allowed to - // contain "." or ".." components. - virtual io::ZeroCopyOutputStream* Open(const std::string& filename) = 0; - - // Similar to Open() but the output will be appended to the file if exists - virtual io::ZeroCopyOutputStream* OpenForAppend(const std::string& filename); - - // Creates a ZeroCopyOutputStream which will insert code into the given file - // at the given insertion point. See plugin.proto (plugin.pb.h) for more - // information on insertion points. The default implementation - // assert-fails -- it exists only for backwards-compatibility. - // - // WARNING: This feature is currently EXPERIMENTAL and is subject to change. - virtual io::ZeroCopyOutputStream* OpenForInsert( - const std::string& filename, const std::string& insertion_point); - - // Similar to OpenForInsert, but if `info` is non-empty, will open (or create) - // filename.pb.meta and insert info at the appropriate place with the - // necessary shifts. The default implementation ignores `info`. - // - // WARNING: This feature will be REMOVED in the near future. - virtual io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo( - const std::string& filename, const std::string& insertion_point, - const google::protobuf::GeneratedCodeInfo& info); - - // Returns a vector of FileDescriptors for all the files being compiled - // in this run. Useful for languages, such as Go, that treat files - // differently when compiled as a set rather than individually. - virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output); - - // Retrieves the version number of the protocol compiler associated with - // this GeneratorContext. - virtual void GetCompilerVersion(Version* version) const; - - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); -}; - -// The type GeneratorContext was once called OutputDirectory. This typedef -// provides backward compatibility. -typedef GeneratorContext OutputDirectory; - -// Several code generators treat the parameter argument as holding a -// list of options separated by commas. This helper function parses -// a set of comma-delimited name/value pairs: e.g., -// "foo=bar,baz,moo=corge" -// parses to the pairs: -// ("foo", "bar"), ("baz", ""), ("moo", "corge") -PROTOC_EXPORT void ParseGeneratorParameter( - const std::string&, std::vector<std::pair<std::string, std::string> >*); - -// Strips ".proto" or ".protodevel" from the end of a filename. -PROTOC_EXPORT std::string StripProto(const std::string& filename); - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/command_line_interface.h b/include/google/protobuf/compiler/command_line_interface.h deleted file mode 100644 index e8425508b1..0000000000 --- a/include/google/protobuf/compiler/command_line_interface.h +++ /dev/null @@ -1,464 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Implements the Protocol Compiler front-end such that it may be reused by -// custom compilers written to support other languages. - -#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ -#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ - -#include <cstdint> -#include <map> -#include <memory> -#include <set> -#include <string> -#include <unordered_map> -#include <unordered_set> -#include <utility> -#include <vector> - -#include <google/protobuf/stubs/common.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; // descriptor.h -class DescriptorDatabase; // descriptor_database.h -class DescriptorPool; // descriptor.h -class FileDescriptor; // descriptor.h -class FileDescriptorSet; // descriptor.h -class FileDescriptorProto; // descriptor.pb.h -template <typename T> -class RepeatedPtrField; // repeated_field.h -class SimpleDescriptorDatabase; // descriptor_database.h - -namespace compiler { - -class CodeGenerator; // code_generator.h -class GeneratorContext; // code_generator.h -class DiskSourceTree; // importer.h - -// This class implements the command-line interface to the protocol compiler. -// It is designed to make it very easy to create a custom protocol compiler -// supporting the languages of your choice. For example, if you wanted to -// create a custom protocol compiler binary which includes both the regular -// C++ support plus support for your own custom output "Foo", you would -// write a class "FooGenerator" which implements the CodeGenerator interface, -// then write a main() procedure like this: -// -// int main(int argc, char* argv[]) { -// google::protobuf::compiler::CommandLineInterface cli; -// -// // Support generation of C++ source and headers. -// google::protobuf::compiler::cpp::CppGenerator cpp_generator; -// cli.RegisterGenerator("--cpp_out", &cpp_generator, -// "Generate C++ source and header."); -// -// // Support generation of Foo code. -// FooGenerator foo_generator; -// cli.RegisterGenerator("--foo_out", &foo_generator, -// "Generate Foo file."); -// -// return cli.Run(argc, argv); -// } -// -// The compiler is invoked with syntax like: -// protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto -// -// The .proto file to compile can be specified on the command line using either -// its physical file path, or a virtual path relative to a directory specified -// in --proto_path. For example, for src/foo.proto, the following two protoc -// invocations work the same way: -// 1. protoc --proto_path=src src/foo.proto (physical file path) -// 2. protoc --proto_path=src foo.proto (virtual path relative to src) -// -// If a file path can be interpreted both as a physical file path and as a -// relative virtual path, the physical file path takes precedence. -// -// For a full description of the command-line syntax, invoke it with --help. -class PROTOC_EXPORT CommandLineInterface { - public: - static const char* const kPathSeparator; - - CommandLineInterface(); - ~CommandLineInterface(); - - // Register a code generator for a language. - // - // Parameters: - // * flag_name: The command-line flag used to specify an output file of - // this type. The name must start with a '-'. If the name is longer - // than one letter, it must start with two '-'s. - // * generator: The CodeGenerator which will be called to generate files - // of this type. - // * help_text: Text describing this flag in the --help output. - // - // Some generators accept extra parameters. You can specify this parameter - // on the command-line by placing it before the output directory, separated - // by a colon: - // protoc --foo_out=enable_bar:outdir - // The text before the colon is passed to CodeGenerator::Generate() as the - // "parameter". - void RegisterGenerator(const std::string& flag_name, CodeGenerator* generator, - const std::string& help_text); - - // Register a code generator for a language. - // Besides flag_name you can specify another option_flag_name that could be - // used to pass extra parameters to the registered code generator. - // Suppose you have registered a generator by calling: - // command_line_interface.RegisterGenerator("--foo_out", "--foo_opt", ...) - // Then you could invoke the compiler with a command like: - // protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz - // This will pass "enable_bar,enable_baz" as the parameter to the generator. - void RegisterGenerator(const std::string& flag_name, - const std::string& option_flag_name, - CodeGenerator* generator, - const std::string& help_text); - - // Enables "plugins". In this mode, if a command-line flag ends with "_out" - // but does not match any registered generator, the compiler will attempt to - // find a "plugin" to implement the generator. Plugins are just executables. - // They should live somewhere in the PATH. - // - // The compiler determines the executable name to search for by concatenating - // exe_name_prefix with the unrecognized flag name, removing "_out". So, for - // example, if exe_name_prefix is "protoc-" and you pass the flag --foo_out, - // the compiler will try to run the program "protoc-gen-foo". - // - // The plugin program should implement the following usage: - // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS - // --out indicates the output directory (as passed to the --foo_out - // parameter); if omitted, the current directory should be used. --parameter - // gives the generator parameter, if any was provided (see below). The - // PROTO_FILES list the .proto files which were given on the compiler - // command-line; these are the files for which the plugin is expected to - // generate output code. Finally, DESCRIPTORS is an encoded FileDescriptorSet - // (as defined in descriptor.proto). This is piped to the plugin's stdin. - // The set will include descriptors for all the files listed in PROTO_FILES as - // well as all files that they import. The plugin MUST NOT attempt to read - // the PROTO_FILES directly -- it must use the FileDescriptorSet. - // - // The plugin should generate whatever files are necessary, as code generators - // normally do. It should write the names of all files it generates to - // stdout. The names should be relative to the output directory, NOT absolute - // names or relative to the current directory. If any errors occur, error - // messages should be written to stderr. If an error is fatal, the plugin - // should exit with a non-zero exit code. - // - // Plugins can have generator parameters similar to normal built-in - // generators. Extra generator parameters can be passed in via a matching - // "_opt" parameter. For example: - // protoc --plug_out=enable_bar:outdir --plug_opt=enable_baz - // This will pass "enable_bar,enable_baz" as the parameter to the plugin. - // - void AllowPlugins(const std::string& exe_name_prefix); - - // Run the Protocol Compiler with the given command-line parameters. - // Returns the error code which should be returned by main(). - // - // It may not be safe to call Run() in a multi-threaded environment because - // it calls strerror(). I'm not sure why you'd want to do this anyway. - int Run(int argc, const char* const argv[]); - - // DEPRECATED. Calling this method has no effect. Protocol compiler now - // always try to find the .proto file relative to the current directory - // first and if the file is not found, it will then treat the input path - // as a virtual path. - void SetInputsAreProtoPathRelative(bool /* enable */) {} - - // Provides some text which will be printed when the --version flag is - // used. The version of libprotoc will also be printed on the next line - // after this text. - void SetVersionInfo(const std::string& text) { version_info_ = text; } - - - private: - // ----------------------------------------------------------------- - - class ErrorPrinter; - class GeneratorContextImpl; - class MemoryOutputStream; - typedef std::unordered_map<std::string, std::unique_ptr<GeneratorContextImpl>> - GeneratorContextMap; - - // Clear state from previous Run(). - void Clear(); - - // Remaps the proto file so that it is relative to one of the directories - // in proto_path_. Returns false if an error occurred. - bool MakeProtoProtoPathRelative(DiskSourceTree* source_tree, - std::string* proto, - DescriptorDatabase* fallback_database); - - // Remaps each file in input_files_ so that it is relative to one of the - // directories in proto_path_. Returns false if an error occurred. - bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree, - DescriptorDatabase* fallback_database); - - // Fails if these files use proto3 optional and the code generator doesn't - // support it. This is a permanent check. - bool EnforceProto3OptionalSupport( - const std::string& codegen_name, uint64_t supported_features, - const std::vector<const FileDescriptor*>& parsed_files) const; - - - // Return status for ParseArguments() and InterpretArgument(). - enum ParseArgumentStatus { - PARSE_ARGUMENT_DONE_AND_CONTINUE, - PARSE_ARGUMENT_DONE_AND_EXIT, - PARSE_ARGUMENT_FAIL - }; - - // Parse all command-line arguments. - ParseArgumentStatus ParseArguments(int argc, const char* const argv[]); - - // Read an argument file and append the file's content to the list of - // arguments. Return false if the file cannot be read. - bool ExpandArgumentFile(const std::string& file, - std::vector<std::string>* arguments); - - // Parses a command-line argument into a name/value pair. Returns - // true if the next argument in the argv should be used as the value, - // false otherwise. - // - // Examples: - // "-Isrc/protos" -> - // name = "-I", value = "src/protos" - // "--cpp_out=src/foo.pb2.cc" -> - // name = "--cpp_out", value = "src/foo.pb2.cc" - // "foo.proto" -> - // name = "", value = "foo.proto" - bool ParseArgument(const char* arg, std::string* name, std::string* value); - - // Interprets arguments parsed with ParseArgument. - ParseArgumentStatus InterpretArgument(const std::string& name, - const std::string& value); - - // Print the --help text to stderr. - void PrintHelpText(); - - // Loads proto_path_ into the provided source_tree. - bool InitializeDiskSourceTree(DiskSourceTree* source_tree, - DescriptorDatabase* fallback_database); - - // Verify that all the input files exist in the given database. - bool VerifyInputFilesInDescriptors(DescriptorDatabase* fallback_database); - - // Parses input_files_ into parsed_files - bool ParseInputFiles(DescriptorPool* descriptor_pool, - DiskSourceTree* source_tree, - std::vector<const FileDescriptor*>* parsed_files); - - // Generate the given output file from the given input. - struct OutputDirective; // see below - bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files, - const OutputDirective& output_directive, - GeneratorContext* generator_context); - bool GeneratePluginOutput( - const std::vector<const FileDescriptor*>& parsed_files, - const std::string& plugin_name, const std::string& parameter, - GeneratorContext* generator_context, std::string* error); - - // Implements --encode and --decode. - bool EncodeOrDecode(const DescriptorPool* pool); - - // Implements the --descriptor_set_out option. - bool WriteDescriptorSet( - const std::vector<const FileDescriptor*>& parsed_files); - - // Implements the --dependency_out option - bool GenerateDependencyManifestFile( - const std::vector<const FileDescriptor*>& parsed_files, - const GeneratorContextMap& output_directories, - DiskSourceTree* source_tree); - - // Get all transitive dependencies of the given file (including the file - // itself), adding them to the given list of FileDescriptorProtos. The - // protos will be ordered such that every file is listed before any file that - // depends on it, so that you can call DescriptorPool::BuildFile() on them - // in order. Any files in *already_seen will not be added, and each file - // added will be inserted into *already_seen. If include_source_code_info is - // true then include the source code information in the FileDescriptorProtos. - // If include_json_name is true, populate the json_name field of - // FieldDescriptorProto for all fields. - static void GetTransitiveDependencies( - const FileDescriptor* file, bool include_json_name, - bool include_source_code_info, - std::set<const FileDescriptor*>* already_seen, - RepeatedPtrField<FileDescriptorProto>* output); - - // Implements the --print_free_field_numbers. This function prints free field - // numbers into stdout for the message and it's nested message types in - // post-order, i.e. nested types first. Printed range are left-right - // inclusive, i.e. [a, b]. - // - // Groups: - // For historical reasons, groups are considered to share the same - // field number space with the parent message, thus it will not print free - // field numbers for groups. The field numbers used in the groups are - // excluded in the free field numbers of the parent message. - // - // Extension Ranges: - // Extension ranges are considered ocuppied field numbers and they will not be - // listed as free numbers in the output. - void PrintFreeFieldNumbers(const Descriptor* descriptor); - - // ----------------------------------------------------------------- - - // The name of the executable as invoked (i.e. argv[0]). - std::string executable_name_; - - // Version info set with SetVersionInfo(). - std::string version_info_; - - // Registered generators. - struct GeneratorInfo { - std::string flag_name; - std::string option_flag_name; - CodeGenerator* generator; - std::string help_text; - }; - typedef std::map<std::string, GeneratorInfo> GeneratorMap; - GeneratorMap generators_by_flag_name_; - GeneratorMap generators_by_option_name_; - // A map from generator names to the parameters specified using the option - // flag. For example, if the user invokes the compiler with: - // protoc --foo_out=outputdir --foo_opt=enable_bar ... - // Then there will be an entry ("--foo_out", "enable_bar") in this map. - std::map<std::string, std::string> generator_parameters_; - // Similar to generator_parameters_, but stores the parameters for plugins. - std::map<std::string, std::string> plugin_parameters_; - - // See AllowPlugins(). If this is empty, plugins aren't allowed. - std::string plugin_prefix_; - - // Maps specific plugin names to files. When executing a plugin, this map - // is searched first to find the plugin executable. If not found here, the - // PATH (or other OS-specific search strategy) is searched. - std::map<std::string, std::string> plugins_; - - // Stuff parsed from command line. - enum Mode { - MODE_COMPILE, // Normal mode: parse .proto files and compile them. - MODE_ENCODE, // --encode: read text from stdin, write binary to stdout. - MODE_DECODE, // --decode: read binary from stdin, write text to stdout. - MODE_PRINT, // Print mode: print info of the given .proto files and exit. - }; - - Mode mode_ = MODE_COMPILE; - - enum PrintMode { - PRINT_NONE, // Not in MODE_PRINT - PRINT_FREE_FIELDS, // --print_free_fields - }; - - PrintMode print_mode_ = PRINT_NONE; - - enum ErrorFormat { - ERROR_FORMAT_GCC, // GCC error output format (default). - ERROR_FORMAT_MSVS // Visual Studio output (--error_format=msvs). - }; - - ErrorFormat error_format_ = ERROR_FORMAT_GCC; - - // True if we should treat warnings as errors that fail the compilation. - bool fatal_warnings_ = false; - - std::vector<std::pair<std::string, std::string> > - proto_path_; // Search path for proto files. - std::vector<std::string> input_files_; // Names of the input proto files. - - // Names of proto files which are allowed to be imported. Used by build - // systems to enforce depend-on-what-you-import. - std::set<std::string> direct_dependencies_; - bool direct_dependencies_explicitly_set_ = false; - - // If there's a violation of depend-on-what-you-import, this string will be - // presented to the user. "%s" will be replaced with the violating import. - std::string direct_dependencies_violation_msg_; - - // output_directives_ lists all the files we are supposed to output and what - // generator to use for each. - struct OutputDirective { - std::string name; // E.g. "--foo_out" - CodeGenerator* generator; // NULL for plugins - std::string parameter; - std::string output_location; - }; - std::vector<OutputDirective> output_directives_; - - // When using --encode or --decode, this names the type we are encoding or - // decoding. (Empty string indicates --decode_raw.) - std::string codec_type_; - - // If --descriptor_set_in was given, these are filenames containing - // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty. - std::vector<std::string> descriptor_set_in_names_; - - // If --descriptor_set_out was given, this is the filename to which the - // FileDescriptorSet should be written. Otherwise, empty. - std::string descriptor_set_out_name_; - - // If --dependency_out was given, this is the path to the file where the - // dependency file will be written. Otherwise, empty. - std::string dependency_out_name_; - - // True if --include_imports was given, meaning that we should - // write all transitive dependencies to the DescriptorSet. Otherwise, only - // the .proto files listed on the command-line are added. - bool imports_in_descriptor_set_; - - // True if --include_source_info was given, meaning that we should not strip - // SourceCodeInfo from the DescriptorSet. - bool source_info_in_descriptor_set_ = false; - - // Was the --disallow_services flag used? - bool disallow_services_ = false; - - // When using --encode, this will be passed to SetSerializationDeterministic. - bool deterministic_output_ = false; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface); -}; - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ diff --git a/include/google/protobuf/compiler/cpp/cpp_generator.h b/include/google/protobuf/compiler/cpp/cpp_generator.h deleted file mode 100644 index 1716ab20de..0000000000 --- a/include/google/protobuf/compiler/cpp/cpp_generator.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ -#define GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ - -#include <google/protobuf/compiler/cpp/generator.h> - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ diff --git a/include/google/protobuf/compiler/cpp/file.h b/include/google/protobuf/compiler/cpp/file.h deleted file mode 100644 index ca05361b42..0000000000 --- a/include/google/protobuf/compiler/cpp/file.h +++ /dev/null @@ -1,209 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ - -#include <algorithm> -#include <memory> -#include <set> -#include <string> -#include <vector> - -#include <google/protobuf/stubs/common.h> -#include <google/protobuf/compiler/cpp/field.h> -#include <google/protobuf/compiler/cpp/helpers.h> -#include <google/protobuf/compiler/scc.h> -#include <google/protobuf/compiler/cpp/options.h> - -namespace google { -namespace protobuf { -class FileDescriptor; // descriptor.h -namespace io { -class Printer; // printer.h -} -} // namespace protobuf -} // namespace google - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -class EnumGenerator; // enum.h -class MessageGenerator; // message.h -class ServiceGenerator; // service.h -class ExtensionGenerator; // extension.h - -class FileGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - FileGenerator(const FileDescriptor* file, const Options& options); - ~FileGenerator(); - - // Shared code between the two header generators below. - void GenerateHeader(io::Printer* printer); - - // info_path, if non-empty, should be the path (relative to printer's - // output) to the metadata file describing this proto header. - void GenerateProtoHeader(io::Printer* printer, const std::string& info_path); - // info_path, if non-empty, should be the path (relative to printer's - // output) to the metadata file describing this PB header. - void GeneratePBHeader(io::Printer* printer, const std::string& info_path); - void GenerateSource(io::Printer* printer); - - // The following member functions are used when the lite_implicit_weak_fields - // option is set. In this mode the code is organized a bit differently to - // promote better linker stripping of unused code. In particular, we generate - // one .cc file per message, one .cc file per extension, and a main pb.cc file - // containing everything else. - - int NumMessages() const { return message_generators_.size(); } - int NumExtensions() const { return extension_generators_.size(); } - // Generates the source file for one message. - void GenerateSourceForMessage(int idx, io::Printer* printer); - // Generates the source file for one extension. - void GenerateSourceForExtension(int idx, io::Printer* printer); - // Generates a source file containing everything except messages and - // extensions. - void GenerateGlobalSource(io::Printer* printer); - - private: - // Internal type used by GenerateForwardDeclarations (defined in file.cc). - class ForwardDeclarations; - struct CrossFileReferences; - - void IncludeFile(const std::string& google3_name, io::Printer* printer) { - DoIncludeFile(google3_name, false, printer); - } - void IncludeFileAndExport(const std::string& google3_name, - io::Printer* printer) { - DoIncludeFile(google3_name, true, printer); - } - void DoIncludeFile(const std::string& google3_name, bool do_export, - io::Printer* printer); - - std::string CreateHeaderInclude(const std::string& basename, - const FileDescriptor* file); - void GetCrossFileReferencesForField(const FieldDescriptor* field, - CrossFileReferences* refs); - void GetCrossFileReferencesForFile(const FileDescriptor* file, - CrossFileReferences* refs); - void GenerateInternalForwardDeclarations(const CrossFileReferences& refs, - io::Printer* printer); - void GenerateSourceIncludes(io::Printer* printer); - void GenerateSourcePrelude(io::Printer* printer); - void GenerateSourceDefaultInstance(int idx, io::Printer* printer); - - void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs, - io::Printer* printer); - void GenerateReflectionInitializationCode(io::Printer* printer); - - // For other imports, generates their forward-declarations. - void GenerateForwardDeclarations(io::Printer* printer); - - // Generates top or bottom of a header file. - void GenerateTopHeaderGuard(io::Printer* printer, bool pb_h); - void GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h); - - // Generates #include directives. - void GenerateLibraryIncludes(io::Printer* printer); - void GenerateDependencyIncludes(io::Printer* printer); - - // Generate a pragma to pull in metadata using the given info_path (if - // non-empty). info_path should be relative to printer's output. - void GenerateMetadataPragma(io::Printer* printer, - const std::string& info_path); - - // Generates a couple of different pieces before definitions: - void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); - - // Generates types for classes. - void GenerateMessageDefinitions(io::Printer* printer); - - void GenerateEnumDefinitions(io::Printer* printer); - - // Generates generic service definitions. - void GenerateServiceDefinitions(io::Printer* printer); - - // Generates extension identifiers. - void GenerateExtensionIdentifiers(io::Printer* printer); - - // Generates inline function definitions. - void GenerateInlineFunctionDefinitions(io::Printer* printer); - - void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); - - // Sometimes the names we use in a .proto file happen to be defined as - // macros on some platforms (e.g., macro/minor used in plugin.proto are - // defined as macros in sys/types.h on FreeBSD and a few other platforms). - // To make the generated code compile on these platforms, we either have to - // undef the macro for these few platforms, or rename the field name for all - // platforms. Since these names are part of protobuf public API, renaming is - // generally a breaking change so we prefer the #undef approach. - void GenerateMacroUndefs(io::Printer* printer); - - bool IsDepWeak(const FileDescriptor* dep) const { - if (weak_deps_.count(dep) != 0) { - GOOGLE_CHECK(!options_.opensource_runtime); - return true; - } - return false; - } - - std::set<const FileDescriptor*> weak_deps_; - - const FileDescriptor* file_; - const Options options_; - - MessageSCCAnalyzer scc_analyzer_; - - std::map<std::string, std::string> variables_; - - // Contains the post-order walk of all the messages (and child messages) in - // this file. If you need a pre-order walk just reverse iterate. - std::vector<std::unique_ptr<MessageGenerator>> message_generators_; - std::vector<std::unique_ptr<EnumGenerator>> enum_generators_; - std::vector<std::unique_ptr<ServiceGenerator>> service_generators_; - std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ diff --git a/include/google/protobuf/compiler/cpp/generator.h b/include/google/protobuf/compiler/cpp/generator.h deleted file mode 100644 index 1a374b9f16..0000000000 --- a/include/google/protobuf/compiler/cpp/generator.h +++ /dev/null @@ -1,107 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates C++ code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ - -#include <string> -#include <google/protobuf/compiler/code_generator.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// CodeGenerator implementation which generates a C++ source file and -// header. If you create your own protocol compiler binary and you want -// it to support C++ output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT CppGenerator : public CodeGenerator { - public: - CppGenerator(); - ~CppGenerator() override; - - enum class Runtime { - kGoogle3, // Use the internal google3 runtime. - kOpensource, // Use the open-source runtime. - - // Use the open-source runtime with google3 #include paths. We make these - // absolute to avoid ambiguity, so the runtime will be #included like: - // #include "third_party/protobuf/.../google/protobuf/message.h" - kOpensourceGoogle3 - }; - - void set_opensource_runtime(bool opensource) { - opensource_runtime_ = opensource; - } - - // If set to a non-empty string, generated code will do: - // #include "<BASE>/google/protobuf/message.h" - // instead of: - // #include <google/protobuf/message.h> - // This has no effect if opensource_runtime = false. - void set_runtime_include_base(const std::string& base) { - runtime_include_base_ = base; - } - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override { - // We don't fully support this yet, but this is needed to unblock the tests, - // and we will have full support before the experimental flag is removed. - return FEATURE_PROTO3_OPTIONAL; - } - - private: - bool opensource_runtime_ = true; - std::string runtime_include_base_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/cpp/helpers.h b/include/google/protobuf/compiler/cpp/helpers.h deleted file mode 100644 index d8dcda7248..0000000000 --- a/include/google/protobuf/compiler/cpp/helpers.h +++ /dev/null @@ -1,1064 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ - -#include <algorithm> -#include <cstdint> -#include <iterator> -#include <map> -#include <string> - -#include <google/protobuf/compiler/scc.h> -#include <google/protobuf/compiler/code_generator.h> -#include <google/protobuf/compiler/cpp/names.h> -#include <google/protobuf/compiler/cpp/options.h> -#include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/io/printer.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/port.h> -#include <google/protobuf/stubs/strutil.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 }; - -inline std::string ProtobufNamespace(const Options& /* options */) { - return "PROTOBUF_NAMESPACE_ID"; -} - -inline std::string MacroPrefix(const Options& /* options */) { - return "GOOGLE_PROTOBUF"; -} - -inline std::string DeprecatedAttribute(const Options& /* options */, - const FieldDescriptor* d) { - return d->options().deprecated() ? "PROTOBUF_DEPRECATED " : ""; -} - -inline std::string DeprecatedAttribute(const Options& /* options */, - const EnumValueDescriptor* d) { - return d->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM " : ""; -} - -// Commonly-used separator comments. Thick is a line of '=', thin is a line -// of '-'. -extern const char kThickSeparator[]; -extern const char kThinSeparator[]; - -void SetCommonVars(const Options& options, - std::map<std::string, std::string>* variables); - -// Variables to access message data from the message scope. -void SetCommonMessageDataVariables( - const Descriptor* descriptor, - std::map<std::string, std::string>* variables); - -void SetUnknownFieldsVariable(const Descriptor* descriptor, - const Options& options, - std::map<std::string, std::string>* variables); - -bool GetBootstrapBasename(const Options& options, const std::string& basename, - std::string* bootstrap_basename); -bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context, - bool bootstrap_flag, std::string* basename); -bool IsBootstrapProto(const Options& options, const FileDescriptor* file); - -// Name space of the proto file. This namespace is such that the string -// "<namespace>::some_name" is the correct fully qualified namespace. -// This means if the package is empty the namespace is "", and otherwise -// the namespace is "::foo::bar::...::baz" without trailing semi-colons. -std::string Namespace(const FileDescriptor* d, const Options& options); -std::string Namespace(const Descriptor* d, const Options& options); -std::string Namespace(const FieldDescriptor* d, const Options& options); -std::string Namespace(const EnumDescriptor* d, const Options& options); - -// Returns true if it's safe to reset "field" to zero. -bool CanInitializeByZeroing(const FieldDescriptor* field); - -std::string ClassName(const Descriptor* descriptor); -std::string ClassName(const EnumDescriptor* enum_descriptor); - -std::string QualifiedClassName(const Descriptor* d, const Options& options); -std::string QualifiedClassName(const EnumDescriptor* d, const Options& options); - -std::string QualifiedClassName(const Descriptor* d); -std::string QualifiedClassName(const EnumDescriptor* d); - -// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very -// unreadable at the callsite. -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Moo {} } -// Then the qualified ClassName for Moo would be: -// ::foo::bar::Baz_Moo -// While the non-qualified version would be: -// Baz_Moo -inline std::string ClassName(const Descriptor* descriptor, bool qualified) { - return qualified ? QualifiedClassName(descriptor, Options()) - : ClassName(descriptor); -} - -inline std::string ClassName(const EnumDescriptor* descriptor, bool qualified) { - return qualified ? QualifiedClassName(descriptor, Options()) - : ClassName(descriptor); -} - -// Returns the extension name prefixed with the class name if nested but without -// the package name. -std::string ExtensionName(const FieldDescriptor* d); - -std::string QualifiedExtensionName(const FieldDescriptor* d, - const Options& options); -std::string QualifiedExtensionName(const FieldDescriptor* d); - -// Type name of default instance. -std::string DefaultInstanceType(const Descriptor* descriptor, - const Options& options, bool split = false); - -// Non-qualified name of the default_instance of this message. -std::string DefaultInstanceName(const Descriptor* descriptor, - const Options& options, bool split = false); - -// Non-qualified name of the default instance pointer. This is used only for -// implicit weak fields, where we need an extra indirection. -std::string DefaultInstancePtr(const Descriptor* descriptor, - const Options& options, bool split = false); - -// Fully qualified name of the default_instance of this message. -std::string QualifiedDefaultInstanceName(const Descriptor* descriptor, - const Options& options, - bool split = false); - -// Fully qualified name of the default instance pointer. -std::string QualifiedDefaultInstancePtr(const Descriptor* descriptor, - const Options& options, - bool split = false); - -// DescriptorTable variable name. -std::string DescriptorTableName(const FileDescriptor* file, - const Options& options); - -// When declaring symbol externs from another file, this macro will supply the -// dllexport needed for the target file, if any. -std::string FileDllExport(const FileDescriptor* file, const Options& options); - -// Name of the base class: google::protobuf::Message or google::protobuf::MessageLite. -std::string SuperClassName(const Descriptor* descriptor, - const Options& options); - -// Adds an underscore if necessary to prevent conflicting with a keyword. -std::string ResolveKeyword(const std::string& name); - -// Get the (unqualified) name that should be used for this field in C++ code. -// The name is coerced to lower-case to emulate proto1 behavior. People -// should be using lowercase-with-underscores style for proto field names -// anyway, so normally this just returns field->name(). -std::string FieldName(const FieldDescriptor* field); - -// Returns the (unqualified) private member name for this field in C++ code. -std::string FieldMemberName(const FieldDescriptor* field, bool split); - -// Returns an estimate of the compiler's alignment for the field. This -// can't guarantee to be correct because the generated code could be compiled on -// different systems with different alignment rules. The estimates below assume -// 64-bit pointers. -int EstimateAlignmentSize(const FieldDescriptor* field); - -// Get the unqualified name that should be used for a field's field -// number constant. -std::string FieldConstantName(const FieldDescriptor* field); - -// Returns the scope where the field was defined (for extensions, this is -// different from the message type to which the field applies). -inline const Descriptor* FieldScope(const FieldDescriptor* field) { - return field->is_extension() ? field->extension_scope() - : field->containing_type(); -} - -// Returns the fully-qualified type name field->message_type(). Usually this -// is just ClassName(field->message_type(), true); -std::string FieldMessageTypeName(const FieldDescriptor* field, - const Options& options); - -// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). -const char* PrimitiveTypeName(FieldDescriptor::CppType type); -std::string PrimitiveTypeName(const Options& options, - FieldDescriptor::CppType type); - -// Get the declared type name in CamelCase format, as is used e.g. for the -// methods of WireFormat. For example, TYPE_INT32 becomes "Int32". -const char* DeclaredTypeMethodName(FieldDescriptor::Type type); - -// Return the code that evaluates to the number when compiled. -std::string Int32ToString(int number); - -// Get code that evaluates to the field's default value. -std::string DefaultValue(const Options& options, const FieldDescriptor* field); - -// Compatibility function for callers outside proto2. -std::string DefaultValue(const FieldDescriptor* field); - -// Convert a file name into a valid identifier. -std::string FilenameIdentifier(const std::string& filename); - -// For each .proto file generates a unique name. To prevent collisions of -// symbols in the global namespace -std::string UniqueName(const std::string& name, const std::string& filename, - const Options& options); -inline std::string UniqueName(const std::string& name, const FileDescriptor* d, - const Options& options) { - return UniqueName(name, d->name(), options); -} -inline std::string UniqueName(const std::string& name, const Descriptor* d, - const Options& options) { - return UniqueName(name, d->file(), options); -} -inline std::string UniqueName(const std::string& name, const EnumDescriptor* d, - const Options& options) { - return UniqueName(name, d->file(), options); -} -inline std::string UniqueName(const std::string& name, - const ServiceDescriptor* d, - const Options& options) { - return UniqueName(name, d->file(), options); -} - -// Versions for call sites that only support the internal runtime (like proto1 -// support). -inline Options InternalRuntimeOptions() { - Options options; - options.opensource_runtime = false; - return options; -} -inline std::string UniqueName(const std::string& name, - const std::string& filename) { - return UniqueName(name, filename, InternalRuntimeOptions()); -} -inline std::string UniqueName(const std::string& name, - const FileDescriptor* d) { - return UniqueName(name, d->name(), InternalRuntimeOptions()); -} -inline std::string UniqueName(const std::string& name, const Descriptor* d) { - return UniqueName(name, d->file(), InternalRuntimeOptions()); -} -inline std::string UniqueName(const std::string& name, - const EnumDescriptor* d) { - return UniqueName(name, d->file(), InternalRuntimeOptions()); -} -inline std::string UniqueName(const std::string& name, - const ServiceDescriptor* d) { - return UniqueName(name, d->file(), InternalRuntimeOptions()); -} - -// Return the qualified C++ name for a file level symbol. -std::string QualifiedFileLevelSymbol(const FileDescriptor* file, - const std::string& name, - const Options& options); - -// Escape C++ trigraphs by escaping question marks to \? -std::string EscapeTrigraphs(const std::string& to_escape); - -// Escaped function name to eliminate naming conflict. -std::string SafeFunctionName(const Descriptor* descriptor, - const FieldDescriptor* field, - const std::string& prefix); - -// Returns true if generated messages have public unknown fields accessors -inline bool PublicUnknownFieldsAccessors(const Descriptor* message) { - return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3; -} - -// Returns the optimize mode for <file>, respecting <options.enforce_lite>. -FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, - const Options& options); - -// Determines whether unknown fields will be stored in an UnknownFieldSet or -// a string. -inline bool UseUnknownFieldSet(const FileDescriptor* file, - const Options& options) { - return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME; -} - -inline bool IsWeak(const FieldDescriptor* field, const Options& options) { - if (field->options().weak()) { - GOOGLE_CHECK(!options.opensource_runtime); - return true; - } - return false; -} - -bool IsStringInlined(const FieldDescriptor* descriptor, const Options& options); - -// For a string field, returns the effective ctype. If the actual ctype is -// not supported, returns the default of STRING. -FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field, - const Options& options); - -inline bool IsCord(const FieldDescriptor* field, const Options& options) { - return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && - EffectiveStringCType(field, options) == FieldOptions::CORD; -} - -inline bool IsString(const FieldDescriptor* field, const Options& options) { - return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && - EffectiveStringCType(field, options) == FieldOptions::STRING; -} - -inline bool IsStringPiece(const FieldDescriptor* field, - const Options& options) { - return field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && - EffectiveStringCType(field, options) == FieldOptions::STRING_PIECE; -} - -class MessageSCCAnalyzer; - -// Does the given FileDescriptor use lazy fields? -bool HasLazyFields(const FileDescriptor* file, const Options& options, - MessageSCCAnalyzer* scc_analyzer); - -// Is the given field a supported lazy field? -bool IsLazy(const FieldDescriptor* field, const Options& options, - MessageSCCAnalyzer* scc_analyzer); - -// Is this an explicit (non-profile driven) lazy field, as denoted by -// lazy/unverified_lazy in the descriptor? -inline bool IsExplicitLazy(const FieldDescriptor* field) { - return field->options().lazy() || field->options().unverified_lazy(); -} - -bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, const Options& options, - MessageSCCAnalyzer* scc_analyzer); - -bool IsLazilyVerifiedLazy(const FieldDescriptor* field, const Options& options); - -// Is the given message being split (go/pdsplit)? -bool ShouldSplit(const Descriptor* desc, const Options& options); - -// Is the given field being split out? -bool ShouldSplit(const FieldDescriptor* field, const Options& options); - -inline bool IsFieldUsed(const FieldDescriptor* /* field */, - const Options& /* options */) { - return true; -} - -// Returns true if "field" is stripped. -inline bool IsFieldStripped(const FieldDescriptor* /*field*/, - const Options& /*options*/) { - return false; -} - -// Does the file contain any definitions that need extension_set.h? -bool HasExtensionsOrExtendableMessage(const FileDescriptor* file); - -// Does the file have any repeated fields, necessitating the file to include -// repeated_field.h? This does not include repeated extensions, since those are -// all stored internally in an ExtensionSet, not a separate RepeatedField*. -bool HasRepeatedFields(const FileDescriptor* file); - -// Does the file have any string/bytes fields with ctype=STRING_PIECE? This -// does not include extensions, since ctype is ignored for extensions. -bool HasStringPieceFields(const FileDescriptor* file, const Options& options); - -// Does the file have any string/bytes fields with ctype=CORD? This does not -// include extensions, since ctype is ignored for extensions. -bool HasCordFields(const FileDescriptor* file, const Options& options); - -// Does the file have any map fields, necessitating the file to include -// map_field_inl.h and map.h. -bool HasMapFields(const FileDescriptor* file); - -// Does this file have any enum type definitions? -bool HasEnumDefinitions(const FileDescriptor* file); - -// Does this file have generated parsing, serialization, and other -// standard methods for which reflection-based fallback implementations exist? -inline bool HasGeneratedMethods(const FileDescriptor* file, - const Options& options) { - return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE; -} - -// Do message classes in this file have descriptor and reflection methods? -inline bool HasDescriptorMethods(const FileDescriptor* file, - const Options& options) { - return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME; -} - -// Should we generate generic services for this file? -inline bool HasGenericServices(const FileDescriptor* file, - const Options& options) { - return file->service_count() > 0 && - GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME && - file->options().cc_generic_services(); -} - -inline bool IsProto2MessageSet(const Descriptor* descriptor, - const Options& options) { - return !options.opensource_runtime && - options.enforce_mode != EnforceOptimizeMode::kLiteRuntime && - !options.lite_implicit_weak_fields && - descriptor->options().message_set_wire_format() && - descriptor->full_name() == "google.protobuf.bridge.MessageSet"; -} - -inline bool IsMapEntryMessage(const Descriptor* descriptor) { - return descriptor->options().map_entry(); -} - -// Returns true if the field's CPPTYPE is string or message. -bool IsStringOrMessage(const FieldDescriptor* field); - -std::string UnderscoresToCamelCase(const std::string& input, - bool cap_next_letter); - -inline bool IsProto3(const FileDescriptor* file) { - return file->syntax() == FileDescriptor::SYNTAX_PROTO3; -} - -inline bool HasHasbit(const FieldDescriptor* field) { - // This predicate includes proto3 message fields only if they have "optional". - // Foo submsg1 = 1; // HasHasbit() == false - // optional Foo submsg2 = 2; // HasHasbit() == true - // This is slightly odd, as adding "optional" to a singular proto3 field does - // not change the semantics or API. However whenever any field in a message - // has a hasbit, it forces reflection to include hasbit offsets for *all* - // fields, even if almost all of them are set to -1 (no hasbit). So to avoid - // causing a sudden size regression for ~all proto3 messages, we give proto3 - // message fields a hasbit only if "optional" is present. If the user is - // explicitly writing "optional", it is likely they are writing it on - // primitive fields also. - return (field->has_optional_keyword() || field->is_required()) && - !field->options().weak(); -} - -// Returns true if 'enum' semantics are such that unknown values are preserved -// in the enum field itself, rather than going to the UnknownFieldSet. -inline bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) { - return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3; -} - -inline bool IsCrossFileMessage(const FieldDescriptor* field) { - return field->type() == FieldDescriptor::TYPE_MESSAGE && - field->message_type()->file() != field->file(); -} - -inline std::string MakeDefaultName(const FieldDescriptor* field) { - return StrCat("_i_give_permission_to_break_this_code_default_", - FieldName(field), "_"); -} - -// Semantically distinct from MakeDefaultName in that it gives the C++ code -// referencing a default field from the message scope, rather than just the -// variable name. -// For example, declarations of default variables should always use just -// MakeDefaultName to produce code like: -// Type _i_give_permission_to_break_this_code_default_field_; -// -// Code that references these should use MakeDefaultFieldName, in case the field -// exists at some nested level like: -// internal_container_._i_give_permission_to_break_this_code_default_field_; -inline std::string MakeDefaultFieldName(const FieldDescriptor* field) { - return StrCat("Impl_::", MakeDefaultName(field)); -} - -inline std::string MakeVarintCachedSizeName(const FieldDescriptor* field) { - return StrCat("_", FieldName(field), "_cached_byte_size_"); -} - -// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++ -// code referencing the object from the message scope, rather than just the -// variable name. -// For example, declarations of default variables should always use just -// MakeVarintCachedSizeName to produce code like: -// Type _field_cached_byte_size_; -// -// Code that references these variables should use -// MakeVarintCachedSizeFieldName, in case the field exists at some nested level -// like: -// internal_container_._field_cached_byte_size_; -inline std::string MakeVarintCachedSizeFieldName(const FieldDescriptor* field, - bool split) { - return StrCat("_impl_.", split ? "_split_->" : "", "_", - FieldName(field), "_cached_byte_size_"); -} - -// Note: A lot of libraries detect Any protos based on Descriptor::full_name() -// while the two functions below use FileDescriptor::name(). In a sane world the -// two approaches should be equivalent. But if you are dealing with descriptors -// from untrusted sources, you might need to match semantics across libraries. -bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options); -bool IsAnyMessage(const Descriptor* descriptor, const Options& options); - -bool IsWellKnownMessage(const FileDescriptor* descriptor); - -inline std::string IncludeGuard(const FileDescriptor* file, bool pb_h, - const Options& options) { - // If we are generating a .pb.h file and the proto_h option is enabled, then - // the .pb.h gets an extra suffix. - std::string filename_identifier = FilenameIdentifier( - file->name() + (pb_h && options.proto_h ? ".pb.h" : "")); - - if (IsWellKnownMessage(file)) { - // For well-known messages we need third_party/protobuf and net/proto2 to - // have distinct include guards, because some source files include both and - // both need to be defined (the third_party copies will be in the - // google::protobuf_opensource namespace). - return MacroPrefix(options) + "_INCLUDED_" + filename_identifier; - } else { - // Ideally this case would use distinct include guards for opensource and - // google3 protos also. (The behavior of "first #included wins" is not - // ideal). But unfortunately some legacy code includes both and depends on - // the identical include guards to avoid compile errors. - // - // We should clean this up so that this case can be removed. - return "GOOGLE_PROTOBUF_INCLUDED_" + filename_identifier; - } -} - -// Returns the OptimizeMode for this file, furthermore it updates a status -// bool if has_opt_codesize_extension is non-null. If this status bool is true -// it means this file contains an extension that itself is defined as -// optimized_for = CODE_SIZE. -FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, - const Options& options, - bool* has_opt_codesize_extension); -inline FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, - const Options& options) { - return GetOptimizeFor(file, options, nullptr); -} -inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file, - const Options& options) { - bool has_opt_codesize_extension; - if (GetOptimizeFor(file, options, &has_opt_codesize_extension) == - FileOptions::CODE_SIZE && - has_opt_codesize_extension) { - // If this filedescriptor contains an extension from another file which - // is optimized_for = CODE_SIZE. We need to be careful in the ordering so - // we eagerly build the descriptors in the dependencies before building - // the descriptors of this file. - return true; - } else { - // If we have a generated code based parser we never need eager - // initialization of descriptors of our deps. - return false; - } -} - -// This orders the messages in a .pb.cc as it's outputted by file.cc -void FlattenMessagesInFile(const FileDescriptor* file, - std::vector<const Descriptor*>* result); -inline std::vector<const Descriptor*> FlattenMessagesInFile( - const FileDescriptor* file) { - std::vector<const Descriptor*> result; - FlattenMessagesInFile(file, &result); - return result; -} - -template <typename F> -void ForEachMessage(const Descriptor* descriptor, F&& func) { - for (int i = 0; i < descriptor->nested_type_count(); i++) - ForEachMessage(descriptor->nested_type(i), std::forward<F&&>(func)); - func(descriptor); -} - -template <typename F> -void ForEachMessage(const FileDescriptor* descriptor, F&& func) { - for (int i = 0; i < descriptor->message_type_count(); i++) - ForEachMessage(descriptor->message_type(i), std::forward<F&&>(func)); -} - -bool HasWeakFields(const Descriptor* desc, const Options& options); -bool HasWeakFields(const FileDescriptor* desc, const Options& options); - -// Returns true if the "required" restriction check should be ignored for the -// given field. -inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field, - const Options& options) { - // Do not check "required" for lazily verified lazy fields. - return IsLazilyVerifiedLazy(field, options); -} - -struct MessageAnalysis { - bool is_recursive = false; - bool contains_cord = false; - bool contains_extension = false; - bool contains_required = false; - bool contains_weak = false; // Implicit weak as well. -}; - -// This class is used in FileGenerator, to ensure linear instead of -// quadratic performance, if we do this per message we would get O(V*(V+E)). -// Logically this is just only used in message.cc, but in the header for -// FileGenerator to help share it. -class PROTOC_EXPORT MessageSCCAnalyzer { - public: - explicit MessageSCCAnalyzer(const Options& options) : options_(options) {} - - MessageAnalysis GetSCCAnalysis(const SCC* scc); - - bool HasRequiredFields(const Descriptor* descriptor) { - MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor)); - return result.contains_required || result.contains_extension; - } - bool HasWeakField(const Descriptor* descriptor) { - MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor)); - return result.contains_weak; - } - const SCC* GetSCC(const Descriptor* descriptor) { - return analyzer_.GetSCC(descriptor); - } - - private: - struct DepsGenerator { - std::vector<const Descriptor*> operator()(const Descriptor* desc) const { - std::vector<const Descriptor*> deps; - for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->message_type()) { - deps.push_back(desc->field(i)->message_type()); - } - } - return deps; - } - }; - SCCAnalyzer<DepsGenerator> analyzer_; - Options options_; - std::map<const SCC*, MessageAnalysis> analysis_cache_; -}; - -void ListAllFields(const Descriptor* d, - std::vector<const FieldDescriptor*>* fields); -void ListAllFields(const FileDescriptor* d, - std::vector<const FieldDescriptor*>* fields); - -template <class T> -void ForEachField(const Descriptor* d, T&& func) { - for (int i = 0; i < d->nested_type_count(); i++) { - ForEachField(d->nested_type(i), std::forward<T&&>(func)); - } - for (int i = 0; i < d->extension_count(); i++) { - func(d->extension(i)); - } - for (int i = 0; i < d->field_count(); i++) { - func(d->field(i)); - } -} - -template <class T> -void ForEachField(const FileDescriptor* d, T&& func) { - for (int i = 0; i < d->message_type_count(); i++) { - ForEachField(d->message_type(i), std::forward<T&&>(func)); - } - for (int i = 0; i < d->extension_count(); i++) { - func(d->extension(i)); - } -} - -void ListAllTypesForServices(const FileDescriptor* fd, - std::vector<const Descriptor*>* types); - -// Indicates whether we should use implicit weak fields for this file. -bool UsingImplicitWeakFields(const FileDescriptor* file, - const Options& options); - -// Indicates whether to treat this field as implicitly weak. -bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, - MessageSCCAnalyzer* scc_analyzer); - -inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) { - if (!HasDescriptorMethods(desc->file(), options)) return false; - if (desc->extension_range_count() != 0) return false; - if (desc->field_count() == 0) return true; - // TODO(jorg): Support additional common message types with only one - // or two fields - return false; -} - -inline bool HasSimpleBaseClasses(const FileDescriptor* file, - const Options& options) { - bool v = false; - ForEachMessage(file, [&v, &options](const Descriptor* desc) { - v |= HasSimpleBaseClass(desc, options); - }); - return v; -} - -inline std::string SimpleBaseClass(const Descriptor* desc, - const Options& options) { - if (!HasDescriptorMethods(desc->file(), options)) return ""; - if (desc->extension_range_count() != 0) return ""; - if (desc->field_count() == 0) { - return "ZeroFieldsBase"; - } - // TODO(jorg): Support additional common message types with only one - // or two fields - return ""; -} - -// Returns true if this message has a _tracker_ field. -inline bool HasTracker(const Descriptor* desc, const Options& options) { - return options.field_listener_options.inject_field_listener_events && - desc->file()->options().optimize_for() != - google::protobuf::FileOptions::LITE_RUNTIME; -} - -// Returns true if this message needs an Impl_ struct for it's data. -inline bool HasImplData(const Descriptor* desc, const Options& options) { - return !HasSimpleBaseClass(desc, options); -} - -// Formatter is a functor class which acts as a closure around printer and -// the variable map. It's much like printer->Print except it supports both named -// variables that are substituted using a key value map and direct arguments. In -// the format string $1$, $2$, etc... are substituted for the first, second, ... -// direct argument respectively in the format call, it accepts both strings and -// integers. The implementation verifies all arguments are used and are "first" -// used in order of appearance in the argument list. For example, -// -// Format("return array[$1$];", 3) -> "return array[3];" -// Format("array[$2$] = $1$;", "Bla", 3) -> FATAL error (wrong order) -// Format("array[$1$] = $2$;", 3, "Bla") -> "array[3] = Bla;" -// -// The arguments can be used more than once like -// -// Format("array[$1$] = $2$; // Index = $1$", 3, "Bla") -> -// "array[3] = Bla; // Index = 3" -// -// If you use more arguments use the following style to help the reader, -// -// Format("int $1$() {\n" -// " array[$2$] = $3$;\n" -// " return $4$;" -// "}\n", -// funname, // 1 -// idx, // 2 -// varname, // 3 -// retval); // 4 -// -// but consider using named variables. Named variables like $foo$, with some -// identifier foo, are looked up in the map. One additional feature is that -// spaces are accepted between the '$' delimiters, $ foo$ will -// substitute to " bar" if foo stands for "bar", but in case it's empty -// will substitute to "". Hence, for example, -// -// Format(vars, "$dllexport $void fun();") -> "void fun();" -// "__declspec(export) void fun();" -// -// which is convenient to prevent double, leading or trailing spaces. -class PROTOC_EXPORT Formatter { - public: - explicit Formatter(io::Printer* printer) : printer_(printer) {} - Formatter(io::Printer* printer, - const std::map<std::string, std::string>& vars) - : printer_(printer), vars_(vars) {} - - template <typename T> - void Set(const std::string& key, const T& value) { - vars_[key] = ToString(value); - } - - void AddMap(const std::map<std::string, std::string>& vars) { - for (const auto& keyval : vars) vars_[keyval.first] = keyval.second; - } - - template <typename... Args> - void operator()(const char* format, const Args&... args) const { - printer_->FormatInternal({ToString(args)...}, vars_, format); - } - - void Indent() const { printer_->Indent(); } - void Outdent() const { printer_->Outdent(); } - io::Printer* printer() const { return printer_; } - - class PROTOC_EXPORT ScopedIndenter { - public: - explicit ScopedIndenter(Formatter* format) : format_(format) { - format_->Indent(); - } - ~ScopedIndenter() { format_->Outdent(); } - - private: - Formatter* format_; - }; - - PROTOBUF_NODISCARD ScopedIndenter ScopedIndent() { - return ScopedIndenter(this); - } - template <typename... Args> - PROTOBUF_NODISCARD ScopedIndenter ScopedIndent(const char* format, - const Args&&... args) { - (*this)(format, static_cast<Args&&>(args)...); - return ScopedIndenter(this); - } - - class PROTOC_EXPORT SaveState { - public: - explicit SaveState(Formatter* format) - : format_(format), vars_(format->vars_) {} - ~SaveState() { format_->vars_.swap(vars_); } - - private: - Formatter* format_; - std::map<std::string, std::string> vars_; - }; - - private: - io::Printer* printer_; - std::map<std::string, std::string> vars_; - - // Convenience overloads to accept different types as arguments. - static std::string ToString(const std::string& s) { return s; } - template <typename I, typename = typename std::enable_if< - std::is_integral<I>::value>::type> - static std::string ToString(I x) { - return StrCat(x); - } - static std::string ToString(strings::Hex x) { return StrCat(x); } - static std::string ToString(const FieldDescriptor* d) { return Payload(d); } - static std::string ToString(const Descriptor* d) { return Payload(d); } - static std::string ToString(const EnumDescriptor* d) { return Payload(d); } - static std::string ToString(const EnumValueDescriptor* d) { - return Payload(d); - } - static std::string ToString(const OneofDescriptor* d) { return Payload(d); } - - template <typename Descriptor> - static std::string Payload(const Descriptor* descriptor) { - std::vector<int> path; - descriptor->GetLocationPath(&path); - GeneratedCodeInfo::Annotation annotation; - for (int index : path) { - annotation.add_path(index); - } - annotation.set_source_file(descriptor->file()->name()); - return annotation.SerializeAsString(); - } -}; - -template <class T> -void PrintFieldComment(const Formatter& format, const T* field) { - // Print the field's (or oneof's) proto-syntax definition as a comment. - // We don't want to print group bodies so we cut off after the first - // line. - DebugStringOptions options; - options.elide_group_body = true; - options.elide_oneof_body = true; - std::string def = field->DebugStringWithOptions(options); - format("// $1$\n", def.substr(0, def.find_first_of('\n'))); -} - -class PROTOC_EXPORT NamespaceOpener { - public: - explicit NamespaceOpener(const Formatter& format) - : printer_(format.printer()) {} - NamespaceOpener(const std::string& name, const Formatter& format) - : NamespaceOpener(format) { - ChangeTo(name); - } - ~NamespaceOpener() { ChangeTo(""); } - - void ChangeTo(const std::string& name) { - std::vector<std::string> new_stack_ = - Split(name, "::", true); - size_t len = std::min(name_stack_.size(), new_stack_.size()); - size_t common_idx = 0; - while (common_idx < len) { - if (name_stack_[common_idx] != new_stack_[common_idx]) break; - common_idx++; - } - for (auto it = name_stack_.crbegin(); - it != name_stack_.crend() - common_idx; ++it) { - if (*it == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n"); - } else { - printer_->Print("} // namespace $ns$\n", "ns", *it); - } - } - name_stack_.swap(new_stack_); - for (size_t i = common_idx; i < name_stack_.size(); ++i) { - if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_OPEN\n"); - } else { - printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]); - } - } - } - - private: - io::Printer* printer_; - std::vector<std::string> name_stack_; -}; - -enum class Utf8CheckMode { - kStrict = 0, // Parsing will fail if non UTF-8 data is in string fields. - kVerify = 1, // Only log an error but parsing will succeed. - kNone = 2, // No UTF-8 check. -}; - -Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, - const Options& options); - -void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, - const Options& options, bool for_parse, - const char* parameters, - const Formatter& format); - -void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, - const Options& options, bool for_parse, - const char* parameters, - const Formatter& format); - -template <typename T> -struct FieldRangeImpl { - struct Iterator { - using iterator_category = std::forward_iterator_tag; - using value_type = const FieldDescriptor*; - using difference_type = int; - - value_type operator*() { return descriptor->field(idx); } - - friend bool operator==(const Iterator& a, const Iterator& b) { - GOOGLE_DCHECK(a.descriptor == b.descriptor); - return a.idx == b.idx; - } - friend bool operator!=(const Iterator& a, const Iterator& b) { - return !(a == b); - } - - Iterator& operator++() { - idx++; - return *this; - } - - int idx; - const T* descriptor; - }; - - Iterator begin() const { return {0, descriptor}; } - Iterator end() const { return {descriptor->field_count(), descriptor}; } - - const T* descriptor; -}; - -template <typename T> -FieldRangeImpl<T> FieldRange(const T* desc) { - return {desc}; -} - -struct OneOfRangeImpl { - struct Iterator { - using iterator_category = std::forward_iterator_tag; - using value_type = const OneofDescriptor*; - using difference_type = int; - - value_type operator*() { return descriptor->oneof_decl(idx); } - - friend bool operator==(const Iterator& a, const Iterator& b) { - GOOGLE_DCHECK(a.descriptor == b.descriptor); - return a.idx == b.idx; - } - friend bool operator!=(const Iterator& a, const Iterator& b) { - return !(a == b); - } - - Iterator& operator++() { - idx++; - return *this; - } - - int idx; - const Descriptor* descriptor; - }; - - Iterator begin() const { return {0, descriptor}; } - Iterator end() const { - return {descriptor->real_oneof_decl_count(), descriptor}; - } - - const Descriptor* descriptor; -}; - -inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; } - -PROTOC_EXPORT std::string StripProto(const std::string& filename); - -bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options); - -bool EnableMessageOwnedArenaTrial(const Descriptor* desc, - const Options& options); - -bool ShouldVerify(const Descriptor* descriptor, const Options& options, - MessageSCCAnalyzer* scc_analyzer); -bool ShouldVerify(const FileDescriptor* file, const Options& options, - MessageSCCAnalyzer* scc_analyzer); - -// Indicates whether to use predefined verify methods for a given message. If a -// message is "simple" and needs no special verification per field (e.g. message -// field, repeated packed, UTF8 string, etc.), we can use either VerifySimple or -// VerifySimpleAlwaysCheckInt32 methods as all verification can be done based on -// the wire type. -// -// Otherwise, we need "custom" verify methods tailored to a message to pass -// which field needs a special verification; i.e. InternalVerify. -enum class VerifySimpleType { - kSimpleInt32Never, // Use VerifySimple - kSimpleInt32Always, // Use VerifySimpleAlwaysCheckInt32 - kCustom, // Use InternalVerify and check only for int32 - kCustomInt32Never, // Use InternalVerify but never check for int32 - kCustomInt32Always, // Use InternalVerify and always check for int32 -}; - -// Returns VerifySimpleType if messages can be verified by predefined methods. -VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor); - -bool IsUtf8String(const FieldDescriptor* field); - -bool HasMessageFieldOrExtension(const Descriptor* desc); - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ diff --git a/include/google/protobuf/compiler/cpp/names.h b/include/google/protobuf/compiler/cpp/names.h deleted file mode 100644 index 7404ac530f..0000000000 --- a/include/google/protobuf/compiler/cpp/names.h +++ /dev/null @@ -1,97 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ - -#include <string> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class EnumValueDescriptor; -class FieldDescriptor; - -namespace compiler { -namespace cpp { - -// Returns the unqualified C++ name. -// -// For example, if you had: -// package foo.bar; -// message Baz { message Moo {} } -// Then the non-qualified version would be: -// Baz_Moo -std::string ClassName(const Descriptor* descriptor); -std::string ClassName(const EnumDescriptor* enum_descriptor); - -// Returns the fully qualified C++ name. -// -// For example, if you had: -// package foo.bar; -// message Baz { message Moo {} } -// Then the qualified ClassName for Moo would be: -// ::foo::bar::Baz_Moo -std::string QualifiedClassName(const Descriptor* d); -std::string QualifiedClassName(const EnumDescriptor* d); -std::string QualifiedExtensionName(const FieldDescriptor* d); - -// Get the (unqualified) name that should be used for this field in C++ code. -// The name is coerced to lower-case to emulate proto1 behavior. People -// should be using lowercase-with-underscores style for proto field names -// anyway, so normally this just returns field->name(). -std::string FieldName(const FieldDescriptor* field); - -// Requires that this field is in a oneof. Returns the (unqualified) case -// constant for this field. -std::string OneofCaseConstantName(const FieldDescriptor* field); -// Returns the quafilied case constant for this field. -std::string QualifiedOneofCaseConstantName(const FieldDescriptor* field); - -// Get the (unqualified) name that should be used for this enum value in C++ -// code. -std::string EnumValueName(const EnumValueDescriptor* enum_value); - -// Strips ".proto" or ".protodevel" from the end of a filename. -PROTOC_EXPORT std::string StripProto(const std::string& filename); - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ diff --git a/include/google/protobuf/compiler/csharp/csharp_doc_comment.h b/include/google/protobuf/compiler/csharp/csharp_doc_comment.h deleted file mode 100644 index 75eb0ea04d..0000000000 --- a/include/google/protobuf/compiler/csharp/csharp_doc_comment.h +++ /dev/null @@ -1,51 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__ - -#include <google/protobuf/io/printer.h> -#include <google/protobuf/descriptor.h> - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - void WriteMessageDocComment(io::Printer* printer, const Descriptor* message); - void WritePropertyDocComment(io::Printer* printer, const FieldDescriptor* field); - void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enumDescriptor); - void WriteEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); - void WriteMethodDocComment(io::Printer* printer, const MethodDescriptor* method); -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__ diff --git a/include/google/protobuf/compiler/csharp/csharp_generator.h b/include/google/protobuf/compiler/csharp/csharp_generator.h deleted file mode 100644 index f41f9b8358..0000000000 --- a/include/google/protobuf/compiler/csharp/csharp_generator.h +++ /dev/null @@ -1,70 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Generates C# code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ - -#include <string> - -#include <google/protobuf/compiler/code_generator.h> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -// CodeGenerator implementation which generates a C# source file and -// header. If you create your own protocol compiler binary and you want -// it to support C# output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator : public CodeGenerator { - public: - Generator(); - ~Generator(); - bool Generate( - const FileDescriptor* file, - const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - uint64_t GetSupportedFeatures() const override; -}; - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/csharp/csharp_names.h b/include/google/protobuf/compiler/csharp/csharp_names.h deleted file mode 100644 index 67e53b6401..0000000000 --- a/include/google/protobuf/compiler/csharp/csharp_names.h +++ /dev/null @@ -1,109 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Provides a mechanism for mapping a descriptor to the -// fully-qualified name of the corresponding C# class. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ - -#include <string> -#include <google/protobuf/port.h> -#include <google/protobuf/stubs/common.h> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class FileDescriptor; -class ServiceDescriptor; - -namespace compiler { -namespace csharp { - -// Requires: -// descriptor != NULL -// -// Returns: -// The namespace to use for given file descriptor. -std::string PROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified C# class name. -std::string PROTOC_EXPORT GetClassName(const Descriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified name of the C# class that provides -// access to the file descriptor. Proto compiler generates -// such class for each .proto file processed. -std::string PROTOC_EXPORT -GetReflectionClassName(const FileDescriptor* descriptor); - -// Generates output file name for given file descriptor. If generate_directories -// is true, the output file will be put under directory corresponding to file's -// namespace. base_namespace can be used to strip some of the top level -// directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar", -// the resulting file will be put under directory "Foo" (and not "Bar/Foo"). -// -// Requires: -// descriptor != NULL -// error != NULL -// -// Returns: -// The file name to use as output file for given file descriptor. In case -// of failure, this function will return empty string and error parameter -// will contain the error message. -std::string PROTOC_EXPORT GetOutputFile(const FileDescriptor* descriptor, - const std::string file_extension, - const bool generate_directories, - const std::string base_namespace, - std::string* error); - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ diff --git a/include/google/protobuf/compiler/csharp/csharp_options.h b/include/google/protobuf/compiler/csharp/csharp_options.h deleted file mode 100644 index 42ff6d8662..0000000000 --- a/include/google/protobuf/compiler/csharp/csharp_options.h +++ /dev/null @@ -1,81 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__ - -#include <string> - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -// Generator options (used by csharp_generator.cc): -struct Options { - Options() : - file_extension(".cs"), - base_namespace(""), - base_namespace_specified(false), - internal_access(false), - serializable(false) { - } - // Extension of the generated file. Defaults to ".cs" - std::string file_extension; - // Base namespace to use to create directory hierarchy. Defaults to "". - // This option allows the simple creation of a conventional C# file layout, - // where directories are created relative to a project-specific base - // namespace. For example, in a project with a base namespace of PetShop, a - // proto of user.proto with a C# namespace of PetShop.Model.Shared would - // generate Model/Shared/User.cs underneath the specified --csharp_out - // directory. - // - // If no base namespace is specified, all files are generated in the - // --csharp_out directory, with no subdirectories created automatically. - std::string base_namespace; - // Whether the base namespace has been explicitly specified by the user. - // This is required as the base namespace can be explicitly set to the empty - // string, meaning "create a full directory hierarchy, starting from the first - // segment of the namespace." - bool base_namespace_specified; - // Whether the generated classes should have accessibility level of "internal". - // Defaults to false that generates "public" classes. - bool internal_access; - // Whether the generated classes should have a global::System.Serializable attribute added - // Defaults to false - bool serializable; -}; - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__ diff --git a/include/google/protobuf/compiler/importer.h b/include/google/protobuf/compiler/importer.h deleted file mode 100644 index 2fb88b923e..0000000000 --- a/include/google/protobuf/compiler/importer.h +++ /dev/null @@ -1,338 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file is the public interface to the .proto file parser. - -#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ -#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ - -#include <set> -#include <string> -#include <utility> -#include <vector> - -#include <google/protobuf/compiler/parser.h> -#include <google/protobuf/descriptor.h> -#include <google/protobuf/descriptor_database.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -namespace io { -class ZeroCopyInputStream; -} - -namespace compiler { - -// Defined in this file. -class Importer; -class MultiFileErrorCollector; -class SourceTree; -class DiskSourceTree; - -// TODO(kenton): Move all SourceTree stuff to a separate file? - -// An implementation of DescriptorDatabase which loads files from a SourceTree -// and parses them. -// -// Note: This class is not thread-safe since it maintains a table of source -// code locations for error reporting. However, when a DescriptorPool wraps -// a DescriptorDatabase, it uses mutex locking to make sure only one method -// of the database is called at a time, even if the DescriptorPool is used -// from multiple threads. Therefore, there is only a problem if you create -// multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase -// and use them from multiple threads. -// -// Note: This class does not implement FindFileContainingSymbol() or -// FindFileContainingExtension(); these will always return false. -class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase { - public: - SourceTreeDescriptorDatabase(SourceTree* source_tree); - - // If non-NULL, fallback_database will be checked if a file doesn't exist in - // the specified source_tree. - SourceTreeDescriptorDatabase(SourceTree* source_tree, - DescriptorDatabase* fallback_database); - ~SourceTreeDescriptorDatabase() override; - - // Instructs the SourceTreeDescriptorDatabase to report any parse errors - // to the given MultiFileErrorCollector. This should be called before - // parsing. error_collector must remain valid until either this method - // is called again or the SourceTreeDescriptorDatabase is destroyed. - void RecordErrorsTo(MultiFileErrorCollector* error_collector) { - error_collector_ = error_collector; - } - - // Gets a DescriptorPool::ErrorCollector which records errors to the - // MultiFileErrorCollector specified with RecordErrorsTo(). This collector - // has the ability to determine exact line and column numbers of errors - // from the information given to it by the DescriptorPool. - DescriptorPool::ErrorCollector* GetValidationErrorCollector() { - using_validation_error_collector_ = true; - return &validation_error_collector_; - } - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const std::string& filename, - FileDescriptorProto* output) override; - bool FindFileContainingSymbol(const std::string& symbol_name, - FileDescriptorProto* output) override; - bool FindFileContainingExtension(const std::string& containing_type, - int field_number, - FileDescriptorProto* output) override; - - private: - class SingleFileErrorCollector; - - SourceTree* source_tree_; - DescriptorDatabase* fallback_database_; - MultiFileErrorCollector* error_collector_; - - class PROTOBUF_EXPORT ValidationErrorCollector - : public DescriptorPool::ErrorCollector { - public: - ValidationErrorCollector(SourceTreeDescriptorDatabase* owner); - ~ValidationErrorCollector() override; - - // implements ErrorCollector --------------------------------------- - void AddError(const std::string& filename, const std::string& element_name, - const Message* descriptor, ErrorLocation location, - const std::string& message) override; - - void AddWarning(const std::string& filename, - const std::string& element_name, const Message* descriptor, - ErrorLocation location, - const std::string& message) override; - - private: - SourceTreeDescriptorDatabase* owner_; - }; - friend class ValidationErrorCollector; - - bool using_validation_error_collector_; - SourceLocationTable source_locations_; - ValidationErrorCollector validation_error_collector_; -}; - -// Simple interface for parsing .proto files. This wraps the process -// of opening the file, parsing it with a Parser, recursively parsing all its -// imports, and then cross-linking the results to produce a FileDescriptor. -// -// This is really just a thin wrapper around SourceTreeDescriptorDatabase. -// You may find that SourceTreeDescriptorDatabase is more flexible. -// -// TODO(kenton): I feel like this class is not well-named. -class PROTOBUF_EXPORT Importer { - public: - Importer(SourceTree* source_tree, MultiFileErrorCollector* error_collector); - ~Importer(); - - // Import the given file and build a FileDescriptor representing it. If - // the file is already in the DescriptorPool, the existing FileDescriptor - // will be returned. The FileDescriptor is property of the DescriptorPool, - // and will remain valid until it is destroyed. If any errors occur, they - // will be reported using the error collector and Import() will return NULL. - // - // A particular Importer object will only report errors for a particular - // file once. All future attempts to import the same file will return NULL - // without reporting any errors. The idea is that you might want to import - // a lot of files without seeing the same errors over and over again. If - // you want to see errors for the same files repeatedly, you can use a - // separate Importer object to import each one (but use the same - // DescriptorPool so that they can be cross-linked). - const FileDescriptor* Import(const std::string& filename); - - // The DescriptorPool in which all imported FileDescriptors and their - // contents are stored. - inline const DescriptorPool* pool() const { return &pool_; } - - void AddUnusedImportTrackFile(const std::string& file_name, - bool is_error = false); - void ClearUnusedImportTrackFiles(); - - - private: - SourceTreeDescriptorDatabase database_; - DescriptorPool pool_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer); -}; - -// If the importer encounters problems while trying to import the proto files, -// it reports them to a MultiFileErrorCollector. -class PROTOBUF_EXPORT MultiFileErrorCollector { - public: - inline MultiFileErrorCollector() {} - virtual ~MultiFileErrorCollector(); - - // Line and column numbers are zero-based. A line number of -1 indicates - // an error with the entire file (e.g. "not found"). - virtual void AddError(const std::string& filename, int line, int column, - const std::string& message) = 0; - - virtual void AddWarning(const std::string& /* filename */, int /* line */, - int /* column */, const std::string& /* message */) {} - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector); -}; - -// Abstract interface which represents a directory tree containing proto files. -// Used by the default implementation of Importer to resolve import statements -// Most users will probably want to use the DiskSourceTree implementation, -// below. -class PROTOBUF_EXPORT SourceTree { - public: - inline SourceTree() {} - virtual ~SourceTree(); - - // Open the given file and return a stream that reads it, or NULL if not - // found. The caller takes ownership of the returned object. The filename - // must be a path relative to the root of the source tree and must not - // contain "." or ".." components. - virtual io::ZeroCopyInputStream* Open(const std::string& filename) = 0; - - // If Open() returns NULL, calling this method immediately will return an - // description of the error. - // Subclasses should implement this method and return a meaningful value for - // better error reporting. - // TODO(xiaofeng): change this to a pure virtual function. - virtual std::string GetLastErrorMessage(); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree); -}; - -// An implementation of SourceTree which loads files from locations on disk. -// Multiple mappings can be set up to map locations in the DiskSourceTree to -// locations in the physical filesystem. -class PROTOBUF_EXPORT DiskSourceTree : public SourceTree { - public: - DiskSourceTree(); - ~DiskSourceTree() override; - - // Map a path on disk to a location in the SourceTree. The path may be - // either a file or a directory. If it is a directory, the entire tree - // under it will be mapped to the given virtual location. To map a directory - // to the root of the source tree, pass an empty string for virtual_path. - // - // If multiple mapped paths apply when opening a file, they will be searched - // in order. For example, if you do: - // MapPath("bar", "foo/bar"); - // MapPath("", "baz"); - // and then you do: - // Open("bar/qux"); - // the DiskSourceTree will first try to open foo/bar/qux, then baz/bar/qux, - // returning the first one that opens successfully. - // - // disk_path may be an absolute path or relative to the current directory, - // just like a path you'd pass to open(). - void MapPath(const std::string& virtual_path, const std::string& disk_path); - - // Return type for DiskFileToVirtualFile(). - enum DiskFileToVirtualFileResult { - SUCCESS, - SHADOWED, - CANNOT_OPEN, - NO_MAPPING - }; - - // Given a path to a file on disk, find a virtual path mapping to that - // file. The first mapping created with MapPath() whose disk_path contains - // the filename is used. However, that virtual path may not actually be - // usable to open the given file. Possible return values are: - // * SUCCESS: The mapping was found. *virtual_file is filled in so that - // calling Open(*virtual_file) will open the file named by disk_file. - // * SHADOWED: A mapping was found, but using Open() to open this virtual - // path will end up returning some different file. This is because some - // other mapping with a higher precedence also matches this virtual path - // and maps it to a different file that exists on disk. *virtual_file - // is filled in as it would be in the SUCCESS case. *shadowing_disk_file - // is filled in with the disk path of the file which would be opened if - // you were to call Open(*virtual_file). - // * CANNOT_OPEN: The mapping was found and was not shadowed, but the - // file specified cannot be opened. When this value is returned, - // errno will indicate the reason the file cannot be opened. *virtual_file - // will be set to the virtual path as in the SUCCESS case, even though - // it is not useful. - // * NO_MAPPING: Indicates that no mapping was found which contains this - // file. - DiskFileToVirtualFileResult DiskFileToVirtualFile( - const std::string& disk_file, std::string* virtual_file, - std::string* shadowing_disk_file); - - // Given a virtual path, find the path to the file on disk. - // Return true and update disk_file with the on-disk path if the file exists. - // Return false and leave disk_file untouched if the file doesn't exist. - bool VirtualFileToDiskFile(const std::string& virtual_file, - std::string* disk_file); - - // implements SourceTree ------------------------------------------- - io::ZeroCopyInputStream* Open(const std::string& filename) override; - - std::string GetLastErrorMessage() override; - - private: - struct Mapping { - std::string virtual_path; - std::string disk_path; - - inline Mapping(const std::string& virtual_path_param, - const std::string& disk_path_param) - : virtual_path(virtual_path_param), disk_path(disk_path_param) {} - }; - std::vector<Mapping> mappings_; - std::string last_error_message_; - - // Like Open(), but returns the on-disk path in disk_file if disk_file is - // non-NULL and the file could be successfully opened. - io::ZeroCopyInputStream* OpenVirtualFile(const std::string& virtual_file, - std::string* disk_file); - - // Like Open() but given the actual on-disk path. - io::ZeroCopyInputStream* OpenDiskFile(const std::string& filename); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree); -}; - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ diff --git a/include/google/protobuf/compiler/java/generator.h b/include/google/protobuf/compiler/java/generator.h deleted file mode 100644 index bbc71700c6..0000000000 --- a/include/google/protobuf/compiler/java/generator.h +++ /dev/null @@ -1,77 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates Java code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ - -#include <string> -#include <google/protobuf/compiler/code_generator.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -// CodeGenerator implementation which generates Java code. If you create your -// own protocol compiler binary and you want it to support Java output, you -// can do so by registering an instance of this CodeGenerator with the -// CommandLineInterface in your main() function. -class PROTOC_EXPORT JavaGenerator : public CodeGenerator { - public: - JavaGenerator(); - ~JavaGenerator() override; - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const override; - - uint64_t GetSupportedFeatures() const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/java/java_generator.h b/include/google/protobuf/compiler/java/java_generator.h deleted file mode 100644 index 294b1bde02..0000000000 --- a/include/google/protobuf/compiler/java/java_generator.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ - -#include <google/protobuf/compiler/java/generator.h> - -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ diff --git a/include/google/protobuf/compiler/java/kotlin_generator.h b/include/google/protobuf/compiler/java/kotlin_generator.h deleted file mode 100644 index ccd9688ca0..0000000000 --- a/include/google/protobuf/compiler/java/kotlin_generator.h +++ /dev/null @@ -1,74 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Generates Kotlin code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__ - -#include <string> - -#include <google/protobuf/compiler/code_generator.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -// CodeGenerator implementation which generates Kotlin code. If you create your -// own protocol compiler binary and you want it to support Kotlin output, you -// can do so by registering an instance of this CodeGenerator with the -// CommandLineInterface in your main() function. -class PROTOC_EXPORT KotlinGenerator : public CodeGenerator { - public: - KotlinGenerator(); - ~KotlinGenerator() override; - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const override; - - uint64_t GetSupportedFeatures() const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(KotlinGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/java/names.h b/include/google/protobuf/compiler/java/names.h deleted file mode 100644 index 313ace4feb..0000000000 --- a/include/google/protobuf/compiler/java/names.h +++ /dev/null @@ -1,100 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Provides a mechanism for mapping a descriptor to the -// fully-qualified name of the corresponding Java class. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ - -#include <string> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class FileDescriptor; -class FieldDescriptor; -class ServiceDescriptor; - -namespace compiler { -namespace java { - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified Java class name. -std::string ClassName(const Descriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified Java class name. -std::string ClassName(const EnumDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified Java class name. -std::string ClassName(const FileDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// The fully-qualified Java class name. -std::string ClassName(const ServiceDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// -// Returns: -// Java package name. -std::string FileJavaPackage(const FileDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// Returns: -// Capitalized camel case name field name. -std::string CapitalizedFieldName(const FieldDescriptor* descriptor); - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ diff --git a/include/google/protobuf/compiler/objectivec/objectivec_generator.h b/include/google/protobuf/compiler/objectivec/objectivec_generator.h deleted file mode 100644 index 1dbc666af1..0000000000 --- a/include/google/protobuf/compiler/objectivec/objectivec_generator.h +++ /dev/null @@ -1,79 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Generates ObjectiveC code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ - -#include <string> -#include <google/protobuf/compiler/code_generator.h> -#include <google/protobuf/descriptor.h> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace objectivec { - -// CodeGenerator implementation which generates a ObjectiveC source file and -// header. If you create your own protocol compiler binary and you want it to -// support ObjectiveC output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator { - public: - ObjectiveCGenerator(); - ~ObjectiveCGenerator(); - - ObjectiveCGenerator(const ObjectiveCGenerator&) = delete; - ObjectiveCGenerator& operator=(const ObjectiveCGenerator&) = delete; - - // implements CodeGenerator ---------------------------------------- - bool HasGenerateAll() const override; - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const override; - bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, GeneratorContext* context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } -}; - -} // namespace objectivec -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/objectivec/objectivec_helpers.h b/include/google/protobuf/compiler/objectivec/objectivec_helpers.h deleted file mode 100644 index d21fed215a..0000000000 --- a/include/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ /dev/null @@ -1,353 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Helper functions for generating ObjectiveC code. - -#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__ -#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__ - -#include <string> -#include <vector> - -#include <google/protobuf/descriptor.h> -#include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/io/zero_copy_stream.h> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace objectivec { - -// Get/Set the path to a file to load for objc class prefix lookups. -std::string PROTOC_EXPORT GetPackageToPrefixMappingsPath(); -void PROTOC_EXPORT SetPackageToPrefixMappingsPath( - const std::string& file_path); -// Get/Set if the proto package should be used to make the default prefix for -// symbols. This will then impact most of the type naming apis below. It is done -// as a global to not break any other generator reusing the methods since they -// are exported. -bool PROTOC_EXPORT UseProtoPackageAsDefaultPrefix(); -void PROTOC_EXPORT SetUseProtoPackageAsDefaultPrefix(bool on_or_off); -// Get/Set the path to a file to load as exceptions when -// `UseProtoPackageAsDefaultPrefix()` is `true`. An empty string means there -// should be no exceptions. -std::string PROTOC_EXPORT GetProtoPackagePrefixExceptionList(); -void PROTOC_EXPORT SetProtoPackagePrefixExceptionList( - const std::string& file_path); - -// Generator Prefix Validation Options (see objectivec_generator.cc for a -// description of each): -struct Options { - Options(); - std::string expected_prefixes_path; - std::vector<std::string> expected_prefixes_suppressions; - bool prefixes_must_be_registered; - bool require_prefixes; -}; - -// Escape C++ trigraphs by escaping question marks to "\?". -std::string PROTOC_EXPORT EscapeTrigraphs(const std::string& to_escape); - -// Remove white space from either end of a StringPiece. -void PROTOC_EXPORT TrimWhitespace(StringPiece* input); - -// Returns true if the name requires a ns_returns_not_retained attribute applied -// to it. -bool PROTOC_EXPORT IsRetainedName(const std::string& name); - -// Returns true if the name starts with "init" and will need to have special -// handling under ARC. -bool PROTOC_EXPORT IsInitName(const std::string& name); - -// Gets the objc_class_prefix or the prefix made from the proto package. -std::string PROTOC_EXPORT FileClassPrefix(const FileDescriptor* file); - -// Gets the path of the file we're going to generate (sans the .pb.h -// extension). The path will be dependent on the objectivec package -// declared in the proto package. -std::string PROTOC_EXPORT FilePath(const FileDescriptor* file); - -// Just like FilePath(), but without the directory part. -std::string PROTOC_EXPORT FilePathBasename(const FileDescriptor* file); - -// Gets the name of the root class we'll generate in the file. This class -// is not meant for external consumption, but instead contains helpers that -// the rest of the classes need -std::string PROTOC_EXPORT FileClassName(const FileDescriptor* file); - -// These return the fully-qualified class name corresponding to the given -// descriptor. -std::string PROTOC_EXPORT ClassName(const Descriptor* descriptor); -std::string PROTOC_EXPORT ClassName(const Descriptor* descriptor, - std::string* out_suffix_added); -std::string PROTOC_EXPORT EnumName(const EnumDescriptor* descriptor); - -// Returns the fully-qualified name of the enum value corresponding to the -// the descriptor. -std::string PROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor); - -// Returns the name of the enum value corresponding to the descriptor. -std::string PROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor); - -// Reverse what an enum does. -std::string PROTOC_EXPORT UnCamelCaseEnumShortName(const std::string& name); - -// Returns the name to use for the extension (used as the method off the file's -// Root class). -std::string PROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor); - -// Returns the transformed field name. -std::string PROTOC_EXPORT FieldName(const FieldDescriptor* field); -std::string PROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field); - -// Returns the transformed oneof name. -std::string PROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor); -std::string PROTOC_EXPORT OneofName(const OneofDescriptor* descriptor); -std::string PROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor); - -// Returns a symbol that can be used in C code to refer to an Objective C -// class without initializing the class. -std::string PROTOC_EXPORT ObjCClass(const std::string& class_name); - -// Declares an Objective C class without initializing the class so that it can -// be refrerred to by ObjCClass. -std::string PROTOC_EXPORT ObjCClassDeclaration(const std::string& class_name); - -inline bool HasPreservingUnknownEnumSemantics(const FileDescriptor* file) { - return file->syntax() == FileDescriptor::SYNTAX_PROTO3; -} - -inline bool IsMapEntryMessage(const Descriptor* descriptor) { - return descriptor->options().map_entry(); -} - -// Reverse of the above. -std::string PROTOC_EXPORT UnCamelCaseFieldName(const std::string& name, - const FieldDescriptor* field); - -enum ObjectiveCType { - OBJECTIVECTYPE_INT32, - OBJECTIVECTYPE_UINT32, - OBJECTIVECTYPE_INT64, - OBJECTIVECTYPE_UINT64, - OBJECTIVECTYPE_FLOAT, - OBJECTIVECTYPE_DOUBLE, - OBJECTIVECTYPE_BOOLEAN, - OBJECTIVECTYPE_STRING, - OBJECTIVECTYPE_DATA, - OBJECTIVECTYPE_ENUM, - OBJECTIVECTYPE_MESSAGE -}; - -enum FlagType { - FLAGTYPE_DESCRIPTOR_INITIALIZATION, - FLAGTYPE_EXTENSION, - FLAGTYPE_FIELD -}; - -template <class TDescriptor> -std::string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, - const FileDescriptor* file = NULL, - bool preSpace = true, - bool postNewline = false) { - bool isDeprecated = descriptor->options().deprecated(); - // The file is only passed when checking Messages & Enums, so those types - // get tagged. At the moment, it doesn't seem to make sense to tag every - // field or enum value with when the file is deprecated. - bool isFileLevelDeprecation = false; - if (!isDeprecated && file) { - isFileLevelDeprecation = file->options().deprecated(); - isDeprecated = isFileLevelDeprecation; - } - if (isDeprecated) { - std::string message; - const FileDescriptor* sourceFile = descriptor->file(); - if (isFileLevelDeprecation) { - message = sourceFile->name() + " is deprecated."; - } else { - message = descriptor->full_name() + " is deprecated (see " + - sourceFile->name() + ")."; - } - - std::string result = std::string("GPB_DEPRECATED_MSG(\"") + message + "\")"; - if (preSpace) { - result.insert(0, " "); - } - if (postNewline) { - result.append("\n"); - } - return result; - } else { - return ""; - } -} - -std::string PROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field); - -ObjectiveCType PROTOC_EXPORT -GetObjectiveCType(FieldDescriptor::Type field_type); - -inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) { - return GetObjectiveCType(field->type()); -} - -bool PROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field); -bool PROTOC_EXPORT IsReferenceType(const FieldDescriptor* field); - -std::string PROTOC_EXPORT -GPBGenericValueFieldName(const FieldDescriptor* field); -std::string PROTOC_EXPORT DefaultValue(const FieldDescriptor* field); -bool PROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field); - -std::string PROTOC_EXPORT -BuildFlagsString(const FlagType type, const std::vector<std::string>& strings); - -// Builds HeaderDoc/appledoc style comments out of the comments in the .proto -// file. -std::string PROTOC_EXPORT BuildCommentsString(const SourceLocation& location, - bool prefer_single_line); - -// The name the commonly used by the library when built as a framework. -// This lines up to the name used in the CocoaPod. -extern PROTOC_EXPORT const char* const ProtobufLibraryFrameworkName; -// Returns the CPP symbol name to use as the gate for framework style imports -// for the given framework name to use. -std::string PROTOC_EXPORT -ProtobufFrameworkImportSymbol(const std::string& framework_name); - -// Checks if the file is one of the proto's bundled with the library. -bool PROTOC_EXPORT -IsProtobufLibraryBundledProtoFile(const FileDescriptor* file); - -// Checks the prefix for the given files and outputs any warnings as needed. If -// there are flat out errors, then out_error is filled in with the first error -// and the result is false. -bool PROTOC_EXPORT ValidateObjCClassPrefixes( - const std::vector<const FileDescriptor*>& files, - const Options& validation_options, std::string* out_error); -// Same was the other ValidateObjCClassPrefixes() calls, but the options all -// come from the environment variables. -bool PROTOC_EXPORT ValidateObjCClassPrefixes( - const std::vector<const FileDescriptor*>& files, std::string* out_error); - -// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform -// the input into the expected output. -class PROTOC_EXPORT TextFormatDecodeData { - public: - TextFormatDecodeData(); - ~TextFormatDecodeData(); - - TextFormatDecodeData(const TextFormatDecodeData&) = delete; - TextFormatDecodeData& operator=(const TextFormatDecodeData&) = delete; - - void AddString(int32_t key, const std::string& input_for_decode, - const std::string& desired_output); - size_t num_entries() const { return entries_.size(); } - std::string Data() const; - - static std::string DecodeDataForString(const std::string& input_for_decode, - const std::string& desired_output); - - private: - typedef std::pair<int32_t, std::string> DataEntry; - std::vector<DataEntry> entries_; -}; - -// Helper for parsing simple files. -class PROTOC_EXPORT LineConsumer { - public: - LineConsumer(); - virtual ~LineConsumer(); - virtual bool ConsumeLine(const StringPiece& line, std::string* out_error) = 0; -}; - -bool PROTOC_EXPORT ParseSimpleFile(const std::string& path, - LineConsumer* line_consumer, - std::string* out_error); - -bool PROTOC_EXPORT ParseSimpleStream(io::ZeroCopyInputStream& input_stream, - const std::string& stream_name, - LineConsumer* line_consumer, - std::string* out_error); - -// Helper class for parsing framework import mappings and generating -// import statements. -class PROTOC_EXPORT ImportWriter { - public: - ImportWriter(const std::string& generate_for_named_framework, - const std::string& named_framework_to_proto_path_mappings_path, - const std::string& runtime_import_prefix, - bool include_wkt_imports); - ~ImportWriter(); - - void AddFile(const FileDescriptor* file, const std::string& header_extension); - void Print(io::Printer* printer) const; - - static void PrintRuntimeImports(io::Printer* printer, - const std::vector<std::string>& header_to_import, - const std::string& runtime_import_prefix, - bool default_cpp_symbol = false); - - private: - class ProtoFrameworkCollector : public LineConsumer { - public: - ProtoFrameworkCollector(std::map<std::string, std::string>* inout_proto_file_to_framework_name) - : map_(inout_proto_file_to_framework_name) {} - - virtual bool ConsumeLine(const StringPiece& line, std::string* out_error) override; - - private: - std::map<std::string, std::string>* map_; - }; - - void ParseFrameworkMappings(); - - const std::string generate_for_named_framework_; - const std::string named_framework_to_proto_path_mappings_path_; - const std::string runtime_import_prefix_; - const bool include_wkt_imports_; - std::map<std::string, std::string> proto_file_to_framework_name_; - bool need_to_parse_mapping_file_; - - std::vector<std::string> protobuf_imports_; - std::vector<std::string> other_framework_imports_; - std::vector<std::string> other_imports_; -}; - -} // namespace objectivec -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__ diff --git a/include/google/protobuf/compiler/parser.h b/include/google/protobuf/compiler/parser.h deleted file mode 100644 index d4eb76302c..0000000000 --- a/include/google/protobuf/compiler/parser.h +++ /dev/null @@ -1,602 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Implements parsing of .proto files to FileDescriptorProtos. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__ -#define GOOGLE_PROTOBUF_COMPILER_PARSER_H__ - -#include <cstdint> -#include <map> -#include <string> -#include <utility> - -#include <google/protobuf/descriptor.h> -#include <google/protobuf/descriptor.pb.h> -#include <google/protobuf/io/tokenizer.h> -#include <google/protobuf/repeated_field.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Message; - -namespace compiler { - -// Defined in this file. -class Parser; -class SourceLocationTable; - -// Implements parsing of protocol definitions (such as .proto files). -// -// Note that most users will be more interested in the Importer class. -// Parser is a lower-level class which simply converts a single .proto file -// to a FileDescriptorProto. It does not resolve import directives or perform -// many other kinds of validation needed to construct a complete -// FileDescriptor. -class PROTOBUF_EXPORT Parser { - public: - Parser(); - ~Parser(); - - // Parse the entire input and construct a FileDescriptorProto representing - // it. Returns true if no errors occurred, false otherwise. - bool Parse(io::Tokenizer* input, FileDescriptorProto* file); - - // Optional features: - - // DEPRECATED: New code should use the SourceCodeInfo embedded in the - // FileDescriptorProto. - // - // Requests that locations of certain definitions be recorded to the given - // SourceLocationTable while parsing. This can be used to look up exact line - // and column numbers for errors reported by DescriptorPool during validation. - // Set to NULL (the default) to discard source location information. - void RecordSourceLocationsTo(SourceLocationTable* location_table) { - source_location_table_ = location_table; - } - - // Requests that errors be recorded to the given ErrorCollector while - // parsing. Set to NULL (the default) to discard error messages. - void RecordErrorsTo(io::ErrorCollector* error_collector) { - error_collector_ = error_collector; - } - - // Returns the identifier used in the "syntax = " declaration, if one was - // seen during the last call to Parse(), or the empty string otherwise. - const std::string& GetSyntaxIdentifier() { return syntax_identifier_; } - - // If set true, input files will be required to begin with a syntax - // identifier. Otherwise, files may omit this. If a syntax identifier - // is provided, it must be 'syntax = "proto2";' and must appear at the - // top of this file regardless of whether or not it was required. - void SetRequireSyntaxIdentifier(bool value) { - require_syntax_identifier_ = value; - } - - // Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop - // parsing as soon as it has seen the syntax identifier, or lack thereof. - // This is useful for quickly identifying the syntax of the file without - // parsing the whole thing. If this is enabled, no error will be recorded - // if the syntax identifier is something other than "proto2" (since - // presumably the caller intends to deal with that), but other kinds of - // errors (e.g. parse errors) will still be reported. When this is enabled, - // you may pass a NULL FileDescriptorProto to Parse(). - void SetStopAfterSyntaxIdentifier(bool value) { - stop_after_syntax_identifier_ = value; - } - - private: - class LocationRecorder; - struct MapField; - - // ================================================================= - // Error recovery helpers - - // Consume the rest of the current statement. This consumes tokens - // until it sees one of: - // ';' Consumes the token and returns. - // '{' Consumes the brace then calls SkipRestOfBlock(). - // '}' Returns without consuming. - // EOF Returns (can't consume). - // The Parser often calls SkipStatement() after encountering a syntax - // error. This allows it to go on parsing the following lines, allowing - // it to report more than just one error in the file. - void SkipStatement(); - - // Consume the rest of the current block, including nested blocks, - // ending after the closing '}' is encountered and consumed, or at EOF. - void SkipRestOfBlock(); - - // ----------------------------------------------------------------- - // Single-token consuming helpers - // - // These make parsing code more readable. - - // True if the current token is TYPE_END. - inline bool AtEnd(); - - // True if the next token matches the given text. - inline bool LookingAt(const char* text); - // True if the next token is of the given type. - inline bool LookingAtType(io::Tokenizer::TokenType token_type); - - // If the next token exactly matches the text given, consume it and return - // true. Otherwise, return false without logging an error. - bool TryConsume(const char* text); - - // These attempt to read some kind of token from the input. If successful, - // they return true. Otherwise they return false and add the given error - // to the error list. - - // Consume a token with the exact text given. - bool Consume(const char* text, const char* error); - // Same as above, but automatically generates the error "Expected \"text\".", - // where "text" is the expected token text. - bool Consume(const char* text); - // Consume a token of type IDENTIFIER and store its text in "output". - bool ConsumeIdentifier(std::string* output, const char* error); - // Consume an integer and store its value in "output". - bool ConsumeInteger(int* output, const char* error); - // Consume a signed integer and store its value in "output". - bool ConsumeSignedInteger(int* output, const char* error); - // Consume a 64-bit integer and store its value in "output". If the value - // is greater than max_value, an error will be reported. - bool ConsumeInteger64(uint64_t max_value, uint64_t* output, - const char* error); - // Consume a number and store its value in "output". This will accept - // tokens of either INTEGER or FLOAT type. - bool ConsumeNumber(double* output, const char* error); - // Consume a string literal and store its (unescaped) value in "output". - bool ConsumeString(std::string* output, const char* error); - - // Consume a token representing the end of the statement. Comments between - // this token and the next will be harvested for documentation. The given - // LocationRecorder should refer to the declaration that was just parsed; - // it will be populated with these comments. - // - // TODO(kenton): The LocationRecorder is const because historically locations - // have been passed around by const reference, for no particularly good - // reason. We should probably go through and change them all to mutable - // pointer to make this more intuitive. - bool TryConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location); - bool TryConsumeEndOfDeclarationFinishScope(const char* text, - const LocationRecorder* location); - - bool ConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location); - - // ----------------------------------------------------------------- - // Error logging helpers - - // Invokes error_collector_->AddError(), if error_collector_ is not NULL. - void AddError(int line, int column, const std::string& error); - - // Invokes error_collector_->AddError() with the line and column number - // of the current token. - void AddError(const std::string& error); - - // Invokes error_collector_->AddWarning() with the line and column number - // of the current token. - void AddWarning(const std::string& warning); - - // Records a location in the SourceCodeInfo.location table (see - // descriptor.proto). We use RAII to ensure that the start and end locations - // are recorded -- the constructor records the start location and the - // destructor records the end location. Since the parser is - // recursive-descent, this works out beautifully. - class PROTOBUF_EXPORT LocationRecorder { - public: - // Construct the file's "root" location. - LocationRecorder(Parser* parser); - - // Construct a location that represents a declaration nested within the - // given parent. E.g. a field's location is nested within the location - // for a message type. The parent's path will be copied, so you should - // call AddPath() only to add the path components leading from the parent - // to the child (as opposed to leading from the root to the child). - LocationRecorder(const LocationRecorder& parent); - - // Convenience constructors that call AddPath() one or two times. - LocationRecorder(const LocationRecorder& parent, int path1); - LocationRecorder(const LocationRecorder& parent, int path1, int path2); - - // Creates a recorder that generates locations into given source code info. - LocationRecorder(const LocationRecorder& parent, int path1, - SourceCodeInfo* source_code_info); - - ~LocationRecorder(); - - // Add a path component. See SourceCodeInfo.Location.path in - // descriptor.proto. - void AddPath(int path_component); - - // By default the location is considered to start at the current token at - // the time the LocationRecorder is created. StartAt() sets the start - // location to the given token instead. - void StartAt(const io::Tokenizer::Token& token); - - // Start at the same location as some other LocationRecorder. - void StartAt(const LocationRecorder& other); - - // By default the location is considered to end at the previous token at - // the time the LocationRecorder is destroyed. EndAt() sets the end - // location to the given token instead. - void EndAt(const io::Tokenizer::Token& token); - - // Records the start point of this location to the SourceLocationTable that - // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable - // is an older way of keeping track of source locations which is still - // used in some places. - void RecordLegacyLocation( - const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location); - void RecordLegacyImportLocation(const Message* descriptor, - const std::string& name); - - // Returns the number of path components in the recorder's current location. - int CurrentPathSize() const; - - // Attaches leading and trailing comments to the location. The two strings - // will be swapped into place, so after this is called *leading and - // *trailing will be empty. - // - // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for - // why this is const. - void AttachComments(std::string* leading, std::string* trailing, - std::vector<std::string>* detached_comments) const; - - private: - Parser* parser_; - SourceCodeInfo* source_code_info_; - SourceCodeInfo::Location* location_; - - void Init(const LocationRecorder& parent, SourceCodeInfo* source_code_info); - }; - - // ================================================================= - // Parsers for various language constructs - - // Parses the "syntax = \"proto2\";" line at the top of the file. Returns - // false if it failed to parse or if the syntax identifier was not - // recognized. - bool ParseSyntaxIdentifier(const LocationRecorder& parent); - - // These methods parse various individual bits of code. They return - // false if they completely fail to parse the construct. In this case, - // it is probably necessary to skip the rest of the statement to recover. - // However, if these methods return true, it does NOT mean that there - // were no errors; only that there were no *syntax* errors. For instance, - // if a service method is defined using proper syntax but uses a primitive - // type as its input or output, ParseMethodField() still returns true - // and only reports the error by calling AddError(). In practice, this - // makes logic much simpler for the caller. - - // Parse a top-level message, enum, service, etc. - bool ParseTopLevelStatement(FileDescriptorProto* file, - const LocationRecorder& root_location); - - // Parse various language high-level language construrcts. - bool ParseMessageDefinition(DescriptorProto* message, - const LocationRecorder& message_location, - const FileDescriptorProto* containing_file); - bool ParseEnumDefinition(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location, - const FileDescriptorProto* containing_file); - bool ParseServiceDefinition(ServiceDescriptorProto* service, - const LocationRecorder& service_location, - const FileDescriptorProto* containing_file); - bool ParsePackage(FileDescriptorProto* file, - const LocationRecorder& root_location, - const FileDescriptorProto* containing_file); - bool ParseImport(RepeatedPtrField<std::string>* dependency, - RepeatedField<int32_t>* public_dependency, - RepeatedField<int32_t>* weak_dependency, - const LocationRecorder& root_location, - const FileDescriptorProto* containing_file); - - // These methods parse the contents of a message, enum, or service type and - // add them to the given object. They consume the entire block including - // the beginning and ending brace. - bool ParseMessageBlock(DescriptorProto* message, - const LocationRecorder& message_location, - const FileDescriptorProto* containing_file); - bool ParseEnumBlock(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location, - const FileDescriptorProto* containing_file); - bool ParseServiceBlock(ServiceDescriptorProto* service, - const LocationRecorder& service_location, - const FileDescriptorProto* containing_file); - - // Parse one statement within a message, enum, or service block, including - // final semicolon. - bool ParseMessageStatement(DescriptorProto* message, - const LocationRecorder& message_location, - const FileDescriptorProto* containing_file); - bool ParseEnumStatement(EnumDescriptorProto* message, - const LocationRecorder& enum_location, - const FileDescriptorProto* containing_file); - bool ParseServiceStatement(ServiceDescriptorProto* message, - const LocationRecorder& service_location, - const FileDescriptorProto* containing_file); - - // Parse a field of a message. If the field is a group, its type will be - // added to "messages". - // - // parent_location and location_field_number_for_nested_type are needed when - // parsing groups -- we need to generate a nested message type within the - // parent and record its location accordingly. Since the parent could be - // either a FileDescriptorProto or a DescriptorProto, we must pass in the - // correct field number to use. - bool ParseMessageField(FieldDescriptorProto* field, - RepeatedPtrField<DescriptorProto>* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); - - // Like ParseMessageField() but expects the label has already been filled in - // by the caller. - bool ParseMessageFieldNoLabel(FieldDescriptorProto* field, - RepeatedPtrField<DescriptorProto>* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); - - bool ParseMapType(MapField* map_field, FieldDescriptorProto* field, - LocationRecorder& type_name_location); - - // Parse an "extensions" declaration. - bool ParseExtensions(DescriptorProto* message, - const LocationRecorder& extensions_location, - const FileDescriptorProto* containing_file); - - // Parse a "reserved" declaration. - bool ParseReserved(DescriptorProto* message, - const LocationRecorder& message_location); - bool ParseReservedNames(DescriptorProto* message, - const LocationRecorder& parent_location); - bool ParseReservedNumbers(DescriptorProto* message, - const LocationRecorder& parent_location); - bool ParseReserved(EnumDescriptorProto* message, - const LocationRecorder& message_location); - bool ParseReservedNames(EnumDescriptorProto* message, - const LocationRecorder& parent_location); - bool ParseReservedNumbers(EnumDescriptorProto* message, - const LocationRecorder& parent_location); - - // Parse an "extend" declaration. (See also comments for - // ParseMessageField().) - bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions, - RepeatedPtrField<DescriptorProto>* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& extend_location, - const FileDescriptorProto* containing_file); - - // Parse a "oneof" declaration. The caller is responsible for setting - // oneof_decl->label() since it will have had to parse the label before it - // knew it was parsing a oneof. - bool ParseOneof(OneofDescriptorProto* oneof_decl, - DescriptorProto* containing_type, int oneof_index, - const LocationRecorder& oneof_location, - const LocationRecorder& containing_type_location, - const FileDescriptorProto* containing_file); - - // Parse a single enum value within an enum block. - bool ParseEnumConstant(EnumValueDescriptorProto* enum_value, - const LocationRecorder& enum_value_location, - const FileDescriptorProto* containing_file); - - // Parse enum constant options, i.e. the list in square brackets at the end - // of the enum constant value definition. - bool ParseEnumConstantOptions(EnumValueDescriptorProto* value, - const LocationRecorder& enum_value_location, - const FileDescriptorProto* containing_file); - - // Parse a single method within a service definition. - bool ParseServiceMethod(MethodDescriptorProto* method, - const LocationRecorder& method_location, - const FileDescriptorProto* containing_file); - - // Parse options of a single method or stream. - bool ParseMethodOptions(const LocationRecorder& parent_location, - const FileDescriptorProto* containing_file, - const int optionsFieldNumber, - Message* mutable_options); - - // Parse "required", "optional", or "repeated" and fill in "label" - // with the value. Returns true if such a label is consumed. - bool ParseLabel(FieldDescriptorProto::Label* label, - const LocationRecorder& field_location); - - // Parse a type name and fill in "type" (if it is a primitive) or - // "type_name" (if it is not) with the type parsed. - bool ParseType(FieldDescriptorProto::Type* type, std::string* type_name); - // Parse a user-defined type and fill in "type_name" with the name. - // If a primitive type is named, it is treated as an error. - bool ParseUserDefinedType(std::string* type_name); - - // Parses field options, i.e. the stuff in square brackets at the end - // of a field definition. Also parses default value. - bool ParseFieldOptions(FieldDescriptorProto* field, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); - - // Parse the "default" option. This needs special handling because its - // type is the field's type. - bool ParseDefaultAssignment(FieldDescriptorProto* field, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); - - bool ParseJsonName(FieldDescriptorProto* field, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); - - enum OptionStyle { - OPTION_ASSIGNMENT, // just "name = value" - OPTION_STATEMENT // "option name = value;" - }; - - // Parse a single option name/value pair, e.g. "ctype = CORD". The name - // identifies a field of the given Message, and the value of that field - // is set to the parsed value. - bool ParseOption(Message* options, const LocationRecorder& options_location, - const FileDescriptorProto* containing_file, - OptionStyle style); - - // Parses a single part of a multipart option name. A multipart name consists - // of names separated by dots. Each name is either an identifier or a series - // of identifiers separated by dots and enclosed in parentheses. E.g., - // "foo.(bar.baz).moo". - bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option, - const LocationRecorder& part_location, - const FileDescriptorProto* containing_file); - - // Parses a string surrounded by balanced braces. Strips off the outer - // braces and stores the enclosed string in *value. - // E.g., - // { foo } *value gets 'foo' - // { foo { bar: box } } *value gets 'foo { bar: box }' - // {} *value gets '' - // - // REQUIRES: LookingAt("{") - // When finished successfully, we are looking at the first token past - // the ending brace. - bool ParseUninterpretedBlock(std::string* value); - - struct MapField { - // Whether the field is a map field. - bool is_map_field; - // The types of the key and value if they are primitive types. - FieldDescriptorProto::Type key_type; - FieldDescriptorProto::Type value_type; - // Or the type names string if the types are customized types. - std::string key_type_name; - std::string value_type_name; - - MapField() : is_map_field(false) {} - }; - // Desugar the map syntax to generate a nested map entry message. - void GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field, - RepeatedPtrField<DescriptorProto>* messages); - - // Whether fields without label default to optional fields. - bool DefaultToOptionalFields() const { - return syntax_identifier_ == "proto3"; - } - - bool ValidateEnum(const EnumDescriptorProto* proto); - - // ================================================================= - - io::Tokenizer* input_; - io::ErrorCollector* error_collector_; - SourceCodeInfo* source_code_info_; - SourceLocationTable* source_location_table_; // legacy - bool had_errors_; - bool require_syntax_identifier_; - bool stop_after_syntax_identifier_; - std::string syntax_identifier_; - - // Leading doc comments for the next declaration. These are not complete - // yet; use ConsumeEndOfDeclaration() to get the complete comments. - std::string upcoming_doc_comments_; - - // Detached comments are not connected to any syntax entities. Elements in - // this vector are paragraphs of comments separated by empty lines. The - // detached comments will be put into the leading_detached_comments field for - // the next element (See SourceCodeInfo.Location in descriptor.proto), when - // ConsumeEndOfDeclaration() is called. - std::vector<std::string> upcoming_detached_comments_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); -}; - -// A table mapping (descriptor, ErrorLocation) pairs -- as reported by -// DescriptorPool when validating descriptors -- to line and column numbers -// within the original source code. -// -// This is semi-obsolete: FileDescriptorProto.source_code_info now contains -// far more complete information about source locations. However, as of this -// writing you still need to use SourceLocationTable when integrating with -// DescriptorPool. -class PROTOBUF_EXPORT SourceLocationTable { - public: - SourceLocationTable(); - ~SourceLocationTable(); - - // Finds the precise location of the given error and fills in *line and - // *column with the line and column numbers. If not found, sets *line to - // -1 and *column to 0 (since line = -1 is used to mean "error has no exact - // location" in the ErrorCollector interface). Returns true if found, false - // otherwise. - bool Find(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, int* line, - int* column) const; - bool FindImport(const Message* descriptor, const std::string& name, int* line, - int* column) const; - - // Adds a location to the table. - void Add(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, int line, - int column); - void AddImport(const Message* descriptor, const std::string& name, int line, - int column); - - // Clears the contents of the table. - void Clear(); - - private: - typedef std::map< - std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, - std::pair<int, int> > - LocationMap; - LocationMap location_map_; - std::map<std::pair<const Message*, std::string>, std::pair<int, int> > - import_location_map_; -}; - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__ diff --git a/include/google/protobuf/compiler/php/php_generator.h b/include/google/protobuf/compiler/php/php_generator.h deleted file mode 100644 index 17cb59c08b..0000000000 --- a/include/google/protobuf/compiler/php/php_generator.h +++ /dev/null @@ -1,92 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ - -#include <google/protobuf/compiler/code_generator.h> -#include <google/protobuf/descriptor.h> - -#include <string> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace php { - -struct Options; - -class PROTOC_EXPORT Generator : public CodeGenerator { - public: - virtual bool Generate( - const FileDescriptor* file, - const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } - - private: - bool Generate( - const FileDescriptor* file, - const Options& options, - GeneratorContext* generator_context, - std::string* error) const; -}; - -// To skip reserved keywords in php, some generated classname are prefixed. -// Other code generators may need following API to figure out the actual -// classname. -PROTOC_EXPORT std::string GeneratedClassName(const Descriptor* desc); -PROTOC_EXPORT std::string GeneratedClassName(const EnumDescriptor* desc); -PROTOC_EXPORT std::string GeneratedClassName(const ServiceDescriptor* desc); - -inline bool IsWrapperType(const FieldDescriptor* descriptor) { - return descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto"; -} - -} // namespace php -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/plugin.h b/include/google/protobuf/compiler/plugin.h deleted file mode 100644 index 611713e2c0..0000000000 --- a/include/google/protobuf/compiler/plugin.h +++ /dev/null @@ -1,96 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// Front-end for protoc code generator plugins written in C++. -// -// To implement a protoc plugin in C++, simply write an implementation of -// CodeGenerator, then create a main() function like: -// int main(int argc, char* argv[]) { -// MyCodeGenerator generator; -// return google::protobuf::compiler::PluginMain(argc, argv, &generator); -// } -// You must link your plugin against libprotobuf and libprotoc. -// -// The core part of PluginMain is to invoke the given CodeGenerator on a -// CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is -// abstracted out and made into function GenerateCode so that it can be reused, -// for example, to implement a variant of PluginMain that does some -// preprocessing on the input CodeGeneratorRequest before feeding the request -// to the given code generator. -// -// To get protoc to use the plugin, do one of the following: -// * Place the plugin binary somewhere in the PATH and give it the name -// "protoc-gen-NAME" (replacing "NAME" with the name of your plugin). If you -// then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace -// "NAME" with your plugin's name), protoc will invoke your plugin to generate -// the output, which will be placed in OUT_DIR. -// * Place the plugin binary anywhere, with any name, and pass the --plugin -// parameter to protoc to direct it to your plugin like so: -// protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR -// On Windows, make sure to include the .exe suffix: -// protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR - -#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ -#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ - -#include <string> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { - -class CodeGenerator; // code_generator.h -class CodeGeneratorRequest; -class CodeGeneratorResponse; - -// Implements main() for a protoc plugin exposing the given code generator. -PROTOC_EXPORT int PluginMain(int argc, char* argv[], - const CodeGenerator* generator); - - -// Generates code using the given code generator. Returns true if the code -// generation is successful. If the code generation fails, error_msg may be -// populated to describe the failure cause. -bool GenerateCode(const CodeGeneratorRequest& request, - const CodeGenerator& generator, - CodeGeneratorResponse* response, std::string* error_msg); - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ diff --git a/include/google/protobuf/compiler/plugin.pb.h b/include/google/protobuf/compiler/plugin.pb.h deleted file mode 100644 index 40163f87dc..0000000000 --- a/include/google/protobuf/compiler/plugin.pb.h +++ /dev/null @@ -1,1901 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/compiler/plugin.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto -#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto - -#include <limits> -#include <string> - -#include <google/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3021000 -#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 -#if 3021004 < 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 - -#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> -#include <google/protobuf/descriptor.pb.h> -// @@protoc_insertion_point(includes) -#include <google/protobuf/port_def.inc> -#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT -#ifdef major -#undef major -#endif -#ifdef minor -#undef minor -#endif -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { - static const uint32_t offsets[]; -}; -PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -PROTOBUF_NAMESPACE_OPEN -namespace compiler { -class CodeGeneratorRequest; -struct CodeGeneratorRequestDefaultTypeInternal; -PROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; -class CodeGeneratorResponse; -struct CodeGeneratorResponseDefaultTypeInternal; -PROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; -class CodeGeneratorResponse_File; -struct CodeGeneratorResponse_FileDefaultTypeInternal; -PROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; -class Version; -struct VersionDefaultTypeInternal; -PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; -} // namespace compiler -PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*); -PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -namespace compiler { - -enum CodeGeneratorResponse_Feature : int { - CodeGeneratorResponse_Feature_FEATURE_NONE = 0, - CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1 -}; -PROTOC_EXPORT bool CodeGeneratorResponse_Feature_IsValid(int value); -constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = CodeGeneratorResponse_Feature_FEATURE_NONE; -constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL; -constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = CodeGeneratorResponse_Feature_Feature_MAX + 1; - -PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor(); -template<typename T> -inline const std::string& CodeGeneratorResponse_Feature_Name(T enum_t_value) { - static_assert(::std::is_same<T, CodeGeneratorResponse_Feature>::value || - ::std::is_integral<T>::value, - "Incorrect type passed to function CodeGeneratorResponse_Feature_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - CodeGeneratorResponse_Feature_descriptor(), enum_t_value); -} -inline bool CodeGeneratorResponse_Feature_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CodeGeneratorResponse_Feature* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<CodeGeneratorResponse_Feature>( - CodeGeneratorResponse_Feature_descriptor(), name, value); -} -// =================================================================== - -class PROTOC_EXPORT Version final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { - public: - inline Version() : Version(nullptr) {} - ~Version() override; - explicit PROTOBUF_CONSTEXPR Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Version(const Version& from); - Version(Version&& from) noexcept - : Version() { - *this = ::std::move(from); - } - - inline Version& operator=(const Version& from) { - CopyFrom(from); - return *this; - } - inline Version& operator=(Version&& 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; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - 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 Version& default_instance() { - return *internal_default_instance(); - } - static inline const Version* internal_default_instance() { - return reinterpret_cast<const Version*>( - &_Version_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Version& a, Version& b) { - a.Swap(&b); - } - inline void Swap(Version* 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(Version* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage<Version>(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Version& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const Version& from) { - Version::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, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Version* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "google.protobuf.compiler.Version"; - } - protected: - explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); - 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 { - kSuffixFieldNumber = 4, - kMajorFieldNumber = 1, - kMinorFieldNumber = 2, - kPatchFieldNumber = 3, - }; - // optional string suffix = 4; - bool has_suffix() const; - private: - bool _internal_has_suffix() const; - public: - void clear_suffix(); - const std::string& suffix() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_suffix(ArgT0&& arg0, ArgT... args); - std::string* mutable_suffix(); - PROTOBUF_NODISCARD std::string* release_suffix(); - void set_allocated_suffix(std::string* suffix); - private: - const std::string& _internal_suffix() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_suffix(const std::string& value); - std::string* _internal_mutable_suffix(); - public: - - // optional int32 major = 1; - bool has_major() const; - private: - bool _internal_has_major() const; - public: - void clear_major(); - int32_t major() const; - void set_major(int32_t value); - private: - int32_t _internal_major() const; - void _internal_set_major(int32_t value); - public: - - // optional int32 minor = 2; - bool has_minor() const; - private: - bool _internal_has_minor() const; - public: - void clear_minor(); - int32_t minor() const; - void set_minor(int32_t value); - private: - int32_t _internal_minor() const; - void _internal_set_minor(int32_t value); - public: - - // optional int32 patch = 3; - bool has_patch() const; - private: - bool _internal_has_patch() const; - public: - void clear_patch(); - int32_t patch() const; - void set_patch(int32_t value); - private: - int32_t _internal_patch() const; - void _internal_set_patch(int32_t value); - public: - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) - private: - class _Internal; - - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_; - int32_t major_; - int32_t minor_; - int32_t patch_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- - -class PROTOC_EXPORT CodeGeneratorRequest final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { - public: - inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} - ~CodeGeneratorRequest() override; - explicit PROTOBUF_CONSTEXPR CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - CodeGeneratorRequest(const CodeGeneratorRequest& from); - CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept - : CodeGeneratorRequest() { - *this = ::std::move(from); - } - - inline CodeGeneratorRequest& operator=(const CodeGeneratorRequest& from) { - CopyFrom(from); - return *this; - } - inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& 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; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - 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 CodeGeneratorRequest& default_instance() { - return *internal_default_instance(); - } - static inline const CodeGeneratorRequest* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorRequest*>( - &_CodeGeneratorRequest_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(CodeGeneratorRequest& a, CodeGeneratorRequest& b) { - a.Swap(&b); - } - inline void Swap(CodeGeneratorRequest* 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(CodeGeneratorRequest* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage<CodeGeneratorRequest>(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const CodeGeneratorRequest& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const CodeGeneratorRequest& from) { - CodeGeneratorRequest::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, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(CodeGeneratorRequest* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "google.protobuf.compiler.CodeGeneratorRequest"; - } - protected: - explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); - 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 { - kFileToGenerateFieldNumber = 1, - kProtoFileFieldNumber = 15, - kParameterFieldNumber = 2, - kCompilerVersionFieldNumber = 3, - }; - // repeated string file_to_generate = 1; - int file_to_generate_size() const; - private: - int _internal_file_to_generate_size() const; - public: - void clear_file_to_generate(); - const std::string& file_to_generate(int index) const; - std::string* mutable_file_to_generate(int index); - void set_file_to_generate(int index, const std::string& value); - void set_file_to_generate(int index, std::string&& value); - void set_file_to_generate(int index, const char* value); - void set_file_to_generate(int index, const char* value, size_t size); - std::string* add_file_to_generate(); - void add_file_to_generate(const std::string& value); - void add_file_to_generate(std::string&& value); - void add_file_to_generate(const char* value); - void add_file_to_generate(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& file_to_generate() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* mutable_file_to_generate(); - private: - const std::string& _internal_file_to_generate(int index) const; - std::string* _internal_add_file_to_generate(); - public: - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - int proto_file_size() const; - private: - int _internal_proto_file_size() const; - public: - void clear_proto_file(); - ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_proto_file(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* - mutable_proto_file(); - private: - const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& _internal_proto_file(int index) const; - ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _internal_add_proto_file(); - public: - const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& proto_file(int index) const; - ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* add_proto_file(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >& - proto_file() const; - - // optional string parameter = 2; - bool has_parameter() const; - private: - bool _internal_has_parameter() const; - public: - void clear_parameter(); - const std::string& parameter() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_parameter(ArgT0&& arg0, ArgT... args); - std::string* mutable_parameter(); - PROTOBUF_NODISCARD std::string* release_parameter(); - void set_allocated_parameter(std::string* parameter); - private: - const std::string& _internal_parameter() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_parameter(const std::string& value); - std::string* _internal_mutable_parameter(); - public: - - // optional .google.protobuf.compiler.Version compiler_version = 3; - bool has_compiler_version() const; - private: - bool _internal_has_compiler_version() const; - public: - void clear_compiler_version(); - const ::PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const; - PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); - ::PROTOBUF_NAMESPACE_ID::compiler::Version* mutable_compiler_version(); - void set_allocated_compiler_version(::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version); - private: - const ::PROTOBUF_NAMESPACE_ID::compiler::Version& _internal_compiler_version() const; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* _internal_mutable_compiler_version(); - public: - void unsafe_arena_set_allocated_compiler_version( - ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version); - ::PROTOBUF_NAMESPACE_ID::compiler::Version* unsafe_arena_release_compiler_version(); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) - private: - class _Internal; - - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> file_to_generate_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > proto_file_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- - -class PROTOC_EXPORT CodeGeneratorResponse_File final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { - public: - inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} - ~CodeGeneratorResponse_File() override; - explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); - CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept - : CodeGeneratorResponse_File() { - *this = ::std::move(from); - } - - inline CodeGeneratorResponse_File& operator=(const CodeGeneratorResponse_File& from) { - CopyFrom(from); - return *this; - } - inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& 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; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - 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 CodeGeneratorResponse_File& default_instance() { - return *internal_default_instance(); - } - static inline const CodeGeneratorResponse_File* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorResponse_File*>( - &_CodeGeneratorResponse_File_default_instance_); - } - static constexpr int kIndexInFileMessages = - 2; - - friend void swap(CodeGeneratorResponse_File& a, CodeGeneratorResponse_File& b) { - a.Swap(&b); - } - inline void Swap(CodeGeneratorResponse_File* 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(CodeGeneratorResponse_File* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage<CodeGeneratorResponse_File>(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const CodeGeneratorResponse_File& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const CodeGeneratorResponse_File& from) { - CodeGeneratorResponse_File::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, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(CodeGeneratorResponse_File* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "google.protobuf.compiler.CodeGeneratorResponse.File"; - } - protected: - explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); - 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 { - kNameFieldNumber = 1, - kInsertionPointFieldNumber = 2, - kContentFieldNumber = 15, - kGeneratedCodeInfoFieldNumber = 16, - }; - // optional string name = 1; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_name(ArgT0&& arg0, ArgT... args); - std::string* mutable_name(); - PROTOBUF_NODISCARD std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // optional string insertion_point = 2; - bool has_insertion_point() const; - private: - bool _internal_has_insertion_point() const; - public: - void clear_insertion_point(); - const std::string& insertion_point() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_insertion_point(ArgT0&& arg0, ArgT... args); - std::string* mutable_insertion_point(); - PROTOBUF_NODISCARD std::string* release_insertion_point(); - void set_allocated_insertion_point(std::string* insertion_point); - private: - const std::string& _internal_insertion_point() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_insertion_point(const std::string& value); - std::string* _internal_mutable_insertion_point(); - public: - - // optional string content = 15; - bool has_content() const; - private: - bool _internal_has_content() const; - public: - void clear_content(); - const std::string& content() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_content(ArgT0&& arg0, ArgT... args); - std::string* mutable_content(); - PROTOBUF_NODISCARD std::string* release_content(); - void set_allocated_content(std::string* content); - private: - const std::string& _internal_content() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_content(const std::string& value); - std::string* _internal_mutable_content(); - public: - - // optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16; - bool has_generated_code_info() const; - private: - bool _internal_has_generated_code_info() const; - public: - void clear_generated_code_info(); - const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& generated_code_info() const; - PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* release_generated_code_info(); - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* mutable_generated_code_info(); - void set_allocated_generated_code_info(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info); - private: - const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& _internal_generated_code_info() const; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* _internal_mutable_generated_code_info(); - public: - void unsafe_arena_set_allocated_generated_code_info( - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info); - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* unsafe_arena_release_generated_code_info(); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) - private: - class _Internal; - - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- - -class PROTOC_EXPORT CodeGeneratorResponse final : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { - public: - inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} - ~CodeGeneratorResponse() override; - explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - CodeGeneratorResponse(const CodeGeneratorResponse& from); - CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept - : CodeGeneratorResponse() { - *this = ::std::move(from); - } - - inline CodeGeneratorResponse& operator=(const CodeGeneratorResponse& from) { - CopyFrom(from); - return *this; - } - inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& 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; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - 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 CodeGeneratorResponse& default_instance() { - return *internal_default_instance(); - } - static inline const CodeGeneratorResponse* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorResponse*>( - &_CodeGeneratorResponse_default_instance_); - } - static constexpr int kIndexInFileMessages = - 3; - - friend void swap(CodeGeneratorResponse& a, CodeGeneratorResponse& b) { - a.Swap(&b); - } - inline void Swap(CodeGeneratorResponse* 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(CodeGeneratorResponse* other) { - if (other == this) return; - GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { - return CreateMaybeMessage<CodeGeneratorResponse>(arena); - } - using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const CodeGeneratorResponse& from); - using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom( const CodeGeneratorResponse& from) { - CodeGeneratorResponse::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, bool is_message_owned); - void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(CodeGeneratorResponse* other); - - private: - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "google.protobuf.compiler.CodeGeneratorResponse"; - } - protected: - explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, - bool is_message_owned = false); - public: - - static const ClassData _class_data_; - const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - - // nested types ---------------------------------------------------- - - typedef CodeGeneratorResponse_File File; - - typedef CodeGeneratorResponse_Feature Feature; - static constexpr Feature FEATURE_NONE = - CodeGeneratorResponse_Feature_FEATURE_NONE; - static constexpr Feature FEATURE_PROTO3_OPTIONAL = - CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL; - static inline bool Feature_IsValid(int value) { - return CodeGeneratorResponse_Feature_IsValid(value); - } - static constexpr Feature Feature_MIN = - CodeGeneratorResponse_Feature_Feature_MIN; - static constexpr Feature Feature_MAX = - CodeGeneratorResponse_Feature_Feature_MAX; - static constexpr int Feature_ARRAYSIZE = - CodeGeneratorResponse_Feature_Feature_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Feature_descriptor() { - return CodeGeneratorResponse_Feature_descriptor(); - } - template<typename T> - static inline const std::string& Feature_Name(T enum_t_value) { - static_assert(::std::is_same<T, Feature>::value || - ::std::is_integral<T>::value, - "Incorrect type passed to function Feature_Name."); - return CodeGeneratorResponse_Feature_Name(enum_t_value); - } - static inline bool Feature_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Feature* value) { - return CodeGeneratorResponse_Feature_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - enum : int { - kFileFieldNumber = 15, - kErrorFieldNumber = 1, - kSupportedFeaturesFieldNumber = 2, - }; - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - int file_size() const; - private: - int _internal_file_size() const; - public: - void clear_file(); - ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* mutable_file(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >* - mutable_file(); - private: - const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& _internal_file(int index) const; - ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* _internal_add_file(); - public: - const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& file(int index) const; - ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* add_file(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >& - file() const; - - // optional string error = 1; - bool has_error() const; - private: - bool _internal_has_error() const; - public: - void clear_error(); - const std::string& error() const; - template <typename ArgT0 = const std::string&, typename... ArgT> - void set_error(ArgT0&& arg0, ArgT... args); - std::string* mutable_error(); - PROTOBUF_NODISCARD std::string* release_error(); - void set_allocated_error(std::string* error); - private: - const std::string& _internal_error() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_error(const std::string& value); - std::string* _internal_mutable_error(); - public: - - // optional uint64 supported_features = 2; - bool has_supported_features() const; - private: - bool _internal_has_supported_features() const; - public: - void clear_supported_features(); - uint64_t supported_features() const; - void set_supported_features(uint64_t value); - private: - uint64_t _internal_supported_features() const; - void _internal_set_supported_features(uint64_t value); - public: - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) - private: - class _Internal; - - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - struct Impl_ { - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_; - uint64_t supported_features_; - }; - union { Impl_ _impl_; }; - friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// =================================================================== - - -// =================================================================== - -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// Version - -// optional int32 major = 1; -inline bool Version::_internal_has_major() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool Version::has_major() const { - return _internal_has_major(); -} -inline void Version::clear_major() { - _impl_.major_ = 0; - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline int32_t Version::_internal_major() const { - return _impl_.major_; -} -inline int32_t Version::major() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) - return _internal_major(); -} -inline void Version::_internal_set_major(int32_t value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.major_ = value; -} -inline void Version::set_major(int32_t value) { - _internal_set_major(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) -} - -// optional int32 minor = 2; -inline bool Version::_internal_has_minor() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool Version::has_minor() const { - return _internal_has_minor(); -} -inline void Version::clear_minor() { - _impl_.minor_ = 0; - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline int32_t Version::_internal_minor() const { - return _impl_.minor_; -} -inline int32_t Version::minor() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) - return _internal_minor(); -} -inline void Version::_internal_set_minor(int32_t value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.minor_ = value; -} -inline void Version::set_minor(int32_t value) { - _internal_set_minor(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) -} - -// optional int32 patch = 3; -inline bool Version::_internal_has_patch() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool Version::has_patch() const { - return _internal_has_patch(); -} -inline void Version::clear_patch() { - _impl_.patch_ = 0; - _impl_._has_bits_[0] &= ~0x00000008u; -} -inline int32_t Version::_internal_patch() const { - return _impl_.patch_; -} -inline int32_t Version::patch() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) - return _internal_patch(); -} -inline void Version::_internal_set_patch(int32_t value) { - _impl_._has_bits_[0] |= 0x00000008u; - _impl_.patch_ = value; -} -inline void Version::set_patch(int32_t value) { - _internal_set_patch(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) -} - -// optional string suffix = 4; -inline bool Version::_internal_has_suffix() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool Version::has_suffix() const { - return _internal_has_suffix(); -} -inline void Version::clear_suffix() { - _impl_.suffix_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& Version::suffix() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) - return _internal_suffix(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void Version::set_suffix(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) -} -inline std::string* Version::mutable_suffix() { - std::string* _s = _internal_mutable_suffix(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) - return _s; -} -inline const std::string& Version::_internal_suffix() const { - return _impl_.suffix_.Get(); -} -inline void Version::_internal_set_suffix(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.suffix_.Set(value, GetArenaForAllocation()); -} -inline std::string* Version::_internal_mutable_suffix() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.suffix_.Mutable(GetArenaForAllocation()); -} -inline std::string* Version::release_suffix() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) - if (!_internal_has_suffix()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.suffix_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.suffix_.IsDefault()) { - _impl_.suffix_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void Version::set_allocated_suffix(std::string* suffix) { - if (suffix != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.suffix_.SetAllocated(suffix, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.suffix_.IsDefault()) { - _impl_.suffix_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) -} - -// ------------------------------------------------------------------- - -// CodeGeneratorRequest - -// repeated string file_to_generate = 1; -inline int CodeGeneratorRequest::_internal_file_to_generate_size() const { - return _impl_.file_to_generate_.size(); -} -inline int CodeGeneratorRequest::file_to_generate_size() const { - return _internal_file_to_generate_size(); -} -inline void CodeGeneratorRequest::clear_file_to_generate() { - _impl_.file_to_generate_.Clear(); -} -inline std::string* CodeGeneratorRequest::add_file_to_generate() { - std::string* _s = _internal_add_file_to_generate(); - // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return _s; -} -inline const std::string& CodeGeneratorRequest::_internal_file_to_generate(int index) const { - return _impl_.file_to_generate_.Get(index); -} -inline const std::string& CodeGeneratorRequest::file_to_generate(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return _internal_file_to_generate(index); -} -inline std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return _impl_.file_to_generate_.Mutable(index); -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const std::string& value) { - _impl_.file_to_generate_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, std::string&& value) { - _impl_.file_to_generate_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.file_to_generate_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { - _impl_.file_to_generate_.Mutable(index)->assign( - reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline std::string* CodeGeneratorRequest::_internal_add_file_to_generate() { - return _impl_.file_to_generate_.Add(); -} -inline void CodeGeneratorRequest::add_file_to_generate(const std::string& value) { - _impl_.file_to_generate_.Add()->assign(value); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::add_file_to_generate(std::string&& value) { - _impl_.file_to_generate_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _impl_.file_to_generate_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { - _impl_.file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& -CodeGeneratorRequest::file_to_generate() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return _impl_.file_to_generate_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* -CodeGeneratorRequest::mutable_file_to_generate() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return &_impl_.file_to_generate_; -} - -// optional string parameter = 2; -inline bool CodeGeneratorRequest::_internal_has_parameter() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool CodeGeneratorRequest::has_parameter() const { - return _internal_has_parameter(); -} -inline void CodeGeneratorRequest::clear_parameter() { - _impl_.parameter_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& CodeGeneratorRequest::parameter() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return _internal_parameter(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} -inline std::string* CodeGeneratorRequest::mutable_parameter() { - std::string* _s = _internal_mutable_parameter(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return _s; -} -inline const std::string& CodeGeneratorRequest::_internal_parameter() const { - return _impl_.parameter_.Get(); -} -inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.parameter_.Set(value, GetArenaForAllocation()); -} -inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.parameter_.Mutable(GetArenaForAllocation()); -} -inline std::string* CodeGeneratorRequest::release_parameter() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) - if (!_internal_has_parameter()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.parameter_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.parameter_.IsDefault()) { - _impl_.parameter_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter) { - if (parameter != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.parameter_.SetAllocated(parameter, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.parameter_.IsDefault()) { - _impl_.parameter_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) -} - -// repeated .google.protobuf.FileDescriptorProto proto_file = 15; -inline int CodeGeneratorRequest::_internal_proto_file_size() const { - return _impl_.proto_file_.size(); -} -inline int CodeGeneratorRequest::proto_file_size() const { - return _internal_proto_file_size(); -} -inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return _impl_.proto_file_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* -CodeGeneratorRequest::mutable_proto_file() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return &_impl_.proto_file_; -} -inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::_internal_proto_file(int index) const { - return _impl_.proto_file_.Get(index); -} -inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return _internal_proto_file(index); -} -inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::_internal_add_proto_file() { - return _impl_.proto_file_.Add(); -} -inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { - ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _add = _internal_add_proto_file(); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return _add; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >& -CodeGeneratorRequest::proto_file() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return _impl_.proto_file_; -} - -// optional .google.protobuf.compiler.Version compiler_version = 3; -inline bool CodeGeneratorRequest::_internal_has_compiler_version() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || _impl_.compiler_version_ != nullptr); - return value; -} -inline bool CodeGeneratorRequest::has_compiler_version() const { - return _internal_has_compiler_version(); -} -inline void CodeGeneratorRequest::clear_compiler_version() { - if (_impl_.compiler_version_ != nullptr) _impl_.compiler_version_->Clear(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const { - const ::PROTOBUF_NAMESPACE_ID::compiler::Version* p = _impl_.compiler_version_; - return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::compiler::Version&>( - ::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_); -} -inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::compiler_version() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return _internal_compiler_version(); -} -inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( - ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.compiler_version_); - } - _impl_.compiler_version_ = compiler_version; - if (compiler_version) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_compiler_version() { - _impl_._has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_; - _impl_.compiler_version_ = 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::compiler::Version* CodeGeneratorRequest::unsafe_arena_release_compiler_version() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - _impl_._has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_; - _impl_.compiler_version_ = nullptr; - return temp; -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() { - _impl_._has_bits_[0] |= 0x00000002u; - if (_impl_.compiler_version_ == nullptr) { - auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(GetArenaForAllocation()); - _impl_.compiler_version_ = p; - } - return _impl_.compiler_version_; -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { - ::PROTOBUF_NAMESPACE_ID::compiler::Version* _msg = _internal_mutable_compiler_version(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - return _msg; -} -inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete _impl_.compiler_version_; - } - if (compiler_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(compiler_version); - if (message_arena != submessage_arena) { - compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, compiler_version, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.compiler_version_ = compiler_version; - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) -} - -// ------------------------------------------------------------------- - -// CodeGeneratorResponse_File - -// optional string name = 1; -inline bool CodeGeneratorResponse_File::_internal_has_name() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool CodeGeneratorResponse_File::has_name() const { - return _internal_has_name(); -} -inline void CodeGeneratorResponse_File::clear_name() { - _impl_.name_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& CodeGeneratorResponse_File::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return _internal_name(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -inline std::string* CodeGeneratorResponse_File::mutable_name() { - std::string* _s = _internal_mutable_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return _s; -} -inline const std::string& CodeGeneratorResponse_File::_internal_name() const { - return _impl_.name_.Get(); -} -inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.name_.Set(value, GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.name_.Mutable(GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) - if (!_internal_has_name()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.name_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { - if (name != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.name_.SetAllocated(name, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.name_.IsDefault()) { - _impl_.name_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} - -// optional string insertion_point = 2; -inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool CodeGeneratorResponse_File::has_insertion_point() const { - return _internal_has_insertion_point(); -} -inline void CodeGeneratorResponse_File::clear_insertion_point() { - _impl_.insertion_point_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline const std::string& CodeGeneratorResponse_File::insertion_point() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return _internal_insertion_point(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { - std::string* _s = _internal_mutable_insertion_point(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return _s; -} -inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point() const { - return _impl_.insertion_point_.Get(); -} -inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.insertion_point_.Set(value, GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { - _impl_._has_bits_[0] |= 0x00000002u; - return _impl_.insertion_point_.Mutable(GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::release_insertion_point() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - if (!_internal_has_insertion_point()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000002u; - auto* p = _impl_.insertion_point_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.insertion_point_.IsDefault()) { - _impl_.insertion_point_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::string* insertion_point) { - if (insertion_point != nullptr) { - _impl_._has_bits_[0] |= 0x00000002u; - } else { - _impl_._has_bits_[0] &= ~0x00000002u; - } - _impl_.insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.insertion_point_.IsDefault()) { - _impl_.insertion_point_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} - -// optional string content = 15; -inline bool CodeGeneratorResponse_File::_internal_has_content() const { - bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool CodeGeneratorResponse_File::has_content() const { - return _internal_has_content(); -} -inline void CodeGeneratorResponse_File::clear_content() { - _impl_.content_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000004u; -} -inline const std::string& CodeGeneratorResponse_File::content() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return _internal_content(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -inline std::string* CodeGeneratorResponse_File::mutable_content() { - std::string* _s = _internal_mutable_content(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return _s; -} -inline const std::string& CodeGeneratorResponse_File::_internal_content() const { - return _impl_.content_.Get(); -} -inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000004u; - _impl_.content_.Set(value, GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { - _impl_._has_bits_[0] |= 0x00000004u; - return _impl_.content_.Mutable(GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse_File::release_content() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) - if (!_internal_has_content()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000004u; - auto* p = _impl_.content_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void CodeGeneratorResponse_File::set_allocated_content(std::string* content) { - if (content != nullptr) { - _impl_._has_bits_[0] |= 0x00000004u; - } else { - _impl_._has_bits_[0] &= ~0x00000004u; - } - _impl_.content_.SetAllocated(content, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.content_.IsDefault()) { - _impl_.content_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} - -// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16; -inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const { - bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || _impl_.generated_code_info_ != nullptr); - return value; -} -inline bool CodeGeneratorResponse_File::has_generated_code_info() const { - return _internal_has_generated_code_info(); -} -inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::_internal_generated_code_info() const { - const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = _impl_.generated_code_info_; - return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&>( - ::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_); -} -inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::generated_code_info() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) - return _internal_generated_code_info(); -} -inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info( - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_); - } - _impl_.generated_code_info_ = generated_code_info; - if (generated_code_info) { - _impl_._has_bits_[0] |= 0x00000008u; - } else { - _impl_._has_bits_[0] &= ~0x00000008u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) -} -inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::release_generated_code_info() { - _impl_._has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_; - _impl_.generated_code_info_ = 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::GeneratedCodeInfo* CodeGeneratorResponse_File::unsafe_arena_release_generated_code_info() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) - _impl_._has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_; - _impl_.generated_code_info_ = nullptr; - return temp; -} -inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() { - _impl_._has_bits_[0] |= 0x00000008u; - if (_impl_.generated_code_info_ == nullptr) { - auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArenaForAllocation()); - _impl_.generated_code_info_ = p; - } - return _impl_.generated_code_info_; -} -inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mutable_generated_code_info() { - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* _msg = _internal_mutable_generated_code_info(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) - return _msg; -} -inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_); - } - if (generated_code_info) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)); - if (message_arena != submessage_arena) { - generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, generated_code_info, submessage_arena); - } - _impl_._has_bits_[0] |= 0x00000008u; - } else { - _impl_._has_bits_[0] &= ~0x00000008u; - } - _impl_.generated_code_info_ = generated_code_info; - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) -} - -// ------------------------------------------------------------------- - -// CodeGeneratorResponse - -// optional string error = 1; -inline bool CodeGeneratorResponse::_internal_has_error() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool CodeGeneratorResponse::has_error() const { - return _internal_has_error(); -} -inline void CodeGeneratorResponse::clear_error() { - _impl_.error_.ClearToEmpty(); - _impl_._has_bits_[0] &= ~0x00000001u; -} -inline const std::string& CodeGeneratorResponse::error() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return _internal_error(); -} -template <typename ArgT0, typename... ArgT> -inline PROTOBUF_ALWAYS_INLINE -void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) -} -inline std::string* CodeGeneratorResponse::mutable_error() { - std::string* _s = _internal_mutable_error(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error) - return _s; -} -inline const std::string& CodeGeneratorResponse::_internal_error() const { - return _impl_.error_.Get(); -} -inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.error_.Set(value, GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse::_internal_mutable_error() { - _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.error_.Mutable(GetArenaForAllocation()); -} -inline std::string* CodeGeneratorResponse::release_error() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) - if (!_internal_has_error()) { - return nullptr; - } - _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.error_.Release(); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.error_.IsDefault()) { - _impl_.error_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - return p; -} -inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { - if (error != nullptr) { - _impl_._has_bits_[0] |= 0x00000001u; - } else { - _impl_._has_bits_[0] &= ~0x00000001u; - } - _impl_.error_.SetAllocated(error, GetArenaForAllocation()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.error_.IsDefault()) { - _impl_.error_.Set("", GetArenaForAllocation()); - } -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) -} - -// optional uint64 supported_features = 2; -inline bool CodeGeneratorResponse::_internal_has_supported_features() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool CodeGeneratorResponse::has_supported_features() const { - return _internal_has_supported_features(); -} -inline void CodeGeneratorResponse::clear_supported_features() { - _impl_.supported_features_ = uint64_t{0u}; - _impl_._has_bits_[0] &= ~0x00000002u; -} -inline uint64_t CodeGeneratorResponse::_internal_supported_features() const { - return _impl_.supported_features_; -} -inline uint64_t CodeGeneratorResponse::supported_features() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.supported_features) - return _internal_supported_features(); -} -inline void CodeGeneratorResponse::_internal_set_supported_features(uint64_t value) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.supported_features_ = value; -} -inline void CodeGeneratorResponse::set_supported_features(uint64_t value) { - _internal_set_supported_features(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.supported_features) -} - -// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; -inline int CodeGeneratorResponse::_internal_file_size() const { - return _impl_.file_.size(); -} -inline int CodeGeneratorResponse::file_size() const { - return _internal_file_size(); -} -inline void CodeGeneratorResponse::clear_file() { - _impl_.file_.Clear(); -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) { - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file) - return _impl_.file_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >* -CodeGeneratorResponse::mutable_file() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return &_impl_.file_; -} -inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::_internal_file(int index) const { - return _impl_.file_.Get(index); -} -inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file) - return _internal_file(index); -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::_internal_add_file() { - return _impl_.file_.Add(); -} -inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { - ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* _add = _internal_add_file(); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file) - return _add; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >& -CodeGeneratorResponse::file() const { - // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return _impl_.file_; -} - -#ifdef __GNUC__ - #pragma GCC diagnostic pop -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace compiler -PROTOBUF_NAMESPACE_CLOSE - -PROTOBUF_NAMESPACE_OPEN - -template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature>() { - return ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature_descriptor(); -} - -PROTOBUF_NAMESPACE_CLOSE - -// @@protoc_insertion_point(global_scope) - -#include <google/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto diff --git a/include/google/protobuf/compiler/plugin.proto b/include/google/protobuf/compiler/plugin.proto deleted file mode 100644 index 9242aacc5b..0000000000 --- a/include/google/protobuf/compiler/plugin.proto +++ /dev/null @@ -1,183 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to -// change. -// -// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is -// just a program that reads a CodeGeneratorRequest from stdin and writes a -// CodeGeneratorResponse to stdout. -// -// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead -// of dealing with the raw protocol defined here. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "protoc-gen-$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to protoc. - -syntax = "proto2"; - -package google.protobuf.compiler; -option java_package = "com.google.protobuf.compiler"; -option java_outer_classname = "PluginProtos"; - -option go_package = "google.golang.org/protobuf/types/pluginpb"; - -import "google/protobuf/descriptor.proto"; - -// The version number of protocol compiler. -message Version { - optional int32 major = 1; - optional int32 minor = 2; - optional int32 patch = 3; - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - optional string suffix = 4; -} - -// An encoded CodeGeneratorRequest is written to the plugin's stdin. -message CodeGeneratorRequest { - // The .proto files that were explicitly listed on the command-line. The - // code generator should generate code only for these files. Each file's - // descriptor will be included in proto_file, below. - repeated string file_to_generate = 1; - - // The generator parameter passed on the command-line. - optional string parameter = 2; - - // FileDescriptorProtos for all files in files_to_generate and everything - // they import. The files will appear in topological order, so each file - // appears before any file that imports it. - // - // protoc guarantees that all proto_files will be written after - // the fields above, even though this is not technically guaranteed by the - // protobuf wire format. This theoretically could allow a plugin to stream - // in the FileDescriptorProtos and handle them one by one rather than read - // the entire set into memory at once. However, as of this writing, this - // is not similarly optimized on protoc's end -- it will store all fields in - // memory at once before sending them to the plugin. - // - // Type names of fields and extensions in the FileDescriptorProto are always - // fully qualified. - repeated FileDescriptorProto proto_file = 15; - - // The version number of protocol compiler. - optional Version compiler_version = 3; - -} - -// The plugin writes an encoded CodeGeneratorResponse to stdout. -message CodeGeneratorResponse { - // Error message. If non-empty, code generation failed. The plugin process - // should exit with status code zero even if it reports an error in this way. - // - // This should be used to indicate errors in .proto files which prevent the - // code generator from generating correct code. Errors which indicate a - // problem in protoc itself -- such as the input CodeGeneratorRequest being - // unparseable -- should be reported by writing a message to stderr and - // exiting with a non-zero status code. - optional string error = 1; - - // A bitmask of supported features that the code generator supports. - // This is a bitwise "or" of values from the Feature enum. - optional uint64 supported_features = 2; - - // Sync with code_generator.h. - enum Feature { - FEATURE_NONE = 0; - FEATURE_PROTO3_OPTIONAL = 1; - } - - // Represents a single generated file. - message File { - // The file name, relative to the output directory. The name must not - // contain "." or ".." components and must be relative, not be absolute (so, - // the file cannot lie outside the output directory). "/" must be used as - // the path separator, not "\". - // - // If the name is omitted, the content will be appended to the previous - // file. This allows the generator to break large files into small chunks, - // and allows the generated text to be streamed back to protoc so that large - // files need not reside completely in memory at one time. Note that as of - // this writing protoc does not optimize for this -- it will read the entire - // CodeGeneratorResponse before writing files to disk. - optional string name = 1; - - // If non-empty, indicates that the named file should already exist, and the - // content here is to be inserted into that file at a defined insertion - // point. This feature allows a code generator to extend the output - // produced by another code generator. The original generator may provide - // insertion points by placing special annotations in the file that look - // like: - // @@protoc_insertion_point(NAME) - // The annotation can have arbitrary text before and after it on the line, - // which allows it to be placed in a comment. NAME should be replaced with - // an identifier naming the point -- this is what other generators will use - // as the insertion_point. Code inserted at this point will be placed - // immediately above the line containing the insertion point (thus multiple - // insertions to the same point will come out in the order they were added). - // The double-@ is intended to make it unlikely that the generated code - // could contain things that look like insertion points by accident. - // - // For example, the C++ code generator places the following line in the - // .pb.h files that it generates: - // // @@protoc_insertion_point(namespace_scope) - // This line appears within the scope of the file's package namespace, but - // outside of any particular class. Another plugin can then specify the - // insertion_point "namespace_scope" to generate additional classes or - // other declarations that should be placed in this scope. - // - // Note that if the line containing the insertion point begins with - // whitespace, the same whitespace will be added to every line of the - // inserted text. This is useful for languages like Python, where - // indentation matters. In these languages, the insertion point comment - // should be indented the same amount as any inserted code will need to be - // in order to work correctly in that context. - // - // The code generator that generates the initial file and the one which - // inserts into it must both run as part of a single invocation of protoc. - // Code generators are executed in the order in which they appear on the - // command line. - // - // If |insertion_point| is present, |name| must also be present. - optional string insertion_point = 2; - - // The file contents. - optional string content = 15; - - // Information describing the file content being inserted. If an insertion - // point is used, this information will be appropriately offset and inserted - // into the code generation metadata for the generated files. - optional GeneratedCodeInfo generated_code_info = 16; - } - repeated File file = 15; -} diff --git a/include/google/protobuf/compiler/python/generator.h b/include/google/protobuf/compiler/python/generator.h deleted file mode 100644 index f1fecbc735..0000000000 --- a/include/google/protobuf/compiler/python/generator.h +++ /dev/null @@ -1,185 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: robinson@google.com (Will Robinson) -// -// Generates Python code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ - -#include <string> - -#include <google/protobuf/stubs/mutex.h> -#include <google/protobuf/compiler/code_generator.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class EnumValueDescriptor; -class FieldDescriptor; -class OneofDescriptor; -class ServiceDescriptor; - -namespace io { -class Printer; -} - -namespace compiler { -namespace python { - -// CodeGenerator implementation for generated Python protocol buffer classes. -// If you create your own protocol compiler binary and you want it to support -// Python output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator : public CodeGenerator { - public: - Generator(); - ~Generator() override; - - // CodeGenerator methods. - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override; - - private: - void PrintImports() const; - void PrintFileDescriptor() const; - void PrintAllNestedEnumsInFile() const; - void PrintNestedEnums(const Descriptor& descriptor) const; - void PrintEnum(const EnumDescriptor& enum_descriptor) const; - - void PrintFieldDescriptor(const FieldDescriptor& field, - bool is_extension) const; - void PrintFieldDescriptorsInDescriptor( - const Descriptor& message_descriptor, bool is_extension, - const std::string& list_variable_name, int (Descriptor::*CountFn)() const, - const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const; - void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; - void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; - void PrintMessageDescriptors() const; - void PrintDescriptor(const Descriptor& message_descriptor) const; - void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; - - void PrintMessages() const; - void PrintMessage(const Descriptor& message_descriptor, - const std::string& prefix, - std::vector<std::string>* to_register, - bool is_nested) const; - void PrintNestedMessages(const Descriptor& containing_descriptor, - const std::string& prefix, - std::vector<std::string>* to_register) const; - - void FixForeignFieldsInDescriptors() const; - void FixForeignFieldsInDescriptor( - const Descriptor& descriptor, - const Descriptor* containing_descriptor) const; - void FixForeignFieldsInField(const Descriptor* containing_type, - const FieldDescriptor& field, - const std::string& python_dict_name) const; - void AddMessageToFileDescriptor(const Descriptor& descriptor) const; - void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; - void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const; - void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; - std::string FieldReferencingExpression( - const Descriptor* containing_type, const FieldDescriptor& field, - const std::string& python_dict_name) const; - template <typename DescriptorT> - void FixContainingTypeInDescriptor( - const DescriptorT& descriptor, - const Descriptor* containing_descriptor) const; - - void FixForeignFieldsInExtensions() const; - void FixForeignFieldsInExtension( - const FieldDescriptor& extension_field) const; - void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; - - void PrintServices() const; - void PrintServiceDescriptors() const; - void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; - void PrintServiceClass(const ServiceDescriptor& descriptor) const; - void PrintServiceStub(const ServiceDescriptor& descriptor) const; - void PrintDescriptorKeyAndModuleName( - const ServiceDescriptor& descriptor) const; - - void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; - std::string OptionsValue(const std::string& serialized_options) const; - bool GeneratingDescriptorProto() const; - - template <typename DescriptorT> - std::string ModuleLevelDescriptorName(const DescriptorT& descriptor) const; - std::string ModuleLevelMessageName(const Descriptor& descriptor) const; - std::string ModuleLevelServiceDescriptorName( - const ServiceDescriptor& descriptor) const; - - template <typename DescriptorT, typename DescriptorProtoT> - void PrintSerializedPbInterval(const DescriptorT& descriptor, - DescriptorProtoT& proto, - const std::string& name) const; - - void FixAllDescriptorOptions() const; - void FixOptionsForField(const FieldDescriptor& field) const; - void FixOptionsForOneof(const OneofDescriptor& oneof) const; - void FixOptionsForEnum(const EnumDescriptor& descriptor) const; - void FixOptionsForService(const ServiceDescriptor& descriptor) const; - void FixOptionsForMessage(const Descriptor& descriptor) const; - - void SetSerializedPbInterval() const; - void SetMessagePbInterval(const Descriptor& descriptor) const; - - void CopyPublicDependenciesAliases(const std::string& copy_from, - const FileDescriptor* file) const; - - // Very coarse-grained lock to ensure that Generate() is reentrant. - // Guards file_, printer_ and file_descriptor_serialized_. - mutable Mutex mutex_; - mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. - mutable std::string file_descriptor_serialized_; - mutable io::Printer* printer_; // Set in Generate(). Under mutex_. - mutable bool pure_python_workable_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); -}; - -} // namespace python -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/python/pyi_generator.h b/include/google/protobuf/compiler/python/pyi_generator.h deleted file mode 100644 index 9611ed43d1..0000000000 --- a/include/google/protobuf/compiler/python/pyi_generator.h +++ /dev/null @@ -1,120 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jieluo@google.com (Jie Luo) -// -// Generates Python stub (.pyi) for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ - -#include <map> -#include <set> -#include <string> - -#include <google/protobuf/stubs/mutex.h> -#include <google/protobuf/compiler/code_generator.h> - -// Must be included last. -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -class Descriptor; -class EnumDescriptor; -class FieldDescriptor; -class MethodDescriptor; -class ServiceDescriptor; - -namespace io { -class Printer; -} - -namespace compiler { -namespace python { - -class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenerator { - public: - PyiGenerator(); - ~PyiGenerator() override; - - // CodeGenerator methods. - uint64_t GetSupportedFeatures() const override { - // Code generators must explicitly support proto3 optional. - return CodeGenerator::FEATURE_PROTO3_OPTIONAL; - } - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - private: - void PrintImportForDescriptor(const FileDescriptor& desc, - std::map<std::string, std::string>* import_map, - std::set<std::string>* seen_aliases) const; - void PrintImports(std::map<std::string, std::string>* item_map, - std::map<std::string, std::string>* import_map) const; - void PrintEnum(const EnumDescriptor& enum_descriptor) const; - void AddEnumValue(const EnumDescriptor& enum_descriptor, - std::map<std::string, std::string>* item_map, - const std::map<std::string, std::string>& import_map) const; - void PrintTopLevelEnums() const; - template <typename DescriptorT> - void AddExtensions(const DescriptorT& descriptor, - std::map<std::string, std::string>* item_map) const; - void PrintMessages( - const std::map<std::string, std::string>& import_map) const; - void PrintMessage(const Descriptor& message_descriptor, bool is_nested, - const std::map<std::string, std::string>& import_map) const; - void PrintServices() const; - void PrintItemMap(const std::map<std::string, std::string>& item_map) const; - std::string GetFieldType( - const FieldDescriptor& field_des, const Descriptor& containing_des, - const std::map<std::string, std::string>& import_map) const; - template <typename DescriptorT> - std::string ModuleLevelName( - const DescriptorT& descriptor, - const std::map<std::string, std::string>& import_map) const; - - // Very coarse-grained lock to ensure that Generate() is reentrant. - // Guards file_ and printer_. - mutable Mutex mutex_; - mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. - mutable io::Printer* printer_; // Set in Generate(). Under mutex_. - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PyiGenerator); -}; - -} // namespace python -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ diff --git a/include/google/protobuf/compiler/python/python_generator.h b/include/google/protobuf/compiler/python/python_generator.h deleted file mode 100644 index 21d48cd9a0..0000000000 --- a/include/google/protobuf/compiler/python/python_generator.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ -#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ - -#include <google/protobuf/compiler/python/generator.h> - -#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ diff --git a/include/google/protobuf/compiler/ruby/ruby_generator.h b/include/google/protobuf/compiler/ruby/ruby_generator.h deleted file mode 100644 index 647bb83606..0000000000 --- a/include/google/protobuf/compiler/ruby/ruby_generator.h +++ /dev/null @@ -1,67 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Generates Ruby code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ - -#include <string> - -#include <google/protobuf/compiler/code_generator.h> - -#include <google/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace ruby { - -// CodeGenerator implementation for generated Ruby protocol buffer classes. -// If you create your own protocol compiler binary and you want it to support -// Ruby output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator : public CodeGenerator { - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } -}; - -} // namespace ruby -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <google/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ |