浏览代码

Add an intermediate method to propagate the friendship access to nested classes as a workaround for old compilers (e.g. gcc 3.4)

liujisi@google.com 14 年之前
父节点
当前提交
17d57dbbcd
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/google/protobuf/descriptor.cc

+ 6 - 3
src/google/protobuf/descriptor.cc

@@ -2160,6 +2160,11 @@ class DescriptorBuilder {
   static inline bool get_is_placeholder(const Descriptor* descriptor) {
   static inline bool get_is_placeholder(const Descriptor* descriptor) {
     return descriptor->is_placeholder_;
     return descriptor->is_placeholder_;
   }
   }
+  static inline void assert_mutex_held(const DescriptorPool* pool) {
+    if (pool->mutex_ != NULL) {
+      pool->mutex_->AssertHeld();
+    }
+  }
 
 
   // Must be run only after options have been interpreted.
   // Must be run only after options have been interpreted.
   //
   //
@@ -4338,9 +4343,7 @@ class DescriptorBuilder::OptionInterpreter::AggregateOptionFinder
 
 
   virtual const FieldDescriptor* FindExtension(
   virtual const FieldDescriptor* FindExtension(
       Message* message, const string& name) const {
       Message* message, const string& name) const {
-    if (builder_->pool_->mutex_ != NULL) {
-      builder_->pool_->mutex_->AssertHeld();
-    }
+    assert_mutex_held(builder_->pool_);
     Symbol result = builder_->LookupSymbolNoPlaceholder(
     Symbol result = builder_->LookupSymbolNoPlaceholder(
         name, message->GetDescriptor()->full_name());
         name, message->GetDescriptor()->full_name());
     if (result.type == Symbol::FIELD &&
     if (result.type == Symbol::FIELD &&