diff --git a/CHANGES.txt b/CHANGES.txt index b55e275deb25..85e6a034b784 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,22 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) implementation detail users must not rely on. It should not be used in unit tests. * Change the signature of Any::PackFrom() to return false on error. + * Add fast reflection getter API for strings. + * Constant initialize the global message instances + * Avoid potential for missed wakeup in UnknownFieldSet + * Now Proto3 Oneof fields have "has" methods for checking their presence in + C++. + * Bugfix for NVCC + * Return early in _InternalSerialize for empty maps. + * Adding functionality for outputting map key values in proto path logging + output (does not affect comparison logic) and stop printing 'value' in the + path. The modified print functionality is in the + MessageDifferencer::StreamReporter. + * Fixes https://github.com/protocolbuffers/protobuf/issues/8129 + * Ensure that null char symbol, package and file names do not result in a + crash. + * Constant initialize the global message instances + * Pretty print 'max' instead of numeric values in reserved ranges. Java * Avoid possible UnsupportedOperationException when using CodedInputSteam @@ -19,10 +35,20 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) * Make Durations.comparator() and Timestamps.comparator() Serializable. * Add more detailed error information for dynamic message field type validation failure + * Removed declarations of functions declared in java_names.h from + java_helpers.h. + * Now Proto3 Oneof fields have "has" methods for checking their presence in + Java. + * Annotates Java proto generated *_FIELD_NUMBER constants. Python * Provided an override for the reverse() method that will reverse the internal collection directly instead of using the other methods of the BaseContainer. + * MessageFactory.CreateProtoype can be overridden to customize class creation. + + Javascript + * Generate `getDescriptor` methods with `*` as their `this` type. + * Enforce `let/const` for generated messages. 2020-11-11 version 3.14.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index b71f2f1ba9a6..ecb5a851b8a2 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -93,6 +93,7 @@ set(libprotoc_headers ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.h ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.h ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h + ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_names.h ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_options.h ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.h diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index c30b00ddf730..51597fa3db62 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -190,7 +190,7 @@ public Descriptor findMessageTypeByName(String name) { name = packageName + '.' + name; } final GenericDescriptor result = pool.findSymbol(name); - if (result != null && result instanceof Descriptor && result.getFile() == this) { + if (result instanceof Descriptor && result.getFile() == this) { return (Descriptor) result; } else { return null; @@ -214,7 +214,7 @@ public EnumDescriptor findEnumTypeByName(String name) { name = packageName + '.' + name; } final GenericDescriptor result = pool.findSymbol(name); - if (result != null && result instanceof EnumDescriptor && result.getFile() == this) { + if (result instanceof EnumDescriptor && result.getFile() == this) { return (EnumDescriptor) result; } else { return null; @@ -238,7 +238,7 @@ public ServiceDescriptor findServiceByName(String name) { name = packageName + '.' + name; } final GenericDescriptor result = pool.findSymbol(name); - if (result != null && result instanceof ServiceDescriptor && result.getFile() == this) { + if (result instanceof ServiceDescriptor && result.getFile() == this) { return (ServiceDescriptor) result; } else { return null; @@ -260,7 +260,7 @@ public FieldDescriptor findExtensionByName(String name) { name = packageName + '.' + name; } final GenericDescriptor result = pool.findSymbol(name); - if (result != null && result instanceof FieldDescriptor && result.getFile() == this) { + if (result instanceof FieldDescriptor && result.getFile() == this) { return (FieldDescriptor) result; } else { return null; @@ -338,7 +338,7 @@ private static FileDescriptor[] findDescriptors( final Class descriptorOuterClass, final String[] dependencyClassNames, final String[] dependencyFileNames) { - List descriptors = new ArrayList(); + List descriptors = new ArrayList<>(); for (int i = 0; i < dependencyClassNames.length; i++) { try { Class clazz = descriptorOuterClass.getClassLoader().loadClass(dependencyClassNames[i]); @@ -507,11 +507,11 @@ private FileDescriptor( this.pool = pool; this.proto = proto; this.dependencies = dependencies.clone(); - HashMap nameToFileMap = new HashMap(); + HashMap nameToFileMap = new HashMap<>(); for (FileDescriptor file : dependencies) { nameToFileMap.put(file.getName(), file); } - List publicDependencies = new ArrayList(); + List publicDependencies = new ArrayList<>(); for (int i = 0; i < proto.getPublicDependencyCount(); i++) { int index = proto.getPublicDependency(i); if (index < 0 || index >= proto.getDependencyCount()) { @@ -758,7 +758,7 @@ public boolean isReservedName(final String name) { * y" ranges declared on it. */ public boolean isExtendable() { - return proto.getExtensionRangeList().size() != 0; + return !proto.getExtensionRangeList().isEmpty(); } /** @@ -772,7 +772,7 @@ public boolean isExtendable() { */ public FieldDescriptor findFieldByName(final String name) { final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name); - if (result != null && result instanceof FieldDescriptor) { + if (result instanceof FieldDescriptor) { return (FieldDescriptor) result; } else { return null; @@ -797,7 +797,7 @@ public FieldDescriptor findFieldByNumber(final int number) { */ public Descriptor findNestedTypeByName(final String name) { final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name); - if (result != null && result instanceof Descriptor) { + if (result instanceof Descriptor) { return (Descriptor) result; } else { return null; @@ -812,7 +812,7 @@ public Descriptor findNestedTypeByName(final String name) { */ public EnumDescriptor findEnumTypeByName(final String name) { final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name); - if (result != null && result instanceof EnumDescriptor) { + if (result instanceof EnumDescriptor) { return (EnumDescriptor) result; } else { return null; @@ -1701,7 +1701,7 @@ public List getValues() { */ public EnumValueDescriptor findValueByName(final String name) { final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name); - if (result != null && result instanceof EnumValueDescriptor) { + if (result instanceof EnumValueDescriptor) { return (EnumValueDescriptor) result; } else { return null; @@ -1785,7 +1785,7 @@ int getUnknownEnumValueDescriptorCount() { private final Descriptor containingType; private EnumValueDescriptor[] values; private final WeakHashMap> unknownValues = - new WeakHashMap>(); + new WeakHashMap<>(); private EnumDescriptor( final EnumDescriptorProto proto, @@ -1991,7 +1991,7 @@ public List getMethods() { */ public MethodDescriptor findMethodByName(final String name) { final GenericDescriptor result = file.pool.findSymbol(fullName + '.' + name); - if (result != null && result instanceof MethodDescriptor) { + if (result instanceof MethodDescriptor) { return (MethodDescriptor) result; } else { return null; @@ -2265,12 +2265,12 @@ enum SearchFilter { } DescriptorPool(final FileDescriptor[] dependencies, boolean allowUnknownDependencies) { - this.dependencies = new HashSet(); + this.dependencies = new HashSet<>(); this.allowUnknownDependencies = allowUnknownDependencies; - for (int i = 0; i < dependencies.length; i++) { - this.dependencies.add(dependencies[i]); - importPublicDependencies(dependencies[i]); + for (Descriptors.FileDescriptor dependency : dependencies) { + this.dependencies.add(dependency); + importPublicDependencies(dependency); } for (final FileDescriptor dependency : this.dependencies) { @@ -2297,12 +2297,9 @@ private void importPublicDependencies(final FileDescriptor file) { private final Set dependencies; private boolean allowUnknownDependencies; - private final Map descriptorsByName = - new HashMap(); - private final Map fieldsByNumber = - new HashMap(); - private final Map enumValuesByNumber = - new HashMap(); + private final Map descriptorsByName = new HashMap<>(); + private final Map fieldsByNumber = new HashMap<>(); + private final Map enumValuesByNumber = new HashMap<>(); /** Find a generic descriptor by fully-qualified name. */ GenericDescriptor findSymbol(final String fullName) { diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java index 27f52100979f..5e3ee0f75549 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -266,12 +266,14 @@ void setMemoizedSerializedSize(int size) { memoizedSerializedSize = size; } + @Override public void writeTo(CodedOutputStream output) throws IOException { Protobuf.getInstance() .schemaFor(this) .writeTo(this, CodedOutputStreamWriter.forCodedOutput(output)); } + @Override public int getSerializedSize() { if (memoizedSerializedSize == -1) { memoizedSerializedSize = Protobuf.getInstance().schemaFor(this).getSerializedSize(this); diff --git a/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java b/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java index 72f56ed88e5d..3fbfaa108d86 100644 --- a/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java +++ b/java/core/src/main/java/com/google/protobuf/RawMessageInfo.java @@ -80,14 +80,15 @@ final class RawMessageInfo implements MessageInfo { *
  • [1]: field type with extra bits: *
      *
    • v & 0xFF = field type as defined in the FieldType class - *
    • v & 0x100 = is required? - *
    • v & 0x200 = is checkUtf8? - *
    • v & 0x400 = needs isInitialized check? - *
    • v & 0x800 = is map field with proto2 enum value? + *
    • v & 0x0100 = is required? + *
    • v & 0x0200 = is checkUtf8? + *
    • v & 0x0400 = needs isInitialized check? + *
    • v & 0x0800 = is map field with proto2 enum value? + *
    • v & 0x1000 = supports presence checking? *
    * * - * If the file is proto2 and this is a singular field: + * If the (singular) field supports presence checking: * *
      *
    • [2]: hasbits offset @@ -180,8 +181,32 @@ final class RawMessageInfo implements MessageInfo { this.defaultInstance = defaultInstance; this.info = info; this.objects = objects; - int position = 0; - int value = (int) info.charAt(position++); + int value; + try { + value = (int) info.charAt(0); + } catch (ArrayIndexOutOfBoundsException e) { + // This is a fix for issues + // that error out on a subset of phones on charAt(0) with an index out of bounds exception. + char[] infoChars = info.toCharArray(); + info = new String(infoChars); + try { + value = (int) info.charAt(0); + } catch (ArrayIndexOutOfBoundsException e2) { + try { + char[] infoChars2 = new char[info.length()]; + info.getChars(0, info.length(), infoChars2, 0); + info = new String(infoChars2); + value = (int) info.charAt(0); + } catch (ArrayIndexOutOfBoundsException e3) { + throw new IllegalStateException( + String.format( + "Failed parsing '%s' with charArray.length of %d", info, infoChars.length), + e3); + } + } + } + int position = 1; + if (value < 0xD800) { flags = value; } else { diff --git a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java index b9b32af15823..0acf22e571cb 100644 --- a/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java +++ b/java/core/src/main/java/com/google/protobuf/UnsafeUtil.java @@ -332,83 +332,18 @@ private static MemoryAccessor getMemoryAccessor() { return new JvmMemoryAccessor(UNSAFE); } - /** Indicates whether or not unsafe array operations are supported on this platform. */ private static boolean supportsUnsafeArrayOperations() { - if (UNSAFE == null) { + if (MEMORY_ACCESSOR == null) { return false; } - try { - Class clazz = UNSAFE.getClass(); - clazz.getMethod("objectFieldOffset", Field.class); - clazz.getMethod("arrayBaseOffset", Class.class); - clazz.getMethod("arrayIndexScale", Class.class); - clazz.getMethod("getInt", Object.class, long.class); - clazz.getMethod("putInt", Object.class, long.class, int.class); - clazz.getMethod("getLong", Object.class, long.class); - clazz.getMethod("putLong", Object.class, long.class, long.class); - clazz.getMethod("getObject", Object.class, long.class); - clazz.getMethod("putObject", Object.class, long.class, Object.class); - if (Android.isOnAndroidDevice()) { - return true; - } - clazz.getMethod("getByte", Object.class, long.class); - clazz.getMethod("putByte", Object.class, long.class, byte.class); - clazz.getMethod("getBoolean", Object.class, long.class); - clazz.getMethod("putBoolean", Object.class, long.class, boolean.class); - clazz.getMethod("getFloat", Object.class, long.class); - clazz.getMethod("putFloat", Object.class, long.class, float.class); - clazz.getMethod("getDouble", Object.class, long.class); - clazz.getMethod("putDouble", Object.class, long.class, double.class); - - return true; - } catch (Throwable e) { - // Because log statements are fairly sparse in this class, this logger is initialized - // non-statically. Static initialization adds undue runtime costs to the first client to - // initialize this class. - Logger.getLogger(UnsafeUtil.class.getName()) - .log( - Level.WARNING, - "platform method missing - proto runtime falling back to safer methods: " + e); - } - return false; + return MEMORY_ACCESSOR.supportsUnsafeArrayOperations(); } private static boolean supportsUnsafeByteBufferOperations() { - if (UNSAFE == null) { + if (MEMORY_ACCESSOR == null) { return false; } - try { - Class clazz = UNSAFE.getClass(); - // Methods for getting direct buffer address. - clazz.getMethod("objectFieldOffset", Field.class); - clazz.getMethod("getLong", Object.class, long.class); - - if (bufferAddressField() == null) { - return false; - } - - if (Android.isOnAndroidDevice()) { - return false; - } - clazz.getMethod("getByte", long.class); - clazz.getMethod("putByte", long.class, byte.class); - clazz.getMethod("getInt", long.class); - clazz.getMethod("putInt", long.class, int.class); - clazz.getMethod("getLong", long.class); - clazz.getMethod("putLong", long.class, long.class); - clazz.getMethod("copyMemory", long.class, long.class, long.class); - clazz.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class); - return true; - } catch (Throwable e) { - // Because log statements are fairly sparse in this class, this logger is initialized - // non-statically. Static initialization adds undue runtime costs to the first client to - // initialize this class. - Logger.getLogger(UnsafeUtil.class.getName()) - .log( - Level.WARNING, - "platform method missing - proto runtime falling back to safer methods: " + e); - } - return false; + return MEMORY_ACCESSOR.supportsUnsafeByteBufferOperations(); } private static boolean determineAndroidSupportByAddressSize(Class addressClass) { @@ -553,6 +488,43 @@ public final long objectFieldOffset(Field field) { return unsafe.objectFieldOffset(field); } + public final int arrayBaseOffset(Class clazz) { + return unsafe.arrayBaseOffset(clazz); + } + + public final int arrayIndexScale(Class clazz) { + return unsafe.arrayIndexScale(clazz); + } + + public abstract Object getStaticObject(Field field); + + // Relative Address Operations --------------------------------------------- + + // Indicates whether the following relative address operations are supported + // by this memory accessor. + public boolean supportsUnsafeArrayOperations() { + if (unsafe == null) { + return false; + } + try { + Class clazz = unsafe.getClass(); + clazz.getMethod("objectFieldOffset", Field.class); + clazz.getMethod("arrayBaseOffset", Class.class); + clazz.getMethod("arrayIndexScale", Class.class); + clazz.getMethod("getInt", Object.class, long.class); + clazz.getMethod("putInt", Object.class, long.class, int.class); + clazz.getMethod("getLong", Object.class, long.class); + clazz.getMethod("putLong", Object.class, long.class, long.class); + clazz.getMethod("getObject", Object.class, long.class); + clazz.getMethod("putObject", Object.class, long.class, Object.class); + + return true; + } catch (Throwable e) { + logMissingMethod(e); + } + return false; + } + public abstract byte getByte(Object target, long offset); public abstract void putByte(Object target, long offset, byte value); @@ -593,12 +565,29 @@ public final void putObject(Object target, long offset, Object value) { unsafe.putObject(target, offset, value); } - public final int arrayBaseOffset(Class clazz) { - return unsafe.arrayBaseOffset(clazz); - } + // Absolute Address Operations -------------------------------------------- - public final int arrayIndexScale(Class clazz) { - return unsafe.arrayIndexScale(clazz); + // Indicates whether the following absolute address operations are + // supported by this memory accessor. + public boolean supportsUnsafeByteBufferOperations() { + if (unsafe == null) { + return false; + } + try { + Class clazz = unsafe.getClass(); + // Methods for getting direct buffer address. + clazz.getMethod("objectFieldOffset", Field.class); + clazz.getMethod("getLong", Object.class, long.class); + + if (bufferAddressField() == null) { + return false; + } + + return true; + } catch (Throwable e) { + logMissingMethod(e); + } + return false; } public abstract byte getByte(long address); @@ -613,8 +602,6 @@ public final int arrayIndexScale(Class clazz) { public abstract void putLong(long address, long value); - public abstract Object getStaticObject(Field field); - public abstract void copyMemory(long srcOffset, byte[] target, long targetIndex, long length); public abstract void copyMemory(byte[] src, long srcIndex, long targetOffset, long length); @@ -627,33 +614,32 @@ private static final class JvmMemoryAccessor extends MemoryAccessor { } @Override - public byte getByte(long address) { - return unsafe.getByte(address); - } - - @Override - public void putByte(long address, byte value) { - unsafe.putByte(address, value); - } - - @Override - public int getInt(long address) { - return unsafe.getInt(address); + public Object getStaticObject(Field field) { + return getObject(unsafe.staticFieldBase(field), unsafe.staticFieldOffset(field)); } @Override - public void putInt(long address, int value) { - unsafe.putInt(address, value); - } + public boolean supportsUnsafeArrayOperations() { + if (!super.supportsUnsafeArrayOperations()) { + return false; + } - @Override - public long getLong(long address) { - return unsafe.getLong(address); - } + try { + Class clazz = unsafe.getClass(); + clazz.getMethod("getByte", Object.class, long.class); + clazz.getMethod("putByte", Object.class, long.class, byte.class); + clazz.getMethod("getBoolean", Object.class, long.class); + clazz.getMethod("putBoolean", Object.class, long.class, boolean.class); + clazz.getMethod("getFloat", Object.class, long.class); + clazz.getMethod("putFloat", Object.class, long.class, float.class); + clazz.getMethod("getDouble", Object.class, long.class); + clazz.getMethod("putDouble", Object.class, long.class, double.class); - @Override - public void putLong(long address, long value) { - unsafe.putLong(address, value); + return true; + } catch (Throwable e) { + logMissingMethod(e); + } + return false; } @Override @@ -697,55 +683,83 @@ public void putDouble(Object target, long offset, double value) { } @Override - public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { - unsafe.copyMemory(null, srcOffset, target, BYTE_ARRAY_BASE_OFFSET + targetIndex, length); + public boolean supportsUnsafeByteBufferOperations() { + if (!super.supportsUnsafeByteBufferOperations()) { + return false; + } + + try { + Class clazz = unsafe.getClass(); + clazz.getMethod("getByte", long.class); + clazz.getMethod("putByte", long.class, byte.class); + clazz.getMethod("getInt", long.class); + clazz.getMethod("putInt", long.class, int.class); + clazz.getMethod("getLong", long.class); + clazz.getMethod("putLong", long.class, long.class); + clazz.getMethod("copyMemory", long.class, long.class, long.class); + clazz.getMethod( + "copyMemory", Object.class, long.class, Object.class, long.class, long.class); + return true; + } catch (Throwable e) { + logMissingMethod(e); + } + return false; } @Override - public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { - unsafe.copyMemory(src, BYTE_ARRAY_BASE_OFFSET + srcIndex, null, targetOffset, length); + public byte getByte(long address) { + return unsafe.getByte(address); } @Override - public Object getStaticObject(Field field) { - return getObject(unsafe.staticFieldBase(field), unsafe.staticFieldOffset(field)); + public void putByte(long address, byte value) { + unsafe.putByte(address, value); } - } - - private static final class Android64MemoryAccessor extends MemoryAccessor { - Android64MemoryAccessor(sun.misc.Unsafe unsafe) { - super(unsafe); + @Override + public int getInt(long address) { + return unsafe.getInt(address); } @Override - public byte getByte(long address) { - throw new UnsupportedOperationException(); + public void putInt(long address, int value) { + unsafe.putInt(address, value); } @Override - public void putByte(long address, byte value) { - throw new UnsupportedOperationException(); + public long getLong(long address) { + return unsafe.getLong(address); } @Override - public int getInt(long address) { - throw new UnsupportedOperationException(); + public void putLong(long address, long value) { + unsafe.putLong(address, value); } @Override - public void putInt(long address, int value) { - throw new UnsupportedOperationException(); + public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { + unsafe.copyMemory(null, srcOffset, target, BYTE_ARRAY_BASE_OFFSET + targetIndex, length); } @Override - public long getLong(long address) { - throw new UnsupportedOperationException(); + public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { + unsafe.copyMemory(src, BYTE_ARRAY_BASE_OFFSET + srcIndex, null, targetOffset, length); + } + } + + private static final class Android64MemoryAccessor extends MemoryAccessor { + + Android64MemoryAccessor(sun.misc.Unsafe unsafe) { + super(unsafe); } @Override - public void putLong(long address, long value) { - throw new UnsupportedOperationException(); + public Object getStaticObject(Field field) { + try { + return field.get(null); + } catch (IllegalAccessException e) { + return null; + } } @Override @@ -805,67 +819,72 @@ public void putDouble(Object target, long offset, double value) { } @Override - public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { - throw new UnsupportedOperationException(); + public boolean supportsUnsafeByteBufferOperations() { + return false; } @Override - public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { + public byte getByte(long address) { throw new UnsupportedOperationException(); } @Override - public Object getStaticObject(Field field) { - try { - return field.get(null); - } catch (IllegalAccessException e) { - return null; - } - } - } - - private static final class Android32MemoryAccessor extends MemoryAccessor { - - /** Mask used to convert a 64 bit memory address to a 32 bit address. */ - private static final long SMALL_ADDRESS_MASK = 0x00000000FFFFFFFF; - - /** Truncate a {@code long} address into a short {@code int} address. */ - private static int smallAddress(long address) { - return (int) (SMALL_ADDRESS_MASK & address); + public void putByte(long address, byte value) { + throw new UnsupportedOperationException(); } - Android32MemoryAccessor(sun.misc.Unsafe unsafe) { - super(unsafe); + @Override + public int getInt(long address) { + throw new UnsupportedOperationException(); } @Override - public byte getByte(long address) { + public void putInt(long address, int value) { throw new UnsupportedOperationException(); } @Override - public void putByte(long address, byte value) { + public long getLong(long address) { throw new UnsupportedOperationException(); } @Override - public int getInt(long address) { + public void putLong(long address, long value) { throw new UnsupportedOperationException(); } @Override - public void putInt(long address, int value) { + public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { throw new UnsupportedOperationException(); } @Override - public long getLong(long address) { + public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { throw new UnsupportedOperationException(); } + } + + private static final class Android32MemoryAccessor extends MemoryAccessor { + + /** Mask used to convert a 64 bit memory address to a 32 bit address. */ + private static final long SMALL_ADDRESS_MASK = 0x00000000FFFFFFFF; + + /** Truncate a {@code long} address into a short {@code int} address. */ + private static int smallAddress(long address) { + return (int) (SMALL_ADDRESS_MASK & address); + } + + Android32MemoryAccessor(sun.misc.Unsafe unsafe) { + super(unsafe); + } @Override - public void putLong(long address, long value) { - throw new UnsupportedOperationException(); + public Object getStaticObject(Field field) { + try { + return field.get(null); + } catch (IllegalAccessException e) { + return null; + } } @Override @@ -925,22 +944,48 @@ public void putDouble(Object target, long offset, double value) { } @Override - public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { + public boolean supportsUnsafeByteBufferOperations() { + return false; + } + + @Override + public byte getByte(long address) { throw new UnsupportedOperationException(); } @Override - public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { + public void putByte(long address, byte value) { throw new UnsupportedOperationException(); } @Override - public Object getStaticObject(Field field) { - try { - return field.get(null); - } catch (IllegalAccessException e) { - return null; - } + public int getInt(long address) { + throw new UnsupportedOperationException(); + } + + @Override + public void putInt(long address, int value) { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(long address) { + throw new UnsupportedOperationException(); + } + + @Override + public void putLong(long address, long value) { + throw new UnsupportedOperationException(); + } + + @Override + public void copyMemory(long srcOffset, byte[] target, long targetIndex, long length) { + throw new UnsupportedOperationException(); + } + + @Override + public void copyMemory(byte[] src, long srcIndex, long targetOffset, long length) { + throw new UnsupportedOperationException(); } } @@ -981,4 +1026,11 @@ private static void putBooleanBigEndian(Object target, long offset, boolean valu private static void putBooleanLittleEndian(Object target, long offset, boolean value) { putByteLittleEndian(target, offset, (byte) (value ? 1 : 0)); } + + private static void logMissingMethod(Throwable e) { + Logger.getLogger(UnsafeUtil.class.getName()) + .log( + Level.WARNING, + "platform method missing - proto runtime falling back to safer methods: " + e); + } } diff --git a/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java index a1c98c0cef8e..726672980cd2 100644 --- a/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java +++ b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java @@ -66,6 +66,11 @@ private static void assertHasMethodRemoved( assertFalse(hasMethod(classWithoutFieldPresence, "has" + camelName)); } + private static void assertHasMethodExisting(Class clazz, String camelName) { + assertTrue(hasMethod(clazz, "get" + camelName)); + assertTrue(hasMethod(clazz, "has" + camelName)); + } + public void testHasMethod() { // Optional non-message fields don't have a hasFoo() method generated. assertHasMethodRemoved(UnittestProto.TestAllTypes.class, TestAllTypes.class, "OptionalInt32"); @@ -87,19 +92,16 @@ public void testHasMethod() { assertFalse(TestAllTypes.getDefaultInstance().hasOptionalNestedMessage()); assertFalse(TestAllTypes.newBuilder().hasOptionalNestedMessage()); - // oneof fields don't have hasFoo() methods for non-message types. - assertHasMethodRemoved(UnittestProto.TestAllTypes.class, TestAllTypes.class, "OneofUint32"); - assertHasMethodRemoved(UnittestProto.TestAllTypes.class, TestAllTypes.class, "OneofString"); - assertHasMethodRemoved(UnittestProto.TestAllTypes.class, TestAllTypes.class, "OneofBytes"); + // oneof fields support hasFoo() methods for non-message types. + assertHasMethodExisting(TestAllTypes.class, "OneofUint32"); + assertHasMethodExisting(TestAllTypes.class, "OneofString"); + assertHasMethodExisting(TestAllTypes.class, "OneofBytes"); assertFalse(TestAllTypes.getDefaultInstance().hasOneofNestedMessage()); assertFalse(TestAllTypes.newBuilder().hasOneofNestedMessage()); - assertHasMethodRemoved( - UnittestProto.TestAllTypes.Builder.class, TestAllTypes.Builder.class, "OneofUint32"); - assertHasMethodRemoved( - UnittestProto.TestAllTypes.Builder.class, TestAllTypes.Builder.class, "OneofString"); - assertHasMethodRemoved( - UnittestProto.TestAllTypes.Builder.class, TestAllTypes.Builder.class, "OneofBytes"); + assertHasMethodExisting(TestAllTypes.Builder.class, "OneofUint32"); + assertHasMethodExisting(TestAllTypes.Builder.class, "OneofString"); + assertHasMethodExisting(TestAllTypes.Builder.class, "OneofBytes"); } public void testHasMethodForProto3Optional() throws Exception { diff --git a/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java b/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java index 66e406af7d95..3c0c629c20de 100644 --- a/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java +++ b/java/core/src/test/java/com/google/protobuf/Proto3MessageLiteInfoFactory.java @@ -139,12 +139,12 @@ private MessageInfo newRawMessageInfoForProto3MessageLite() { // the content of the generated buildMessageInfo() method here. java.lang.String info = "\u0000@\u0001\u0000\u0001D@\u0000\u001f\u0000\u0001\u0000\u0002\u0001\u0003\u0002" - + "\u0004\u0003\u0005\u0004\u0006\u0005\u0007\u0006\b\u0007\t\u0208\n\t\u000b\n\f\u000b" - + "\r\f\u000e\r\u000f\u000e\u0010\u000f\u0011\u0010\u0012\u0012\u0013\u0013\u0014\u0014" - + "\u0015\u0015\u0016\u0016\u0017\u0017\u0018\u0018\u0019\u0019\u001a\u021a\u001b\u001b" - + "\u001c\u001c\u001d\u001d\u001e\u001e\u001f\u001f !!\"\"##$$%%&&\'\'(())**++,,--" - + "..//0053\u000064\u000075\u000086\u000097\u0000:8\u0000;9\u0000<:\u0000=\u023b\u0000" - + "><\u0000?=\u0000@>\u0000A@\u0000BA\u0000CB\u0000DC\u0000"; + + "\u0004\u0003\u0005\u0004\u0006\u0005\u0007\u0006\b\u0007\t\u0208\n\t\u000b\n\f\u000b" + + "\r\f\u000e\r\u000f\u000e\u0010\u000f\u0011\u0010\u0012\u0012\u0013\u0013\u0014\u0014" + + "\u0015\u0015\u0016\u0016\u0017\u0017\u0018\u0018\u0019\u0019\u001a\u021a\u001b\u001b" + + "\u001c\u001c\u001d\u001d\u001e\u001e\u001f\u001f !!\"\"##$$%%&&\'\'(())**++,,--" + + "..//0053\u000064\u000075\u000086\u000097\u0000:8\u0000;9\u0000<:\u0000=\u023b\u0000" + + "><\u0000?=\u0000@>\u0000A@\u0000BA\u0000CB\u0000DC\u0000"; return new RawMessageInfo(Proto3MessageLite.getDefaultInstance(), info, objects); } diff --git a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java index 915dddf39218..a919f3b9ff6a 100644 --- a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java @@ -1507,9 +1507,9 @@ public void testMapDuplicateKeys() throws Exception { + " value: -1\n" + "}\n"; TestMap msg = TextFormat.parse(input, TestMap.class); - int i1 = msg.getInt32ToInt32Field().get(1); + int i1 = msg.getInt32ToInt32FieldMap().get(1); TestMap msg2 = TextFormat.parse(msg.toString(), TestMap.class); - int i2 = msg2.getInt32ToInt32Field().get(1); + int i2 = msg2.getInt32ToInt32FieldMap().get(1); assertEquals(i1, i2); } @@ -1521,10 +1521,10 @@ public void testMapShortForm() throws Exception { TestMap.Builder dest = TestMap.newBuilder(); parserWithOverwriteForbidden.merge(text, dest); TestMap message = dest.build(); - assertEquals(2, message.getStringToInt32Field().size()); - assertEquals(2, message.getInt32ToMessageField().size()); - assertEquals(10, message.getStringToInt32Field().get("x").intValue()); - assertEquals(200, message.getInt32ToMessageField().get(2).getValue()); + assertEquals(2, message.getStringToInt32FieldMap().size()); + assertEquals(2, message.getInt32ToMessageFieldMap().size()); + assertEquals(10, message.getStringToInt32FieldMap().get("x").intValue()); + assertEquals(200, message.getInt32ToMessageFieldMap().get(2).getValue()); } public void testMapShortFormEmpty() throws Exception { @@ -1532,8 +1532,8 @@ public void testMapShortFormEmpty() throws Exception { TestMap.Builder dest = TestMap.newBuilder(); parserWithOverwriteForbidden.merge(text, dest); TestMap message = dest.build(); - assertEquals(0, message.getStringToInt32Field().size()); - assertEquals(0, message.getInt32ToMessageField().size()); + assertEquals(0, message.getStringToInt32FieldMap().size()); + assertEquals(0, message.getInt32ToMessageFieldMap().size()); } public void testMapShortFormTrailingComma() throws Exception { @@ -1558,8 +1558,8 @@ public void testMapOverwrite() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); defaultParser.merge(text, builder); TestMap map = builder.build(); - assertEquals(2, map.getInt32ToInt32Field().size()); - assertEquals(30, map.getInt32ToInt32Field().get(1).intValue()); + assertEquals(2, map.getInt32ToInt32FieldMap().size()); + assertEquals(30, map.getInt32ToInt32FieldMap().get(1).intValue()); } { @@ -1568,8 +1568,8 @@ public void testMapOverwrite() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); parserWithOverwriteForbidden.merge(text, builder); TestMap map = builder.build(); - assertEquals(2, map.getInt32ToInt32Field().size()); - assertEquals(30, map.getInt32ToInt32Field().get(1).intValue()); + assertEquals(2, map.getInt32ToInt32FieldMap().size()); + assertEquals(30, map.getInt32ToInt32FieldMap().get(1).intValue()); } { @@ -1580,8 +1580,8 @@ public void testMapOverwrite() throws Exception { TestMap map = TestMap.parseFrom( builder.build().toByteString(), ExtensionRegistryLite.getEmptyRegistry()); - assertEquals(2, map.getInt32ToInt32Field().size()); - assertEquals(30, map.getInt32ToInt32Field().get(1).intValue()); + assertEquals(2, map.getInt32ToInt32FieldMap().size()); + assertEquals(30, map.getInt32ToInt32FieldMap().get(1).intValue()); } } diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java index 46d3cc4c352c..6133bb49a83c 100644 --- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java +++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java @@ -1697,6 +1697,7 @@ public void testRecursionLimit() throws Exception { public void testJsonException() throws Exception { InputStream throwingInputStream = new InputStream() { + @Override public int read() throws IOException { throw new IOException("12345"); } diff --git a/js/binary/decoder_test.js b/js/binary/decoder_test.js index 8fce993f5d81..0fddc4b3445a 100644 --- a/js/binary/decoder_test.js +++ b/js/binary/decoder_test.js @@ -315,8 +315,8 @@ describe('binaryDecoderTest', function() { // 64-bit extremes, not in dev guide. {original: '9223372036854775807', zigzag: '18446744073709551614'}, {original: '-9223372036854775808', zigzag: '18446744073709551615'}, - // None of the above catch: bitsLow < 0 && bitsHigh > 0 && bitsHigh < 0x1FFFFF. - // The following used to be broken. + // None of the above catch: bitsLow < 0 && bitsHigh > 0 && bitsHigh < + // 0x1FFFFF. The following used to be broken. {original: '72000000000', zigzag: '144000000000'}, ]; var encoder = new jspb.BinaryEncoder(); diff --git a/python/google/protobuf/descriptor.py b/python/google/protobuf/descriptor.py index 7583ea39f7a2..190b89536fdf 100644 --- a/python/google/protobuf/descriptor.py +++ b/python/google/protobuf/descriptor.py @@ -287,12 +287,26 @@ class Descriptor(_NestedDescriptorBase): if _USE_C_DESCRIPTORS: _C_DESCRIPTOR_CLASS = _message.Descriptor - def __new__(cls, name, full_name, filename, containing_type, fields, - nested_types, enum_types, extensions, options=None, - serialized_options=None, - is_extendable=True, extension_ranges=None, oneofs=None, - file=None, serialized_start=None, serialized_end=None, # pylint: disable=redefined-builtin - syntax=None, create_key=None): + def __new__( + cls, + name=None, + full_name=None, + filename=None, + containing_type=None, + fields=None, + nested_types=None, + enum_types=None, + extensions=None, + options=None, + serialized_options=None, + is_extendable=True, + extension_ranges=None, + oneofs=None, + file=None, # pylint: disable=redefined-builtin + serialized_start=None, + serialized_end=None, + syntax=None, + create_key=None): _message.Message._CheckCalledFromGeneratedFile() return _message.default_pool.FindMessageTypeByName(full_name) @@ -799,9 +813,18 @@ class ServiceDescriptor(_NestedDescriptorBase): if _USE_C_DESCRIPTORS: _C_DESCRIPTOR_CLASS = _message.ServiceDescriptor - def __new__(cls, name, full_name, index, methods, options=None, - serialized_options=None, file=None, # pylint: disable=redefined-builtin - serialized_start=None, serialized_end=None, create_key=None): + def __new__( + cls, + name=None, + full_name=None, + index=None, + methods=None, + options=None, + serialized_options=None, + file=None, # pylint: disable=redefined-builtin + serialized_start=None, + serialized_end=None, + create_key=None): _message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access return _message.default_pool.FindServiceByName(full_name) diff --git a/python/google/protobuf/internal/factory_test1.proto b/python/google/protobuf/internal/factory_test1.proto index f5bd03833165..5e729f5b086d 100644 --- a/python/google/protobuf/internal/factory_test1.proto +++ b/python/google/protobuf/internal/factory_test1.proto @@ -34,7 +34,6 @@ syntax = "proto2"; package google.protobuf.python.internal; - enum Factory1Enum { FACTORY_1_VALUE_0 = 0; FACTORY_1_VALUE_1 = 1; @@ -67,6 +66,5 @@ message Factory1MethodResponse { service Factory1Service { // Dummy method for this dummy service. - rpc Factory1Method(Factory1MethodRequest) returns (Factory1MethodResponse) { - } + rpc Factory1Method(Factory1MethodRequest) returns (Factory1MethodResponse) {} } diff --git a/python/google/protobuf/internal/message_factory_test.py b/python/google/protobuf/internal/message_factory_test.py index 24b79ecc9e61..42f91b2365bf 100755 --- a/python/google/protobuf/internal/message_factory_test.py +++ b/python/google/protobuf/internal/message_factory_test.py @@ -106,6 +106,23 @@ def testGetPrototype(self): 'google.protobuf.python.internal.Factory2Message')) self.assertTrue(cls is cls2) + def testCreatePrototypeOverride(self): + class MyMessageFactory(message_factory.MessageFactory): + + def CreatePrototype(self, descriptor): + cls = super(MyMessageFactory, self).CreatePrototype(descriptor) + cls.additional_field = 'Some value' + return cls + + db = descriptor_database.DescriptorDatabase() + pool = descriptor_pool.DescriptorPool(db) + db.Add(self.factory_test1_fd) + db.Add(self.factory_test2_fd) + factory = MyMessageFactory() + cls = factory.GetPrototype(pool.FindMessageTypeByName( + 'google.protobuf.python.internal.Factory2Message')) + self.assertTrue(hasattr(cls, 'additional_field')) + def testGetMessages(self): # performed twice because multiple calls with the same input must be allowed for _ in range(2): diff --git a/python/google/protobuf/internal/unknown_fields_test.py b/python/google/protobuf/internal/unknown_fields_test.py index a60b942cdfb0..d0ac5d90520e 100755 --- a/python/google/protobuf/internal/unknown_fields_test.py +++ b/python/google/protobuf/internal/unknown_fields_test.py @@ -40,11 +40,6 @@ except ImportError: import unittest import sys -try: - import tracemalloc -except ImportError: - # Requires python 3.4+ - pass from google.protobuf import map_unittest_pb2 from google.protobuf import unittest_mset_pb2 from google.protobuf import unittest_pb2 @@ -59,6 +54,12 @@ from google.protobuf.internal import wire_format from google.protobuf import descriptor +try: + import tracemalloc # pylint: disable=g-import-not-at-top +except ImportError: + # Requires python 3.4+ + pass + @testing_refleaks.TestCase class UnknownFieldsTest(unittest.TestCase): @@ -318,14 +319,16 @@ def testClear(self): self.assertIn('UnknownFields does not exist.', str(context.exception)) - @unittest.skipIf((sys.version_info.major, sys.version_info.minor) < (3, 4), + @unittest.skipIf((sys.version_info.major, sys.version_info.minor) < (3, 4), 'tracemalloc requires python 3.4+') def testUnknownFieldsNoMemoryLeak(self): # Call to UnknownFields must not leak memory nb_leaks = 1234 + def leaking_function(): for _ in range(nb_leaks): self.empty_message.UnknownFields() + tracemalloc.start() snapshot1 = tracemalloc.take_snapshot() leaking_function() diff --git a/python/google/protobuf/message_factory.py b/python/google/protobuf/message_factory.py index 24a524af4fa3..7dfaec88e15e 100644 --- a/python/google/protobuf/message_factory.py +++ b/python/google/protobuf/message_factory.py @@ -64,7 +64,7 @@ def __init__(self, pool=None): self._classes = {} def GetPrototype(self, descriptor): - """Builds a proto2 message class based on the passed in descriptor. + """Obtains a proto2 message class based on the passed in descriptor. Passing a descriptor with a fully qualified name matching a previous invocation will cause the same class to be returned. @@ -76,27 +76,52 @@ def GetPrototype(self, descriptor): A class describing the passed in descriptor. """ if descriptor not in self._classes: - descriptor_name = descriptor.name - if str is bytes: # PY2 - descriptor_name = descriptor.name.encode('ascii', 'ignore') - result_class = _GENERATED_PROTOCOL_MESSAGE_TYPE( - descriptor_name, - (message.Message,), - {'DESCRIPTOR': descriptor, '__module__': None}) - # pylint: disable=protected-access - result_class._FACTORY = self - # If module not set, it wrongly points to message_factory module. + result_class = self.CreatePrototype(descriptor) + # The assignment to _classes is redundant for the base implementation, but + # might avoid confusion in cases where CreatePrototype gets overridden and + # does not call the base implementation. self._classes[descriptor] = result_class - for field in descriptor.fields: - if field.message_type: - self.GetPrototype(field.message_type) - for extension in result_class.DESCRIPTOR.extensions: - if extension.containing_type not in self._classes: - self.GetPrototype(extension.containing_type) - extended_class = self._classes[extension.containing_type] - extended_class.RegisterExtension(extension) + return result_class return self._classes[descriptor] + def CreatePrototype(self, descriptor): + """Builds a proto2 message class based on the passed in descriptor. + + Don't call this function directly, it always creates a new class. Call + GetPrototype() instead. This method is meant to be overridden in subblasses + to perform additional operations on the newly constructed class. + + Args: + descriptor: The descriptor to build from. + + Returns: + A class describing the passed in descriptor. + """ + descriptor_name = descriptor.name + if str is bytes: # PY2 + descriptor_name = descriptor.name.encode('ascii', 'ignore') + result_class = _GENERATED_PROTOCOL_MESSAGE_TYPE( + descriptor_name, + (message.Message,), + { + 'DESCRIPTOR': descriptor, + # If module not set, it wrongly points to message_factory module. + '__module__': None, + }) + result_class._FACTORY = self # pylint: disable=protected-access + # Assign in _classes before doing recursive calls to avoid infinite + # recursion. + self._classes[descriptor] = result_class + for field in descriptor.fields: + if field.message_type: + self.GetPrototype(field.message_type) + for extension in result_class.DESCRIPTOR.extensions: + if extension.containing_type not in self._classes: + self.GetPrototype(extension.containing_type) + extended_class = self._classes[extension.containing_type] + extended_class.RegisterExtension(extension) + return result_class + def GetMessages(self, files): """Gets all the messages from a specified file. diff --git a/python/google/protobuf/proto_api.h b/python/google/protobuf/proto_api.h index 75ee9795aef8..c869bce058fd 100644 --- a/python/google/protobuf/proto_api.h +++ b/python/google/protobuf/proto_api.h @@ -82,6 +82,32 @@ struct PyProto_API { // to create Python-compatible message. virtual const DescriptorPool* GetDefaultDescriptorPool() const = 0; virtual MessageFactory* GetDefaultMessageFactory() const = 0; + + // Allocate a new protocol buffer as a python object for the provided + // descriptor. This function works even if no Python module has been imported + // for the corresponding protocol buffer class. + // The factory is usually null; when provided, it is the MessageFactory which + // owns the Python class, and will be used to find and create Extensions for + // this message. + // When null is returned, a python error has already been set. + virtual PyObject* NewMessage(const Descriptor* descriptor, + PyObject* py_message_factory) const = 0; + + // Allocate a new protocol buffer where the underlying object is owned by C++. + // The factory must currently be null. This function works even if no Python + // module has been imported for the corresponding protocol buffer class. + // When null is returned, a python error has already been set. + // + // Since this call returns a python object owned by C++, some operations + // are risky, and it must be used carefully. In particular: + // * Avoid modifying the returned object from the C++ side while there are + // existing python references to it or it's subobjects. + // * Avoid using python references to this object or any subobjects after the + // C++ object has been freed. + // * Calling this with the same C++ pointer will result in multiple distinct + // python objects referencing the same C++ object. + virtual PyObject* NewMessageOwnedExternally( + Message* msg, PyObject* py_message_factory) const = 0; }; inline const char* PyProtoAPICapsuleName() { diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 0301e9634daf..4e74386e2d1b 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -121,7 +121,7 @@ inline void LowerString(std::string* s) { if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A'; } } -} +} // namespace // Finalize the creation of the Message class. static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) { @@ -145,7 +145,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) { PyEnumDescriptor_FromDescriptor(enum_descriptor)); if (enum_type == NULL) { return -1; - } + } // Add wrapped enum type to message class. ScopedPyObjectPtr wrapped(PyObject_CallFunctionObjArgs( EnumTypeWrapper_class, enum_type.get(), NULL)); @@ -195,8 +195,7 @@ static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) { return 0; } -static PyObject* New(PyTypeObject* type, - PyObject* args, PyObject* kwargs) { +static PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) { static char *kwlist[] = {"name", "bases", "dict", 0}; PyObject *bases, *dict; const char* name; @@ -219,41 +218,20 @@ static PyObject* New(PyTypeObject* type, } // Check dict['DESCRIPTOR'] - PyObject* descriptor_or_name = PyDict_GetItem(dict, kDESCRIPTOR); - if (descriptor_or_name == nullptr) { + PyObject* py_descriptor = PyDict_GetItem(dict, kDESCRIPTOR); + if (py_descriptor == nullptr) { PyErr_SetString(PyExc_TypeError, "Message class has no DESCRIPTOR"); - return NULL; + return nullptr; } - - Py_ssize_t name_size; - char* full_name; - const Descriptor* message_descriptor; - PyObject* py_descriptor; - - if (PyObject_TypeCheck(descriptor_or_name, &PyMessageDescriptor_Type)) { - py_descriptor = descriptor_or_name; - message_descriptor = PyMessageDescriptor_AsDescriptor(py_descriptor); - if (message_descriptor == nullptr) { - return nullptr; - } - } else { - if (PyString_AsStringAndSize(descriptor_or_name, &full_name, &name_size) < - 0) { - return nullptr; - } - message_descriptor = - GetDefaultDescriptorPool()->pool->FindMessageTypeByName( - StringParam(full_name, name_size)); - if (message_descriptor == nullptr) { - PyErr_Format(PyExc_KeyError, - "Can not find message descriptor %s " - "from pool", - full_name); - return nullptr; - } - py_descriptor = PyMessageDescriptor_FromDescriptor(message_descriptor); - // reset the dict['DESCRIPTOR'] to py_descriptor. - PyDict_SetItem(dict, kDESCRIPTOR, py_descriptor); + if (!PyObject_TypeCheck(py_descriptor, &PyMessageDescriptor_Type)) { + PyErr_Format(PyExc_TypeError, "Expected a message Descriptor, got %s", + py_descriptor->ob_type->tp_name); + return nullptr; + } + const Descriptor* message_descriptor = + PyMessageDescriptor_AsDescriptor(py_descriptor); + if (message_descriptor == nullptr) { + return nullptr; } // Messages have no __dict__ @@ -603,15 +581,15 @@ bool VerifyIntegerCastAndRange(PyObject* arg, ValueType value) { OutOfRangeError(arg); } // Otherwise propagate existing error. return false; - } - if (PROTOBUF_PREDICT_FALSE(!IsValidNumericCast(value))) { - OutOfRangeError(arg); - return false; - } + } + if (PROTOBUF_PREDICT_FALSE(!IsValidNumericCast(value))) { + OutOfRangeError(arg); + return false; + } return true; } -template +template bool CheckAndGetInteger(PyObject* arg, T* value) { // The fast path. #if PY_MAJOR_VERSION < 3 @@ -631,10 +609,10 @@ bool CheckAndGetInteger(PyObject* arg, T* value) { // an integer and can be used as an ordinal number". // This definition includes everything that implements numbers.Integral // and shouldn't cast the net too wide. - if (PROTOBUF_PREDICT_FALSE(!PyIndex_Check(arg))) { - FormatTypeError(arg, "int, long"); - return false; - } + if (PROTOBUF_PREDICT_FALSE(!PyIndex_Check(arg))) { + FormatTypeError(arg, "int, long"); + return false; + } // Now we have an integral number so we can safely use PyLong_ functions. // We need to treat the signed and unsigned cases differently in case arg is @@ -651,7 +629,7 @@ bool CheckAndGetInteger(PyObject* arg, T* value) { if (PROTOBUF_PREDICT_FALSE(casted == nullptr)) { // Propagate existing error. return false; - } + } ulong_result = PyLong_AsUnsignedLongLong(casted); Py_DECREF(casted); } @@ -676,7 +654,7 @@ bool CheckAndGetInteger(PyObject* arg, T* value) { if (PROTOBUF_PREDICT_FALSE(casted == nullptr)) { // Propagate existing error. return false; - } + } long_result = PyLong_AsLongLong(casted); Py_DECREF(casted); } @@ -702,7 +680,7 @@ bool CheckAndGetDouble(PyObject* arg, double* value) { if (PROTOBUF_PREDICT_FALSE(*value == -1 && PyErr_Occurred())) { FormatTypeError(arg, "int, long, float"); return false; - } + } return true; } @@ -928,9 +906,9 @@ int AssureWritable(CMessage* self) { // Toplevel messages are always mutable. GOOGLE_DCHECK(self->parent); - if (AssureWritable(self->parent) == -1) + if (AssureWritable(self->parent) == -1) { return -1; - + } // If this message is part of a oneof, there might be a field to release in // the parent. if (MaybeReleaseOverlappingOneofField(self->parent, @@ -1279,32 +1257,41 @@ CMessage* NewEmptyMessage(CMessageClass* type) { // The __new__ method of Message classes. // Creates a new C++ message and takes ownership. -static PyObject* New(PyTypeObject* cls, - PyObject* unused_args, PyObject* unused_kwargs) { - CMessageClass* type = CheckMessageClass(cls); - if (type == NULL) { - return NULL; - } +static CMessage* NewCMessage(CMessageClass* type) { // Retrieve the message descriptor and the default instance (=prototype). const Descriptor* message_descriptor = type->message_descriptor; - if (message_descriptor == NULL) { - return NULL; + if (message_descriptor == nullptr) { + // This would be very unexpected since the CMessageClass has already + // been checked. + PyErr_Format(PyExc_TypeError, + "CMessageClass object '%s' has no descriptor.", + Py_TYPE(type)->tp_name); + return nullptr; } const Message* prototype = type->py_message_factory->message_factory->GetPrototype( message_descriptor); - if (prototype == NULL) { + if (prototype == nullptr) { PyErr_SetString(PyExc_TypeError, message_descriptor->full_name().c_str()); - return NULL; + return nullptr; } CMessage* self = NewEmptyMessage(type); - if (self == NULL) { - return NULL; + if (self == nullptr) { + return nullptr; } self->message = prototype->New(); self->parent = nullptr; // This message owns its data. - return reinterpret_cast(self); + return self; +} + +static PyObject* New(PyTypeObject* cls, PyObject* unused_args, + PyObject* unused_kwargs) { + CMessageClass* type = CheckMessageClass(cls); + if (type == nullptr) { + return nullptr; + } + return reinterpret_cast(NewCMessage(type)); } // The __init__ method of Message classes. @@ -2866,28 +2853,57 @@ Message* PyMessage_GetMutableMessagePointer(PyObject* msg) { return cmsg->message; } +PyObject* PyMessage_New(const Descriptor* descriptor, + PyObject* py_message_factory) { + PyMessageFactory* factory = nullptr; + if (py_message_factory == nullptr) { + factory = GetDescriptorPool_FromPool(descriptor->file()->pool()) + ->py_message_factory; + } else if (PyObject_TypeCheck(py_message_factory, &PyMessageFactory_Type)) { + factory = reinterpret_cast(py_message_factory); + } else { + PyErr_SetString(PyExc_TypeError, "Expected a MessageFactory"); + return nullptr; + } + auto* message_class = + message_factory::GetOrCreateMessageClass(factory, descriptor); + if (message_class == nullptr) { + return nullptr; + } + + CMessage* self = cmessage::NewCMessage(message_class); + Py_DECREF(message_class); + if (self == nullptr) { + return nullptr; + } + return self->AsPyObject(); +} + PyObject* PyMessage_NewMessageOwnedExternally(Message* message, - PyObject* message_factory) { - if (message_factory) { + PyObject* py_message_factory) { + if (py_message_factory) { PyErr_SetString(PyExc_NotImplementedError, "Default message_factory=NULL is the only supported value"); - return NULL; + return nullptr; } if (message->GetReflection()->GetMessageFactory() != MessageFactory::generated_factory()) { PyErr_SetString(PyExc_TypeError, "Message pointer was not created from the default factory"); - return NULL; + return nullptr; } CMessageClass* message_class = message_factory::GetOrCreateMessageClass( GetDefaultDescriptorPool()->py_message_factory, message->GetDescriptor()); + if (message_class == nullptr) { + return nullptr; + } CMessage* self = cmessage::NewEmptyMessage(message_class); - if (self == NULL) { - return NULL; - } Py_DECREF(message_class); + if (self == nullptr) { + return nullptr; + } self->message = message; Py_INCREF(Py_None); self->parent = reinterpret_cast(Py_None); @@ -2954,9 +2970,9 @@ bool InitProto2MessageModule(PyObject *m) { return false; } - PyModule_AddObject(m, "RepeatedScalarContainer", - reinterpret_cast( - &RepeatedScalarContainer_Type)); + PyModule_AddObject( + m, "RepeatedScalarContainer", + reinterpret_cast(&RepeatedScalarContainer_Type)); if (PyType_Ready(&RepeatedCompositeContainer_Type) < 0) { return false; @@ -2964,8 +2980,7 @@ bool InitProto2MessageModule(PyObject *m) { PyModule_AddObject( m, "RepeatedCompositeContainer", - reinterpret_cast( - &RepeatedCompositeContainer_Type)); + reinterpret_cast(&RepeatedCompositeContainer_Type)); // Register them as MutableSequence. #if PY_MAJOR_VERSION >= 3 @@ -2998,16 +3013,14 @@ bool InitProto2MessageModule(PyObject *m) { } PyModule_AddObject(m, "UnknownFieldSet", - reinterpret_cast( - &PyUnknownFields_Type)); + reinterpret_cast(&PyUnknownFields_Type)); if (PyType_Ready(&PyUnknownFieldRef_Type) < 0) { return false; } PyModule_AddObject(m, "UnknownField", - reinterpret_cast( - &PyUnknownFieldRef_Type)); + reinterpret_cast(&PyUnknownFieldRef_Type)); // Initialize Map container types. if (!InitMapContainers()) { @@ -3023,9 +3036,8 @@ bool InitProto2MessageModule(PyObject *m) { if (PyType_Ready(&ExtensionDict_Type) < 0) { return false; } - PyModule_AddObject( - m, "ExtensionDict", - reinterpret_cast(&ExtensionDict_Type)); + PyModule_AddObject(m, "ExtensionDict", + reinterpret_cast(&ExtensionDict_Type)); if (PyType_Ready(&ExtensionIterator_Type) < 0) { return false; } @@ -3039,25 +3051,24 @@ bool InitProto2MessageModule(PyObject *m) { PyModule_AddObject(m, "default_pool", reinterpret_cast(GetDefaultDescriptorPool())); - PyModule_AddObject(m, "DescriptorPool", reinterpret_cast( - &PyDescriptorPool_Type)); - - PyModule_AddObject(m, "Descriptor", reinterpret_cast( - &PyMessageDescriptor_Type)); - PyModule_AddObject(m, "FieldDescriptor", reinterpret_cast( - &PyFieldDescriptor_Type)); - PyModule_AddObject(m, "EnumDescriptor", reinterpret_cast( - &PyEnumDescriptor_Type)); - PyModule_AddObject(m, "EnumValueDescriptor", reinterpret_cast( - &PyEnumValueDescriptor_Type)); - PyModule_AddObject(m, "FileDescriptor", reinterpret_cast( - &PyFileDescriptor_Type)); - PyModule_AddObject(m, "OneofDescriptor", reinterpret_cast( - &PyOneofDescriptor_Type)); - PyModule_AddObject(m, "ServiceDescriptor", reinterpret_cast( - &PyServiceDescriptor_Type)); - PyModule_AddObject(m, "MethodDescriptor", reinterpret_cast( - &PyMethodDescriptor_Type)); + PyModule_AddObject(m, "DescriptorPool", + reinterpret_cast(&PyDescriptorPool_Type)); + PyModule_AddObject(m, "Descriptor", + reinterpret_cast(&PyMessageDescriptor_Type)); + PyModule_AddObject(m, "FieldDescriptor", + reinterpret_cast(&PyFieldDescriptor_Type)); + PyModule_AddObject(m, "EnumDescriptor", + reinterpret_cast(&PyEnumDescriptor_Type)); + PyModule_AddObject(m, "EnumValueDescriptor", + reinterpret_cast(&PyEnumValueDescriptor_Type)); + PyModule_AddObject(m, "FileDescriptor", + reinterpret_cast(&PyFileDescriptor_Type)); + PyModule_AddObject(m, "OneofDescriptor", + reinterpret_cast(&PyOneofDescriptor_Type)); + PyModule_AddObject(m, "ServiceDescriptor", + reinterpret_cast(&PyServiceDescriptor_Type)); + PyModule_AddObject(m, "MethodDescriptor", + reinterpret_cast(&PyMethodDescriptor_Type)); PyObject* enum_type_wrapper = PyImport_ImportModule( "google.protobuf.internal.enum_type_wrapper"); diff --git a/python/google/protobuf/pyext/message.h b/python/google/protobuf/pyext/message.h index c5a635da024b..a1e832651237 100644 --- a/python/google/protobuf/pyext/message.h +++ b/python/google/protobuf/pyext/message.h @@ -282,51 +282,50 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg); /* Is 64bit */ #define IS_64BIT (SIZEOF_LONG == 8) -#define FIELD_IS_REPEATED(field_descriptor) \ - ((field_descriptor)->label() == FieldDescriptor::LABEL_REPEATED) - -#define GOOGLE_CHECK_GET_INT32(arg, value, err) \ - int32 value; \ - if (!CheckAndGetInteger(arg, &value)) { \ - return err; \ - } - -#define GOOGLE_CHECK_GET_INT64(arg, value, err) \ - int64 value; \ - if (!CheckAndGetInteger(arg, &value)) { \ - return err; \ - } - -#define GOOGLE_CHECK_GET_UINT32(arg, value, err) \ - uint32 value; \ - if (!CheckAndGetInteger(arg, &value)) { \ - return err; \ - } - -#define GOOGLE_CHECK_GET_UINT64(arg, value, err) \ - uint64 value; \ - if (!CheckAndGetInteger(arg, &value)) { \ - return err; \ - } - -#define GOOGLE_CHECK_GET_FLOAT(arg, value, err) \ - float value; \ - if (!CheckAndGetFloat(arg, &value)) { \ - return err; \ - } \ - -#define GOOGLE_CHECK_GET_DOUBLE(arg, value, err) \ - double value; \ - if (!CheckAndGetDouble(arg, &value)) { \ - return err; \ - } - -#define GOOGLE_CHECK_GET_BOOL(arg, value, err) \ - bool value; \ - if (!CheckAndGetBool(arg, &value)) { \ - return err; \ - } +#define FIELD_IS_REPEATED(field_descriptor) \ + ((field_descriptor)->label() == FieldDescriptor::LABEL_REPEATED) +#define GOOGLE_CHECK_GET_INT32(arg, value, err) \ + int32 value; \ + if (!CheckAndGetInteger(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_INT64(arg, value, err) \ + int64 value; \ + if (!CheckAndGetInteger(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_UINT32(arg, value, err) \ + uint32 value; \ + if (!CheckAndGetInteger(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_UINT64(arg, value, err) \ + uint64 value; \ + if (!CheckAndGetInteger(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_FLOAT(arg, value, err) \ + float value; \ + if (!CheckAndGetFloat(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_DOUBLE(arg, value, err) \ + double value; \ + if (!CheckAndGetDouble(arg, &value)) { \ + return err; \ + } + +#define GOOGLE_CHECK_GET_BOOL(arg, value, err) \ + bool value; \ + if (!CheckAndGetBool(arg, &value)) { \ + return err; \ + } #define FULL_MODULE_NAME "google.protobuf.pyext._message" @@ -353,10 +352,12 @@ bool CheckFieldBelongsToMessage(const FieldDescriptor* field_descriptor, extern PyObject* PickleError_class; +PyObject* PyMessage_New(const Descriptor* descriptor, + PyObject* py_message_factory); const Message* PyMessage_GetMessagePointer(PyObject* msg); Message* PyMessage_GetMutableMessagePointer(PyObject* msg); PyObject* PyMessage_NewMessageOwnedExternally(Message* message, - PyObject* message_factory); + PyObject* py_message_factory); bool InitProto2MessageModule(PyObject *m); diff --git a/python/google/protobuf/pyext/message_module.cc b/python/google/protobuf/pyext/message_module.cc index 63d60b70e7b3..b5975f76c562 100644 --- a/python/google/protobuf/pyext/message_module.cc +++ b/python/google/protobuf/pyext/message_module.cc @@ -30,13 +30,12 @@ #include +#include #include #include #include #include -#include - namespace { // C++ API. Clients get at this via proto_api.h @@ -55,6 +54,15 @@ struct ApiImplementation : google::protobuf::python::PyProto_API { return google::protobuf::python::GetDefaultDescriptorPool() ->py_message_factory->message_factory; } + PyObject* NewMessage(const google::protobuf::Descriptor* descriptor, + PyObject* py_message_factory) const override { + return google::protobuf::python::PyMessage_New(descriptor, py_message_factory); + } + PyObject* NewMessageOwnedExternally( + google::protobuf::Message* msg, PyObject* py_message_factory) const override { + return google::protobuf::python::PyMessage_NewMessageOwnedExternally( + msg, py_message_factory); + } }; } // namespace diff --git a/python/google/protobuf/pyext/repeated_composite_container.cc b/python/google/protobuf/pyext/repeated_composite_container.cc index 1b739ae23936..cbc0f9f8af9b 100644 --- a/python/google/protobuf/pyext/repeated_composite_container.cc +++ b/python/google/protobuf/pyext/repeated_composite_container.cc @@ -567,7 +567,11 @@ PyTypeObject RepeatedCompositeContainer_Type = { sizeof(RepeatedCompositeContainer), // tp_basicsize 0, // tp_itemsize repeated_composite_container::Dealloc, // tp_dealloc - 0, // tp_print, in Python >=3.8: Py_ssize_t tp_vectorcall_offset +#if PY_VERSION_HEX >= 0x03080000 + 0, // tp_vectorcall_offset +#else + nullptr, // tp_print +#endif nullptr, // tp_getattr nullptr, // tp_setattr nullptr, // tp_compare diff --git a/python/google/protobuf/pyext/repeated_scalar_container.cc b/python/google/protobuf/pyext/repeated_scalar_container.cc index 6b15258fd81c..5a5c4db16e29 100644 --- a/python/google/protobuf/pyext/repeated_scalar_container.cc +++ b/python/google/protobuf/pyext/repeated_scalar_container.cc @@ -753,7 +753,11 @@ PyTypeObject RepeatedScalarContainer_Type = { sizeof(RepeatedScalarContainer), // tp_basicsize 0, // tp_itemsize repeated_scalar_container::Dealloc, // tp_dealloc - 0, // tp_print, in Python >=3.8: Py_ssize_t tp_vectorcall_offset +#if PY_VERSION_HEX >= 0x03080000 + 0, // tp_vectorcall_offset +#else + nullptr, // tp_print +#endif nullptr, // tp_getattr nullptr, // tp_setattr nullptr, // tp_compare diff --git a/python/google/protobuf/service_reflection.py b/python/google/protobuf/service_reflection.py index 8590e46b17ee..75c51ff3221a 100644 --- a/python/google/protobuf/service_reflection.py +++ b/python/google/protobuf/service_reflection.py @@ -38,12 +38,6 @@ __author__ = 'petar@google.com (Petar Petrov)' -from google.protobuf.internal import api_implementation - -if api_implementation.Type() == 'cpp': - # pylint: disable=g-import-not-at-top - from google.protobuf.pyext import _message - class GeneratedServiceType(type): @@ -84,10 +78,6 @@ def __init__(cls, name, bases, dictionary): return descriptor = dictionary[GeneratedServiceType._DESCRIPTOR_KEY] - if isinstance(descriptor, str): - descriptor = _message.default_pool.FindServiceByName(descriptor) - dictionary[GeneratedServiceType._DESCRIPTOR_KEY] = descriptor - service_builder = _ServiceBuilder(descriptor) service_builder.BuildService(cls) cls.DESCRIPTOR = descriptor @@ -113,16 +103,13 @@ def __init__(cls, name, bases, dictionary): dictionary[_DESCRIPTOR_KEY] must contain a ServiceDescriptor object describing this protocol service type. """ - descriptor = dictionary.get(cls._DESCRIPTOR_KEY) - if isinstance(descriptor, str): - descriptor = _message.default_pool.FindServiceByName(descriptor) - dictionary[GeneratedServiceStubType._DESCRIPTOR_KEY] = descriptor super(GeneratedServiceStubType, cls).__init__(name, bases, dictionary) # Don't do anything if this class doesn't have a descriptor. This happens # when a service stub is subclassed. if GeneratedServiceStubType._DESCRIPTOR_KEY not in dictionary: return + descriptor = dictionary[GeneratedServiceStubType._DESCRIPTOR_KEY] service_stub_builder = _ServiceStubBuilder(descriptor) service_stub_builder.BuildServiceStub(cls) diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index 9ebe8b46b17e..c376c7bac78a 100644 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py @@ -541,7 +541,7 @@ def _PrintFieldName(self, field): # For groups, use the capitalized name. out.write(field.message_type.name) else: - out.write(field.name) + out.write(field.name) if (self.force_colon or field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE): @@ -902,6 +902,8 @@ def _MergeField(self, tokenizer, message): # pylint: disable=protected-access field = message.Extensions._FindExtensionByName(name) # pylint: enable=protected-access + + if not field: if self.allow_unknown_extension: field = None @@ -988,6 +990,7 @@ def _MergeField(self, tokenizer, message): if not tokenizer.TryConsume(','): tokenizer.TryConsume(';') + def _ConsumeAnyTypeUrl(self, tokenizer): """Consumes a google.protobuf.Any type URL and returns the type name.""" # Consume "type.googleapis.com/". diff --git a/src/Makefile.am b/src/Makefile.am index 980a357afd37..5940ce187ec1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -341,6 +341,7 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/cpp/cpp_message_field.cc \ google/protobuf/compiler/cpp/cpp_message_field.h \ google/protobuf/compiler/cpp/cpp_message_layout_helper.h \ + google/protobuf/compiler/cpp/cpp_names.h \ google/protobuf/compiler/cpp/cpp_options.h \ google/protobuf/compiler/cpp/cpp_padding_optimizer.cc \ google/protobuf/compiler/cpp/cpp_padding_optimizer.h \ diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index c421045fba98..dea9cd648d83 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -17,24 +17,21 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class AnyDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Any_default_instance_; +constexpr Any::Any( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , _any_metadata_(&type_url_, &value_){} +struct AnyDefaultTypeInternal { + constexpr AnyDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~AnyDefaultTypeInternal() {} + union { + Any _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY AnyDefaultTypeInternal _Any_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Any_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Any(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; @@ -64,18 +61,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_ "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT" "ypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fany_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fany_2eproto_sccs[1] = { - &scc_info_Any_google_2fprotobuf_2fany_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", 212, - &descriptor_table_google_2fprotobuf_2fany_2eproto_once, descriptor_table_google_2fprotobuf_2fany_2eproto_sccs, descriptor_table_google_2fprotobuf_2fany_2eproto_deps, 1, 0, + false, false, 212, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", + &descriptor_table_google_2fprotobuf_2fany_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fany_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, + file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fany_2eproto); + return descriptor_table_google_2fprotobuf_2fany_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto); @@ -126,9 +123,8 @@ Any::Any(const Any& from) } void Any::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Any_google_2fprotobuf_2fany_2eproto.base); - type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } Any::~Any() { @@ -152,11 +148,6 @@ void Any::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Any::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Any& Any::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Any_google_2fprotobuf_2fany_2eproto.base); - return *internal_default_instance(); -} - void Any::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Any) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index ae1151ae5534..a91d4565ff08 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Any; -class AnyDefaultTypeInternal; +struct AnyDefaultTypeInternal; PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : public: inline Any() : Any(nullptr) {} virtual ~Any(); + explicit constexpr Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Any(const Any& from); Any(Any&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Any& default_instance(); - + static const Any& default_instance() { + return *internal_default_instance(); + } static inline const Any* internal_default_instance() { return reinterpret_cast( &_Any_default_instance_); @@ -199,8 +202,7 @@ class PROTOBUF_EXPORT Any PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fany_2eproto); - return ::descriptor_table_google_2fprotobuf_2fany_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fany_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc index 55b55ee18abb..48e0faccf7f5 100644 --- a/src/google/protobuf/any_lite.cc +++ b/src/google/protobuf/any_lite.cc @@ -79,7 +79,7 @@ bool AnyMetadata::InternalIs(StringPiece type_name) const { bool ParseAnyTypeUrl(StringPiece type_url, std::string* url_prefix, std::string* full_type_name) { - size_t pos = type_url.find_last_of("/"); + size_t pos = type_url.find_last_of('/'); if (pos == std::string::npos || pos + 1 == type_url.size()) { return false; } diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 7ee673a527a7..64aa6c0af023 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -16,68 +16,59 @@ #include PROTOBUF_PRAGMA_INIT_SEG -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fapi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fapi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Option_google_2fprotobuf_2ftype_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto; PROTOBUF_NAMESPACE_OPEN -class ApiDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Api_default_instance_; -class MethodDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Method_default_instance_; -class MixinDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Mixin_default_instance_; +constexpr Api::Api( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : methods_() + , options_() + , mixins_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , version_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , source_context_(nullptr) + , syntax_(0) +{} +struct ApiDefaultTypeInternal { + constexpr ApiDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ApiDefaultTypeInternal() {} + union { + Api _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ApiDefaultTypeInternal _Api_default_instance_; +constexpr Method::Method( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : options_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , request_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , response_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , request_streaming_(false) + , response_streaming_(false) + , syntax_(0) +{} +struct MethodDefaultTypeInternal { + constexpr MethodDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~MethodDefaultTypeInternal() {} + union { + Method _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY MethodDefaultTypeInternal _Method_default_instance_; +constexpr Mixin::Mixin( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , root_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +struct MixinDefaultTypeInternal { + constexpr MixinDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~MixinDefaultTypeInternal() {} + union { + Mixin _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY MixinDefaultTypeInternal _Mixin_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Api_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Api(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 4, 0, InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto}, { - &scc_info_Method_google_2fprotobuf_2fapi_2eproto.base, - &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base, - &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base, - &scc_info_Mixin_google_2fprotobuf_2fapi_2eproto.base,}}; - -static void InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Method_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Method(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto}, { - &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}}; - -static void InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Mixin(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; @@ -152,18 +143,18 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor &::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto, &::descriptor_table_google_2fprotobuf_2ftype_2eproto, }; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fapi_2eproto_sccs[3] = { - &scc_info_Api_google_2fprotobuf_2fapi_2eproto.base, - &scc_info_Method_google_2fprotobuf_2fapi_2eproto.base, - &scc_info_Mixin_google_2fprotobuf_2fapi_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", 751, - &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_sccs, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 3, 2, + false, false, 751, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", + &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 2, 3, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fapi_2eproto, 3, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, + file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fapi_2eproto); + return descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto); @@ -224,13 +215,12 @@ Api::Api(const Api& from) } void Api::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Api_google_2fprotobuf_2fapi_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&source_context_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&syntax_) - - reinterpret_cast(&source_context_)) + sizeof(syntax_)); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&source_context_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&syntax_) - + reinterpret_cast(&source_context_)) + sizeof(syntax_)); } Api::~Api() { @@ -255,11 +245,6 @@ void Api::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Api::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Api& Api::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Api_google_2fprotobuf_2fapi_2eproto.base); - return *internal_default_instance(); -} - void Api::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Api) @@ -636,14 +621,13 @@ Method::Method(const Method& from) } void Method::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Method_google_2fprotobuf_2fapi_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&request_streaming_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&syntax_) - - reinterpret_cast(&request_streaming_)) + sizeof(syntax_)); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&request_streaming_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&syntax_) - + reinterpret_cast(&request_streaming_)) + sizeof(syntax_)); } Method::~Method() { @@ -668,11 +652,6 @@ void Method::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Method::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Method& Method::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Method_google_2fprotobuf_2fapi_2eproto.base); - return *internal_default_instance(); -} - void Method::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Method) @@ -1022,9 +1001,8 @@ Mixin::Mixin(const Mixin& from) } void Mixin::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Mixin_google_2fprotobuf_2fapi_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } Mixin::~Mixin() { @@ -1048,11 +1026,6 @@ void Mixin::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Mixin::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Mixin& Mixin::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Mixin_google_2fprotobuf_2fapi_2eproto.base); - return *internal_default_instance(); -} - void Mixin::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin) diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index b141b549adc9..3aea532804ea 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -55,15 +55,16 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Api; -class ApiDefaultTypeInternal; +struct ApiDefaultTypeInternal; PROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_; class Method; -class MethodDefaultTypeInternal; +struct MethodDefaultTypeInternal; PROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_; class Mixin; -class MixinDefaultTypeInternal; +struct MixinDefaultTypeInternal; PROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -80,6 +81,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : public: inline Api() : Api(nullptr) {} virtual ~Api(); + explicit constexpr Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Api(const Api& from); Api(Api&& from) noexcept @@ -109,8 +111,9 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Api& default_instance(); - + static const Api& default_instance() { + return *internal_default_instance(); + } static inline const Api* internal_default_instance() { return reinterpret_cast( &_Api_default_instance_); @@ -176,8 +179,7 @@ class PROTOBUF_EXPORT Api PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fapi_2eproto); - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -332,6 +334,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : public: inline Method() : Method(nullptr) {} virtual ~Method(); + explicit constexpr Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Method(const Method& from); Method(Method&& from) noexcept @@ -361,8 +364,9 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Method& default_instance(); - + static const Method& default_instance() { + return *internal_default_instance(); + } static inline const Method* internal_default_instance() { return reinterpret_cast( &_Method_default_instance_); @@ -428,8 +432,7 @@ class PROTOBUF_EXPORT Method PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fapi_2eproto); - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -564,6 +567,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : public: inline Mixin() : Mixin(nullptr) {} virtual ~Mixin(); + explicit constexpr Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Mixin(const Mixin& from); Mixin(Mixin&& from) noexcept @@ -593,8 +597,9 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Mixin& default_instance(); - + static const Mixin& default_instance() { + return *internal_default_instance(); + } static inline const Mixin* internal_default_instance() { return reinterpret_cast( &_Mixin_default_instance_); @@ -660,8 +665,7 @@ class PROTOBUF_EXPORT Mixin PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fapi_2eproto); - return ::descriptor_table_google_2fprotobuf_2fapi_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fapi_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index d4779a2c6c80..bd9516b600d3 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -46,9 +46,6 @@ #include -static const size_t kMinCleanupListElements = 8; -static const size_t kMaxCleanupListElements = 64; // 1kB on 64-bit. - namespace google { namespace protobuf { namespace internal { diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 2b8782a422e2..87443ad41492 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -313,17 +313,9 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // if the object were allocated on the heap (except that the underlying memory // is obtained from the arena). template - PROTOBUF_ALWAYS_INLINE static T* Create(Arena* arena, Args&&... args) { - if (arena == NULL) { - return new T(std::forward(args)...); - } else { - auto destructor = - internal::ObjectDestructor::value, - T>::destructor; - return new (arena->AllocateInternal(sizeof(T), alignof(T), destructor, - RTTI_TYPE_ID(T))) - T(std::forward(args)...); - } + PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) { + return CreateInternal(arena, std::is_convertible(), + std::forward(args)...); } // Create an array of object type T on the arena *without* invoking the @@ -333,7 +325,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // (when compiled as C++11) that T is trivially default-constructible and // trivially destructible. template - PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena, + PROTOBUF_NDEBUG_INLINE static T* CreateArray(Arena* arena, size_t num_elements) { static_assert(std::is_standard_layout::value && std::is_trivial::value, "CreateArray requires a trivially constructible type"); @@ -477,7 +469,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { struct has_get_arena : InternalHelper::has_get_arena {}; template - PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena, + PROTOBUF_NDEBUG_INLINE static T* CreateMessageInternal(Arena* arena, Args&&... args) { static_assert( InternalHelper::is_arena_constructable::value, @@ -493,7 +485,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // slightly different. When the arena pointer is nullptr, it calls T() // instead of T(nullptr). template - PROTOBUF_ALWAYS_INLINE static T* CreateMessageInternal(Arena* arena) { + PROTOBUF_NDEBUG_INLINE static T* CreateMessageInternal(Arena* arena) { static_assert( InternalHelper::is_arena_constructable::value, "CreateMessage can only construct types that are ArenaConstructable"); @@ -506,7 +498,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // Allocate and also optionally call collector with the allocated type info // when allocation recording is enabled. - PROTOBUF_ALWAYS_INLINE void* AllocateInternal(size_t size, size_t align, + PROTOBUF_NDEBUG_INLINE void* AllocateInternal(size_t size, size_t align, void (*destructor)(void*), const std::type_info* type) { // Monitor allocation if needed. @@ -557,7 +549,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // Just allocate the required size for the given type assuming the // type has a trivial constructor. template - PROTOBUF_ALWAYS_INLINE T* CreateInternalRawArray(size_t num_elements) { + PROTOBUF_NDEBUG_INLINE T* CreateInternalRawArray(size_t num_elements) { GOOGLE_CHECK_LE(num_elements, std::numeric_limits::max() / sizeof(T)) << "Requested size is too large to fit into size_t."; // We count on compiler to realize that if sizeof(T) is a multiple of @@ -568,7 +560,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { } template - PROTOBUF_ALWAYS_INLINE T* DoCreateMessage(Args&&... args) { + PROTOBUF_NDEBUG_INLINE T* DoCreateMessage(Args&&... args) { return InternalHelper::Construct( AllocateInternal(sizeof(T), alignof(T), internal::ObjectDestructor< @@ -611,6 +603,40 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { arena->OwnDestructor(ptr); } + // These implement Create(). The second parameter has type 'true_type' if T is + // a subtype of Message and 'false_type' otherwise. + template + PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena, std::true_type, + Args&&... args) { + if (arena == nullptr) { + return new T(std::forward(args)...); + } else { + auto destructor = + internal::ObjectDestructor::value, + T>::destructor; + T* result = + new (arena->AllocateInternal(sizeof(T), alignof(T), destructor, + RTTI_TYPE_ID(T))) + T(std::forward(args)...); + result->SetOwningArena(arena); + return result; + } + } + template + PROTOBUF_ALWAYS_INLINE static T* CreateInternal(Arena* arena, std::false_type, + Args&&... args) { + if (arena == nullptr) { + return new T(std::forward(args)...); + } else { + auto destructor = + internal::ObjectDestructor::value, + T>::destructor; + return new (arena->AllocateInternal(sizeof(T), alignof(T), destructor, + RTTI_TYPE_ID(T))) + T(std::forward(args)...); + } + } + // These implement Own(), which registers an object for deletion (destructor // call and operator delete()). The second parameter has type 'true_type' if T // is a subtype of Message and 'false_type' otherwise. Collapsing @@ -620,6 +646,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { PROTOBUF_ALWAYS_INLINE void OwnInternal(T* object, std::true_type) { if (object != NULL) { impl_.AddCleanup(object, &internal::arena_delete_object); + object->SetOwningArena(this); } } template diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h index 84c5d058804f..40608dfe0d30 100644 --- a/src/google/protobuf/arena_impl.h +++ b/src/google/protobuf/arena_impl.h @@ -296,7 +296,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { // semantics is necessary to allow callers to program functions that only // have fallback function calls in tail position. This substantially improves // code for the happy path. - PROTOBUF_ALWAYS_INLINE bool MaybeAllocateAligned(size_t n, void** out) { + PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) { SerialArena* a; if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFromThreadCache(tag_and_id_, &a))) { return a->MaybeAllocateAligned(n, out); @@ -362,7 +362,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { hint_.store(serial, std::memory_order_release); } - PROTOBUF_ALWAYS_INLINE bool GetSerialArenaFast(uint64 lifecycle_id, + PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFast(uint64 lifecycle_id, SerialArena** arena) { if (GetSerialArenaFromThreadCache(lifecycle_id, arena)) return true; if (lifecycle_id & kRecordAllocs) return false; @@ -378,7 +378,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { return false; } - PROTOBUF_ALWAYS_INLINE bool GetSerialArenaFromThreadCache( + PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFromThreadCache( uint64 lifecycle_id, SerialArena** arena) { // If this thread already owns a block in this arena then try to use that. // This fast path optimizes the case where multiple threads allocate from diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index acd177f15c91..927553c3b55d 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -51,6 +51,9 @@ namespace google { namespace protobuf { namespace internal { +template +class ExplicitlyConstructed; + // Lazy string instance to support string fields with non-empty default. // These are initialized on the first call to .get(). class PROTOBUF_EXPORT LazyString { @@ -88,8 +91,8 @@ template class TaggedPtr { public: TaggedPtr() = default; - explicit constexpr TaggedPtr(const std::string* ptr) - : ptr_(const_cast(ptr)) {} + explicit constexpr TaggedPtr(const ExplicitlyConstructed* ptr) + : ptr_(const_cast*>(ptr)) {} void SetTagged(T* p) { Set(p); @@ -171,7 +174,8 @@ static_assert(std::is_trivial>::value, // requires the String tag to be 0 so we can avoid the mask before comparing.) struct PROTOBUF_EXPORT ArenaStringPtr { ArenaStringPtr() = default; - explicit constexpr ArenaStringPtr(const std::string* default_value) + explicit constexpr ArenaStringPtr( + const ExplicitlyConstructed* default_value) : tagged_ptr_(default_value) {} // Some methods below are overloaded on a `default_value` and on tags. @@ -191,11 +195,11 @@ struct PROTOBUF_EXPORT ArenaStringPtr { void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); // Basic accessors. - const std::string& Get() const PROTOBUF_ALWAYS_INLINE { + const std::string& Get() const PROTOBUF_NDEBUG_INLINE { // Unconditionally mask away the tag. return *tagged_ptr_.Get(); } - const std::string* GetPointer() const PROTOBUF_ALWAYS_INLINE { + const std::string* GetPointer() const PROTOBUF_NDEBUG_INLINE { // Unconditionally mask away the tag. return tagged_ptr_.Get(); } @@ -224,7 +228,7 @@ struct PROTOBUF_EXPORT ArenaStringPtr { // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is // 'unsafe' if called directly. inline void Swap(ArenaStringPtr* other, const std::string* default_value, - Arena* arena) PROTOBUF_ALWAYS_INLINE; + Arena* arena) PROTOBUF_NDEBUG_INLINE; // Frees storage (if not on an arena). void Destroy(const std::string* default_value, ::google::protobuf::Arena* arena); @@ -329,8 +333,8 @@ inline void ArenaStringPtr::Swap(ArenaStringPtr* other, this_ptr->swap(*other_ptr); } #else - (void) default_value; - (void) arena; + (void)default_value; + (void)arena; std::swap(tagged_ptr_, other->tagged_ptr_); #endif } diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index 8d7b520ac031..bd4b4d8452a4 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/src/google/protobuf/compiler/annotation_test_util.cc b/src/google/protobuf/compiler/annotation_test_util.cc index d33f29fb94fa..fb659f627f51 100644 --- a/src/google/protobuf/compiler/annotation_test_util.cc +++ b/src/google/protobuf/compiler/annotation_test_util.cc @@ -31,15 +31,15 @@ #include #include + +#include +#include #include #include #include #include #include #include - -#include -#include #include #include diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 242cb7de4396..ab49ac2614a3 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -234,7 +234,7 @@ bool IsInstalledProtoPath(const std::string& path) { // Add the paths where google/protobuf/descriptor.proto and other well-known // type protos are installed. void AddDefaultProtoPaths( - std::vector >* paths) { + std::vector>* paths) { // TODO(xiaofeng): The code currently only checks relative paths of where // the protoc binary is installed. We probably should make it handle more // cases than that. diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index 7602e9fed316..57e6d7e6ce9d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -156,6 +156,12 @@ void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { "));\n"); } +void EnumFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_($default$)\n"); +} + // =================================================================== EnumOneofFieldGenerator::EnumOneofFieldGenerator( @@ -484,6 +490,16 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { format("}\n"); } +void RepeatedEnumFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_()"); + if (descriptor_->is_packed() && + HasGeneratedMethods(descriptor_->file(), options_)) { + format("\n, _$name$_cached_byte_size_()"); + } +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index 3b97608eafee..3fa64a864059 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -60,6 +60,7 @@ class EnumFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); @@ -100,6 +101,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 2d11f907bce0..5a7763940734 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -164,6 +164,12 @@ class FieldGenerator { return false; } + // Generate initialization code for private members declared by + // GeneratePrivateMembers(), specifically for the constexpr constructor. + // These go into the constructor's initializer list and must follow that + // syntax (eg `field_(args)`). Does not include `:` or `,` separators. + virtual void GenerateConstinitInitializer(io::Printer* printer) const {} + // Generate lines to serialize this field directly to the array "target", // which are placed within the message's SerializeWithCachedSizesToArray() // method. This must also advance "target" past the written bytes. diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 8ca7ba2f57e1..d590af30878a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,7 @@ #include #include +// Must be last. #include namespace google { @@ -138,13 +140,6 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) for (int i = 0; i < file->weak_dependency_count(); ++i) { weak_deps_.insert(file->weak_dependency(i)); } - for (int i = 0; i < message_generators_.size(); i++) { - if (IsSCCRepresentative(message_generators_[i]->descriptor_)) { - sccs_.push_back(GetSCC(message_generators_[i]->descriptor_)); - } - } - - std::sort(sccs_.begin(), sccs_.end(), CompareSortKeys); } FileGenerator::~FileGenerator() = default; @@ -426,6 +421,10 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { format("#include \"$1$.proto.h\"\n", basename); } } + if (HasCordFields(file_, options_)) { + format( + "#include \"third_party/absl/strings/internal/string_constant.h\"\n"); + } format("// @@protoc_insertion_point(includes)\n"); IncludeFile("net/proto2/public/port_def.inc", printer); @@ -441,13 +440,28 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* printer) { Formatter format(printer, variables_); MessageGenerator* generator = message_generators_[idx].get(); + generator->GenerateConstexprConstructor(printer); + // Use a union to disable the destructor of the _instance member. + // We can constant initialize, but the object will still have a non-trivial + // destructor that we need to elide. format( - "class $1$ {\n" - " public:\n" - " ::$proto_ns$::internal::ExplicitlyConstructed<$2$> _instance;\n", + "struct $1$ {\n" + " constexpr $1$()\n" + " : _instance(::$proto_ns$::internal::ConstantInitialized{}) {}\n" + " ~$1$() {}\n" + " union {\n" + " $2$ _instance;\n" + " };\n" + "};\n", DefaultInstanceType(generator->descriptor_, options_), generator->classname_); - format("} $1$;\n", DefaultInstanceName(generator->descriptor_, options_)); + // NO_DESTROY is not necessary for correctness. The empty destructor is + // enough. However, the empty destructor fails to be elided in some + // configurations (like non-opt or with certain sanitizers). NO_DESTROY is + // there just to improve performance and binary size in these builds. + format("PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY $1$ $2$;\n", + DefaultInstanceType(generator->descriptor_, options_), + DefaultInstanceName(generator->descriptor_, options_)); if (options_.lite_implicit_weak_fields) { format("$1$* $2$ = &$3$;\n", @@ -461,8 +475,6 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, // another .pb.cc file. struct FileGenerator::CrossFileReferences { // Populated if we are referencing from messages or files. - std::unordered_set strong_sccs; - std::unordered_set weak_sccs; std::unordered_set weak_default_instances; // Only if we are referencing from files. @@ -474,16 +486,10 @@ void FileGenerator::GetCrossFileReferencesForField(const FieldDescriptor* field, CrossFileReferences* refs) { const Descriptor* msg = field->message_type(); if (msg == nullptr) return; - const SCC* scc = GetSCC(msg); if (IsImplicitWeakField(field, options_, &scc_analyzer_) || IsWeak(field, options_)) { - refs->weak_sccs.insert(scc); refs->weak_default_instances.insert(msg); - } else { - refs->strong_sccs.insert(scc); - // We don't need to declare default instances, because it is declared in the - // .proto.h file we imported. } } @@ -510,35 +516,6 @@ void FileGenerator::GenerateInternalForwardDeclarations( const CrossFileReferences& refs, io::Printer* printer) { Formatter format(printer, variables_); - for (auto scc : Sorted(refs.strong_sccs)) { - format("extern $1$ ::$proto_ns$::internal::SCCInfo<$2$> $3$;\n", - FileDllExport(scc->GetFile(), options_), scc->children.size(), - SccInfoSymbol(scc, options_)); - } - - for (auto scc : Sorted(refs.weak_sccs)) { - // We do things a little bit differently for proto1-style weak fields versus - // lite implicit weak fields, even though they are trying to accomplish - // similar things. We need to support implicit weak fields on iOS, and the - // Apple linker only supports weak definitions, not weak declarations. For - // that reason we need a pointer type which we can weakly define to be null. - // However, code size considerations prevent us from using the same approach - // for proto1-style weak fields. - if (options_.lite_implicit_weak_fields) { - format("extern ::$proto_ns$::internal::SCCInfo<$1$> $2$;\n", - scc->children.size(), SccInfoSymbol(scc, options_)); - format( - "__attribute__((weak)) ::$proto_ns$::internal::SCCInfo<$1$>*\n" - " $2$ = nullptr;\n", - scc->children.size(), SccInfoPtrSymbol(scc, options_)); - } else { - format( - "extern __attribute__((weak)) ::$proto_ns$::internal::SCCInfo<$1$> " - "$2$;\n", - scc->children.size(), SccInfoSymbol(scc, options_)); - } - } - { NamespaceOpener ns(format); for (auto instance : Sorted(refs.weak_default_instances)) { @@ -569,24 +546,13 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); - // Generate weak declarations. We do this for the whole strongly-connected - // component (SCC), because we have a single InitDefaults* function for the - // SCC. CrossFileReferences refs; - for (const Descriptor* message : - scc_analyzer_.GetSCC(message_generators_[idx]->descriptor_) - ->descriptors) { - ForEachField(message, [this, &refs](const FieldDescriptor* field) { - GetCrossFileReferencesForField(field, &refs); - }); - } + ForEachField(message_generators_[idx]->descriptor_, + [this, &refs](const FieldDescriptor* field) { + GetCrossFileReferencesForField(field, &refs); + }); GenerateInternalForwardDeclarations(refs, printer); - if (IsSCCRepresentative(message_generators_[idx]->descriptor_)) { - GenerateInitForSCC(GetSCC(message_generators_[idx]->descriptor_), refs, - printer); - } - { // package namespace NamespaceOpener ns(Namespace(file_, options_), format); @@ -668,11 +634,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { { GenerateTables(printer); - // Now generate the InitDefaults for each SCC. - for (auto scc : sccs_) { - GenerateInitForSCC(scc, refs, printer); - } - if (HasDescriptorMethods(file_, options_)) { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. @@ -872,32 +833,22 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { refs.strong_reflection_files.size() + refs.weak_reflection_files.size(); // Build array of DescriptorTable deps. - format( - "static const ::$proto_ns$::internal::DescriptorTable*const " - "$desc_table$_deps[$1$] = {\n", - std::max(num_deps, 1)); - - for (auto dep : Sorted(refs.strong_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - for (auto dep : Sorted(refs.weak_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - - format("};\n"); + if (num_deps > 0) { + format( + "static const ::$proto_ns$::internal::DescriptorTable*const " + "$desc_table$_deps[$1$] = {\n", + num_deps); - // Build array of SCCs from this file. - format( - "static ::$proto_ns$::internal::SCCInfoBase*const " - "$desc_table$_sccs[$1$] = {\n", - std::max(sccs_.size(), 1)); + for (auto dep : Sorted(refs.strong_reflection_files)) { + format(" &::$1$,\n", DescriptorTableName(dep, options_)); + } + for (auto dep : Sorted(refs.weak_reflection_files)) { + format(" &::$1$,\n", DescriptorTableName(dep, options_)); + } - for (auto scc : sccs_) { - format(" &$1$.base,\n", SccInfoSymbol(scc, options_)); + format("};\n"); } - format("};\n"); - // The DescriptorTable itself. // Should be "bool eager = NeedsEagerDescriptorAssignment(file_, options_);" // however this might cause a tsan failure in superroot b/148382879, @@ -906,14 +857,27 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format( "static ::$proto_ns$::internal::once_flag $desc_table$_once;\n" "const ::$proto_ns$::internal::DescriptorTable $desc_table$ = {\n" - " false, $1$, $2$, \"$filename$\", $3$,\n" - " &$desc_table$_once, $desc_table$_sccs, $desc_table$_deps, $4$, $5$,\n" + " false, $1$, $2$, $3$, \"$filename$\", \n" + " &$desc_table$_once, $4$, $5$, $6$,\n" " schemas, file_default_instances, $tablename$::offsets,\n" - " $file_level_metadata$, $6$, $file_level_enum_descriptors$, " + " $file_level_metadata$, $file_level_enum_descriptors$, " "$file_level_service_descriptors$,\n" - "};\n\n", - eager ? "true" : "false", protodef_name, file_data.size(), sccs_.size(), - num_deps, message_generators_.size()); + "};\n" + // This function exists to be marked as weak. + // It can significantly speed up compilation by breaking up the SCC. + // Without the weak attribute all the messages in the file, including all + // the vtables and everything they use become part of the same SCC. + // By adding a weak function here we break the connection from the + // individual vtables back into the descriptor table. + "PROTOBUF_ATTRIBUTE_WEAK ::$proto_ns$::Metadata\n" + "$desc_table$_metadata_getter(int index) {\n" + " ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n" + " return $desc_table$.file_level_metadata[index];\n" + "}\n" + "\n", + eager ? "true" : "false", file_data.size(), protodef_name, + num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps, + message_generators_.size()); // For descriptor.proto we want to avoid doing any dynamic initialization, // because in some situations that would otherwise pull in a lot of @@ -929,86 +893,6 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { } } -void FileGenerator::GenerateInitForSCC(const SCC* scc, - const CrossFileReferences& refs, - io::Printer* printer) { - Formatter format(printer, variables_); - // We use static and not anonymous namespace because symbol names are - // substantially shorter. - format("static void InitDefaults$1$() {\n", SccInfoSymbol(scc, options_)); - - if (options_.opensource_runtime) { - format(" GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n"); - } - - format.Indent(); - - // First construct all the necessary default instances. - for (int i = 0; i < message_generators_.size(); i++) { - if (scc_analyzer_.GetSCC(message_generators_[i]->descriptor_) != scc) { - continue; - } - format( - "{\n" - " void* ptr = &$1$;\n" - " new (ptr) $2$();\n", - QualifiedDefaultInstanceName(message_generators_[i]->descriptor_, - options_), - QualifiedClassName(message_generators_[i]->descriptor_, options_)); - if (options_.opensource_runtime && - !IsMapEntryMessage(message_generators_[i]->descriptor_)) { - format( - " " - "::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);" - "\n"); - } - format("}\n"); - } - format.Outdent(); - format("}\n\n"); - - // If we are using lite implicit weak fields then we need to distinguish - // between regular SCC dependencies and ones that we need to reference weakly - // through an extra pointer indirection. - std::vector regular_sccs; - std::vector implicit_weak_sccs; - for (const SCC* child : scc->children) { - if (options_.lite_implicit_weak_fields && - refs.weak_sccs.find(child) != refs.weak_sccs.end()) { - implicit_weak_sccs.push_back(child); - } else { - regular_sccs.push_back(child); - } - } - - format( - "$dllexport_decl $::$proto_ns$::internal::SCCInfo<$1$> $2$ =\n" - " " - "{{ATOMIC_VAR_INIT(::$proto_ns$::internal::SCCInfoBase::kUninitialized), " - "$3$, $4$, InitDefaults$2$}, {", - scc->children.size(), // 1 - SccInfoSymbol(scc, options_), regular_sccs.size(), - implicit_weak_sccs.size()); - for (const SCC* child : regular_sccs) { - format("\n &$1$.base,", SccInfoSymbol(child, options_)); - } - for (const SCC* child : implicit_weak_sccs) { - format( - "\n reinterpret_cast<::$proto_ns$::internal::SCCInfoBase**>(" - "\n &$1$),", - SccInfoPtrSymbol(child, options_)); - } - format("}};\n\n"); - - if (options_.lite_implicit_weak_fields) { - format( - "$dllexport_decl $::$proto_ns$::internal::SCCInfo<$1$>*\n" - " $2$ = &$3$;\n\n", - scc->children.size(), SccInfoPtrSymbol(scc, options_), - SccInfoSymbol(scc, options_)); - } -} - void FileGenerator::GenerateTables(io::Printer* printer) { Formatter format(printer, variables_); if (options_.table_driven_parsing) { @@ -1138,7 +1022,7 @@ class FileGenerator::ForwardDeclarations { const Descriptor* class_desc = p.second; format( "class ${1$$2$$}$;\n" - "class $3$;\n" + "struct $3$;\n" "$dllexport_decl $extern $3$ $4$;\n", class_desc, classname, DefaultInstanceType(class_desc, options), DefaultInstanceName(class_desc, options)); @@ -1409,7 +1293,9 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( if (HasDescriptorMethods(file_, options_)) { format( "extern $dllexport_decl $const ::$proto_ns$::internal::DescriptorTable " - "$desc_table$;\n"); + "$desc_table$;\n" + "$dllexport_decl $::$proto_ns$::Metadata " + "$desc_table$_metadata_getter(int index);\n"); } } diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index da5e1dec5d54..35a9085fd4c3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -162,14 +162,6 @@ class FileGenerator { // generally a breaking change so we prefer the #undef approach. void GenerateMacroUndefs(io::Printer* printer); - bool IsSCCRepresentative(const Descriptor* d) { - return GetSCCRepresentative(d) == d; - } - const Descriptor* GetSCCRepresentative(const Descriptor* d) { - return GetSCC(d)->GetRepresentative(); - } - const SCC* GetSCC(const Descriptor* d) { return scc_analyzer_.GetSCC(d); } - bool IsDepWeak(const FileDescriptor* dep) const { if (weak_deps_.count(dep) != 0) { GOOGLE_CHECK(!options_.opensource_runtime); @@ -179,7 +171,6 @@ class FileGenerator { } std::set weak_deps_; - std::vector sccs_; const FileDescriptor* file_; const Options options_; diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 46fe55c41dc3..5825af218168 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -521,6 +522,14 @@ std::string FieldMessageTypeName(const FieldDescriptor* field, return QualifiedClassName(field->message_type(), options); } +std::string StripProto(const std::string& filename) { + /* + * TODO(github/georgthegreat) remove this proxy method + * once Google's internal codebase will become ready + */ + return compiler::StripProto(filename); +} + const char* PrimitiveTypeName(FieldDescriptor::CppType type) { switch (type) { case FieldDescriptor::CPPTYPE_INT32: @@ -1147,11 +1156,6 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { const Descriptor* descriptor = scc->descriptors[i]; if (descriptor->extension_range_count() > 0) { result.contains_extension = true; - // Extensions are found by looking up default_instance and extension - // number in a map. So you'd maybe expect here - // result.constructor_requires_initialization = true; - // However the extension registration mechanism already makes sure - // the default will be initialized. } for (int i = 0; i < descriptor->field_count(); i++) { const FieldDescriptor* field = descriptor->field(i); @@ -1161,7 +1165,6 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { switch (field->type()) { case FieldDescriptor::TYPE_STRING: case FieldDescriptor::TYPE_BYTES: { - result.constructor_requires_initialization = true; if (field->options().ctype() == FieldOptions::CORD) { result.contains_cord = true; } @@ -1169,7 +1172,6 @@ MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { } case FieldDescriptor::TYPE_GROUP: case FieldDescriptor::TYPE_MESSAGE: { - result.constructor_requires_initialization = true; const SCC* child = analyzer_.GetSCC(field->message_type()); if (child != scc) { MessageAnalysis analysis = GetSCCAnalysis(child); diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 125f0591edf5..46d9477f5e47 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -539,7 +539,6 @@ struct MessageAnalysis { bool contains_cord; bool contains_extension; bool contains_required; - bool constructor_requires_initialization; }; // This class is used in FileGenerator, to ensure linear instead of @@ -577,16 +576,6 @@ class PROTOC_EXPORT MessageSCCAnalyzer { std::map analysis_cache_; }; -inline std::string SccInfoSymbol(const SCC* scc, const Options& options) { - return UniqueName("scc_info_" + ClassName(scc->GetRepresentative()), - scc->GetRepresentative(), options); -} - -inline std::string SccInfoPtrSymbol(const SCC* scc, const Options& options) { - return UniqueName("scc_info_ptr_" + ClassName(scc->GetRepresentative()), - scc->GetRepresentative(), options); -} - void ListAllFields(const Descriptor* d, std::vector* fields); void ListAllFields(const FileDescriptor* d, @@ -881,13 +870,7 @@ void GenerateParserLoop(const Descriptor* descriptor, int num_hasbits, const Options& options, MessageSCCAnalyzer* scc_analyzer, io::Printer* printer); -inline std::string StripProto(const std::string& filename) { - /* - * TODO(github/georgthegreat) remove this proxy method - * once Google's internal codebase will become ready - */ - return compiler::StripProto(filename); -} +PROTOC_EXPORT std::string StripProto(const std::string& filename); } // namespace cpp } // namespace compiler diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 39312b3adbf7..c9c30e0c635b 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -290,6 +290,16 @@ void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const { "}\n"); } +void MapFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (HasDescriptorMethods(descriptor_->file(), options_)) { + format("$name$_(::$proto_ns$::internal::ConstantInitialized{})"); + } else { + format("$name$_()"); + } +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h index e0c14f3ce234..149e8a35e90a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -57,6 +57,7 @@ class MapFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index c72ed6857ee2..4878d18a154e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -241,9 +241,9 @@ bool HasHasMethod(const FieldDescriptor* field) { return true; } // For message types without true field presence, only fields with a message - // type have a has_$name$() method. + // type or inside an one-of have a has_$name$() method. return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->has_optional_keyword(); + field->has_optional_keyword() || field->real_containing_oneof(); } // Collects map entry message type information. @@ -296,21 +296,6 @@ bool ShouldMarkClearAsFinal(const Descriptor* descriptor, options.opensource_runtime; } -bool ShouldMarkIsInitializedAsFinal(const Descriptor* descriptor, - const Options& options) { - static std::set exclusions{ - }; - - const std::string name = ClassName(descriptor, true); - return exclusions.find(name) == exclusions.end() || - options.opensource_runtime; -} - -bool ShouldMarkNewAsFinal(const Descriptor* descriptor, - const Options& options) { - return true; -} - // Returns true to make the message serialize in order, decided by the following // factors in the order of precedence. // --options().message_set_wire_format() == true @@ -582,8 +567,6 @@ MessageGenerator::MessageGenerator( // Variables that apply to this class variables_["classname"] = classname_; variables_["classtype"] = QualifiedClassName(descriptor_, options); - variables_["scc_info"] = - SccInfoSymbol(scc_analyzer_->GetSCC(descriptor_), options_); variables_["full_name"] = descriptor_->full_name(); variables_["superclass"] = SuperClassName(descriptor_, options_); @@ -1024,6 +1007,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> " "SuperType;\n" " $classname$();\n" + " explicit constexpr $classname$(\n" + " ::$proto_ns$::internal::ConstantInitialized);\n" " explicit $classname$(::$proto_ns$::Arena* arena);\n" " void MergeFrom(const $classname$& other);\n" " static const $classname$* internal_default_instance() { return " @@ -1041,7 +1026,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " }\n", descriptor_->field(0)->full_name()); } else { - GOOGLE_CHECK(utf8_check == VERIFY); + GOOGLE_CHECK_EQ(utf8_check, VERIFY); format( " static bool ValidateKey(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1070,7 +1055,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " }\n", descriptor_->field(1)->full_name()); } else { - GOOGLE_CHECK(utf8_check == VERIFY); + GOOGLE_CHECK_EQ(utf8_check, VERIFY); format( " static bool ValidateValue(std::string* s) {\n" "#ifndef NDEBUG\n" @@ -1118,6 +1103,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format( "inline $classname$() : $classname$(nullptr) {}\n" "virtual ~$classname$();\n" + "explicit constexpr " + "$classname$(::$proto_ns$::internal::ConstantInitialized);\n" "\n" "$classname$(const $classname$& from);\n" "$classname$($classname$&& from) noexcept\n" @@ -1189,8 +1176,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { } format( - "static const $classname$& default_instance();\n" - "\n"); + "static const $classname$& default_instance() {\n" + " return *internal_default_instance();\n" + "}\n"); // Generate enum values for every field in oneofs. One list is generated for // each oneof with an additional *_NOT_SET value. @@ -1288,9 +1276,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " std::string* full_type_name);\n"); } - format.Set("new_final", - ShouldMarkNewAsFinal(descriptor_, options_) ? "final" : ""); - format( "friend void swap($classname$& a, $classname$& b) {\n" " a.Swap(&b);\n" @@ -1313,11 +1298,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n" "// implements Message ----------------------------------------------\n" "\n" - "inline $classname$* New() const$ new_final$ {\n" + "inline $classname$* New() const final {\n" " return CreateMaybeMessage<$classname$>(nullptr);\n" "}\n" "\n" - "$classname$* New(::$proto_ns$::Arena* arena) const$ new_final$ {\n" + "$classname$* New(::$proto_ns$::Arena* arena) const final {\n" " return CreateMaybeMessage<$classname$>(arena);\n" "}\n"); @@ -1340,15 +1325,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format.Set("clear_final", ShouldMarkClearAsFinal(descriptor_, options_) ? "final" : ""); - format.Set( - "is_initialized_final", - ShouldMarkIsInitializedAsFinal(descriptor_, options_) ? "final" : ""); format( "void CopyFrom(const $classname$& from);\n" "void MergeFrom(const $classname$& from);\n" "PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear()$ clear_final$;\n" - "bool IsInitialized() const$ is_initialized_final$;\n" + "bool IsInitialized() const final;\n" "\n" "size_t ByteSizeLong() const final;\n" "const char* _InternalParse(const char* ptr, " @@ -1400,8 +1382,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "::$proto_ns$::Metadata GetMetadata() const final;\n" "private:\n" "static ::$proto_ns$::Metadata GetMetadataStatic() {\n" - " ::$proto_ns$::internal::AssignDescriptors(&::$desc_table$);\n" - " return ::$desc_table$.file_level_metadata[kIndexInFileMessages];\n" + " return ::$desc_table$_metadata_getter(kIndexInFileMessages);\n" "}\n" "\n" "public:\n" @@ -1540,13 +1521,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { // For each oneof generate a union for (auto oneof : OneOfRange(descriptor_)) { std::string camel_oneof_name = UnderscoresToCamelCase(oneof->name(), true); + format("union $1$Union {\n", camel_oneof_name); + format.Indent(); format( - "union $1$Union {\n" // explicit empty constructor is needed when union contains // ArenaStringPtr members for string fields. - " $1$Union() {}\n", + "constexpr $1$Union() : _constinit_{} {}\n" + " ::$proto_ns$::internal::ConstantInitialized _constinit_;\n", camel_oneof_name); - format.Indent(); for (auto field : FieldRange(oneof)) { if (!IsFieldStripped(field, options_)) { field_generators_.get(field).GeneratePrivateMembers(printer); @@ -2328,12 +2310,6 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { Formatter format(printer, variables_); format("void $classname$::SharedCtor() {\n"); - if (scc_analyzer_->GetSCCAnalysis(scc_analyzer_->GetSCC(descriptor_)) - .constructor_requires_initialization) { - format(" ::$proto_ns$::internal::InitSCC(&$scc_info$.base);\n"); - } - - format.Indent(); std::vector processed(optimized_order_.size(), false); GenerateConstructorBody(printer, processed, false); @@ -2342,7 +2318,6 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { format("clear_has_$1$();\n", oneof->name()); } - format.Outdent(); format("}\n\n"); } @@ -2413,12 +2388,6 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { } } } - if (num_weak_fields_) { - // _this is the object being destructed (we are inside a static method - // here). - format("_this->_weak_field_map_.ClearAll();\n"); - need_registration = true; - } format.Outdent(); format("}\n"); @@ -2438,6 +2407,42 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { } } +void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) { + Formatter format(printer, variables_); + + format( + "constexpr $classname$::$classname$(\n" + " ::$proto_ns$::internal::ConstantInitialized)"); + format.Indent(); + const char* field_sep = ":"; + const auto put_sep = [&] { + format("\n$1$ ", field_sep); + field_sep = ","; + }; + + if (!IsMapEntryMessage(descriptor_)) { + // Process non-oneof fields first. + for (auto field : optimized_order_) { + auto& gen = field_generators_.get(field); + put_sep(); + gen.GenerateConstinitInitializer(printer); + } + + if (IsAnyMessage(descriptor_, options_)) { + put_sep(); + format("_any_metadata_(&type_url_, &value_)"); + } + + if (descriptor_->real_oneof_decl_count() != 0) { + put_sep(); + format("_oneof_case_{}"); + } + } + + format.Outdent(); + format("{}\n"); +} + void MessageGenerator::GenerateConstructorBody(io::Printer* printer, std::vector processed, bool copy_constructor) const { @@ -2664,14 +2669,6 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { "void $classname$::SetCachedSize(int size) const {\n" " _cached_size_.Set(size);\n" "}\n"); - - format( - "const $classname$& $classname$::default_instance() {\n" - " " - "::$proto_ns$::internal::InitSCC(&::$scc_info$.base)" - ";\n" - " return *internal_default_instance();\n" - "}\n\n"); } void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index 933386fbd5fc..4e3f4b9822ac 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -124,6 +124,10 @@ class MessageGenerator { // Generate the arena-specific destructor code. void GenerateArenaDestructorCode(io::Printer* printer); + // Generate the constexpr constructor for constant initialization of the + // default instance. + void GenerateConstexprConstructor(io::Printer* printer); + // Generate standard Message methods. void GenerateClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer); diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index f1a5cef1de0c..7bad24ca84f7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -466,6 +466,12 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { " *$field_member$);\n"); } +void MessageFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_(nullptr)"); +} + // =================================================================== MessageOneofFieldGenerator::MessageOneofFieldGenerator( @@ -809,6 +815,12 @@ void RepeatedMessageFieldGenerator::GenerateByteSize( "}\n"); } +void RepeatedMessageFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_()"); +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h index fe5cf13cbd8d..4b4b8ea59b0e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -68,6 +68,7 @@ class MessageFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; protected: const bool implicit_weak_field_; @@ -117,6 +118,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: const bool implicit_weak_field_; diff --git a/src/google/protobuf/compiler/cpp/cpp_names.h b/src/google/protobuf/compiler/cpp/cpp_names.h new file mode 100644 index 000000000000..9bede74fc8a3 --- /dev/null +++ b/src/google/protobuf/compiler/cpp/cpp_names.h @@ -0,0 +1,85 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ +#define GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ + +#include + +#include + +namespace google { +namespace protobuf { + +class Descriptor; +class EnumDescriptor; +class FieldDescriptor; + +namespace compiler { +namespace cpp { + +// Returns the unqualified C++ name. +// +// For example, if you had: +// package foo.bar; +// message Baz { message Qux {} } +// Then the non-qualified version would be: +// Baz_Qux +std::string ClassName(const Descriptor* descriptor); +std::string ClassName(const EnumDescriptor* enum_descriptor); + +// Returns the fully qualified C++ name. +// +// For example, if you had: +// package foo.bar; +// message Baz { message Qux {} } +// Then the qualified ClassName for Qux would be: +// ::foo::bar::Baz_Qux +std::string QualifiedClassName(const Descriptor* d); +std::string QualifiedClassName(const EnumDescriptor* d); +std::string QualifiedExtensionName(const FieldDescriptor* d); + +// Get the (unqualified) name that should be used for this field in C++ code. +// The name is coerced to lower-case to emulate proto1 behavior. People +// should be using lowercase-with-underscores style for proto field names +// anyway, so normally this just returns field->name(). +std::string FieldName(const FieldDescriptor* field); + +// Strips ".proto" or ".protodevel" from the end of a filename. +PROTOC_EXPORT std::string StripProto(const std::string& filename); + +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#include + +#endif // GOOGLE_PROTOBUF_COMPILER_CPP_NAMES_H__ diff --git a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc index 10e468b0b94b..31f3f0cc0dc5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc @@ -36,13 +36,12 @@ #include +#include +#include #include #include #include #include - -#include -#include #include #include diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 042776c2d029..d840492b6873 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -217,6 +217,12 @@ void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const { } } +void PrimitiveFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_($default$)"); +} + // =================================================================== PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator( @@ -470,6 +476,16 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize( format("}\n"); } +void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_()"); + if (descriptor_->is_packed() && + HasGeneratedMethods(descriptor_->file(), options_)) { + format("\n, _$name$_cached_byte_size_()"); + } +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index fe54ce332579..394b304770fc 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -61,6 +61,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); @@ -99,6 +100,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index beed6e5107fa..3769437e2269 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -399,6 +399,16 @@ void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const { " this->_internal_$name$());\n"); } +void StringFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (descriptor_->default_value_string().empty()) { + format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)"); + } else { + format("$name$_(nullptr)"); + } +} + // =================================================================== StringOneofFieldGenerator::StringOneofFieldGenerator( @@ -818,6 +828,12 @@ void RepeatedStringFieldGenerator::GenerateByteSize( "}\n"); } +void RepeatedStringFieldGenerator::GenerateConstinitInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$name$_()"); +} + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index 91424d221c53..213f13465d43 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -65,6 +65,7 @@ class StringFieldGenerator : public FieldGenerator { void GenerateDestructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); @@ -107,6 +108,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; + void GenerateConstinitInitializer(io::Printer* printer) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc index a16c8b530f7f..b5cac8f42f7f 100644 --- a/src/google/protobuf/compiler/cpp/metadata_test.cc +++ b/src/google/protobuf/compiler/cpp/metadata_test.cc @@ -30,14 +30,13 @@ #include +#include +#include #include #include #include #include #include - -#include -#include #include #include diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 23a4effe6372..c629b2e22b7a 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -497,8 +497,8 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile( } while (ret != 0 && errno == EINTR); #if defined(_WIN32) if (ret == 0 && sb.st_mode & S_IFDIR) { - last_error_message_ = "Input file is a directory."; - return NULL; + last_error_message_ = "Input file is a directory."; + return NULL; } #else if (ret == 0 && S_ISDIR(sb.st_mode)) { diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index d96ac7d7724e..9706c6d02758 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -154,7 +154,7 @@ int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -171,7 +171,7 @@ void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { printer->Print(variables_, "private int $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override $deprecation$public boolean " @@ -203,7 +203,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { void ImmutableEnumFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private int $name$_ = $default_number$;\n"); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "@java.lang.Override $deprecation$public boolean " @@ -287,7 +287,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderClearCode( void ImmutableEnumFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { printer->Print(variables_, "if (other.has$capitalized_name$()) {\n" " set$capitalized_name$(other.get$capitalized_name$());\n" @@ -305,7 +305,7 @@ void ImmutableEnumFieldGenerator::GenerateMergingCode( void ImmutableEnumFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" " $set_has_field_bit_to_local$;\n" @@ -389,15 +389,14 @@ ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {} void ImmutableEnumOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -426,16 +425,15 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); printer->Print( diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc index b0b3b78cc698..dfa051c16d30 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -142,7 +142,7 @@ int ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const { void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -160,7 +160,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { printer->Print(variables_, "private int $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -214,7 +214,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -316,16 +316,15 @@ ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {} void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -393,16 +392,15 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return instance.has$capitalized_name$();\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return instance.has$capitalized_name$();\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); printer->Print( diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index fb00110c4183..5cdb00d5c137 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -387,7 +387,6 @@ void FileGenerator::Generate(io::Printer* printer) { printer->Print("}\n"); } - void FileGenerator::GenerateDescriptorInitializationCodeForImmutable( io::Printer* printer) { printer->Print( @@ -676,6 +675,7 @@ void FileGenerator::GenerateSiblings( } } + bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor, bool immutable_api) { return true; diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index e9bc6f76738d..3aebf72c7ecf 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -89,17 +90,6 @@ const std::unordered_set* kReservedNames = "transient", "try", "void", "volatile", "while", }); -// Names that should be avoided as field names in Kotlin. -// All Kotlin hard keywords are in this list. -const std::unordered_set* kKotlinForbiddenNames = - new std::unordered_set({ - "as", "as?", "break", "class", "continue", "do", "else", - "false", "for", "fun", "if", "in", "!in", "interface", - "is", "!is", "null", "object", "package", "return", "super", - "this", "throw", "true", "try", "typealias", "typeof", "val", - "var", "when", "while", - }); - bool IsForbidden(const std::string& field_name) { for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) { if (field_name == kForbiddenWordList[i]) { diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h index 1ff4667a7a77..8cc2f5af80e5 100644 --- a/src/google/protobuf/compiler/java/java_helpers.h +++ b/src/google/protobuf/compiler/java/java_helpers.h @@ -103,21 +103,11 @@ std::string UniqueFileScopeIdentifier(const Descriptor* descriptor); std::string FileClassName(const FileDescriptor* file, bool immutable = true); // Returns the file's Java package name. -std::string FileJavaPackage(const FileDescriptor* file); std::string FileJavaPackage(const FileDescriptor* file, bool immutable); // Returns output directory for the given package name. std::string JavaPackageToDir(std::string package_name); -// TODO(xiaofeng): the following methods are kept for they are exposed -// publicly in //net/proto2/compiler/java/public/names.h. They return -// immutable names only and should be removed after mutable API is -// integrated into google3. -std::string ClassName(const Descriptor* descriptor); -std::string ClassName(const EnumDescriptor* descriptor); -std::string ClassName(const ServiceDescriptor* descriptor); -std::string ClassName(const FileDescriptor* descriptor); - // Comma-separate list of option-specified interfaces implemented by the // Message, to follow the "implements" declaration of the Message definition. std::string ExtraMessageInterfaces(const Descriptor* descriptor); @@ -357,24 +347,22 @@ inline bool IsProto2(const FileDescriptor* descriptor) { return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2; } -inline bool SupportFieldPresence(const FieldDescriptor* descriptor) { - // Note that while proto3 oneofs do conceptually support present, we return - // false for them because they do not offer a public hazzer. Therefore this - // method could be named HasHazzer(). - return !descriptor->is_repeated() && - (descriptor->message_type() || descriptor->has_optional_keyword() || - IsProto2(descriptor->file())); -} - inline bool IsRealOneof(const FieldDescriptor* descriptor) { return descriptor->containing_oneof() && !descriptor->containing_oneof()->is_synthetic(); } +inline bool HasHazzer(const FieldDescriptor* descriptor) { + return !descriptor->is_repeated() && + (descriptor->message_type() || descriptor->has_optional_keyword() || + IsProto2(descriptor->file()) || IsRealOneof(descriptor)); +} + inline bool HasHasbit(const FieldDescriptor* descriptor) { // Note that currently message fields inside oneofs have hasbits. This is // surprising, as the oneof case should avoid any need for a hasbit. But if // you change this method to remove hasbits for oneofs, a few tests fail. + // TODO(b/124347790): remove hasbits for oneofs return !descriptor->is_repeated() && (descriptor->has_optional_keyword() || IsProto2(descriptor->file())); } diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 6623595b1175..f9d4e43ff84a 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -491,6 +491,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { printer->Print("public static final int $constant_name$ = $number$;\n", "constant_name", FieldConstantName(descriptor_->field(i)), "number", StrCat(descriptor_->field(i)->number())); + printer->Annotate("constant_name", descriptor_->field(i)); field_generators_.get(descriptor_->field(i)).GenerateMembers(printer); printer->Print("\n"); } diff --git a/src/google/protobuf/compiler/java/java_name_resolver.cc b/src/google/protobuf/compiler/java/java_name_resolver.cc index f3c96c4d3d42..ed33dae5ff57 100644 --- a/src/google/protobuf/compiler/java/java_name_resolver.cc +++ b/src/google/protobuf/compiler/java/java_name_resolver.cc @@ -33,8 +33,9 @@ #include #include -#include #include +#include +#include #include namespace google { diff --git a/src/google/protobuf/compiler/java/java_names.h b/src/google/protobuf/compiler/java/java_names.h index 73a340e9ff08..313ace4feb05 100644 --- a/src/google/protobuf/compiler/java/java_names.h +++ b/src/google/protobuf/compiler/java/java_names.h @@ -93,18 +93,6 @@ std::string FileJavaPackage(const FileDescriptor* descriptor); // Capitalized camel case name field name. std::string CapitalizedFieldName(const FieldDescriptor* descriptor); -// Requires: -// descriptor != NULL -// Returns: -// Primitive Java type name for the field. -const char* PrimitiveTypeName(const FieldDescriptor* descriptor); - -// Requires: -// descriptor != NULL -// Returns: -// Boes primitive Java type name for the field. -const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor); - } // namespace java } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/java/java_plugin_unittest.cc b/src/google/protobuf/compiler/java/java_plugin_unittest.cc index 744b2c8be7ae..3bdd53bff67e 100644 --- a/src/google/protobuf/compiler/java/java_plugin_unittest.cc +++ b/src/google/protobuf/compiler/java/java_plugin_unittest.cc @@ -36,13 +36,12 @@ #include +#include +#include #include #include #include #include - -#include -#include #include #include diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index f06e8fb203d4..8bc68b7b22c5 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -204,7 +204,7 @@ int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -217,7 +217,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers( io::Printer* printer) const { printer->Print(variables_, "private $field_type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -241,7 +241,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private $field_type$ $name$_ $default_init$;\n"); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -318,7 +318,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode( void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { printer->Print(variables_, "if (other.has$capitalized_name$()) {\n" " set$capitalized_name$(other.get$capitalized_name$());\n" @@ -333,7 +333,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { if (IsDefaultValueJavaDefault(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" @@ -497,16 +497,14 @@ ImmutablePrimitiveOneofFieldGenerator:: void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -522,15 +520,13 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index 59dba76cc03f..e80706624757 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -193,7 +193,7 @@ int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const { void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -213,7 +213,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( } printer->Print(variables_, "private $field_type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -259,7 +259,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -345,16 +345,14 @@ ImmutablePrimitiveOneofFieldLiteGenerator:: void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -395,16 +393,14 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return instance.has$capitalized_name$();\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return instance.has$capitalized_name$();\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index f673e68301bd..45943d76226d 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -36,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index 548f898e464f..485fcf812e8d 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -188,7 +188,7 @@ int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { // UnmodifiableLazyStringList. void ImmutableStringFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -207,7 +207,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( printer->Print(variables_, "private volatile java.lang.Object $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -266,7 +266,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, "private java.lang.Object $name$_ $default_init$;\n"); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -384,7 +384,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderClearCode( void ImmutableStringFieldGenerator::GenerateMergingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { // Allow a slight breach of abstraction here in order to avoid forcing // all string fields to Strings when copying fields from a Message. printer->Print(variables_, @@ -404,7 +404,7 @@ void ImmutableStringFieldGenerator::GenerateMergingCode( void ImmutableStringFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n" " $set_has_field_bit_to_local$;\n" @@ -484,16 +484,13 @@ ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {} void ImmutableStringOneofFieldGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -551,16 +548,14 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 06a3c25bd928..25bfedcae2ae 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -157,7 +157,7 @@ int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const { // shouldn't be necessary or used on devices. void ImmutableStringFieldLiteGenerator::GenerateInterfaceMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n"); @@ -176,7 +176,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( printer->Print(variables_, "private java.lang.String $name$_;\n"); PrintExtraFieldInfo(variables_, printer); - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -238,7 +238,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { + if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( variables_, @@ -337,17 +337,14 @@ ImmutableStringOneofFieldLiteGenerator:: void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( io::Printer* printer) const { PrintExtraFieldInfo(variables_, printer); - - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $has_oneof_case_message$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $has_oneof_case_message$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -418,16 +415,14 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo( void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { - if (SupportFieldPresence(descriptor_)) { - WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return instance.has$capitalized_name$();\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + GOOGLE_DCHECK(HasHazzer(descriptor_)); + WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return instance.has$capitalized_name$();\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index cbb24a50a58c..a413d74d06f9 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -2184,7 +2184,7 @@ void SortMessages(FileDescriptorProto* file_descriptor_proto) { void StripFieldTypeName(DescriptorProto* proto) { for (int i = 0; i < proto->field_size(); ++i) { std::string type_name = proto->field(i).type_name(); - std::string::size_type pos = type_name.find_last_of("."); + std::string::size_type pos = type_name.find_last_of('.'); if (pos != std::string::npos) { proto->mutable_field(i)->mutable_type_name()->assign( type_name.begin() + pos + 1, type_name.end()); diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 58283cd742bd..84a90f6963a0 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -16,86 +16,69 @@ #include PROTOBUF_PRAGMA_INIT_SEG -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto; PROTOBUF_NAMESPACE_OPEN namespace compiler { -class VersionDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Version_default_instance_; -class CodeGeneratorRequestDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _CodeGeneratorRequest_default_instance_; -class CodeGeneratorResponse_FileDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _CodeGeneratorResponse_File_default_instance_; -class CodeGeneratorResponseDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _CodeGeneratorResponse_default_instance_; +constexpr Version::Version( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : suffix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , major_(0) + , minor_(0) + , patch_(0){} +struct VersionDefaultTypeInternal { + constexpr VersionDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~VersionDefaultTypeInternal() {} + union { + Version _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY VersionDefaultTypeInternal _Version_default_instance_; +constexpr CodeGeneratorRequest::CodeGeneratorRequest( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : file_to_generate_() + , proto_file_() + , parameter_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , compiler_version_(nullptr){} +struct CodeGeneratorRequestDefaultTypeInternal { + constexpr CodeGeneratorRequestDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~CodeGeneratorRequestDefaultTypeInternal() {} + union { + CodeGeneratorRequest _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , insertion_point_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , content_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , generated_code_info_(nullptr){} +struct CodeGeneratorResponse_FileDefaultTypeInternal { + constexpr CodeGeneratorResponse_FileDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~CodeGeneratorResponse_FileDefaultTypeInternal() {} + union { + CodeGeneratorResponse_File _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +constexpr CodeGeneratorResponse::CodeGeneratorResponse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : file_() + , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , supported_features_(PROTOBUF_ULONGLONG(0)){} +struct CodeGeneratorResponseDefaultTypeInternal { + constexpr CodeGeneratorResponseDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~CodeGeneratorResponseDefaultTypeInternal() {} + union { + CodeGeneratorResponse _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; } // namespace compiler PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { - &scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}}; - -static void InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { - &scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}}; - -static void InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { - &scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::compiler::Version(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; @@ -191,19 +174,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2epro static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_sccs[4] = { - &scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base, - &scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base, - &scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base, - &scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", 773, - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_sccs, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 4, 1, + false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + return descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); @@ -272,12 +254,11 @@ Version::Version(const Version& from) } void Version::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&major_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&patch_) - - reinterpret_cast(&major_)) + sizeof(patch_)); +suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&major_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&patch_) - + reinterpret_cast(&major_)) + sizeof(patch_)); } Version::~Version() { @@ -300,11 +281,6 @@ void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Version::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Version& Version::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - return *internal_default_instance(); -} - void Version::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) @@ -607,9 +583,8 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) } void CodeGeneratorRequest::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - compiler_version_ = nullptr; +parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +compiler_version_ = nullptr; } CodeGeneratorRequest::~CodeGeneratorRequest() { @@ -633,11 +608,6 @@ void CodeGeneratorRequest::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void CodeGeneratorRequest::SetCachedSize(int size) const { _cached_size_.Set(size); } -const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - return *internal_default_instance(); -} - void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) @@ -969,11 +939,10 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon } void CodeGeneratorResponse_File::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - generated_code_info_ = nullptr; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +generated_code_info_ = nullptr; } CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { @@ -999,11 +968,6 @@ void CodeGeneratorResponse_File::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Aren void CodeGeneratorResponse_File::SetCachedSize(int size) const { _cached_size_.Set(size); } -const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - return *internal_default_instance(); -} - void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1310,9 +1274,8 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) } void CodeGeneratorResponse::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - supported_features_ = PROTOBUF_ULONGLONG(0); +error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +supported_features_ = PROTOBUF_ULONGLONG(0); } CodeGeneratorResponse::~CodeGeneratorResponse() { @@ -1335,11 +1298,6 @@ void CodeGeneratorResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void CodeGeneratorResponse::SetCachedSize(int size) const { _cached_size_.Set(size); } -const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base); - return *internal_default_instance(); -} - void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 6f48efa66289..208b8ef5e946 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -61,19 +61,20 @@ struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN namespace compiler { class CodeGeneratorRequest; -class CodeGeneratorRequestDefaultTypeInternal; +struct CodeGeneratorRequestDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; class CodeGeneratorResponse; -class CodeGeneratorResponseDefaultTypeInternal; +struct CodeGeneratorResponseDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; class CodeGeneratorResponse_File; -class CodeGeneratorResponse_FileDefaultTypeInternal; +struct CodeGeneratorResponse_FileDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; class Version; -class VersionDefaultTypeInternal; +struct VersionDefaultTypeInternal; PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; } // namespace compiler PROTOBUF_NAMESPACE_CLOSE @@ -116,6 +117,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : public: inline Version() : Version(nullptr) {} virtual ~Version(); + explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Version(const Version& from); Version(Version&& from) noexcept @@ -152,8 +154,9 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Version& default_instance(); - + static const Version& default_instance() { + return *internal_default_instance(); + } static inline const Version* internal_default_instance() { return reinterpret_cast( &_Version_default_instance_); @@ -219,8 +222,7 @@ class PROTOC_EXPORT Version PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -316,6 +318,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : public: inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} virtual ~CodeGeneratorRequest(); + explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorRequest(const CodeGeneratorRequest& from); CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept @@ -352,8 +355,9 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const CodeGeneratorRequest& default_instance(); - + static const CodeGeneratorRequest& default_instance() { + return *internal_default_instance(); + } static inline const CodeGeneratorRequest* internal_default_instance() { return reinterpret_cast( &_CodeGeneratorRequest_default_instance_); @@ -419,8 +423,7 @@ class PROTOC_EXPORT CodeGeneratorRequest PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -537,6 +540,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : public: inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} virtual ~CodeGeneratorResponse_File(); + explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept @@ -573,8 +577,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const CodeGeneratorResponse_File& default_instance(); - + static const CodeGeneratorResponse_File& default_instance() { + return *internal_default_instance(); + } static inline const CodeGeneratorResponse_File* internal_default_instance() { return reinterpret_cast( &_CodeGeneratorResponse_File_default_instance_); @@ -640,8 +645,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -756,6 +760,7 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : public: inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} virtual ~CodeGeneratorResponse(); + explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse(const CodeGeneratorResponse& from); CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept @@ -792,8 +797,9 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const CodeGeneratorResponse& default_instance(); - + static const CodeGeneratorResponse& default_instance() { + return *internal_default_instance(); + } static inline const CodeGeneratorResponse* internal_default_instance() { return reinterpret_cast( &_CodeGeneratorResponse_default_instance_); @@ -859,8 +865,7 @@ class PROTOC_EXPORT CodeGeneratorResponse PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); - return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index d849fa6eee6f..95de716f923e 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -69,6 +69,7 @@ namespace python { namespace { + // Returns the Python module name expected for a given .proto filename. std::string ModuleName(const std::string& filename) { std::string basename = StripProto(filename); @@ -312,7 +313,6 @@ bool Generator::Generate(const FileDescriptor* file, } } - // Completely serialize all Generate() calls on this instance. The // thread-safety constraints of the CodeGenerator interface aren't clear so // just be as conservative as possible. It's easier to relax this later if @@ -675,7 +675,8 @@ void Generator::PrintDescriptorKeyAndModuleName( const ServiceDescriptor& descriptor) const { std::string name = ModuleLevelServiceDescriptorName(descriptor); if (!pure_python_workable_) { - name = "'" + descriptor.full_name() + "'"; + name = "_descriptor.ServiceDescriptor(full_name='" + + descriptor.full_name() + "')"; } printer_->Print("$descriptor_key$ = $descriptor_name$,\n", "descriptor_key", kDescriptorKey, "descriptor_name", name); @@ -872,7 +873,8 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, if (pure_python_workable_) { m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); } else { - m["descriptor_name"] = "'" + message_descriptor.full_name() + "'"; + m["descriptor_name"] = "_descriptor.Descriptor(full_name='" + + message_descriptor.full_name() + "')"; } printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n"); std::string module_name = ModuleName(file_->name()); diff --git a/src/google/protobuf/compiler/python/python_plugin_unittest.cc b/src/google/protobuf/compiler/python/python_plugin_unittest.cc index 8d7ef98b27d0..76ceef32a0af 100644 --- a/src/google/protobuf/compiler/python/python_plugin_unittest.cc +++ b/src/google/protobuf/compiler/python/python_plugin_unittest.cc @@ -36,13 +36,12 @@ #include +#include +#include #include #include #include #include - -#include -#include #include #include #include diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 7af37c57f309..03c4e2b516ff 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -1090,7 +1090,7 @@ inline void DescriptorPool::Tables::FindAllExtensions( bool DescriptorPool::Tables::AddSymbol(const std::string& full_name, Symbol symbol) { - if (InsertIfNotPresent(&symbols_by_name_, full_name.c_str(), symbol)) { + if (InsertIfNotPresent(&symbols_by_name_, full_name, symbol)) { symbols_after_checkpoint_.push_back(full_name.c_str()); return true; } else { @@ -1106,7 +1106,7 @@ bool FileDescriptorTables::AddAliasUnderParent(const void* parent, } bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) { - if (InsertIfNotPresent(&files_by_name_, file->name().c_str(), file)) { + if (InsertIfNotPresent(&files_by_name_, file->name(), file)) { files_after_checkpoint_.push_back(file->name().c_str()); return true; } else { @@ -2626,6 +2626,8 @@ void Descriptor::DebugString(int depth, std::string* contents, const Descriptor::ReservedRange* range = reserved_range(i); if (range->end == range->start + 1) { strings::SubstituteAndAppend(contents, "$0, ", range->start); + } else if (range->end > FieldDescriptor::kMaxNumber) { + strings::SubstituteAndAppend(contents, "$0 to max, ", range->start); } else { strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start, range->end - 1); @@ -2829,6 +2831,8 @@ void EnumDescriptor::DebugString( const EnumDescriptor::ReservedRange* range = reserved_range(i); if (range->end == range->start) { strings::SubstituteAndAppend(contents, "$0, ", range->start); + } else if (range->end == INT_MAX) { + strings::SubstituteAndAppend(contents, "$0 to max, ", range->start); } else { strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start, range->end); @@ -4019,6 +4023,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name, // Use its file as the parent instead. if (parent == nullptr) parent = file_; + if (full_name.find('\0') != std::string::npos) { + AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, + "\"" + full_name + "\" contains null character."); + return false; + } if (tables_->AddSymbol(full_name, symbol)) { if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) { // This is only possible if there was already an error adding something of @@ -4059,6 +4068,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name, void DescriptorBuilder::AddPackage(const std::string& name, const Message& proto, const FileDescriptor* file) { + if (name.find('\0') != std::string::npos) { + AddError(name, proto, DescriptorPool::ErrorCollector::NAME, + "\"" + name + "\" contains null character."); + return; + } if (tables_->AddSymbol(name, Symbol(file))) { // Success. Also add parent package, if any. std::string::size_type dot_pos = name.find_last_of('.'); @@ -4372,6 +4386,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( } result->pool_ = pool_; + if (result->name().find('\0') != std::string::npos) { + AddError(result->name(), proto, DescriptorPool::ErrorCollector::NAME, + "\"" + result->name() + "\" contains null character."); + return nullptr; + } + // Add to tables. if (!tables_->AddFile(result)) { AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER, diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index d9590f8b8e8b..443a8bfa2d4a 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -16,527 +16,439 @@ #include PROTOBUF_PRAGMA_INIT_SEG -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto; PROTOBUF_NAMESPACE_OPEN -class FileDescriptorSetDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FileDescriptorSet_default_instance_; -class FileDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FileDescriptorProto_default_instance_; -class DescriptorProto_ExtensionRangeDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _DescriptorProto_ExtensionRange_default_instance_; -class DescriptorProto_ReservedRangeDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _DescriptorProto_ReservedRange_default_instance_; -class DescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _DescriptorProto_default_instance_; -class ExtensionRangeOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _ExtensionRangeOptions_default_instance_; -class FieldDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FieldDescriptorProto_default_instance_; -class OneofDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OneofDescriptorProto_default_instance_; -class EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumDescriptorProto_EnumReservedRange_default_instance_; -class EnumDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumDescriptorProto_default_instance_; -class EnumValueDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumValueDescriptorProto_default_instance_; -class ServiceDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _ServiceDescriptorProto_default_instance_; -class MethodDescriptorProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _MethodDescriptorProto_default_instance_; -class FileOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FileOptions_default_instance_; -class MessageOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _MessageOptions_default_instance_; -class FieldOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FieldOptions_default_instance_; -class OneofOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OneofOptions_default_instance_; -class EnumOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumOptions_default_instance_; -class EnumValueOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumValueOptions_default_instance_; -class ServiceOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _ServiceOptions_default_instance_; -class MethodOptionsDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _MethodOptions_default_instance_; -class UninterpretedOption_NamePartDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _UninterpretedOption_NamePart_default_instance_; -class UninterpretedOptionDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _UninterpretedOption_default_instance_; -class SourceCodeInfo_LocationDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _SourceCodeInfo_Location_default_instance_; -class SourceCodeInfoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _SourceCodeInfo_default_instance_; -class GeneratedCodeInfo_AnnotationDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _GeneratedCodeInfo_Annotation_default_instance_; -class GeneratedCodeInfoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _GeneratedCodeInfo_default_instance_; +constexpr FileDescriptorSet::FileDescriptorSet( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : file_(){} +struct FileDescriptorSetDefaultTypeInternal { + constexpr FileDescriptorSetDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FileDescriptorSetDefaultTypeInternal() {} + union { + FileDescriptorSet _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +constexpr FileDescriptorProto::FileDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : dependency_() + , message_type_() + , enum_type_() + , service_() + , extension_() + , public_dependency_() + , weak_dependency_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , syntax_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr) + , source_code_info_(nullptr){} +struct FileDescriptorProtoDefaultTypeInternal { + constexpr FileDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FileDescriptorProtoDefaultTypeInternal() {} + union { + FileDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +constexpr DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : options_(nullptr) + , start_(0) + , end_(0){} +struct DescriptorProto_ExtensionRangeDefaultTypeInternal { + constexpr DescriptorProto_ExtensionRangeDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~DescriptorProto_ExtensionRangeDefaultTypeInternal() {} + union { + DescriptorProto_ExtensionRange _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +constexpr DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : start_(0) + , end_(0){} +struct DescriptorProto_ReservedRangeDefaultTypeInternal { + constexpr DescriptorProto_ReservedRangeDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~DescriptorProto_ReservedRangeDefaultTypeInternal() {} + union { + DescriptorProto_ReservedRange _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +constexpr DescriptorProto::DescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : field_() + , nested_type_() + , enum_type_() + , extension_range_() + , extension_() + , oneof_decl_() + , reserved_range_() + , reserved_name_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr){} +struct DescriptorProtoDefaultTypeInternal { + constexpr DescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~DescriptorProtoDefaultTypeInternal() {} + union { + DescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +constexpr ExtensionRangeOptions::ExtensionRangeOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_(){} +struct ExtensionRangeOptionsDefaultTypeInternal { + constexpr ExtensionRangeOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ExtensionRangeOptionsDefaultTypeInternal() {} + union { + ExtensionRangeOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; +constexpr FieldDescriptorProto::FieldDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , extendee_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , type_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr) + , number_(0) + , oneof_index_(0) + , proto3_optional_(false) + , label_(1) + + , type_(1) +{} +struct FieldDescriptorProtoDefaultTypeInternal { + constexpr FieldDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FieldDescriptorProtoDefaultTypeInternal() {} + union { + FieldDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +constexpr OneofDescriptorProto::OneofDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr){} +struct OneofDescriptorProtoDefaultTypeInternal { + constexpr OneofDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~OneofDescriptorProtoDefaultTypeInternal() {} + union { + OneofDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +constexpr EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : start_(0) + , end_(0){} +struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { + constexpr EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {} + union { + EnumDescriptorProto_EnumReservedRange _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; +constexpr EnumDescriptorProto::EnumDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : value_() + , reserved_range_() + , reserved_name_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr){} +struct EnumDescriptorProtoDefaultTypeInternal { + constexpr EnumDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EnumDescriptorProtoDefaultTypeInternal() {} + union { + EnumDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +constexpr EnumValueDescriptorProto::EnumValueDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr) + , number_(0){} +struct EnumValueDescriptorProtoDefaultTypeInternal { + constexpr EnumValueDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EnumValueDescriptorProtoDefaultTypeInternal() {} + union { + EnumValueDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +constexpr ServiceDescriptorProto::ServiceDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : method_() + , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr){} +struct ServiceDescriptorProtoDefaultTypeInternal { + constexpr ServiceDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ServiceDescriptorProtoDefaultTypeInternal() {} + union { + ServiceDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +constexpr MethodDescriptorProto::MethodDescriptorProto( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , input_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , output_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , options_(nullptr) + , client_streaming_(false) + , server_streaming_(false){} +struct MethodDescriptorProtoDefaultTypeInternal { + constexpr MethodDescriptorProtoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~MethodDescriptorProtoDefaultTypeInternal() {} + union { + MethodDescriptorProto _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +constexpr FileOptions::FileOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , java_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , java_outer_classname_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , go_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , objc_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , csharp_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , swift_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , php_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , php_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , php_metadata_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , ruby_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , java_multiple_files_(false) + , java_generate_equals_and_hash_(false) + , java_string_check_utf8_(false) + , cc_generic_services_(false) + , java_generic_services_(false) + , py_generic_services_(false) + , php_generic_services_(false) + , deprecated_(false) + , optimize_for_(1) + + , cc_enable_arenas_(true){} +struct FileOptionsDefaultTypeInternal { + constexpr FileOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FileOptionsDefaultTypeInternal() {} + union { + FileOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +constexpr MessageOptions::MessageOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , message_set_wire_format_(false) + , no_standard_descriptor_accessor_(false) + , deprecated_(false) + , map_entry_(false){} +struct MessageOptionsDefaultTypeInternal { + constexpr MessageOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~MessageOptionsDefaultTypeInternal() {} + union { + MessageOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +constexpr FieldOptions::FieldOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , ctype_(0) + + , packed_(false) + , lazy_(false) + , deprecated_(false) + , weak_(false) + , jstype_(0) +{} +struct FieldOptionsDefaultTypeInternal { + constexpr FieldOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FieldOptionsDefaultTypeInternal() {} + union { + FieldOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +constexpr OneofOptions::OneofOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_(){} +struct OneofOptionsDefaultTypeInternal { + constexpr OneofOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~OneofOptionsDefaultTypeInternal() {} + union { + OneofOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +constexpr EnumOptions::EnumOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , allow_alias_(false) + , deprecated_(false){} +struct EnumOptionsDefaultTypeInternal { + constexpr EnumOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EnumOptionsDefaultTypeInternal() {} + union { + EnumOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +constexpr EnumValueOptions::EnumValueOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , deprecated_(false){} +struct EnumValueOptionsDefaultTypeInternal { + constexpr EnumValueOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EnumValueOptionsDefaultTypeInternal() {} + union { + EnumValueOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +constexpr ServiceOptions::ServiceOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , deprecated_(false){} +struct ServiceOptionsDefaultTypeInternal { + constexpr ServiceOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ServiceOptionsDefaultTypeInternal() {} + union { + ServiceOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +constexpr MethodOptions::MethodOptions( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : uninterpreted_option_() + , deprecated_(false) + , idempotency_level_(0) +{} +struct MethodOptionsDefaultTypeInternal { + constexpr MethodOptionsDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~MethodOptionsDefaultTypeInternal() {} + union { + MethodOptions _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +constexpr UninterpretedOption_NamePart::UninterpretedOption_NamePart( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_part_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , is_extension_(false){} +struct UninterpretedOption_NamePartDefaultTypeInternal { + constexpr UninterpretedOption_NamePartDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~UninterpretedOption_NamePartDefaultTypeInternal() {} + union { + UninterpretedOption_NamePart _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +constexpr UninterpretedOption::UninterpretedOption( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : name_() + , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , string_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , positive_int_value_(PROTOBUF_ULONGLONG(0)) + , negative_int_value_(PROTOBUF_LONGLONG(0)) + , double_value_(0){} +struct UninterpretedOptionDefaultTypeInternal { + constexpr UninterpretedOptionDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~UninterpretedOptionDefaultTypeInternal() {} + union { + UninterpretedOption _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +constexpr SourceCodeInfo_Location::SourceCodeInfo_Location( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : path_() + , _path_cached_byte_size_() + , span_() + , _span_cached_byte_size_() + , leading_detached_comments_() + , leading_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , trailing_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +struct SourceCodeInfo_LocationDefaultTypeInternal { + constexpr SourceCodeInfo_LocationDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~SourceCodeInfo_LocationDefaultTypeInternal() {} + union { + SourceCodeInfo_Location _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +constexpr SourceCodeInfo::SourceCodeInfo( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : location_(){} +struct SourceCodeInfoDefaultTypeInternal { + constexpr SourceCodeInfoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~SourceCodeInfoDefaultTypeInternal() {} + union { + SourceCodeInfo _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : path_() + , _path_cached_byte_size_() + , source_file_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) + , begin_(0) + , end_(0){} +struct GeneratedCodeInfo_AnnotationDefaultTypeInternal { + constexpr GeneratedCodeInfo_AnnotationDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {} + union { + GeneratedCodeInfo_Annotation _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +constexpr GeneratedCodeInfo::GeneratedCodeInfo( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : annotation_(){} +struct GeneratedCodeInfoDefaultTypeInternal { + constexpr GeneratedCodeInfoDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~GeneratedCodeInfoDefaultTypeInternal() {} + union { + GeneratedCodeInfo _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, 0, InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; - -static void InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; - -static void InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::EnumOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::EnumValueOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FieldDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FieldOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, 0, InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FileDescriptorSet(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FileOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto}, {}}; - -static void InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::MessageOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::MethodDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::MethodOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::OneofDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::OneofOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::ServiceOptions(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto}, {}}; - -static void InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto}, { - &scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base,}}; - -static void InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; @@ -1136,44 +1048,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "rg/protobuf/types/descriptorpb\370\001\001\242\002\003GPB\252" "\002\032Google.Protobuf.Reflection" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_sccs[27] = { - &scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base, - &scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", 6028, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_sccs, descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_deps, 27, 0, + false, false, 6028, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, 27, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); + return descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); @@ -1368,7 +1254,6 @@ FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) } void FileDescriptorSet::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto.base); } FileDescriptorSet::~FileDescriptorSet() { @@ -1390,11 +1275,6 @@ void FileDescriptorSet::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FileDescriptorSet::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FileDescriptorSet& FileDescriptorSet::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) @@ -1633,14 +1513,13 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) } void FileDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&options_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&source_code_info_) - - reinterpret_cast(&options_)) + sizeof(source_code_info_)); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&options_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&source_code_info_) - + reinterpret_cast(&options_)) + sizeof(source_code_info_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1667,11 +1546,6 @@ void FileDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FileDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FileDescriptorProto& FileDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void FileDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto) @@ -2250,11 +2124,10 @@ DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorP } void DescriptorProto_ExtensionRange::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&options_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&end_) - - reinterpret_cast(&options_)) + sizeof(end_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&options_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&end_) - + reinterpret_cast(&options_)) + sizeof(end_)); } DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { @@ -2277,11 +2150,6 @@ void DescriptorProto_ExtensionRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID:: void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { _cached_size_.Set(size); } -const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void DescriptorProto_ExtensionRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange) @@ -2538,10 +2406,10 @@ DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorPro } void DescriptorProto_ReservedRange::SharedCtor() { - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&start_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&end_) - - reinterpret_cast(&start_)) + sizeof(end_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&start_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&end_) - + reinterpret_cast(&start_)) + sizeof(end_)); } DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { @@ -2563,11 +2431,6 @@ void DescriptorProto_ReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::A void DescriptorProto_ReservedRange::SetCachedSize(int size) const { _cached_size_.Set(size); } -const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void DescriptorProto_ReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange) @@ -2820,9 +2683,8 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from) } void DescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - options_ = nullptr; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +options_ = nullptr; } DescriptorProto::~DescriptorProto() { @@ -2846,11 +2708,6 @@ void DescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void DescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const DescriptorProto& DescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void DescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto) @@ -3331,7 +3188,6 @@ ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from) } void ExtensionRangeOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base); } ExtensionRangeOptions::~ExtensionRangeOptions() { @@ -3353,11 +3209,6 @@ void ExtensionRangeOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void ExtensionRangeOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const ExtensionRangeOptions& ExtensionRangeOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void ExtensionRangeOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions) @@ -3622,18 +3473,17 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) } void FieldDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&options_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&proto3_optional_) - - reinterpret_cast(&options_)) + sizeof(proto3_optional_)); - label_ = 1; - type_ = 1; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&options_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&proto3_optional_) - + reinterpret_cast(&options_)) + sizeof(proto3_optional_)); +label_ = 1; +type_ = 1; } FieldDescriptorProto::~FieldDescriptorProto() { @@ -3661,11 +3511,6 @@ void FieldDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FieldDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) @@ -4201,9 +4046,8 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) } void OneofDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - options_ = nullptr; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +options_ = nullptr; } OneofDescriptorProto::~OneofDescriptorProto() { @@ -4227,11 +4071,6 @@ void OneofDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void OneofDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const OneofDescriptorProto& OneofDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void OneofDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto) @@ -4466,10 +4305,10 @@ EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(con } void EnumDescriptorProto_EnumReservedRange::SharedCtor() { - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&start_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&end_) - - reinterpret_cast(&start_)) + sizeof(end_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&start_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&end_) - + reinterpret_cast(&start_)) + sizeof(end_)); } EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() { @@ -4491,11 +4330,6 @@ void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPA void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const { _cached_size_.Set(size); } -const EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto_EnumReservedRange::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void EnumDescriptorProto_EnumReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) @@ -4738,9 +4572,8 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) } void EnumDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - options_ = nullptr; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +options_ = nullptr; } EnumDescriptorProto::~EnumDescriptorProto() { @@ -4764,11 +4597,6 @@ void EnumDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void EnumDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void EnumDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto) @@ -5117,12 +4945,11 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt } void EnumValueDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&options_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&number_) - - reinterpret_cast(&options_)) + sizeof(number_)); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&options_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&number_) - + reinterpret_cast(&options_)) + sizeof(number_)); } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -5146,11 +4973,6 @@ void EnumValueDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* void EnumValueDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void EnumValueDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto) @@ -5430,9 +5252,8 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro } void ServiceDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - options_ = nullptr; +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +options_ = nullptr; } ServiceDescriptorProto::~ServiceDescriptorProto() { @@ -5456,11 +5277,6 @@ void ServiceDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) void ServiceDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void ServiceDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto) @@ -5763,14 +5579,13 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) } void MethodDescriptorProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&options_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&server_streaming_) - - reinterpret_cast(&options_)) + sizeof(server_streaming_)); +name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&options_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&server_streaming_) - + reinterpret_cast(&options_)) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -5796,11 +5611,6 @@ void MethodDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void MethodDescriptorProto::SetCachedSize(int size) const { _cached_size_.Set(size); } -const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void MethodDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto) @@ -6266,23 +6076,22 @@ FileOptions::FileOptions(const FileOptions& from) } void FileOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&java_multiple_files_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&deprecated_) - - reinterpret_cast(&java_multiple_files_)) + sizeof(deprecated_)); - optimize_for_ = 1; - cc_enable_arenas_ = true; +java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&java_multiple_files_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&deprecated_) - + reinterpret_cast(&java_multiple_files_)) + sizeof(deprecated_)); +optimize_for_ = 1; +cc_enable_arenas_ = true; } FileOptions::~FileOptions() { @@ -6314,11 +6123,6 @@ void FileOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FileOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FileOptions& FileOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) @@ -7153,11 +6957,10 @@ MessageOptions::MessageOptions(const MessageOptions& from) } void MessageOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&message_set_wire_format_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&map_entry_) - - reinterpret_cast(&message_set_wire_format_)) + sizeof(map_entry_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&message_set_wire_format_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&map_entry_) - + reinterpret_cast(&message_set_wire_format_)) + sizeof(map_entry_)); } MessageOptions::~MessageOptions() { @@ -7179,11 +6982,6 @@ void MessageOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void MessageOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const MessageOptions& MessageOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void MessageOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions) @@ -7511,11 +7309,10 @@ FieldOptions::FieldOptions(const FieldOptions& from) } void FieldOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&ctype_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&jstype_) - - reinterpret_cast(&ctype_)) + sizeof(jstype_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&ctype_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&jstype_) - + reinterpret_cast(&ctype_)) + sizeof(jstype_)); } FieldOptions::~FieldOptions() { @@ -7537,11 +7334,6 @@ void FieldOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FieldOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FieldOptions& FieldOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void FieldOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions) @@ -7905,7 +7697,6 @@ OneofOptions::OneofOptions(const OneofOptions& from) } void OneofOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base); } OneofOptions::~OneofOptions() { @@ -7927,11 +7718,6 @@ void OneofOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void OneofOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const OneofOptions& OneofOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void OneofOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions) @@ -8138,11 +7924,10 @@ EnumOptions::EnumOptions(const EnumOptions& from) } void EnumOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&allow_alias_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&deprecated_) - - reinterpret_cast(&allow_alias_)) + sizeof(deprecated_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&allow_alias_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&deprecated_) - + reinterpret_cast(&allow_alias_)) + sizeof(deprecated_)); } EnumOptions::~EnumOptions() { @@ -8164,11 +7949,6 @@ void EnumOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void EnumOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const EnumOptions& EnumOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void EnumOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions) @@ -8435,8 +8215,7 @@ EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) } void EnumValueOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - deprecated_ = false; +deprecated_ = false; } EnumValueOptions::~EnumValueOptions() { @@ -8458,11 +8237,6 @@ void EnumValueOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void EnumValueOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const EnumValueOptions& EnumValueOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void EnumValueOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions) @@ -8694,8 +8468,7 @@ ServiceOptions::ServiceOptions(const ServiceOptions& from) } void ServiceOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - deprecated_ = false; +deprecated_ = false; } ServiceOptions::~ServiceOptions() { @@ -8717,11 +8490,6 @@ void ServiceOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void ServiceOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const ServiceOptions& ServiceOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void ServiceOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions) @@ -8958,11 +8726,10 @@ MethodOptions::MethodOptions(const MethodOptions& from) } void MethodOptions::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&deprecated_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&idempotency_level_) - - reinterpret_cast(&deprecated_)) + sizeof(idempotency_level_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&deprecated_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&idempotency_level_) - + reinterpret_cast(&deprecated_)) + sizeof(idempotency_level_)); } MethodOptions::~MethodOptions() { @@ -8984,11 +8751,6 @@ void MethodOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void MethodOptions::SetCachedSize(int size) const { _cached_size_.Set(size); } -const MethodOptions& MethodOptions::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void MethodOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions) @@ -9271,9 +9033,8 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp } void UninterpretedOption_NamePart::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base); - name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - is_extension_ = false; +name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +is_extension_ = false; } UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { @@ -9296,11 +9057,6 @@ void UninterpretedOption_NamePart::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Ar void UninterpretedOption_NamePart::SetCachedSize(int size) const { _cached_size_.Set(size); } -const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void UninterpretedOption_NamePart::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart) @@ -9570,14 +9326,13 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) } void UninterpretedOption::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base); - identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&positive_int_value_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&double_value_) - - reinterpret_cast(&positive_int_value_)) + sizeof(double_value_)); +identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&positive_int_value_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&double_value_) - + reinterpret_cast(&positive_int_value_)) + sizeof(double_value_)); } UninterpretedOption::~UninterpretedOption() { @@ -9602,11 +9357,6 @@ void UninterpretedOption::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void UninterpretedOption::SetCachedSize(int size) const { _cached_size_.Set(size); } -const UninterpretedOption& UninterpretedOption::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void UninterpretedOption::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption) @@ -9997,9 +9747,8 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& } void SourceCodeInfo_Location::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base); - leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } SourceCodeInfo_Location::~SourceCodeInfo_Location() { @@ -10023,11 +9772,6 @@ void SourceCodeInfo_Location::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) void SourceCodeInfo_Location::SetCachedSize(int size) const { _cached_size_.Set(size); } -const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void SourceCodeInfo_Location::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location) @@ -10366,7 +10110,6 @@ SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) } void SourceCodeInfo::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base); } SourceCodeInfo::~SourceCodeInfo() { @@ -10388,11 +10131,6 @@ void SourceCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void SourceCodeInfo::SetCachedSize(int size) const { _cached_size_.Set(size); } -const SourceCodeInfo& SourceCodeInfo::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void SourceCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) @@ -10585,12 +10323,11 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn } void GeneratedCodeInfo_Annotation::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base); - source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&begin_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&end_) - - reinterpret_cast(&begin_)) + sizeof(end_)); +source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&begin_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&end_) - + reinterpret_cast(&begin_)) + sizeof(end_)); } GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { @@ -10613,11 +10350,6 @@ void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Ar void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { _cached_size_.Set(size); } -const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void GeneratedCodeInfo_Annotation::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation) @@ -10905,7 +10637,6 @@ GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) } void GeneratedCodeInfo::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base); } GeneratedCodeInfo::~GeneratedCodeInfo() { @@ -10927,11 +10658,6 @@ void GeneratedCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void GeneratedCodeInfo::SetCachedSize(int size) const { _cached_size_.Set(size); } -const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto.base); - return *internal_default_instance(); -} - void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 381eedeabf5c..cd4caa53aaf8 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -54,87 +54,88 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class DescriptorProto; -class DescriptorProtoDefaultTypeInternal; +struct DescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; class DescriptorProto_ExtensionRange; -class DescriptorProto_ExtensionRangeDefaultTypeInternal; +struct DescriptorProto_ExtensionRangeDefaultTypeInternal; PROTOBUF_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; class DescriptorProto_ReservedRange; -class DescriptorProto_ReservedRangeDefaultTypeInternal; +struct DescriptorProto_ReservedRangeDefaultTypeInternal; PROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; class EnumDescriptorProto; -class EnumDescriptorProtoDefaultTypeInternal; +struct EnumDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; class EnumDescriptorProto_EnumReservedRange; -class EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal; +struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal; PROTOBUF_EXPORT extern EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; class EnumOptions; -class EnumOptionsDefaultTypeInternal; +struct EnumOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; class EnumValueDescriptorProto; -class EnumValueDescriptorProtoDefaultTypeInternal; +struct EnumValueDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; class EnumValueOptions; -class EnumValueOptionsDefaultTypeInternal; +struct EnumValueOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; class ExtensionRangeOptions; -class ExtensionRangeOptionsDefaultTypeInternal; +struct ExtensionRangeOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; class FieldDescriptorProto; -class FieldDescriptorProtoDefaultTypeInternal; +struct FieldDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; class FieldOptions; -class FieldOptionsDefaultTypeInternal; +struct FieldOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; class FileDescriptorProto; -class FileDescriptorProtoDefaultTypeInternal; +struct FileDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; class FileDescriptorSet; -class FileDescriptorSetDefaultTypeInternal; +struct FileDescriptorSetDefaultTypeInternal; PROTOBUF_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; class FileOptions; -class FileOptionsDefaultTypeInternal; +struct FileOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; class GeneratedCodeInfo; -class GeneratedCodeInfoDefaultTypeInternal; +struct GeneratedCodeInfoDefaultTypeInternal; PROTOBUF_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; class GeneratedCodeInfo_Annotation; -class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +struct GeneratedCodeInfo_AnnotationDefaultTypeInternal; PROTOBUF_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; class MessageOptions; -class MessageOptionsDefaultTypeInternal; +struct MessageOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; class MethodDescriptorProto; -class MethodDescriptorProtoDefaultTypeInternal; +struct MethodDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; class MethodOptions; -class MethodOptionsDefaultTypeInternal; +struct MethodOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; class OneofDescriptorProto; -class OneofDescriptorProtoDefaultTypeInternal; +struct OneofDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; class OneofOptions; -class OneofOptionsDefaultTypeInternal; +struct OneofOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; class ServiceDescriptorProto; -class ServiceDescriptorProtoDefaultTypeInternal; +struct ServiceDescriptorProtoDefaultTypeInternal; PROTOBUF_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; class ServiceOptions; -class ServiceOptionsDefaultTypeInternal; +struct ServiceOptionsDefaultTypeInternal; PROTOBUF_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; class SourceCodeInfo; -class SourceCodeInfoDefaultTypeInternal; +struct SourceCodeInfoDefaultTypeInternal; PROTOBUF_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; class SourceCodeInfo_Location; -class SourceCodeInfo_LocationDefaultTypeInternal; +struct SourceCodeInfo_LocationDefaultTypeInternal; PROTOBUF_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; class UninterpretedOption; -class UninterpretedOptionDefaultTypeInternal; +struct UninterpretedOptionDefaultTypeInternal; PROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; class UninterpretedOption_NamePart; -class UninterpretedOption_NamePartDefaultTypeInternal; +struct UninterpretedOption_NamePartDefaultTypeInternal; PROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -334,6 +335,7 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : public: inline FileDescriptorSet() : FileDescriptorSet(nullptr) {} virtual ~FileDescriptorSet(); + explicit constexpr FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorSet(const FileDescriptorSet& from); FileDescriptorSet(FileDescriptorSet&& from) noexcept @@ -370,8 +372,9 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FileDescriptorSet& default_instance(); - + static const FileDescriptorSet& default_instance() { + return *internal_default_instance(); + } static inline const FileDescriptorSet* internal_default_instance() { return reinterpret_cast( &_FileDescriptorSet_default_instance_); @@ -437,8 +440,7 @@ class PROTOBUF_EXPORT FileDescriptorSet PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -486,6 +488,7 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : public: inline FileDescriptorProto() : FileDescriptorProto(nullptr) {} virtual ~FileDescriptorProto(); + explicit constexpr FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorProto(const FileDescriptorProto& from); FileDescriptorProto(FileDescriptorProto&& from) noexcept @@ -522,8 +525,9 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FileDescriptorProto& default_instance(); - + static const FileDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const FileDescriptorProto* internal_default_instance() { return reinterpret_cast( &_FileDescriptorProto_default_instance_); @@ -589,8 +593,7 @@ class PROTOBUF_EXPORT FileDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -879,6 +882,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : public: inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {} virtual ~DescriptorProto_ExtensionRange(); + explicit constexpr DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from); DescriptorProto_ExtensionRange(DescriptorProto_ExtensionRange&& from) noexcept @@ -915,8 +919,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const DescriptorProto_ExtensionRange& default_instance(); - + static const DescriptorProto_ExtensionRange& default_instance() { + return *internal_default_instance(); + } static inline const DescriptorProto_ExtensionRange* internal_default_instance() { return reinterpret_cast( &_DescriptorProto_ExtensionRange_default_instance_); @@ -982,8 +987,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -1062,6 +1066,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : public: inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {} virtual ~DescriptorProto_ReservedRange(); + explicit constexpr DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from); DescriptorProto_ReservedRange(DescriptorProto_ReservedRange&& from) noexcept @@ -1098,8 +1103,9 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const DescriptorProto_ReservedRange& default_instance(); - + static const DescriptorProto_ReservedRange& default_instance() { + return *internal_default_instance(); + } static inline const DescriptorProto_ReservedRange* internal_default_instance() { return reinterpret_cast( &_DescriptorProto_ReservedRange_default_instance_); @@ -1165,8 +1171,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -1225,6 +1230,7 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : public: inline DescriptorProto() : DescriptorProto(nullptr) {} virtual ~DescriptorProto(); + explicit constexpr DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto(const DescriptorProto& from); DescriptorProto(DescriptorProto&& from) noexcept @@ -1261,8 +1267,9 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const DescriptorProto& default_instance(); - + static const DescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const DescriptorProto* internal_default_instance() { return reinterpret_cast( &_DescriptorProto_default_instance_); @@ -1328,8 +1335,7 @@ class PROTOBUF_EXPORT DescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -1569,6 +1575,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : public: inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {} virtual ~ExtensionRangeOptions(); + explicit constexpr ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ExtensionRangeOptions(const ExtensionRangeOptions& from); ExtensionRangeOptions(ExtensionRangeOptions&& from) noexcept @@ -1605,8 +1612,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const ExtensionRangeOptions& default_instance(); - + static const ExtensionRangeOptions& default_instance() { + return *internal_default_instance(); + } static inline const ExtensionRangeOptions* internal_default_instance() { return reinterpret_cast( &_ExtensionRangeOptions_default_instance_); @@ -1672,8 +1680,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -1724,6 +1731,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : public: inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {} virtual ~FieldDescriptorProto(); + explicit constexpr FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldDescriptorProto(const FieldDescriptorProto& from); FieldDescriptorProto(FieldDescriptorProto&& from) noexcept @@ -1760,8 +1768,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FieldDescriptorProto& default_instance(); - + static const FieldDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const FieldDescriptorProto* internal_default_instance() { return reinterpret_cast( &_FieldDescriptorProto_default_instance_); @@ -1827,8 +1836,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -2156,6 +2164,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : public: inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {} virtual ~OneofDescriptorProto(); + explicit constexpr OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofDescriptorProto(const OneofDescriptorProto& from); OneofDescriptorProto(OneofDescriptorProto&& from) noexcept @@ -2192,8 +2201,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const OneofDescriptorProto& default_instance(); - + static const OneofDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const OneofDescriptorProto* internal_default_instance() { return reinterpret_cast( &_OneofDescriptorProto_default_instance_); @@ -2259,8 +2269,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -2331,6 +2340,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : public: inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {} virtual ~EnumDescriptorProto_EnumReservedRange(); + explicit constexpr EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from); EnumDescriptorProto_EnumReservedRange(EnumDescriptorProto_EnumReservedRange&& from) noexcept @@ -2367,8 +2377,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const EnumDescriptorProto_EnumReservedRange& default_instance(); - + static const EnumDescriptorProto_EnumReservedRange& default_instance() { + return *internal_default_instance(); + } static inline const EnumDescriptorProto_EnumReservedRange* internal_default_instance() { return reinterpret_cast( &_EnumDescriptorProto_EnumReservedRange_default_instance_); @@ -2434,8 +2445,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -2494,6 +2504,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : public: inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {} virtual ~EnumDescriptorProto(); + explicit constexpr EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto(const EnumDescriptorProto& from); EnumDescriptorProto(EnumDescriptorProto&& from) noexcept @@ -2530,8 +2541,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const EnumDescriptorProto& default_instance(); - + static const EnumDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const EnumDescriptorProto* internal_default_instance() { return reinterpret_cast( &_EnumDescriptorProto_default_instance_); @@ -2597,8 +2609,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -2737,6 +2748,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : public: inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {} virtual ~EnumValueDescriptorProto(); + explicit constexpr EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueDescriptorProto(const EnumValueDescriptorProto& from); EnumValueDescriptorProto(EnumValueDescriptorProto&& from) noexcept @@ -2773,8 +2785,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const EnumValueDescriptorProto& default_instance(); - + static const EnumValueDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const EnumValueDescriptorProto* internal_default_instance() { return reinterpret_cast( &_EnumValueDescriptorProto_default_instance_); @@ -2840,8 +2853,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -2927,6 +2939,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : public: inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {} virtual ~ServiceDescriptorProto(); + explicit constexpr ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceDescriptorProto(const ServiceDescriptorProto& from); ServiceDescriptorProto(ServiceDescriptorProto&& from) noexcept @@ -2963,8 +2976,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const ServiceDescriptorProto& default_instance(); - + static const ServiceDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const ServiceDescriptorProto* internal_default_instance() { return reinterpret_cast( &_ServiceDescriptorProto_default_instance_); @@ -3030,8 +3044,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -3122,6 +3135,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : public: inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {} virtual ~MethodDescriptorProto(); + explicit constexpr MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodDescriptorProto(const MethodDescriptorProto& from); MethodDescriptorProto(MethodDescriptorProto&& from) noexcept @@ -3158,8 +3172,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const MethodDescriptorProto& default_instance(); - + static const MethodDescriptorProto& default_instance() { + return *internal_default_instance(); + } static inline const MethodDescriptorProto* internal_default_instance() { return reinterpret_cast( &_MethodDescriptorProto_default_instance_); @@ -3225,8 +3240,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -3371,6 +3385,7 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : public: inline FileOptions() : FileOptions(nullptr) {} virtual ~FileOptions(); + explicit constexpr FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileOptions(const FileOptions& from); FileOptions(FileOptions&& from) noexcept @@ -3407,8 +3422,9 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FileOptions& default_instance(); - + static const FileOptions& default_instance() { + return *internal_default_instance(); + } static inline const FileOptions* internal_default_instance() { return reinterpret_cast( &_FileOptions_default_instance_); @@ -3474,8 +3490,7 @@ class PROTOBUF_EXPORT FileOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -3929,6 +3944,7 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : public: inline MessageOptions() : MessageOptions(nullptr) {} virtual ~MessageOptions(); + explicit constexpr MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MessageOptions(const MessageOptions& from); MessageOptions(MessageOptions&& from) noexcept @@ -3965,8 +3981,9 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const MessageOptions& default_instance(); - + static const MessageOptions& default_instance() { + return *internal_default_instance(); + } static inline const MessageOptions* internal_default_instance() { return reinterpret_cast( &_MessageOptions_default_instance_); @@ -4032,8 +4049,7 @@ class PROTOBUF_EXPORT MessageOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -4145,6 +4161,7 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : public: inline FieldOptions() : FieldOptions(nullptr) {} virtual ~FieldOptions(); + explicit constexpr FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldOptions(const FieldOptions& from); FieldOptions(FieldOptions&& from) noexcept @@ -4181,8 +4198,9 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FieldOptions& default_instance(); - + static const FieldOptions& default_instance() { + return *internal_default_instance(); + } static inline const FieldOptions* internal_default_instance() { return reinterpret_cast( &_FieldOptions_default_instance_); @@ -4248,8 +4266,7 @@ class PROTOBUF_EXPORT FieldOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -4455,6 +4472,7 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : public: inline OneofOptions() : OneofOptions(nullptr) {} virtual ~OneofOptions(); + explicit constexpr OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofOptions(const OneofOptions& from); OneofOptions(OneofOptions&& from) noexcept @@ -4491,8 +4509,9 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const OneofOptions& default_instance(); - + static const OneofOptions& default_instance() { + return *internal_default_instance(); + } static inline const OneofOptions* internal_default_instance() { return reinterpret_cast( &_OneofOptions_default_instance_); @@ -4558,8 +4577,7 @@ class PROTOBUF_EXPORT OneofOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -4610,6 +4628,7 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : public: inline EnumOptions() : EnumOptions(nullptr) {} virtual ~EnumOptions(); + explicit constexpr EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumOptions(const EnumOptions& from); EnumOptions(EnumOptions&& from) noexcept @@ -4646,8 +4665,9 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const EnumOptions& default_instance(); - + static const EnumOptions& default_instance() { + return *internal_default_instance(); + } static inline const EnumOptions* internal_default_instance() { return reinterpret_cast( &_EnumOptions_default_instance_); @@ -4713,8 +4733,7 @@ class PROTOBUF_EXPORT EnumOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -4796,6 +4815,7 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : public: inline EnumValueOptions() : EnumValueOptions(nullptr) {} virtual ~EnumValueOptions(); + explicit constexpr EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueOptions(const EnumValueOptions& from); EnumValueOptions(EnumValueOptions&& from) noexcept @@ -4832,8 +4852,9 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const EnumValueOptions& default_instance(); - + static const EnumValueOptions& default_instance() { + return *internal_default_instance(); + } static inline const EnumValueOptions* internal_default_instance() { return reinterpret_cast( &_EnumValueOptions_default_instance_); @@ -4899,8 +4920,7 @@ class PROTOBUF_EXPORT EnumValueOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -4967,6 +4987,7 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : public: inline ServiceOptions() : ServiceOptions(nullptr) {} virtual ~ServiceOptions(); + explicit constexpr ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceOptions(const ServiceOptions& from); ServiceOptions(ServiceOptions&& from) noexcept @@ -5003,8 +5024,9 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const ServiceOptions& default_instance(); - + static const ServiceOptions& default_instance() { + return *internal_default_instance(); + } static inline const ServiceOptions* internal_default_instance() { return reinterpret_cast( &_ServiceOptions_default_instance_); @@ -5070,8 +5092,7 @@ class PROTOBUF_EXPORT ServiceOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -5138,6 +5159,7 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : public: inline MethodOptions() : MethodOptions(nullptr) {} virtual ~MethodOptions(); + explicit constexpr MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodOptions(const MethodOptions& from); MethodOptions(MethodOptions&& from) noexcept @@ -5174,8 +5196,9 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const MethodOptions& default_instance(); - + static const MethodOptions& default_instance() { + return *internal_default_instance(); + } static inline const MethodOptions* internal_default_instance() { return reinterpret_cast( &_MethodOptions_default_instance_); @@ -5241,8 +5264,7 @@ class PROTOBUF_EXPORT MethodOptions PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -5356,6 +5378,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : public: inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {} virtual ~UninterpretedOption_NamePart(); + explicit constexpr UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from); UninterpretedOption_NamePart(UninterpretedOption_NamePart&& from) noexcept @@ -5392,8 +5415,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const UninterpretedOption_NamePart& default_instance(); - + static const UninterpretedOption_NamePart& default_instance() { + return *internal_default_instance(); + } static inline const UninterpretedOption_NamePart* internal_default_instance() { return reinterpret_cast( &_UninterpretedOption_NamePart_default_instance_); @@ -5459,8 +5483,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -5529,6 +5552,7 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : public: inline UninterpretedOption() : UninterpretedOption(nullptr) {} virtual ~UninterpretedOption(); + explicit constexpr UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption(const UninterpretedOption& from); UninterpretedOption(UninterpretedOption&& from) noexcept @@ -5565,8 +5589,9 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const UninterpretedOption& default_instance(); - + static const UninterpretedOption& default_instance() { + return *internal_default_instance(); + } static inline const UninterpretedOption* internal_default_instance() { return reinterpret_cast( &_UninterpretedOption_default_instance_); @@ -5632,8 +5657,7 @@ class PROTOBUF_EXPORT UninterpretedOption PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -5795,6 +5819,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : public: inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {} virtual ~SourceCodeInfo_Location(); + explicit constexpr SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo_Location(const SourceCodeInfo_Location& from); SourceCodeInfo_Location(SourceCodeInfo_Location&& from) noexcept @@ -5831,8 +5856,9 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const SourceCodeInfo_Location& default_instance(); - + static const SourceCodeInfo_Location& default_instance() { + return *internal_default_instance(); + } static inline const SourceCodeInfo_Location* internal_default_instance() { return reinterpret_cast( &_SourceCodeInfo_Location_default_instance_); @@ -5898,8 +5924,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -6048,6 +6073,7 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : public: inline SourceCodeInfo() : SourceCodeInfo(nullptr) {} virtual ~SourceCodeInfo(); + explicit constexpr SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo(const SourceCodeInfo& from); SourceCodeInfo(SourceCodeInfo&& from) noexcept @@ -6084,8 +6110,9 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const SourceCodeInfo& default_instance(); - + static const SourceCodeInfo& default_instance() { + return *internal_default_instance(); + } static inline const SourceCodeInfo* internal_default_instance() { return reinterpret_cast( &_SourceCodeInfo_default_instance_); @@ -6151,8 +6178,7 @@ class PROTOBUF_EXPORT SourceCodeInfo PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -6202,6 +6228,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : public: inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {} virtual ~GeneratedCodeInfo_Annotation(); + explicit constexpr GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from); GeneratedCodeInfo_Annotation(GeneratedCodeInfo_Annotation&& from) noexcept @@ -6238,8 +6265,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const GeneratedCodeInfo_Annotation& default_instance(); - + static const GeneratedCodeInfo_Annotation& default_instance() { + return *internal_default_instance(); + } static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { return reinterpret_cast( &_GeneratedCodeInfo_Annotation_default_instance_); @@ -6305,8 +6333,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -6412,6 +6439,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : public: inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {} virtual ~GeneratedCodeInfo(); + explicit constexpr GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo(const GeneratedCodeInfo& from); GeneratedCodeInfo(GeneratedCodeInfo&& from) noexcept @@ -6448,8 +6476,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const GeneratedCodeInfo& default_instance(); - + static const GeneratedCodeInfo& default_instance() { + return *internal_default_instance(); + } static inline const GeneratedCodeInfo* internal_default_instance() { return reinterpret_cast( &_GeneratedCodeInfo_default_instance_); @@ -6515,8 +6544,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); - return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 2521d92c0ae3..b454ed5ad1c1 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -3816,6 +3816,45 @@ TEST_F(ValidationErrorTest, InvalidPackageName) { "foo.proto: foo.$: NAME: \"$\" is not a valid identifier.\n"); } +// 'str' is a static C-style string that may contain '\0' +#define STATIC_STR(str) std::string((str), sizeof(str) - 1) + +TEST_F(ValidationErrorTest, NullCharSymbolName) { + BuildFileWithErrors( + "name: \"bar.proto\" " + "package: \"foo\"" + "message_type { " + " name: '\\000\\001\\013.Bar' " + " field { name: \"foo\" number: 9 label:LABEL_OPTIONAL type:TYPE_INT32 " + "} " + "}", + STATIC_STR("bar.proto: foo.\0\x1\v.Bar: NAME: \"\0\x1\v.Bar\" is not a " + "valid identifier.\nbar.proto: foo.\0\x1\v.Bar: NAME: " + "\"\0\x1\v.Bar\" is not a valid identifier.\nbar.proto: " + "foo.\0\x1\v.Bar: NAME: \"\0\x1\v.Bar\" is not a valid " + "identifier.\nbar.proto: foo.\0\x1\v.Bar: NAME: " + "\"\0\x1\v.Bar\" is not a valid identifier.\nbar.proto: " + "foo.\0\x1\v.Bar.foo: NAME: \"foo.\0\x1\v.Bar.foo\" contains " + "null character.\nbar.proto: foo.\0\x1\v.Bar: NAME: " + "\"foo.\0\x1\v.Bar\" contains null character.\n")); +} + +TEST_F(ValidationErrorTest, NullCharFileName) { + BuildFileWithErrors( + "name: \"bar\\000\\001\\013.proto\" " + "package: \"outer.foo\"", + STATIC_STR("bar\0\x1\v.proto: bar\0\x1\v.proto: NAME: " + "\"bar\0\x1\v.proto\" contains null character.\n")); +} + +TEST_F(ValidationErrorTest, NullCharPackageName) { + BuildFileWithErrors( + "name: \"bar.proto\" " + "package: \"\\000\\001\\013.\"", + STATIC_STR("bar.proto: \0\x1\v.: NAME: \"\0\x1\v.\" contains null " + "character.\n")); +} + TEST_F(ValidationErrorTest, MissingFileName) { BuildFileWithErrors("", @@ -4031,6 +4070,32 @@ TEST_F(ValidationErrorTest, ReservedFieldsDebugString) { file->DebugString()); } +TEST_F(ValidationErrorTest, DebugStringReservedRangeMax) { + const FileDescriptor* file = BuildFile(strings::Substitute( + "name: \"foo.proto\" " + "enum_type { " + " name: \"Bar\"" + " value { name:\"BAR\" number:1 }" + " reserved_range { start: 5 end: $0 }" + "}" + "message_type {" + " name: \"Foo\"" + " reserved_range { start: 5 end: $1 }" + "}", + std::numeric_limits::max(), FieldDescriptor::kMaxNumber + 1)); + + ASSERT_EQ( + "syntax = \"proto2\";\n\n" + "enum Bar {\n" + " BAR = 1;\n" + " reserved 5 to max;\n" + "}\n\n" + "message Foo {\n" + " reserved 5 to max;\n" + "}\n\n", + file->DebugString()); +} + TEST_F(ValidationErrorTest, EnumReservedFieldError) { BuildFileWithErrors( "name: \"foo.proto\" " diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 87f54dff38b7..d7e4e0035aa1 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -17,24 +17,20 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class DurationDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Duration_default_instance_; +constexpr Duration::Duration( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : seconds_(PROTOBUF_LONGLONG(0)) + , nanos_(0){} +struct DurationDefaultTypeInternal { + constexpr DurationDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~DurationDefaultTypeInternal() {} + union { + Duration _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY DurationDefaultTypeInternal _Duration_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Duration_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Duration(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; @@ -64,18 +60,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROT "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo" "gle.Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fduration_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fduration_2eproto_sccs[1] = { - &scc_info_Duration_google_2fprotobuf_2fduration_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", 235, - &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, descriptor_table_google_2fprotobuf_2fduration_2eproto_sccs, descriptor_table_google_2fprotobuf_2fduration_2eproto_deps, 1, 0, + false, false, 235, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", + &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fduration_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, + file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fduration_2eproto); + return descriptor_table_google_2fprotobuf_2fduration_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fduration_2eproto(&descriptor_table_google_2fprotobuf_2fduration_2eproto); @@ -103,10 +99,10 @@ Duration::Duration(const Duration& from) } void Duration::SharedCtor() { - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&seconds_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&nanos_) - - reinterpret_cast(&seconds_)) + sizeof(nanos_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&seconds_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&nanos_) - + reinterpret_cast(&seconds_)) + sizeof(nanos_)); } Duration::~Duration() { @@ -128,11 +124,6 @@ void Duration::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Duration::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Duration& Duration::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Duration_google_2fprotobuf_2fduration_2eproto.base); - return *internal_default_instance(); -} - void Duration::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Duration) diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index ec648a4d4e87..2065a85bb829 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Duration; -class DurationDefaultTypeInternal; +struct DurationDefaultTypeInternal; PROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : public: inline Duration() : Duration(nullptr) {} virtual ~Duration(); + explicit constexpr Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Duration(const Duration& from); Duration(Duration&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Duration& default_instance(); - + static const Duration& default_instance() { + return *internal_default_instance(); + } static inline const Duration* internal_default_instance() { return reinterpret_cast( &_Duration_default_instance_); @@ -166,8 +169,7 @@ class PROTOBUF_EXPORT Duration PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fduration_2eproto); - return ::descriptor_table_google_2fprotobuf_2fduration_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fduration_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 3a484941d68e..0a52804c354c 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -256,38 +257,10 @@ inline int AlignOffset(int offset) { return AlignTo(offset, kSafeAlignment); } class DynamicMessage : public Message { public: - struct TypeInfo { - int size; - int has_bits_offset; - int oneof_case_offset; - int extensions_offset; - - // Not owned by the TypeInfo. - DynamicMessageFactory* factory; // The factory that created this object. - const DescriptorPool* pool; // The factory's DescriptorPool. - const Descriptor* type; // Type of this DynamicMessage. - - // Warning: The order in which the following pointers are defined is - // important (the prototype must be deleted *before* the offsets). - std::unique_ptr offsets; - std::unique_ptr has_bits_indices; - std::unique_ptr reflection; - // Don't use a unique_ptr to hold the prototype: the destructor for - // DynamicMessage needs to know whether it is the prototype, and does so by - // looking back at this field. This would assume details about the - // implementation of unique_ptr. - const DynamicMessage* prototype; - int weak_field_map_offset; // The offset for the weak_field_map; - - TypeInfo() : prototype(NULL) {} - - ~TypeInfo() { delete prototype; } - }; - - DynamicMessage(const TypeInfo* type_info); + explicit DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info); // This should only be used by GetPrototypeNoLock() to avoid dead lock. - DynamicMessage(TypeInfo* type_info, bool lock_factory); + DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory); ~DynamicMessage(); @@ -311,6 +284,9 @@ class DynamicMessage : public Message { Metadata GetMetadata() const override; +#if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation) + static void operator delete(DynamicMessage* msg, std::destroying_delete_t); +#else // We actually allocate more memory than sizeof(*this) when this // class's memory is allocated via the global operator new. Thus, we need to // manually call the global operator delete. Calling the destructor is taken @@ -319,21 +295,18 @@ class DynamicMessage : public Message { #ifndef _MSC_VER static void operator delete(void* ptr) { ::operator delete(ptr); } #endif // !_MSC_VER +#endif private: - DynamicMessage(const TypeInfo* type_info, Arena* arena); + DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info, + Arena* arena); void SharedCtor(bool lock_factory); // Needed to get the offset of the internal metadata member. friend class DynamicMessageFactory; - inline bool is_prototype() const { - return type_info_->prototype == this || - // If type_info_->prototype is NULL, then we must be constructing - // the prototype now, which means we must be the prototype. - type_info_->prototype == NULL; - } + bool is_prototype() const; inline void* OffsetToPointer(int offset) { return reinterpret_cast(this) + offset; @@ -342,24 +315,52 @@ class DynamicMessage : public Message { return reinterpret_cast(this) + offset; } - const TypeInfo* type_info_; + const DynamicMessageFactory::TypeInfo* type_info_; mutable std::atomic cached_byte_size_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage); }; -DynamicMessage::DynamicMessage(const TypeInfo* type_info) +struct DynamicMessageFactory::TypeInfo { + int size; + int has_bits_offset; + int oneof_case_offset; + int extensions_offset; + + // Not owned by the TypeInfo. + DynamicMessageFactory* factory; // The factory that created this object. + const DescriptorPool* pool; // The factory's DescriptorPool. + const Descriptor* type; // Type of this DynamicMessage. + + // Warning: The order in which the following pointers are defined is + // important (the prototype must be deleted *before* the offsets). + std::unique_ptr offsets; + std::unique_ptr has_bits_indices; + std::unique_ptr reflection; + // Don't use a unique_ptr to hold the prototype: the destructor for + // DynamicMessage needs to know whether it is the prototype, and does so by + // looking back at this field. This would assume details about the + // implementation of unique_ptr. + const DynamicMessage* prototype; + int weak_field_map_offset; // The offset for the weak_field_map; + + TypeInfo() : prototype(nullptr) {} + + ~TypeInfo() { delete prototype; } +}; + +DynamicMessage::DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info) : type_info_(type_info), cached_byte_size_(0) { SharedCtor(true); } -DynamicMessage::DynamicMessage(const TypeInfo* type_info, Arena* arena) - : Message(arena), - type_info_(type_info), - cached_byte_size_(0) { +DynamicMessage::DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info, + Arena* arena) + : Message(arena), type_info_(type_info), cached_byte_size_(0) { SharedCtor(true); } -DynamicMessage::DynamicMessage(TypeInfo* type_info, bool lock_factory) +DynamicMessage::DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, + bool lock_factory) : type_info_(type_info), cached_byte_size_(0) { // The prototype in type_info has to be set before creating the prototype // instance on memory. e.g., message Foo { map a = 1; }. When @@ -484,6 +485,22 @@ void DynamicMessage::SharedCtor(bool lock_factory) { } } +bool DynamicMessage::is_prototype() const { + return type_info_->prototype == this || + // If type_info_->prototype is NULL, then we must be constructing + // the prototype now, which means we must be the prototype. + type_info_->prototype == nullptr; +} + +#if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation) +void DynamicMessage::operator delete(DynamicMessage* msg, + std::destroying_delete_t) { + const size_t size = msg->type_info_->size; + msg->~DynamicMessage(); + ::operator delete(msg, size); +} +#endif + DynamicMessage::~DynamicMessage() { const Descriptor* descriptor = type_info_->type; @@ -517,11 +534,11 @@ DynamicMessage::~DynamicMessage() { switch (field->options().ctype()) { default: case FieldOptions::STRING: { - const std::string* default_value = - reinterpret_cast( - reinterpret_cast(type_info_->prototype) + - type_info_->offsets[i]) - ->GetPointer(); + // Oneof string fields are never set as a default instance. + // We just need to pass some arbitrary default string to make it + // work. This allows us to not have the real default accessible + // from reflection. + const std::string* default_value = nullptr; reinterpret_cast(field_ptr)->Destroy( default_value, NULL); break; @@ -610,6 +627,7 @@ void DynamicMessage::CrossLinkPrototypes() { const FieldDescriptor* field = descriptor->field(i); void* field_ptr = OffsetToPointer(type_info_->offsets[i]); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !field->options().weak() && !InRealOneof(field) && !field->is_repeated()) { // For fields with message types, we need to cross-link with the // prototype for the field's type. @@ -652,27 +670,14 @@ Metadata DynamicMessage::GetMetadata() const { // =================================================================== -struct DynamicMessageFactory::PrototypeMap { - typedef std::unordered_map - Map; - Map map_; -}; - DynamicMessageFactory::DynamicMessageFactory() - : pool_(NULL), - delegate_to_generated_factory_(false), - prototypes_(new PrototypeMap) {} + : pool_(nullptr), delegate_to_generated_factory_(false) {} DynamicMessageFactory::DynamicMessageFactory(const DescriptorPool* pool) - : pool_(pool), - delegate_to_generated_factory_(false), - prototypes_(new PrototypeMap) {} + : pool_(pool), delegate_to_generated_factory_(false) {} DynamicMessageFactory::~DynamicMessageFactory() { - for (PrototypeMap::Map::iterator iter = prototypes_->map_.begin(); - iter != prototypes_->map_.end(); ++iter) { - DeleteDefaultOneofInstance(iter->second->type, iter->second->offsets.get(), - iter->second->prototype); + for (auto iter = prototypes_.begin(); iter != prototypes_.end(); ++iter) { delete iter->second; } } @@ -689,13 +694,13 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( return MessageFactory::generated_factory()->GetPrototype(type); } - const DynamicMessage::TypeInfo** target = &prototypes_->map_[type]; + const TypeInfo** target = &prototypes_[type]; if (*target != NULL) { // Already exists. return (*target)->prototype; } - DynamicMessage::TypeInfo* type_info = new DynamicMessage::TypeInfo; + TypeInfo* type_info = new TypeInfo; *target = type_info; type_info->type = type; @@ -772,7 +777,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( // All the fields. // // TODO(b/31226269): Optimize the order of fields to minimize padding. - int num_weak_fields = 0; for (int i = 0; i < type->field_count(); i++) { // Make sure field is aligned to avoid bus errors. // Oneof fields do not use any space. @@ -807,14 +811,16 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( if (type->oneof_decl(i)->is_synthetic()) continue; for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = type->oneof_decl(i)->field(j); - int field_size = OneofFieldSpaceUsed(field); - size = AlignTo(size, std::min(kSafeAlignment, field_size)); - offsets[field->index()] = size; - size += field_size; + // oneof fields are not accessed through offsets, but we still have the + // entry from a legacy implementation. This should be removed at some + // point. + // Mark the field to prevent unintentional access through reflection. + // Don't use the top bit because that is for unused fields. + offsets[field->index()] = internal::kInvalidFieldOffsetTag; } } - size = AlignOffset(size); - // Allocate the prototype + oneof fields. + + // Allocate the prototype fields. void* base = operator new(size); memset(base, 0, size); @@ -822,12 +828,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( // of dynamic message to avoid dead lock. DynamicMessage* prototype = new (base) DynamicMessage(type_info, false); - if (real_oneof_count > 0 || num_weak_fields > 0) { - // Construct default oneof instance. - ConstructDefaultOneofInstance(type_info->type, type_info->offsets.get(), - prototype); - } - internal::ReflectionSchema schema = { type_info->prototype, type_info->offsets.get(), @@ -848,71 +848,6 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( return prototype; } -void DynamicMessageFactory::ConstructDefaultOneofInstance( - const Descriptor* type, const uint32 offsets[], - void* default_oneof_or_weak_instance) { - for (int i = 0; i < type->oneof_decl_count(); i++) { - if (type->oneof_decl(i)->is_synthetic()) continue; - for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = type->oneof_decl(i)->field(j); - void* field_ptr = - reinterpret_cast(default_oneof_or_weak_instance) + - offsets[field->index()]; - switch (field->cpp_type()) { -#define HANDLE_TYPE(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - new (field_ptr) TYPE(field->default_value_##TYPE()); \ - break; - - HANDLE_TYPE(INT32, int32); - HANDLE_TYPE(INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE(FLOAT, float); - HANDLE_TYPE(BOOL, bool); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_ENUM: - new (field_ptr) int(field->default_value_enum()->number()); - break; - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: - case FieldOptions::STRING: - ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr(); - asp->UnsafeSetDefault(&field->default_value_string()); - break; - } - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: { - new (field_ptr) Message*(NULL); - break; - } - } - } - } -} - -void DynamicMessageFactory::DeleteDefaultOneofInstance( - const Descriptor* type, const uint32 offsets[], - const void* default_oneof_instance) { - for (int i = 0; i < type->oneof_decl_count(); i++) { - if (type->oneof_decl(i)->is_synthetic()) continue; - for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = type->oneof_decl(i)->field(j); - if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - switch (field->options().ctype()) { - default: - case FieldOptions::STRING: - break; - } - } - } - } -} - } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index 9bd609f898e2..b85e00f3e8a1 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -128,28 +129,13 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { const DescriptorPool* pool_; bool delegate_to_generated_factory_; - // This struct just contains a hash_map. We can't #include from - // this header due to hacks needed for hash_map portability in the open source - // release. Namely, stubs/hash.h, which defines hash_map portably, is not a - // public header (for good reason), but dynamic_message.h is, and public - // headers may only #include other public headers. - struct PrototypeMap; - std::unique_ptr prototypes_; + struct TypeInfo; + std::unordered_map prototypes_; mutable internal::WrappedMutex prototypes_mutex_; friend class DynamicMessage; const Message* GetPrototypeNoLock(const Descriptor* type); - // Construct default oneof instance for reflection usage if oneof - // is defined. - static void ConstructDefaultOneofInstance(const Descriptor* type, - const uint32 offsets[], - void* default_oneof_instance); - // Delete default oneof instance. Called by ~DynamicMessageFactory. - static void DeleteDefaultOneofInstance(const Descriptor* type, - const uint32 offsets[], - const void* default_oneof_instance); - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); }; diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 2c6346d7e6bc..22328bda3839 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -17,24 +17,18 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class EmptyDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Empty_default_instance_; +constexpr Empty::Empty( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} +struct EmptyDefaultTypeInternal { + constexpr EmptyDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~EmptyDefaultTypeInternal() {} + union { + Empty _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY EmptyDefaultTypeInternal _Empty_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Empty_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Empty(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; @@ -61,18 +55,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBU "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P" "rotobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fempty_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fempty_2eproto_sccs[1] = { - &scc_info_Empty_google_2fprotobuf_2fempty_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", 190, - &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, descriptor_table_google_2fprotobuf_2fempty_2eproto_sccs, descriptor_table_google_2fprotobuf_2fempty_2eproto_deps, 1, 0, + false, false, 190, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", + &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fempty_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, + file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fempty_2eproto); + return descriptor_table_google_2fprotobuf_2fempty_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fempty_2eproto(&descriptor_table_google_2fprotobuf_2fempty_2eproto); @@ -118,11 +112,6 @@ void Empty::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Empty::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Empty& Empty::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Empty_google_2fprotobuf_2fempty_2eproto.base); - return *internal_default_instance(); -} - void Empty::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Empty) diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 73080030f9d8..3b59d1630fb4 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Empty; -class EmptyDefaultTypeInternal; +struct EmptyDefaultTypeInternal; PROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : public: inline Empty() : Empty(nullptr) {} virtual ~Empty(); + explicit constexpr Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Empty(const Empty& from); Empty(Empty&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Empty& default_instance(); - + static const Empty& default_instance() { + return *internal_default_instance(); + } static inline const Empty* internal_default_instance() { return reinterpret_cast( &_Empty_default_instance_); @@ -166,8 +169,7 @@ class PROTOBUF_EXPORT Empty PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fempty_2eproto); - return ::descriptor_table_google_2fprotobuf_2fempty_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fempty_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 08848c8e8313..bc5348079475 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -1454,9 +1454,9 @@ bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, return ParseMessageSetLite(input, &finder, &skipper); } -uint8* ExtensionSet::_InternalSerialize(int start_field_number, - int end_field_number, uint8* target, - io::EpsCopyOutputStream* stream) const { +uint8* ExtensionSet::_InternalSerializeImpl( + int start_field_number, int end_field_number, uint8* target, + io::EpsCopyOutputStream* stream) const { if (PROTOBUF_PREDICT_FALSE(is_large())) { const auto& end = map_.large->end(); for (auto it = map_.large->lower_bound(start_field_number); @@ -1885,9 +1885,6 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) { } flat_capacity_ = new_flat_capacity; map_ = new_map; - if (is_large()) { - flat_size_ = 0; - } } // static diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index a74d2a96a6df..c4b845a8ee5e 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -469,7 +469,14 @@ class PROTOBUF_EXPORT ExtensionSet { // Returns a pointer past the last written byte. uint8* _InternalSerialize(int start_field_number, int end_field_number, uint8* target, - io::EpsCopyOutputStream* stream) const; + io::EpsCopyOutputStream* stream) const { + if (flat_size_ == 0) { + assert(!is_large()); + return target; + } + return _InternalSerializeImpl(start_field_number, end_field_number, target, + stream); + } // Like above but serializes in MessageSet format. void SerializeMessageSetWithCachedSizes(io::CodedOutputStream* output) const { @@ -510,6 +517,10 @@ class PROTOBUF_EXPORT ExtensionSet { int SpaceUsedExcludingSelf() const; private: + // Implementation of _InternalSerialize for non-empty map_. + uint8* _InternalSerializeImpl(int start_field_number, int end_field_number, + uint8* target, + io::EpsCopyOutputStream* stream) const; // Interface of a lazily parsed singular message extension. class PROTOBUF_EXPORT LazyMessageExtension { public: diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index a3822eaca707..d1f5698ff109 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -17,24 +17,19 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class FieldMaskDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _FieldMask_default_instance_; +constexpr FieldMask::FieldMask( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : paths_(){} +struct FieldMaskDefaultTypeInternal { + constexpr FieldMaskDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~FieldMaskDefaultTypeInternal() {} + union { + FieldMask _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY FieldMaskDefaultTypeInternal _FieldMask_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::FieldMask(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; @@ -63,18 +58,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" ".WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_sccs[1] = { - &scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", 223, - &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_sccs, descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_deps, 1, 0, + false, false, 223, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", + &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, + file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); + return descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ffield_5fmask_2eproto(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); @@ -101,7 +96,6 @@ FieldMask::FieldMask(const FieldMask& from) } void FieldMask::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto.base); } FieldMask::~FieldMask() { @@ -123,11 +117,6 @@ void FieldMask::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void FieldMask::SetCachedSize(int size) const { _cached_size_.Set(size); } -const FieldMask& FieldMask::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto.base); - return *internal_default_instance(); -} - void FieldMask::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask) diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 0fa822f722cc..e7668ba903f1 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class FieldMask; -class FieldMaskDefaultTypeInternal; +struct FieldMaskDefaultTypeInternal; PROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : public: inline FieldMask() : FieldMask(nullptr) {} virtual ~FieldMask(); + explicit constexpr FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldMask(const FieldMask& from); FieldMask(FieldMask&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const FieldMask& default_instance(); - + static const FieldMask& default_instance() { + return *internal_default_instance(); + } static inline const FieldMask* internal_default_instance() { return reinterpret_cast( &_FieldMask_default_instance_); @@ -166,8 +169,7 @@ class PROTOBUF_EXPORT FieldMask PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); - return ::descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index b81f58339736..b2ffe1fa8a36 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -2479,11 +2479,8 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { } void AddDescriptorsImpl(const DescriptorTable* table) { - // Reflection refers to the default instances so make sure they are - // initialized. - for (int i = 0; i < table->num_sccs; i++) { - internal::InitSCC(table->init_default_instances[i]); - } + // Reflection refers to the default fields so make sure they are initialized. + internal::InitProtobufDefaults(); // Ensure all dependent descriptors are registered to the generated descriptor // pool and message factory. diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index ff96bea23422..5916cb7b5dba 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -253,25 +253,24 @@ struct MigrationSchema { int object_size; }; -struct SCCInfoBase; - +// This struct tries to reduce unnecessary padding. +// The num_xxx might not be close to their respective pointer, but this saves +// padding. struct PROTOBUF_EXPORT DescriptorTable { mutable bool is_initialized; bool is_eager; + int size; // of serialized descriptor const char* descriptor; const char* filename; - int size; // of serialized descriptor once_flag* once; - SCCInfoBase* const* init_default_instances; const DescriptorTable* const* deps; - int num_sccs; int num_deps; + int num_messages; const MigrationSchema* schemas; const Message* const* default_instances; const uint32* offsets; // update the following descriptor arrays. Metadata* file_level_metadata; - int num_messages; const EnumDescriptor** file_level_enum_descriptors; const ServiceDescriptor** file_level_service_descriptors; }; diff --git a/src/google/protobuf/generated_message_table_driven.h b/src/google/protobuf/generated_message_table_driven.h index 68d80dcc89b1..0f6309ae988f 100644 --- a/src/google/protobuf/generated_message_table_driven.h +++ b/src/google/protobuf/generated_message_table_driven.h @@ -207,11 +207,15 @@ static_assert(std::is_standard_layout::value, ""); static_assert(std::is_trivial::value, ""); static_assert(std::is_standard_layout::value, ""); static_assert(std::is_trivial::value, ""); -static_assert(std::is_standard_layout::value, ""); +static_assert( + std::is_standard_layout::value, ""); static_assert(std::is_trivial::value, ""); -static_assert(std::is_standard_layout::value, ""); -static_assert(std::is_trivial::value, ""); -static_assert(std::is_standard_layout::value, ""); +static_assert( + std::is_standard_layout::value, ""); +static_assert(std::is_trivial::value, + ""); +static_assert( + std::is_standard_layout::value, ""); static_assert(std::is_trivial::value, ""); static_assert(std::is_standard_layout::value, ""); static_assert(std::is_trivial::value, ""); diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 8f86f6087456..bc7936591b49 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -34,14 +34,8 @@ #include +#include #include - -#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP -// We're only using this as a standard way for getting the thread id. -// We're not using any thread functionality. -#include // NOLINT -#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP - #include #include @@ -51,7 +45,6 @@ #include #include #include -#include #include #include @@ -73,19 +66,15 @@ void DestroyString(const void* s) { } PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY EmptyString - fixed_address_empty_string; // NOLINT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY ExplicitlyConstructed + fixed_address_empty_string{}; // NOLINT PROTOBUF_CONSTINIT std::atomic init_protobuf_defaults_state{false}; static bool InitProtobufDefaultsImpl() { - ::new (static_cast(&fixed_address_empty_string.value)) std::string(); - OnShutdownDestroyString(&fixed_address_empty_string.value); + fixed_address_empty_string.DefaultConstruct(); + OnShutdownDestroyString(fixed_address_empty_string.get_mutable()); - // Verify that we can indeed get the address during constant evaluation. - PROTOBUF_CONSTINIT static const std::string& fixed_address_empty_string_test = - GetEmptyStringAlreadyInited(); - (void)fixed_address_empty_string_test; init_protobuf_defaults_state.store(true, std::memory_order_release); return true; @@ -741,74 +730,6 @@ MessageLite* GetOwnedMessageInternal(Arena* message_arena, } } -namespace { - -void InitSCC_DFS(SCCInfoBase* scc) { - if (scc->visit_status.load(std::memory_order_relaxed) != - SCCInfoBase::kUninitialized) - return; - scc->visit_status.store(SCCInfoBase::kRunning, std::memory_order_relaxed); - // Each base is followed by an array of void*, containing first pointers to - // SCCInfoBase and then pointers-to-pointers to SCCInfoBase. - auto deps = reinterpret_cast(scc + 1); - auto strong_deps = reinterpret_cast(deps); - for (int i = 0; i < scc->num_deps; ++i) { - if (strong_deps[i]) InitSCC_DFS(strong_deps[i]); - } - auto implicit_weak_deps = - reinterpret_cast(deps + scc->num_deps); - for (int i = 0; i < scc->num_implicit_weak_deps; ++i) { - if (*implicit_weak_deps[i]) { - InitSCC_DFS(*implicit_weak_deps[i]); - } - } - scc->init_func(); - // Mark done (note we use memory order release here), other threads could - // now see this as initialized and thus the initialization must have happened - // before. - scc->visit_status.store(SCCInfoBase::kInitialized, std::memory_order_release); -} - -} // namespace - -void InitSCCImpl(SCCInfoBase* scc) { - static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED}; - // Either the default in case no initialization is running or the id of the - // thread that is currently initializing. -#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP - static std::atomic runner; - auto me = std::this_thread::get_id(); -#else - // This is a lightweight replacement for std::thread::id. std::thread does not - // work on Windows XP SP2 with the latest VC++ libraries, because it utilizes - // the Concurrency Runtime that is only supported on Windows XP SP3 and above. - static std::atomic_llong runner(-1); - auto me = ::GetCurrentThreadId(); -#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP - - // This will only happen because the constructor will call InitSCC while - // constructing the default instance. - if (runner.load(std::memory_order_relaxed) == me) { - // Because we're in the process of constructing the default instance. - // We can be assured that we're already exploring this SCC. - GOOGLE_CHECK_EQ(scc->visit_status.load(std::memory_order_relaxed), - SCCInfoBase::kRunning); - return; - } - InitProtobufDefaults(); - mu.Lock(); - runner.store(me, std::memory_order_relaxed); - InitSCC_DFS(scc); - -#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP - runner.store(std::thread::id{}, std::memory_order_relaxed); -#else - runner.store(-1, std::memory_order_relaxed); -#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP - - mu.Unlock(); -} - } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index bae0c1f760a4..94c6c294b2eb 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -192,64 +192,6 @@ class PROTOBUF_EXPORT CachedSize { std::atomic size_{0}; }; -// SCCInfo represents information of a strongly connected component of -// mutual dependent messages. -struct PROTOBUF_EXPORT SCCInfoBase { - // We use 0 for the Initialized state, because test eax,eax, jnz is smaller - // and is subject to macro fusion. - enum { - kInitialized = 0, // final state - kRunning = 1, - kUninitialized = -1, // initial state - }; -#if defined(_MSC_VER) && !defined(__clang__) - // MSVC doesn't make std::atomic constant initialized. This union trick - // makes it so. - union { - int visit_status_to_make_linker_init; - std::atomic visit_status; - }; -#else - std::atomic visit_status; -#endif - int num_deps; - int num_implicit_weak_deps; - void (*init_func)(); - // This is followed by an array of num_deps - // const SCCInfoBase* deps[]; -}; - -// Zero-length arrays are a language extension available in GCC and Clang but -// not MSVC. -#ifdef __GNUC__ -#define PROTOBUF_ARRAY_SIZE(n) (n) -#else -#define PROTOBUF_ARRAY_SIZE(n) ((n) ? (n) : 1) -#endif - -template -struct SCCInfo { - SCCInfoBase base; - // Semantically this is const SCCInfo* which is is a templated type. - // The obvious inheriting from SCCInfoBase mucks with struct initialization. - // Attempts showed the compiler was generating dynamic initialization code. - // This deps array consists of base.num_deps pointers to SCCInfoBase followed - // by base.num_implicit_weak_deps pointers to SCCInfoBase*. We need the extra - // pointer indirection for implicit weak fields. We cannot use a union type - // here, since that would prevent the array from being linker-initialized. - void* deps[PROTOBUF_ARRAY_SIZE(N)]; -}; - -#undef PROTOBUF_ARRAY_SIZE - -PROTOBUF_EXPORT void InitSCCImpl(SCCInfoBase* scc); - -inline void InitSCC(SCCInfoBase* scc) { - auto status = scc->visit_status.load(std::memory_order_acquire); - if (PROTOBUF_PREDICT_FALSE(status != SCCInfoBase::kInitialized)) - InitSCCImpl(scc); -} - PROTOBUF_EXPORT void DestroyMessage(const void* message); PROTOBUF_EXPORT void DestroyString(const void* s); // Destroy (not delete) the message diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h index 1144b9f4618c..7fd92343c7af 100644 --- a/src/google/protobuf/has_bits.h +++ b/src/google/protobuf/has_bits.h @@ -47,17 +47,17 @@ namespace internal { template class HasBits { public: - constexpr HasBits() PROTOBUF_ALWAYS_INLINE : has_bits_{} {} + constexpr HasBits() PROTOBUF_NDEBUG_INLINE : has_bits_{} {} - void Clear() PROTOBUF_ALWAYS_INLINE { + void Clear() PROTOBUF_NDEBUG_INLINE { memset(has_bits_, 0, sizeof(has_bits_)); } - uint32& operator[](int index) PROTOBUF_ALWAYS_INLINE { + uint32& operator[](int index) PROTOBUF_NDEBUG_INLINE { return has_bits_[index]; } - const uint32& operator[](int index) const PROTOBUF_ALWAYS_INLINE { + const uint32& operator[](int index) const PROTOBUF_NDEBUG_INLINE { return has_bits_[index]; } diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index 744d75157de4..e718790ef49f 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -586,7 +586,7 @@ inline bool MapTypeHandler::IsInitialized( constexpr auto \ MapTypeHandler::Constinit() \ ->TypeOnMemory { \ - return TypeOnMemory(&internal::GetEmptyStringAlreadyInited()); \ + return TypeOnMemory(&internal::fixed_address_empty_string); \ } \ template \ inline typename MapTypeHandler -class GeneratedMessageFactory : public MessageFactory { +class GeneratedMessageFactory final : public MessageFactory { public: static GeneratedMessageFactory* singleton(); diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index e20b16239304..52e6a1db19bd 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -231,7 +231,7 @@ bool CreateUnknownEnumValues(const FieldDescriptor* field); // the internal library are allowed to create subclasses. class PROTOBUF_EXPORT Message : public MessageLite { public: - constexpr Message() = default; + constexpr Message() {} // Basic Operations ------------------------------------------------ diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 87e9d2b4ccfa..dcc6e2411c21 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -83,6 +83,7 @@ struct ConstantInitialized { // See parse_context.h for explanation class ParseContext; +class Proto3ArenaTestHelper; class RepeatedPtrFieldBase; class WireFormatLite; class WeakFieldMap; @@ -151,25 +152,14 @@ class ExplicitlyConstructed { } union_; }; -// We need a publicly accessible `value` object to allow constexpr -// support in C++11. -// A constexpr accessor does not work portably. -union EmptyString { - constexpr EmptyString() : dummy{} {} - ~EmptyString() {} - - // We need a dummy object for constant initialization. - std::false_type dummy; - std::string value; -}; - // Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -PROTOBUF_EXPORT extern EmptyString fixed_address_empty_string; +PROTOBUF_EXPORT extern ExplicitlyConstructed + fixed_address_empty_string; PROTOBUF_EXPORT constexpr const std::string& GetEmptyStringAlreadyInited() { - return fixed_address_empty_string.value; + return fixed_address_empty_string.get(); } PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const std::string& str); @@ -204,7 +194,7 @@ PROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const std::string& str); // the internal library are allowed to create subclasses. class PROTOBUF_EXPORT MessageLite { public: - constexpr MessageLite() = default; + constexpr MessageLite() {} virtual ~MessageLite() = default; // Basic Operations ------------------------------------------------ @@ -220,11 +210,11 @@ class PROTOBUF_EXPORT MessageLite { // if arena is a NULL. Default implementation for backwards compatibility. virtual MessageLite* New(Arena* arena) const; - // Get the arena, if any, associated with this message. Virtual method - // required for generic operations but most arena-related operations should - // use the GetArena() generated-code method. Default implementation - // to reduce code size by avoiding the need for per-type implementations - // when types do not implement arena support. + // Get the arena for allocating submessages, if any, associated with this + // message. Virtual method required for generic operations but most + // arena-related operations should use the GetArena() generated-code method. + // Default implementation to reduce code size by avoiding the need for + // per-type implementations when types do not implement arena support. Arena* GetArena() const { return _internal_metadata_.arena(); } // Get a pointer that may be equal to this message's arena, or may not be. @@ -513,8 +503,18 @@ class PROTOBUF_EXPORT MessageLite { // TODO(gerbens) make this a pure abstract function virtual const void* InternalGetTable() const { return NULL; } + // Get the arena that owns this message. + Arena* GetOwningArena() const { return _internal_metadata_.GetOwningArena(); } + + // Set the owning arena to the given one. + void SetOwningArena(Arena* arena) { + _internal_metadata_.SetOwningArena(arena); + } + + friend class Arena; friend class internal::WireFormatLite; friend class Message; + friend class internal::Proto3ArenaTestHelper; friend class internal::WeakFieldMap; void LogInitializationErrorMessage() const; diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index ec5f92389074..9f16180915dc 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -47,15 +47,18 @@ namespace protobuf { namespace internal { // This is the representation for messages that support arena allocation. It -// uses a tagged pointer to either store the Arena pointer, if there are no -// unknown fields, or a pointer to a block of memory with both the Arena pointer -// and the UnknownFieldSet, if there are unknown fields. This optimization -// allows for "zero-overhead" storage of the Arena pointer, relative to the -// above baseline implementation. +// uses a tagged pointer to either store the owning Arena pointer, if there are +// no unknown fields, or a pointer to a block of memory with both the owning +// Arena pointer and the UnknownFieldSet, if there are unknown fields. Besides, +// it also uses the tag to distinguish whether the owning Arena pointer is also +// used by sub-structure allocation. This optimization allows for +// "zero-overhead" storage of the Arena pointer, relative to the above baseline +// implementation. // -// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to -// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container -// pointer. +// The tagged pointer uses the least two significant bits to disambiguate cases. +// It uses bit 0 == 0 to indicate an arena pointer and bit 0 == 1 to indicate a +// UFS+Arena-container pointer. Besides it uses bit 1 == 0 to indicate arena +// allocation and bit 1 == 1 to indicate heap allocation. class InternalMetadata { public: constexpr InternalMetadata() : ptr_(nullptr) {} @@ -69,22 +72,24 @@ class InternalMetadata { } } - PROTOBUF_ALWAYS_INLINE Arena* arena() const { - if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue()->arena; - } else { + PROTOBUF_NDEBUG_INLINE Arena* arena() const { + if (PROTOBUF_PREDICT_TRUE(!has_tag())) { return PtrValue(); + } else if (is_heap_allocating()) { + return nullptr; + } else { + return PtrValue()->arena; } } - PROTOBUF_ALWAYS_INLINE bool have_unknown_fields() const { - return PtrTag() == kTagContainer; + PROTOBUF_NDEBUG_INLINE bool have_unknown_fields() const { + return UnknownTag() == kUnknownTagMask; } - PROTOBUF_ALWAYS_INLINE void* raw_arena_ptr() const { return ptr_; } + PROTOBUF_NDEBUG_INLINE void* raw_arena_ptr() const { return ptr_; } template - PROTOBUF_ALWAYS_INLINE const T& unknown_fields( + PROTOBUF_NDEBUG_INLINE const T& unknown_fields( const T& (*default_instance)()) const { if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { return PtrValue>()->unknown_fields; @@ -94,7 +99,7 @@ class InternalMetadata { } template - PROTOBUF_ALWAYS_INLINE T* mutable_unknown_fields() { + PROTOBUF_NDEBUG_INLINE T* mutable_unknown_fields() { if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) { return &PtrValue>()->unknown_fields; } else { @@ -103,7 +108,7 @@ class InternalMetadata { } template - PROTOBUF_ALWAYS_INLINE void Swap(InternalMetadata* other) { + PROTOBUF_NDEBUG_INLINE void Swap(InternalMetadata* other) { // Semantics here are that we swap only the unknown fields, not the arena // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in @@ -116,36 +121,69 @@ class InternalMetadata { } template - PROTOBUF_ALWAYS_INLINE void MergeFrom(const InternalMetadata& other) { + PROTOBUF_NDEBUG_INLINE void MergeFrom(const InternalMetadata& other) { if (other.have_unknown_fields()) { DoMergeFrom(other.unknown_fields(nullptr)); } } template - PROTOBUF_ALWAYS_INLINE void Clear() { + PROTOBUF_NDEBUG_INLINE void Clear() { if (have_unknown_fields()) { DoClear(); } } + PROTOBUF_ALWAYS_INLINE Arena* GetOwningArena() const { + if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { + return PtrValue()->arena; + } else { + return PtrValue(); + } + } + + PROTOBUF_ALWAYS_INLINE void SetOwningArena(Arena* arena) { + Arena* owning_arena = GetOwningArena(); + GOOGLE_DCHECK(arena != nullptr); // Heap can't own. + GOOGLE_DCHECK(owning_arena == nullptr); // Only heap can be owned. + + if (have_unknown_fields()) { + ContainerBase* container = PtrValue(); + container->arena = arena; + ptr_ = reinterpret_cast(reinterpret_cast(ptr_) | + kHeapAllocatingTagMask); + } else { + ptr_ = reinterpret_cast(reinterpret_cast(arena) | + kHeapAllocatingTagMask); + } + } + private: void* ptr_; // Tagged pointer implementation. - enum { - // ptr_ is an Arena*. - kTagArena = 0, - // ptr_ is a Container*. - kTagContainer = 1, - }; - static constexpr intptr_t kPtrTagMask = 1; + static constexpr intptr_t kUnknownTagMask = 1; + static constexpr intptr_t kHeapAllocatingTagMask = 2; + static constexpr intptr_t kPtrTagMask = + kUnknownTagMask | kHeapAllocatingTagMask; static constexpr intptr_t kPtrValueMask = ~kPtrTagMask; // Accessors for pointer tag and pointer value. - PROTOBUF_ALWAYS_INLINE int PtrTag() const { + PROTOBUF_NDEBUG_INLINE int PtrTag() const { return reinterpret_cast(ptr_) & kPtrTagMask; } + PROTOBUF_ALWAYS_INLINE int UnknownTag() const { + return reinterpret_cast(ptr_) & kUnknownTagMask; + } + PROTOBUF_ALWAYS_INLINE int HeapAllocatingTag() const { + return reinterpret_cast(ptr_) & kHeapAllocatingTagMask; + } + PROTOBUF_ALWAYS_INLINE bool has_tag() const { + return (reinterpret_cast(ptr_) & kPtrTagMask) != 0; + } + PROTOBUF_ALWAYS_INLINE bool is_heap_allocating() const { + return HeapAllocatingTag() == kHeapAllocatingTagMask; + } template U* PtrValue() const { @@ -153,7 +191,8 @@ class InternalMetadata { kPtrValueMask); } - // If ptr_'s tag is kTagContainer, it points to an instance of this struct. + // If ptr_'s tag is kUnknownTagMask, it points to an instance of this + // struct. struct ContainerBase { Arena* arena; }; @@ -166,13 +205,16 @@ class InternalMetadata { template PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); + Arena* owning_arena = GetOwningArena(); Container* container = Arena::Create>(my_arena); // Two-step assignment works around a bug in clang's static analyzer: // https://bugs.llvm.org/show_bug.cgi?id=34198. + intptr_t allocating_tag = + reinterpret_cast(ptr_) & kHeapAllocatingTagMask; ptr_ = container; ptr_ = reinterpret_cast(reinterpret_cast(ptr_) | - kTagContainer); - container->arena = my_arena; + kUnknownTagMask | allocating_tag); + container->arena = owning_arena; return &(container->unknown_fields); } diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 3a3df689d336..7966d99d577b 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -348,7 +348,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { if (ptr - buffer_end_ > limit_) return nullptr; while (limit_ > kSlopBytes) { size_t chunk_size = buffer_end_ + kSlopBytes - ptr; - GOOGLE_DCHECK_GE(chunk_size, 0); + GOOGLE_DCHECK_GE(chunk_size, static_cast(0)); append(ptr, chunk_size); ptr = Next(); if (ptr == nullptr) return limit_end_; @@ -401,7 +401,7 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { const char* ParseMessage(Message* msg, const char* ptr); template - PROTOBUF_MUST_USE_RESULT PROTOBUF_ALWAYS_INLINE const char* ParseGroup( + PROTOBUF_MUST_USE_RESULT PROTOBUF_NDEBUG_INLINE const char* ParseGroup( T* msg, const char* ptr, uint32 tag) { if (--depth_ < 0) return nullptr; group_depth_++; diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index e6e8a4b463ea..d15073a41fa0 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -61,6 +61,9 @@ #ifdef PROTOBUF_ALWAYS_INLINE #error PROTOBUF_ALWAYS_INLINE was previously defined #endif +#ifdef PROTOBUF_NDEBUG_INLINE +#error PROTOBUF_NDEBUG_INLINE was previously defined +#endif #ifdef PROTOBUF_COLD #error PROTOBUF_COLD was previously defined #endif @@ -154,6 +157,9 @@ #ifdef PROTOBUF_PRAGMA_INIT_SEG #error PROTOBUF_PRAGMA_INIT_SEG was previously defined #endif +#ifdef PROTOBUF_ATTRIBUTE_WEAK +#error PROTOBUF_ATTRIBUTE_WEAK was previously defined +#endif #define PROTOBUF_NAMESPACE "google::protobuf" @@ -170,13 +176,13 @@ #define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) #define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) #elif defined(__GNUC__) -# define PROTOBUF_DEPRECATED __attribute__((deprecated)) -# define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -# if __GNUC__ >= 6 -# define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) -# else -# define PROTOBUF_DEPRECATED_ENUM -# endif +#define PROTOBUF_DEPRECATED __attribute__((deprecated)) +#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) +#if __GNUC__ >= 6 +#define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated)) +#else +#define PROTOBUF_DEPRECATED_ENUM +#endif #elif defined(_MSC_VER) #define PROTOBUF_DEPRECATED __declspec(deprecated) #define PROTOBUF_DEPRECATED_ENUM @@ -194,15 +200,18 @@ #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#define PROTOBUF_NDEBUG_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE #else #if defined(__GNUC__) && \ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force inline. // Introduced in gcc 3.1. #define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) +#define PROTOBUF_NDEBUG_INLINE __attribute__((always_inline)) #else // Other compilers will have to figure it out for themselves. #define PROTOBUF_ALWAYS_INLINE +#define PROTOBUF_NDEBUG_INLINE #endif #endif @@ -606,6 +615,15 @@ #define PROTOBUF_PRAGMA_INIT_SEG #endif +#if defined(__has_attribute) +#if __has_attribute(weak) +#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak)) +#endif +#endif +#if !defined(PROTOBUF_ATTRIBUTE_WEAK) +#define PROTOBUF_ATTRIBUTE_WEAK +#endif + // Silence some MSVC warnings in all our code. #if _MSC_VER #pragma warning(push) diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 17cf8378a9b5..daef09bc45af 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -37,6 +37,7 @@ #undef PROTOBUF_NAMESPACE #undef PROTOBUF_NAMESPACE_ID #undef PROTOBUF_ALWAYS_INLINE +#undef PROTOBUF_NDEBUG_INLINE #undef PROTOBUF_COLD #undef PROTOBUF_NOINLINE #undef PROTOBUF_SECTION_VARIABLE @@ -72,9 +73,8 @@ #undef PROTOBUF_FINAL #undef PROTOBUF_THREAD_LOCAL #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT -#undef PROTOBUF_DISABLE_MSVC_UNION_WARNING -#undef PROTOBUF_ENABLE_MSVC_UNION_WARNING #undef PROTOBUF_CONSTINIT +#undef PROTOBUF_ATTRIBUTE_WEAK #undef PROTOBUF_ATTRIBUTE_NO_DESTROY #undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY #undef PROTOBUF_PRAGMA_INIT_SEG diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index b253f702aad3..7731b2841f51 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -42,10 +42,24 @@ #include #include +using proto3_arena_unittest::ForeignMessage; using proto3_arena_unittest::TestAllTypes; namespace google { namespace protobuf { + +namespace internal { + +class Proto3ArenaTestHelper { + public: + template + static Arena* GetOwningArena(const T& msg) { + return msg.GetOwningArena(); + } +}; + +} // namespace internal + namespace { // We selectively set/check a few representative fields rather than all fields // as this test is only expected to cover the basics of arena support. @@ -143,6 +157,79 @@ TEST(Proto3ArenaTest, UnknownFields) { arena_message->GetReflection()->GetUnknownFields(*arena_message).empty()); } +TEST(Proto3ArenaTest, GetArena) { + Arena arena; + + // Tests arena-allocated message and submessages. + auto* arena_message1 = Arena::CreateMessage(&arena); + auto* arena_submessage1 = arena_message1->mutable_optional_foreign_message(); + auto* arena_repeated_submessage1 = + arena_message1->add_repeated_foreign_message(); + EXPECT_EQ(&arena, arena_message1->GetArena()); + EXPECT_EQ(&arena, + internal::Proto3ArenaTestHelper::GetOwningArena(*arena_message1)); + EXPECT_EQ(&arena, arena_submessage1->GetArena()); + EXPECT_EQ(&arena, arena_repeated_submessage1->GetArena()); + + // Tests attached heap-allocated messages. + auto* arena_message2 = Arena::CreateMessage(&arena); + arena_message2->set_allocated_optional_foreign_message(new ForeignMessage()); + arena_message2->mutable_repeated_foreign_message()->AddAllocated( + new ForeignMessage()); + const auto& submessage2 = arena_message2->optional_foreign_message(); + const auto& repeated_submessage2 = + arena_message2->repeated_foreign_message(0); + EXPECT_EQ(nullptr, submessage2.GetArena()); + EXPECT_EQ(&arena, + internal::Proto3ArenaTestHelper::GetOwningArena(submessage2)); + EXPECT_EQ(nullptr, repeated_submessage2.GetArena()); + EXPECT_EQ(&arena, internal::Proto3ArenaTestHelper::GetOwningArena( + repeated_submessage2)); + + // Tests message created by Arena::Create. + auto* arena_message3 = Arena::Create(&arena); + EXPECT_EQ(nullptr, arena_message3->GetArena()); + EXPECT_EQ(&arena, + internal::Proto3ArenaTestHelper::GetOwningArena(*arena_message3)); +} + +TEST(Proto3ArenaTest, GetArenaWithUnknown) { + Arena arena; + + // Tests arena-allocated message and submessages. + auto* arena_message1 = Arena::CreateMessage(&arena); + arena_message1->GetReflection()->MutableUnknownFields(arena_message1); + auto* arena_submessage1 = arena_message1->mutable_optional_foreign_message(); + arena_submessage1->GetReflection()->MutableUnknownFields(arena_submessage1); + auto* arena_repeated_submessage1 = + arena_message1->add_repeated_foreign_message(); + arena_repeated_submessage1->GetReflection()->MutableUnknownFields( + arena_repeated_submessage1); + EXPECT_EQ(&arena, arena_message1->GetArena()); + EXPECT_EQ(&arena, + internal::Proto3ArenaTestHelper::GetOwningArena(*arena_message1)); + EXPECT_EQ(&arena, arena_submessage1->GetArena()); + EXPECT_EQ(&arena, arena_repeated_submessage1->GetArena()); + + // Tests attached heap-allocated messages. + auto* arena_message2 = Arena::CreateMessage(&arena); + arena_message2->set_allocated_optional_foreign_message(new ForeignMessage()); + arena_message2->mutable_repeated_foreign_message()->AddAllocated( + new ForeignMessage()); + auto* submessage2 = arena_message2->mutable_optional_foreign_message(); + submessage2->GetReflection()->MutableUnknownFields(submessage2); + auto* repeated_submessage2 = + arena_message2->mutable_repeated_foreign_message(0); + repeated_submessage2->GetReflection()->MutableUnknownFields( + repeated_submessage2); + EXPECT_EQ(nullptr, submessage2->GetArena()); + EXPECT_EQ(&arena, + internal::Proto3ArenaTestHelper::GetOwningArena(*submessage2)); + EXPECT_EQ(nullptr, repeated_submessage2->GetArena()); + EXPECT_EQ(&arena, internal::Proto3ArenaTestHelper::GetOwningArena( + *repeated_submessage2)); +} + TEST(Proto3ArenaTest, Swap) { Arena arena1; Arena arena2; diff --git a/src/google/protobuf/proto3_lite_unittest.inc b/src/google/protobuf/proto3_lite_unittest.inc index 4cf9cf8f1e7f..85f428a0a8d5 100644 --- a/src/google/protobuf/proto3_lite_unittest.inc +++ b/src/google/protobuf/proto3_lite_unittest.inc @@ -130,6 +130,17 @@ TEST(LITE_TEST_NAME, Swap) { EXPECT_EQ(msg1.ByteSize(), msg2.ByteSize() + 1); } +TEST(LITE_TEST_NAME, OneofHazzers) { + TestAllTypes msg; + msg.set_oneof_uint32(1); + msg.set_oneof_string("test"); + + EXPECT_EQ(true, msg.has_oneof_string()); + EXPECT_EQ(false, msg.has_oneof_uint32()); + EXPECT_EQ(false, msg.has_oneof_bytes()); + EXPECT_EQ(false, msg.has_oneof_nested_message()); +} + } // namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 89f1474603cf..85f6aed59f0d 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -657,7 +657,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { const typename TypeHandler::Type* const* data() const; template - PROTOBUF_ALWAYS_INLINE void Swap(RepeatedPtrFieldBase* other); + PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other); void SwapElements(int index1, int index2); diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index fbd180477f97..3d8401764738 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -17,24 +17,19 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class SourceContextDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _SourceContext_default_instance_; +constexpr SourceContext::SourceContext( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : file_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +struct SourceContextDefaultTypeInternal { + constexpr SourceContextDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~SourceContextDefaultTypeInternal() {} + union { + SourceContext _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY SourceContextDefaultTypeInternal _SourceContext_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::SourceContext(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; @@ -63,18 +58,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eprot "tobuf/types/known/sourcecontextpb\242\002\003GPB\252" "\002\036Google.Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_sccs[1] = { - &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", 240, - &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_sccs, descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_deps, 1, 0, + false, false, 240, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", + &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, + file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); + return descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fsource_5fcontext_2eproto(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); @@ -104,8 +99,7 @@ SourceContext::SourceContext(const SourceContext& from) } void SourceContext::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base); - file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } SourceContext::~SourceContext() { @@ -128,11 +122,6 @@ void SourceContext::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void SourceContext::SetCachedSize(int size) const { _cached_size_.Set(size); } -const SourceContext& SourceContext::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base); - return *internal_default_instance(); -} - void SourceContext::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext) diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index b27ef5afcc98..12d4655da0ad 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class SourceContext; -class SourceContextDefaultTypeInternal; +struct SourceContextDefaultTypeInternal; PROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : public: inline SourceContext() : SourceContext(nullptr) {} virtual ~SourceContext(); + explicit constexpr SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceContext(const SourceContext& from); SourceContext(SourceContext&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const SourceContext& default_instance(); - + static const SourceContext& default_instance() { + return *internal_default_instance(); + } static inline const SourceContext* internal_default_instance() { return reinterpret_cast( &_SourceContext_default_instance_); @@ -166,8 +169,7 @@ class PROTOBUF_EXPORT SourceContext PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); - return ::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 396654cc1849..1458a9bed5f6 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -16,52 +16,55 @@ #include PROTOBUF_PRAGMA_INIT_SEG -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fstruct_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto; PROTOBUF_NAMESPACE_OPEN -class Struct_FieldsEntry_DoNotUseDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Struct_FieldsEntry_DoNotUse_default_instance_; -class StructDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Struct_default_instance_; -class ValueDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Value_default_instance_; -class ListValueDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _ListValue_default_instance_; +constexpr Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} +struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal { + constexpr Struct_FieldsEntry_DoNotUseDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~Struct_FieldsEntry_DoNotUseDefaultTypeInternal() {} + union { + Struct_FieldsEntry_DoNotUse _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_; +constexpr Struct::Struct( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : fields_(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}){} +struct StructDefaultTypeInternal { + constexpr StructDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~StructDefaultTypeInternal() {} + union { + Struct _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY StructDefaultTypeInternal _Struct_default_instance_; +constexpr Value::Value( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : _oneof_case_{}{} +struct ValueDefaultTypeInternal { + constexpr ValueDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ValueDefaultTypeInternal() {} + union { + Value _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ValueDefaultTypeInternal _Value_default_instance_; +constexpr ListValue::ListValue( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : values_(){} +struct ListValueDefaultTypeInternal { + constexpr ListValueDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~ListValueDefaultTypeInternal() {} + union { + ListValue _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY ListValueDefaultTypeInternal _ListValue_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_ListValue_google_2fprotobuf_2fstruct_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Struct_FieldsEntry_DoNotUse_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse(); - } - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Struct_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Struct(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Value_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Value(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::ListValue(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ListValue_google_2fprotobuf_2fstruct_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr; @@ -133,18 +136,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOB "rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036" "Google.Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fstruct_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2fstruct_2eproto_sccs[1] = { - &scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", 638, - &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, descriptor_table_google_2fprotobuf_2fstruct_2eproto_sccs, descriptor_table_google_2fprotobuf_2fstruct_2eproto_deps, 1, 0, + false, false, 638, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, nullptr, 0, 4, schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fstruct_2eproto, 4, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); + return descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fstruct_2eproto(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); @@ -201,7 +204,6 @@ Struct::Struct(const Struct& from) } void Struct::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); } Struct::~Struct() { @@ -223,11 +225,6 @@ void Struct::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Struct::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Struct& Struct::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); - return *internal_default_instance(); -} - void Struct::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Struct) @@ -504,8 +501,7 @@ Value::Value(const Value& from) } void Value::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); - clear_has_kind(); +clear_has_kind(); } Value::~Value() { @@ -530,11 +526,6 @@ void Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Value::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Value& Value::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); - return *internal_default_instance(); -} - void Value::clear_kind() { // @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value) @@ -881,7 +872,6 @@ ListValue::ListValue(const ListValue& from) } void ListValue::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); } ListValue::~ListValue() { @@ -903,11 +893,6 @@ void ListValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void ListValue::SetCachedSize(int size) const { _cached_size_.Set(size); } -const ListValue& ListValue::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto.base); - return *internal_default_instance(); -} - void ListValue::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ListValue) diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 4fda4f3d157a..315c473330e6 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -57,18 +57,19 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class ListValue; -class ListValueDefaultTypeInternal; +struct ListValueDefaultTypeInternal; PROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_; class Struct; -class StructDefaultTypeInternal; +struct StructDefaultTypeInternal; PROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_; class Struct_FieldsEntry_DoNotUse; -class Struct_FieldsEntry_DoNotUseDefaultTypeInternal; +struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal; PROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_; class Value; -class ValueDefaultTypeInternal; +struct ValueDefaultTypeInternal; PROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -115,6 +116,8 @@ class Struct_FieldsEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::Ma ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType; Struct_FieldsEntry_DoNotUse(); + explicit constexpr Struct_FieldsEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); void MergeFrom(const Struct_FieldsEntry_DoNotUse& other); static const Struct_FieldsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast(&_Struct_FieldsEntry_DoNotUse_default_instance_); } @@ -140,6 +143,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : public: inline Struct() : Struct(nullptr) {} virtual ~Struct(); + explicit constexpr Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Struct(const Struct& from); Struct(Struct&& from) noexcept @@ -169,8 +173,9 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Struct& default_instance(); - + static const Struct& default_instance() { + return *internal_default_instance(); + } static inline const Struct* internal_default_instance() { return reinterpret_cast( &_Struct_default_instance_); @@ -236,8 +241,7 @@ class PROTOBUF_EXPORT Struct PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fstruct_2eproto); - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -289,6 +293,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public: inline Value() : Value(nullptr) {} virtual ~Value(); + explicit constexpr Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Value(const Value& from); Value(Value&& from) noexcept @@ -318,8 +323,9 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Value& default_instance(); - + static const Value& default_instance() { + return *internal_default_instance(); + } enum KindCase { kNullValue = 1, kNumberValue = 2, @@ -395,8 +401,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fstruct_2eproto); - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -414,6 +419,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : kListValueFieldNumber = 6, }; // .google.protobuf.NullValue null_value = 1; + bool has_null_value() const; private: bool _internal_has_null_value() const; public: @@ -426,6 +432,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public: // double number_value = 2; + bool has_number_value() const; private: bool _internal_has_number_value() const; public: @@ -438,6 +445,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public: // string string_value = 3; + bool has_string_value() const; private: bool _internal_has_string_value() const; public: @@ -457,6 +465,7 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : public: // bool bool_value = 4; + bool has_bool_value() const; private: bool _internal_has_bool_value() const; public: @@ -523,7 +532,8 @@ class PROTOBUF_EXPORT Value PROTOBUF_FINAL : typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; union KindUnion { - KindUnion() {} + constexpr KindUnion() : _constinit_{} {} + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; int null_value_; double number_value_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_; @@ -543,6 +553,7 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : public: inline ListValue() : ListValue(nullptr) {} virtual ~ListValue(); + explicit constexpr ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ListValue(const ListValue& from); ListValue(ListValue&& from) noexcept @@ -572,8 +583,9 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const ListValue& default_instance(); - + static const ListValue& default_instance() { + return *internal_default_instance(); + } static inline const ListValue* internal_default_instance() { return reinterpret_cast( &_ListValue_default_instance_); @@ -639,8 +651,7 @@ class PROTOBUF_EXPORT ListValue PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2fstruct_2eproto); - return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2fstruct_2eproto_metadata_getter(kIndexInFileMessages); } public: @@ -731,6 +742,9 @@ Struct::mutable_fields() { inline bool Value::_internal_has_null_value() const { return kind_case() == kNullValue; } +inline bool Value::has_null_value() const { + return _internal_has_null_value(); +} inline void Value::set_has_null_value() { _oneof_case_[0] = kNullValue; } @@ -766,6 +780,9 @@ inline void Value::set_null_value(PROTOBUF_NAMESPACE_ID::NullValue value) { inline bool Value::_internal_has_number_value() const { return kind_case() == kNumberValue; } +inline bool Value::has_number_value() const { + return _internal_has_number_value(); +} inline void Value::set_has_number_value() { _oneof_case_[0] = kNumberValue; } @@ -801,6 +818,9 @@ inline void Value::set_number_value(double value) { inline bool Value::_internal_has_string_value() const { return kind_case() == kStringValue; } +inline bool Value::has_string_value() const { + return _internal_has_string_value(); +} inline void Value::set_has_string_value() { _oneof_case_[0] = kStringValue; } @@ -908,6 +928,9 @@ inline void Value::set_allocated_string_value(std::string* string_value) { inline bool Value::_internal_has_bool_value() const { return kind_case() == kBoolValue; } +inline bool Value::has_bool_value() const { + return _internal_has_bool_value(); +} inline void Value::set_has_bool_value() { _oneof_case_[0] = kBoolValue; } diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h index 5c16c7eb3a9e..23f315f4726a 100644 --- a/src/google/protobuf/stubs/mutex.h +++ b/src/google/protobuf/stubs/mutex.h @@ -125,11 +125,11 @@ class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex { private: #if defined(GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP) - CallOnceInitializedMutex mu_ {}; + CallOnceInitializedMutex mu_{}; #elif defined(_MSC_VER) - CallOnceInitializedMutex mu_ {}; + CallOnceInitializedMutex mu_{}; #else - std::mutex mu_ {}; + std::mutex mu_{}; #endif }; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 120ab7e9f427..b7aab404ca07 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -57,17 +57,17 @@ #pragma runtime_checks("c", off) #endif #else - #ifdef __APPLE__ - #include // __BYTE_ORDER - #else - #include // __BYTE_ORDER - #endif - #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \ - (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \ - !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) - #define PROTOBUF_LITTLE_ENDIAN 1 - #endif +#ifdef __APPLE__ +#include // __BYTE_ORDER +#else +#include // __BYTE_ORDER +#endif +#if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ + (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \ + (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) +#define PROTOBUF_LITTLE_ENDIAN 1 +#endif #endif // These #includes are for the byte swap functions declared later on. diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 1af250d3f52a..2abd92766cf9 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -2130,7 +2130,7 @@ class MapFieldPrinterHelper { // DynamicMapSorter::Sort cannot be used because it enfores syncing with // repeated field. static bool SortMap(const Message& message, const Reflection* reflection, - const FieldDescriptor* field, MessageFactory* factory, + const FieldDescriptor* field, std::vector* sorted_map_field); static void CopyKey(const MapKey& key, Message* message, const FieldDescriptor* field_desc); @@ -2141,7 +2141,7 @@ class MapFieldPrinterHelper { // Returns true if elements contained in sorted_map_field need to be released. bool MapFieldPrinterHelper::SortMap( const Message& message, const Reflection* reflection, - const FieldDescriptor* field, MessageFactory* factory, + const FieldDescriptor* field, std::vector* sorted_map_field) { bool need_release = false; const MapFieldBase& base = *reflection->GetMapData(message, field); @@ -2157,7 +2157,8 @@ bool MapFieldPrinterHelper::SortMap( // TODO(teboring): For performance, instead of creating map entry message // for each element, just store map keys and sort them. const Descriptor* map_entry_desc = field->message_type(); - const Message* prototype = factory->GetPrototype(map_entry_desc); + const Message* prototype = + reflection->GetMessageFactory()->GetPrototype(map_entry_desc); for (MapIterator iter = reflection->MapBegin(const_cast(&message), field); iter != reflection->MapEnd(const_cast(&message), field); @@ -2270,13 +2271,12 @@ void TextFormat::Printer::PrintField(const Message& message, count = 1; } - DynamicMessageFactory factory; std::vector sorted_map_field; bool need_release = false; bool is_map = field->is_map(); if (is_map) { need_release = internal::MapFieldPrinterHelper::SortMap( - message, reflection, field, &factory, &sorted_map_field); + message, reflection, field, &sorted_map_field); } for (int j = 0; j < count; ++j) { diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 24b8ee9a0bc2..2c81eb4582cf 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -17,24 +17,20 @@ PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_NAMESPACE_OPEN -class TimestampDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Timestamp_default_instance_; +constexpr Timestamp::Timestamp( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) + : seconds_(PROTOBUF_LONGLONG(0)) + , nanos_(0){} +struct TimestampDefaultTypeInternal { + constexpr TimestampDefaultTypeInternal() + : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + ~TimestampDefaultTypeInternal() {} + union { + Timestamp _instance; + }; +}; +PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY TimestampDefaultTypeInternal _Timestamp_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static void InitDefaultsscc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_; - new (ptr) PROTOBUF_NAMESPACE_ID::Timestamp(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto}, {}}; - static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; @@ -64,18 +60,18 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PRO "tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002" "\036Google.Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_sccs[1] = { - &scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto.base, -}; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = { - false, false, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", 239, - &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_sccs, descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_deps, 1, 0, + false, false, 239, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", + &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, nullptr, 0, 1, schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, 1, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, + file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, }; +PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata +descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index) { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); + return descriptor_table_google_2fprotobuf_2ftimestamp_2eproto.file_level_metadata[index]; +} // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftimestamp_2eproto(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); @@ -103,10 +99,10 @@ Timestamp::Timestamp(const Timestamp& from) } void Timestamp::SharedCtor() { - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&seconds_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&nanos_) - - reinterpret_cast(&seconds_)) + sizeof(nanos_)); +::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&seconds_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&nanos_) - + reinterpret_cast(&seconds_)) + sizeof(nanos_)); } Timestamp::~Timestamp() { @@ -128,11 +124,6 @@ void Timestamp::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { void Timestamp::SetCachedSize(int size) const { _cached_size_.Set(size); } -const Timestamp& Timestamp::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto.base); - return *internal_default_instance(); -} - void Timestamp::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp) diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 4d2947ab32ff..1105edb6bbcc 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -53,9 +53,10 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto { static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; }; extern PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto; +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Metadata descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(int index); PROTOBUF_NAMESPACE_OPEN class Timestamp; -class TimestampDefaultTypeInternal; +struct TimestampDefaultTypeInternal; PROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_; PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -70,6 +71,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : public: inline Timestamp() : Timestamp(nullptr) {} virtual ~Timestamp(); + explicit constexpr Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Timestamp(const Timestamp& from); Timestamp(Timestamp&& from) noexcept @@ -99,8 +101,9 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { return GetMetadataStatic().reflection; } - static const Timestamp& default_instance(); - + static const Timestamp& default_instance() { + return *internal_default_instance(); + } static inline const Timestamp* internal_default_instance() { return reinterpret_cast( &_Timestamp_default_instance_); @@ -166,8 +169,7 @@ class PROTOBUF_EXPORT Timestamp PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); - return ::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto.file_level_metadata[kIndexInFileMessages]; + return ::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_metadata_getter(kIndexInFileMessages); } public: diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 5c94072592f5..a4a3c2706991 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -16,107 +16,93 @@ #include PROTOBUF_PRAGMA_INIT_SEG -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Field_google_2fprotobuf_2ftype_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2ftype_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Option_google_2fprotobuf_2ftype_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto; PROTOBUF_NAMESPACE_OPEN -class TypeDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Type_default_instance_; -class FieldDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Field_default_instance_; -class EnumDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Enum_default_instance_; -class EnumValueDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _EnumValue_default_instance_; -class OptionDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed