diff options
author | Jon Skeet <skeet@pobox.com> | 2015-07-30 09:47:38 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-07-30 09:47:38 +0100 |
commit | 7a0effb9e956ee5509d99a33f7d8fb52a9636871 (patch) | |
tree | 8bae164441950d8792d1b1612596809e45e9ce82 /src | |
parent | 9cfea1d6f6b81462021b928f45c732cd9920d869 (diff) | |
parent | 7ec023acf4019e5401d4e147204ba5de12eed226 (diff) | |
download | protobuf-7a0effb9e956ee5509d99a33f7d8fb52a9636871.tar.gz protobuf-7a0effb9e956ee5509d99a33f7d8fb52a9636871.tar.bz2 protobuf-7a0effb9e956ee5509d99a33f7d8fb52a9636871.zip |
Merge pull request #654 from jtattermusch/csharp_hide_freeze
Remove the C# Freeze API
Diffstat (limited to 'src')
8 files changed, 2 insertions, 46 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index cba24a59..f84ad6f7 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -129,8 +129,6 @@ void MapFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void MapFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 81d62741..86ef0489 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -190,7 +190,6 @@ void MessageGenerator::Generate(io::Printer* printer) { " get { return $name$Case_; }\n" "}\n\n" "public void Clear$property_name$() {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$Case_ = $property_name$OneofCase.None;\n" " $name$_ = null;\n" "}\n\n"); @@ -293,33 +292,6 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { } void MessageGenerator::GenerateFreezingCode(io::Printer* printer) { - map<string, string> vars; - vars["class_name"] = class_name(); - printer->Print( - "public void Freeze() {\n" - " if (IsFrozen) {\n" - " return;\n" - " }\n" - " _frozen = true;\n"); - printer->Indent(); - // Freeze non-oneof fields first (only messages and repeated fields will actually generate any code) - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - scoped_ptr<FieldGeneratorBase> generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - generator->GenerateFreezingCode(printer); - } - } - - // For each oneof, if the value is freezable, freeze it. We don't actually need to know which type it was. - for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { - vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); - printer->Print(vars, - "if ($name$_ is IFreezable) ((IFreezable) $name$_).Freeze();\n"); - } - - printer->Outdent(); - printer->Print("}\n\n"); } void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index d2c3a88b..4f576cd1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -67,7 +67,6 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$_ = value;\n" " }\n" "}\n"); @@ -134,8 +133,6 @@ void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "if ($has_property_check$) $property_name$.Freeze();\n"); } void MessageFieldGenerator::GenerateCodecCode(io::Printer* printer) { @@ -161,7 +158,6 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $oneof_name$_ = value;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " }\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 4454ef02..80f4a92d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -73,8 +73,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" - " set {\n" - " pb::Freezable.CheckMutable(this);\n"); + " set {\n"); if (is_value_type) { printer->Print( variables_, @@ -176,8 +175,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - " set {\n" - " pb::Freezable.CheckMutable(this);\n"); + " set {\n"); if (is_value_type) { printer->Print( variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index c1b29e2b..625631df 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -117,8 +117,6 @@ void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void RepeatedEnumFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index d939fc79..7fbab681 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -132,8 +132,6 @@ void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { } void RepeatedMessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 5b5d9b3d..1163ce73 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -115,8 +115,6 @@ void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) } void RepeatedPrimitiveFieldGenerator::GenerateFreezingCode(io::Printer* printer) { - printer->Print(variables_, - "$name$_.Freeze();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index 75ef5e50..44f832bf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -76,7 +76,6 @@ void WrapperFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $name$_ = value;\n" " }\n" "}\n"); @@ -172,7 +171,6 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\n" " set {\n" - " pb::Freezable.CheckMutable(this);\n" " $oneof_name$_ = value;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " }\n" |