Index: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h |
index f7d99b154cdc1bd854aa2820c0c3b61cf5ce2d4d..1d7f823300ffb30e7ca686e72f74a2729ae504a0 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h |
+++ b/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// http://code.google.com/p/protobuf/ |
+// 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 |
@@ -36,9 +36,12 @@ |
#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__ |
#include <map> |
+#include <memory> |
+#ifndef _SHARED_PTR_H |
+#include <google/protobuf/stubs/shared_ptr.h> |
+#endif |
#include <string> |
-#include <google/protobuf/stubs/common.h> |
#include <google/protobuf/descriptor.h> |
#include <google/protobuf/compiler/cpp/cpp_options.h> |
@@ -61,6 +64,9 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, |
map<string, string>* variables, |
const Options& options); |
+void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, |
+ map<string, string>* variables); |
+ |
class FieldGenerator { |
public: |
FieldGenerator() {} |
@@ -71,20 +77,51 @@ class FieldGenerator { |
// class. |
virtual void GeneratePrivateMembers(io::Printer* printer) const = 0; |
+ // Generate static default variable for this field. These are placed inside |
+ // the message class. Most field types don't need this, so the default |
+ // implementation is empty. |
+ virtual void GenerateStaticMembers(io::Printer* /*printer*/) const {} |
+ |
+ // Generate prototypes for accessors that will manipulate imported |
+ // messages inline. These are for .proto.h headers. |
+ // |
+ // In .proto.h mode, the headers of imports are not #included. However, |
+ // functions that manipulate the imported message types need access to |
+ // the class definition of the imported message, meaning that the headers |
+ // must be #included. To get around this, functions that manipulate |
+ // imported message objects are defined as dependent functions in a base |
+ // template class. By making them dependent template functions, the |
+ // function templates will not be instantiated until they are called, so |
+ // we can defer to those translation units to #include the necessary |
+ // generated headers. |
+ // |
+ // See: |
+ // http://en.cppreference.com/w/cpp/language/class_template#Implicit_instantiation |
+ // |
+ // Most field types don't need this, so the default implementation is empty. |
+ virtual void GenerateDependentAccessorDeclarations( |
+ io::Printer* printer) const {} |
+ |
// Generate prototypes for all of the accessor functions related to this |
// field. These are placed inside the class definition. |
virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0; |
+ // Generate inline definitions of depenent accessor functions for this field. |
+ // These are placed inside the header after all class definitions. |
+ virtual void GenerateDependentInlineAccessorDefinitions( |
+ io::Printer* printer) const {} |
+ |
// Generate inline definitions of accessor functions for this field. |
// These are placed inside the header after all class definitions. |
+ // In non-.proto.h mode, this generates dependent accessor functions as well. |
virtual void GenerateInlineAccessorDefinitions( |
- io::Printer* printer) const = 0; |
+ io::Printer* printer, bool is_inline) const = 0; |
// Generate definitions of accessors that aren't inlined. These are |
// placed somewhere in the .cc file. |
// Most field types don't need this, so the default implementation is empty. |
virtual void GenerateNonInlineAccessorDefinitions( |
- io::Printer* printer) const {} |
+ io::Printer* /*printer*/) const {} |
// Generate lines of code (statements, not declarations) which clear the |
// field. This is used to define the clear_$name$() method as well as |
@@ -114,14 +151,25 @@ class FieldGenerator { |
// Generate any code that needs to go in the class's SharedDtor() method, |
// invoked by the destructor. |
// Most field types don't need this, so the default implementation is empty. |
- virtual void GenerateDestructorCode(io::Printer* printer) const {} |
+ virtual void GenerateDestructorCode(io::Printer* /*printer*/) const {} |
+ |
+ // Generate a manual destructor invocation for use when the message is on an |
+ // arena. The code that this method generates will be executed inside a |
+ // shared-for-the-whole-message-class method registered with OwnDestructor(). |
+ // The method should return |true| if it generated any code that requires a |
+ // call; this allows the message generator to eliminate the OwnDestructor() |
+ // registration if no fields require it. |
+ virtual bool GenerateArenaDestructorCode(io::Printer* printer) const { |
+ return false; |
+ } |
// Generate code that allocates the fields's default instance. |
- virtual void GenerateDefaultInstanceAllocator(io::Printer* printer) const {} |
+ virtual void GenerateDefaultInstanceAllocator(io::Printer* /*printer*/) |
+ const {} |
// Generate code that should be run when ShutdownProtobufLibrary() is called, |
// to delete all dynamically-allocated objects. |
- virtual void GenerateShutdownCode(io::Printer* printer) const {} |
+ virtual void GenerateShutdownCode(io::Printer* /*printer*/) const {} |
// Generate lines to decode this field, which will be placed inside the |
// message's MergeFromCodedStream() method. |
@@ -160,7 +208,7 @@ class FieldGeneratorMap { |
private: |
const Descriptor* descriptor_; |
- scoped_array<scoped_ptr<FieldGenerator> > field_generators_; |
+ google::protobuf::scoped_array<google::protobuf::scoped_ptr<FieldGenerator> > field_generators_; |
static FieldGenerator* MakeGenerator(const FieldDescriptor* field, |
const Options& options); |