diff options
author | Jon Skeet <skeet@pobox.com> | 2008-11-24 11:11:28 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2008-11-24 11:11:28 +0000 |
commit | 4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6 (patch) | |
tree | bf193777749c47932f7ffde7e60b116d70484baa /src/ProtoGen/RepeatedEnumFieldGenerator.cs | |
parent | 1d131c98f058dc0b5e0ebef73602e09dc88fe075 (diff) | |
download | protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.tar.gz protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.tar.bz2 protobuf-4cf9e3c619fbd00e47d5ec2503801814d3c8b4b6.zip |
Fix property special-casing
Diffstat (limited to 'src/ProtoGen/RepeatedEnumFieldGenerator.cs')
-rw-r--r-- | src/ProtoGen/RepeatedEnumFieldGenerator.cs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/ProtoGen/RepeatedEnumFieldGenerator.cs b/src/ProtoGen/RepeatedEnumFieldGenerator.cs index efc6466f..58d0141c 100644 --- a/src/ProtoGen/RepeatedEnumFieldGenerator.cs +++ b/src/ProtoGen/RepeatedEnumFieldGenerator.cs @@ -12,44 +12,44 @@ namespace Google.ProtocolBuffers.ProtoGen { public void GenerateMembers(TextGenerator writer) { writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name); - writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); + writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName); writer.WriteLine(" get {{ return pbc::Lists.AsReadOnly({0}_); }}", Name); writer.WriteLine("}"); // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. - writer.WriteLine("public int {0}Count {{", CapitalizedName); + writer.WriteLine("public int {0}Count {{", PropertyName); writer.WriteLine(" get {{ return {0}_.Count; }}", Name); writer.WriteLine("}"); - writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); + writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName); writer.WriteLine(" return {0}_[index];", Name); writer.WriteLine("}"); } public void GenerateBuilderMembers(TextGenerator writer) { // Note: We can return the original list here, because we make it unmodifiable when we build - writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, CapitalizedName); + writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName); writer.WriteLine(" get {{ return result.{0}_; }}", Name); writer.WriteLine("}"); - writer.WriteLine("public int {0}Count {{", CapitalizedName); - writer.WriteLine(" get {{ return result.{0}Count; }}", CapitalizedName); + writer.WriteLine("public int {0}Count {{", PropertyName); + writer.WriteLine(" get {{ return result.{0}Count; }}", PropertyName); writer.WriteLine("}"); - writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, CapitalizedName); - writer.WriteLine(" return result.Get{0}(index);", CapitalizedName); + writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName); + writer.WriteLine(" return result.Get{0}(index);", PropertyName); writer.WriteLine("}"); - writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", CapitalizedName, TypeName); + writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName); writer.WriteLine(" result.{0}_[index] = value;", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); - writer.WriteLine("public Builder Add{0}({1} value) {{", CapitalizedName, TypeName); + writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName); writer.WriteLine(" result.{0}_.Add(value);", Name, TypeName); writer.WriteLine(" return this;"); writer.WriteLine("}"); - writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", CapitalizedName, TypeName); + writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName); writer.WriteLine(" base.AddRange(values, result.{0}_);", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); - writer.WriteLine("public Builder Clear{0}() {{", CapitalizedName); + writer.WriteLine("public Builder Clear{0}() {{", PropertyName); writer.WriteLine(" result.{0}_.Clear();", Name); writer.WriteLine(" return this;"); writer.WriteLine("}"); @@ -71,18 +71,18 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName); writer.WriteLine(" unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number); writer.WriteLine("} else {"); - writer.WriteLine(" Add{0}(({1}) rawValue);", CapitalizedName, TypeName); + writer.WriteLine(" Add{0}(({1}) rawValue);", PropertyName, TypeName); writer.WriteLine("}"); } public void GenerateSerializationCode(TextGenerator writer) { - writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); + writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName); writer.WriteLine(" output.WriteEnum({0}, (int) element);", Number); writer.WriteLine("}"); } public void GenerateSerializedSizeCode(TextGenerator writer) { - writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, CapitalizedName); + writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName); writer.WriteLine(" size += pb::CodedOutputStream.ComputeEnumSize({0}, (int) element);", Number); writer.WriteLine("}"); } |