aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-07-16 17:03:06 +0100
committerJon Skeet <jonskeet@google.com>2015-07-16 17:03:06 +0100
commit8a0312b20156aa4df092cb6b3c665ef48cb6fa54 (patch)
tree8a5864fa5e8481ed8b04a25404cf51bc1818a37e /src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
parent8d47ec4f3e3368c5f4e7ac195f20978abc8a692f (diff)
downloadprotobuf-8a0312b20156aa4df092cb6b3c665ef48cb6fa54.tar.gz
protobuf-8a0312b20156aa4df092cb6b3c665ef48cb6fa54.tar.bz2
protobuf-8a0312b20156aa4df092cb6b3c665ef48cb6fa54.zip
First pass at wrapper types.
- We do still generate the message types, as otherwise reflection breaks, even though it doesn't actually use those types. - JSON handling hasn't been implemented yet
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc15
1 files changed, 14 insertions, 1 deletions
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 6d4e6984..d939fc79 100644
--- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
@@ -39,6 +39,8 @@
#include <google/protobuf/compiler/csharp/csharp_helpers.h>
#include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>
+#include <google/protobuf/compiler/csharp/csharp_message_field.h>
+#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>
namespace google {
namespace protobuf {
@@ -58,7 +60,18 @@ void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
"private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\n"
- " = pb::FieldCodec.ForMessage($tag$, $type_name$.Parser);\n");
+ " = ");
+ // Don't want to duplicate the codec code here... maybe we should have a
+ // "create single field generator for this repeated field"
+ // function, but it doesn't seem worth it for just this.
+ if (IsWrapperType(descriptor_)) {
+ scoped_ptr<FieldGeneratorBase> single_generator(new WrapperFieldGenerator(descriptor_, fieldOrdinal_));
+ single_generator->GenerateCodecCode(printer);
+ } else {
+ scoped_ptr<FieldGeneratorBase> single_generator(new MessageFieldGenerator(descriptor_, fieldOrdinal_));
+ single_generator->GenerateCodecCode(printer);
+ }
+ printer->Print(";\n");
printer->Print(
variables_,
"private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n");