diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2015-12-21 00:31:04 -0800 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2015-12-21 00:34:19 -0800 |
commit | d21780841734326d8a7653710f4f23b5366c4447 (patch) | |
tree | 25df44708c81059a3e1c7025e12b734cc80ee3f4 /src/google | |
parent | 1e2fece3e01b8e079b4f6930306377a9332a2ddb (diff) | |
parent | b27f2893b2a118b4e3bfcd23d32114dbdd4e6d9b (diff) | |
download | protobuf-d21780841734326d8a7653710f4f23b5366c4447.tar.gz protobuf-d21780841734326d8a7653710f4f23b5366c4447.tar.bz2 protobuf-d21780841734326d8a7653710f4f23b5366c4447.zip |
Merge branch master into v3.0.0-beta-2
Diffstat (limited to 'src/google')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_message.cc | 2 | ||||
-rw-r--r-- | src/google/protobuf/descriptor.cc | 31 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 9c72043b..e0230a24 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -353,7 +353,7 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { printer->Print( "public override string ToString() {\n" - " return pb::JsonFormatter.Default.Format(this);\n" + " return pb::JsonFormatter.ToDiagnosticString(this);\n" "}\n\n"); } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 1aac360b..78a34617 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -560,7 +560,7 @@ class FileDescriptorTables { ~FileDescriptorTables(); // Empty table, used with placeholder files. - static const FileDescriptorTables kEmpty; + inline static const FileDescriptorTables& GetEmptyInstance(); // ----------------------------------------------------------------- // Finding items. @@ -665,7 +665,32 @@ FileDescriptorTables::FileDescriptorTables() FileDescriptorTables::~FileDescriptorTables() {} -const FileDescriptorTables FileDescriptorTables::kEmpty; +namespace { + +FileDescriptorTables* file_descriptor_tables_ = NULL; +GOOGLE_PROTOBUF_DECLARE_ONCE(file_descriptor_tables_once_init_); + +void DeleteFileDescriptorTables() { + delete file_descriptor_tables_; + file_descriptor_tables_ = NULL; +} + +void InitFileDescriptorTables() { + file_descriptor_tables_ = new FileDescriptorTables(); + internal::OnShutdown(&DeleteFileDescriptorTables); +} + +inline void InitFileDescriptorTablesOnce() { + ::google::protobuf::GoogleOnceInit( + &file_descriptor_tables_once_init_, &InitFileDescriptorTables); +} + +} // anonymous namespace + +inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() { + InitFileDescriptorTablesOnce(); + return *file_descriptor_tables_; +} void DescriptorPool::Tables::AddCheckpoint() { checkpoints_.push_back(CheckPoint(this)); @@ -3537,7 +3562,7 @@ FileDescriptor* DescriptorBuilder::NewPlaceholderFile( placeholder->package_ = &internal::GetEmptyString(); placeholder->pool_ = pool_; placeholder->options_ = &FileOptions::default_instance(); - placeholder->tables_ = &FileDescriptorTables::kEmpty; + placeholder->tables_ = &FileDescriptorTables::GetEmptyInstance(); placeholder->source_code_info_ = &SourceCodeInfo::default_instance(); placeholder->is_placeholder_ = true; placeholder->syntax_ = FileDescriptor::SYNTAX_PROTO2; |