diff options
Diffstat (limited to 'src/google/protobuf/compiler/js/js_generator.h')
-rw-r--r--[-rwxr-xr-x] | src/google/protobuf/compiler/js/js_generator.h | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 3cc60e22..4567b07a 100755..100644 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -40,6 +40,8 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/port_def.inc> + namespace google { namespace protobuf { @@ -56,17 +58,18 @@ namespace js { struct GeneratorOptions { // Output path. - string output_dir; + std::string output_dir; // Namespace prefix. - string namespace_prefix; + std::string namespace_prefix; // Enable binary-format support? bool binary; // What style of imports should be used. enum ImportStyle { - kImportClosure, // goog.require() - kImportCommonJs, // require() - kImportBrowser, // no import statements - kImportEs6, // import { member } from '' + kImportClosure, // goog.require() + kImportCommonJs, // require() + kImportCommonJsStrict, // require() with no global export + kImportBrowser, // no import statements + kImportEs6, // import { member } from '' } import_style; GeneratorOptions() @@ -83,11 +86,11 @@ struct GeneratorOptions { annotate_code(false) {} bool ParseFromOptions( - const std::vector< std::pair< string, string > >& options, - string* error); + const std::vector< std::pair< std::string, std::string > >& options, + std::string* error); // Returns the file name extension to use for generated code. - string GetFileNameExtension() const { + std::string GetFileNameExtension() const { return import_style == kImportClosure ? extension : "_pb.js"; } @@ -112,11 +115,11 @@ struct GeneratorOptions { bool testonly; // Create a library with name <name>_lib.js rather than a separate .js file // per type? - string library; + std::string library; // Error if there are two types that would generate the same output file? bool error_on_name_conflict; // The extension to use for output file names. - string extension; + std::string extension; // Create a separate output file for each input file? bool one_output_file_per_input_file; // If true, we should build .meta files that contain annotations for @@ -128,15 +131,15 @@ struct GeneratorOptions { // header. If you create your own protocol compiler binary and you want it to // support JavaScript output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT Generator : public CodeGenerator { +class PROTOC_EXPORT Generator : public CodeGenerator { public: Generator() {} virtual ~Generator() {} virtual bool Generate(const FileDescriptor* file, - const string& parameter, + const std::string& parameter, GeneratorContext* context, - string* error) const { + std::string* error) const { *error = "Unimplemented Generate() method. Call GenerateAll() instead."; return false; } @@ -144,9 +147,9 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { virtual bool HasGenerateAll() const { return true; } virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const string& parameter, + const std::string& parameter, GeneratorContext* context, - string* error) const; + std::string* error) const; private: void GenerateHeader(const GeneratorOptions& options, @@ -156,28 +159,28 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void FindProvides(const GeneratorOptions& options, io::Printer* printer, const std::vector<const FileDescriptor*>& file, - std::set<string>* provided) const; + std::set<std::string>* provided) const; void FindProvidesForFile(const GeneratorOptions& options, io::Printer* printer, const FileDescriptor* file, - std::set<string>* provided) const; + std::set<std::string>* provided) const; void FindProvidesForMessage(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc, - std::set<string>* provided) const; + std::set<std::string>* provided) const; void FindProvidesForEnum(const GeneratorOptions& options, io::Printer* printer, const EnumDescriptor* enumdesc, - std::set<string>* provided) const; + std::set<std::string>* provided) const; // For extension fields at file scope. void FindProvidesForFields(const GeneratorOptions& options, io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, - std::set<string>* provided) const; + std::set<std::string>* provided) const; // Print the goog.provides() found by the methods above. void GenerateProvides(const GeneratorOptions& options, io::Printer* printer, - std::set<string>* provided) const; + std::set<std::string>* provided) const; // Generate goog.setTestOnly() if indicated. void GenerateTestOnly(const GeneratorOptions& options, @@ -187,34 +190,34 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void GenerateRequiresForLibrary( const GeneratorOptions& options, io::Printer* printer, const std::vector<const FileDescriptor*>& files, - std::set<string>* provided) const; + std::set<std::string>* provided) const; void GenerateRequiresForMessage(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc, - std::set<string>* provided) const; + std::set<std::string>* provided) const; // For extension fields at file scope. void GenerateRequiresForExtensions( const GeneratorOptions& options, io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, - std::set<string>* provided) const; + std::set<std::string>* provided) const; void GenerateRequiresImpl(const GeneratorOptions& options, - io::Printer* printer, std::set<string>* required, - std::set<string>* forwards, - std::set<string>* provided, bool require_jspb, + io::Printer* printer, std::set<std::string>* required, + std::set<std::string>* forwards, + std::set<std::string>* provided, bool require_jspb, bool require_extension, bool require_map) const; void FindRequiresForMessage(const GeneratorOptions& options, const Descriptor* desc, - std::set<string>* required, - std::set<string>* forwards, + std::set<std::string>* required, + std::set<std::string>* forwards, bool* have_message) const; void FindRequiresForField(const GeneratorOptions& options, const FieldDescriptor* field, - std::set<string>* required, - std::set<string>* forwards) const; + std::set<std::string>* required, + std::set<std::string>* forwards) const; void FindRequiresForExtension(const GeneratorOptions& options, const FieldDescriptor* field, - std::set<string>* required, - std::set<string>* forwards) const; + std::set<std::string>* required, + std::set<std::string>* forwards) const; void GenerateFile(const GeneratorOptions& options, io::Printer* printer, @@ -328,6 +331,8 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { } // namespace js } // namespace compiler } // namespace protobuf - } // namespace google + +#include <google/protobuf/port_undef.inc> + #endif // GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ |