| Index: third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc
|
| ===================================================================
|
| --- third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc (revision 216642)
|
| +++ third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc (working copy)
|
| @@ -45,8 +45,9 @@
|
| namespace {
|
|
|
| void SetMessageVariables(const FieldDescriptor* descriptor,
|
| - map<string, string>* variables) {
|
| - SetCommonFieldVariables(descriptor, variables);
|
| + map<string, string>* variables,
|
| + const Options& options) {
|
| + SetCommonFieldVariables(descriptor, variables, options);
|
| (*variables)["type"] = FieldMessageTypeName(descriptor);
|
| (*variables)["stream_writer"] = (*variables)["declared_type"] +
|
| (HasFastArraySerialization(descriptor->message_type()->file()) ?
|
| @@ -59,9 +60,10 @@
|
| // ===================================================================
|
|
|
| MessageFieldGenerator::
|
| -MessageFieldGenerator(const FieldDescriptor* descriptor)
|
| +MessageFieldGenerator(const FieldDescriptor* descriptor,
|
| + const Options& options)
|
| : descriptor_(descriptor) {
|
| - SetMessageVariables(descriptor, &variables_);
|
| + SetMessageVariables(descriptor, &variables_, options);
|
| }
|
|
|
| MessageFieldGenerator::~MessageFieldGenerator() {}
|
| @@ -76,7 +78,8 @@
|
| printer->Print(variables_,
|
| "inline const $type$& $name$() const$deprecation$;\n"
|
| "inline $type$* mutable_$name$()$deprecation$;\n"
|
| - "inline $type$* release_$name$()$deprecation$;\n");
|
| + "inline $type$* release_$name$()$deprecation$;\n"
|
| + "inline void set_allocated_$name$($type$* $name$)$deprecation$;\n");
|
| }
|
|
|
| void MessageFieldGenerator::
|
| @@ -103,6 +106,15 @@
|
| " $type$* temp = $name$_;\n"
|
| " $name$_ = NULL;\n"
|
| " return temp;\n"
|
| + "}\n"
|
| + "inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
|
| + " delete $name$_;\n"
|
| + " $name$_ = $name$;\n"
|
| + " if ($name$) {\n"
|
| + " set_has_$name$();\n"
|
| + " } else {\n"
|
| + " clear_has_$name$();\n"
|
| + " }\n"
|
| "}\n");
|
| }
|
|
|
| @@ -167,9 +179,10 @@
|
| // ===================================================================
|
|
|
| RepeatedMessageFieldGenerator::
|
| -RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor)
|
| +RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
|
| + const Options& options)
|
| : descriptor_(descriptor) {
|
| - SetMessageVariables(descriptor, &variables_);
|
| + SetMessageVariables(descriptor, &variables_, options);
|
| }
|
|
|
| RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
|
| @@ -197,7 +210,7 @@
|
| GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
| printer->Print(variables_,
|
| "inline const $type$& $classname$::$name$(int index) const {\n"
|
| - " return $name$_.Get(index);\n"
|
| + " return $name$_.$cppget$(index);\n"
|
| "}\n"
|
| "inline $type$* $classname$::mutable_$name$(int index) {\n"
|
| " return $name$_.Mutable(index);\n"
|
|
|