Merge branch 'master' into 201910111201

pull/6752/head^2
Rafi Kamal 5 years ago committed by GitHub
commit 27c1defe35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 71
      CHANGES.txt
  3. 2
      Protobuf-C++.podspec
  4. 2
      Protobuf.podspec
  5. 2
      cmake/CMakeLists.txt
  6. 2
      configure.ac
  7. 4
      conformance/binary_json_conformance_suite.cc
  8. 2
      conformance/failure_list_php_c.txt
  9. 2
      csharp/Google.Protobuf.Tools.nuspec
  10. 4
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  11. 4
      csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
  12. 4
      csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
  13. 4
      csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
  14. 4
      csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
  15. 4
      csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
  16. 4
      csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
  17. 4
      csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs
  18. 4
      docs/options.md
  19. 6
      java/README.md
  20. 6
      java/bom/pom.xml
  21. 2
      java/core/pom.xml
  22. 2
      java/lite/pom.xml
  23. 2
      java/pom.xml
  24. 2
      java/util/pom.xml
  25. 2
      js/package.json
  26. 12
      objectivec/GPBCodedInputStream.m
  27. 28
      objectivec/GPBUtilities_PackagePrivate.h
  28. 42
      php/README.md
  29. 34
      php/ext/google/protobuf/encode_decode.c
  30. 128
      php/ext/google/protobuf/message.c
  31. 54
      php/ext/google/protobuf/package.xml
  32. 2
      php/ext/google/protobuf/protobuf.h
  33. 54
      php/ext/google/protobuf/type_check.c
  34. 50
      php/ext/google/protobuf/upb.c
  35. 41
      php/tests/encode_decode_test.php
  36. 1
      php/tests/memory_leak_test.php
  37. 11
      php/tests/proto/test.proto
  38. 2
      protoc-artifacts/pom.xml
  39. 2
      python/google/protobuf/__init__.py
  40. 64
      ruby/ext/google/protobuf_c/upb.c
  41. 2
      ruby/google-protobuf.gemspec
  42. 12
      ruby/tests/common_tests.rb
  43. 2
      src/Makefile.am
  44. 4
      src/google/protobuf/any.pb.h
  45. 4
      src/google/protobuf/api.pb.h
  46. 4
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  47. 8
      src/google/protobuf/compiler/cpp/cpp_message.cc
  48. 4
      src/google/protobuf/compiler/plugin.pb.h
  49. 2
      src/google/protobuf/descriptor.cc
  50. 4
      src/google/protobuf/descriptor.pb.h
  51. 2
      src/google/protobuf/descriptor_database.h
  52. 4
      src/google/protobuf/descriptor_unittest.cc
  53. 4
      src/google/protobuf/duration.pb.h
  54. 1
      src/google/protobuf/dynamic_message.h
  55. 4
      src/google/protobuf/empty.pb.h
  56. 4
      src/google/protobuf/field_mask.pb.h
  57. 197
      src/google/protobuf/port_def.inc
  58. 14
      src/google/protobuf/port_undef.inc
  59. 24
      src/google/protobuf/repeated_field.cc
  60. 23
      src/google/protobuf/repeated_field.h
  61. 4
      src/google/protobuf/source_context.pb.h
  62. 4
      src/google/protobuf/struct.pb.h
  63. 2
      src/google/protobuf/stubs/bytestream.h
  64. 8
      src/google/protobuf/stubs/common.h
  65. 5
      src/google/protobuf/stubs/port.h
  66. 15
      src/google/protobuf/stubs/strutil.cc
  67. 2
      src/google/protobuf/stubs/strutil.h
  68. 44
      src/google/protobuf/stubs/strutil_unittest.cc
  69. 1
      src/google/protobuf/text_format.h
  70. 4
      src/google/protobuf/timestamp.pb.h
  71. 4
      src/google/protobuf/type.pb.h
  72. 4
      src/google/protobuf/wrappers.pb.h
  73. 1
      third_party/BUILD
  74. 81
      update_version.py

@ -59,6 +59,7 @@ COPTS = select({
"-Wno-unused-function",
# Prevents ISO C++ const string assignment warnings for pyext sources.
"-Wno-write-strings",
"-Wno-deprecated-declarations",
],
})

@ -1,3 +1,74 @@
2019-09-03 version 3.10.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
* Switch the proto parser to the faster MOMI parser.
* Properly escape Struct keys in the proto3 JSON serializer.
* Fix crash on uninitialized map entries.
* Informed the compiler of has-bit invariant to produce better code
* Unused imports of files defining descriptor extensions will now be reported
* Add proto2::util::RemoveSubranges to remove multiple subranges in linear time.
* Added BaseTextGenerator::GetCurrentIndentationSize()
* Made implicit weak fields compatible with the Apple linker
* Support 32 bit values for ProtoStreamObjectWriter to Struct.
* Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there.
* Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction).
* Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big.
* Do not convert unknown field name to snake case to accurately report error.
* Fix a UBSAN warnings. (#6333)
* Add podspec for C++ (#6404)
* protoc: fix source code info location for missing label (#6436)
* C++ Add move constructor for Reflection's SetString (#6477)
Java
* Call loadDescriptor outside of synchronized block to remove one possible source of deadlock.
* Have oneof enums implement a separate interface (other than EnumLite) for clarity.
* Opensource Android Memory Accessors
* Update TextFormat to make use of the new TypeRegistry.
* Support getFieldBuilder and getRepeatedFieldBuilder in ExtendableBuilder
* Update JsonFormat to make use of the new TypeRegistry.
* Add proguard config generator for GmmBenchmarkSuiteLite.
* Change ProtobufArrayList to use Object[] instead of ArrayList for 5-10% faster parsing
* Implement ProtobufArrayList.add(E) for 20% (5%-40%) faster overall protolite2 parsing
* Make a copy of JsonFormat.TypeRegistry at the protobuf top level package. This will eventually replace JsonFormat.TypeRegistry.
* Fix javadoc warnings in generated files (#6231)
* Java: Add Automatic-Module-Name entries to the Manifest (#6568)
Python
* Add descriptor methods in descriptor_pool are deprecated.
* Uses explicit imports to prevent multithread test failures in py3.
* Added __delitem__ for Python extension dict
* Update six version to 1.12.0 and fix legacy_create_init issue (#6391)
JavaScript
* Remove deprecated boolean option to getResultBase64String().
* Fix sint64 zig-zag encoding.
* Simplify hash64 string conversion to avoid DIGIT array. Should reduce overhead if these functions aren't used, and be more efficient by avoiding linear array searches.
* Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?).
* Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively.
* Migrate moneys to TypeScript.
PHP
* Fix incorrect leap day for Timestamp (#6696)
* Initialize well known type values (#6713)
Ruby
* Fix scope resolution for Google namespace (#5878)
* Support hashes for struct initializers (#5716)
* Optimized away the creation of empty string objects. (#6502)
* Roll forward Ruby upb changes now that protobuf Ruby build is fixed (#5866)
* Optimized layout_mark() for Ruby (#6521)
* Optimization for layout_init() (#6547)
* Fix for GC of Ruby map frames. (#6533)
* Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695)
Objective C
* Remove OSReadLittle* due to alignment requirements (#6678)
* Don't use unions and instead use memcpy for the type swaps. (#6672)
Other
* Override CocoaPods module to lowercase (#6464)
2019-06-28 version 3.9.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
s.version = '3.9.0-rc1'
s.version = '3.11.0-rc0'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'

@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.9.1'
s.version = '3.11.0-rc0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = '3-Clause BSD License'

@ -199,7 +199,7 @@ if (MSVC)
configure_file(extract_includes.bat.in extract_includes.bat)
# Suppress linker warnings about files with no symbols defined.
set(CMAKE_STATIC_LINKER_FLAGS /ignore:4221)
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# Configure Resource Compiler
enable_language(RC)

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.9.1],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.11.0-rc-0],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])

@ -2689,6 +2689,10 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
})",
"repeated_timestamp: {seconds: -62135596800}"
"repeated_timestamp: {seconds: 253402300799 nanos: 999999999}");
RunValidJsonTest(
"TimestampLeap", REQUIRED,
R"({"optionalTimestamp": "1993-02-10T00:00:00.000Z"})",
"optional_timestamp: {seconds: 729302400}");
RunValidJsonTest("TimestampWithPositiveOffset", REQUIRED,
R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})",
"optional_timestamp: {seconds: 1}");

@ -66,8 +66,6 @@ Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
Required.Proto3.ProtobufInput.ValidDataMap.STRING.MESSAGE.MissingDefault.JsonOutput
Required.Proto3.ProtobufInput.ValidDataMap.STRING.MESSAGE.MissingDefault.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.9.1</version>
<version>3.11.0-rc0</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>

@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.9.1</VersionPrefix>
<VersionPrefix>3.11.0-rc0</VersionPrefix>
<LangVersion>6</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;netstandard2.0;net45</TargetFrameworks>
@ -28,7 +28,7 @@
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0-preview.2"/>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">

@ -77,7 +77,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value enum value option for this descriptor
/// </summary>
public T GetOption<T>(Extension<EnumValueOptions, T> extension)
{
@ -86,7 +86,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value enum value option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumValueOptions, T> extension)
{

@ -302,7 +302,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value field option for this descriptor
/// </summary>
public T GetOption<T>(Extension<FieldOptions, T> extension)
{
@ -311,7 +311,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value field option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FieldOptions, T> extension)
{

@ -545,7 +545,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value file option for this descriptor
/// </summary>
public T GetOption<T>(Extension<FileOptions, T> extension)
{
@ -554,7 +554,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value file option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FileOptions, T> extension)
{

@ -264,7 +264,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value message option for this descriptor
/// </summary>
public T GetOption<T>(Extension<MessageOptions, T> extension)
{
@ -273,7 +273,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value message option for this descriptor
/// </summary>
public Collections.RepeatedField<T> GetOption<T>(RepeatedExtension<MessageOptions, T> extension)
{

@ -77,7 +77,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value method option for this descriptor
/// </summary>
public T GetOption<T>(Extension<MethodOptions, T> extension)
{
@ -86,7 +86,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value method option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<MethodOptions, T> extension)
{

@ -109,7 +109,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value oneof option for this descriptor
/// </summary>
public T GetOption<T>(Extension<OneofOptions, T> extension)
{
@ -118,7 +118,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value oneof option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension)
{

@ -98,7 +98,7 @@ namespace Google.Protobuf.Reflection
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// Gets a single value service option for this descriptor
/// </summary>
public T GetOption<T>(Extension<ServiceOptions, T> extension)
{
@ -107,7 +107,7 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// Gets a repeated value service option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<ServiceOptions, T> extension)
{

@ -208,3 +208,7 @@ with info about your project (name and website) so we can add an entry for you.
1. protokt
* Website: https://github.com/toasttab/protokt (Currently Private but will be open soon.)
* Extensions: 1072
1. Dart port of protocol buffers
* Website https://github.com/dart-lang/protobuf
* Extensions: 1073

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.9.1</version>
<version>3.9.2</version>
</dependency>
```
@ -37,7 +37,7 @@ protobuf-java-util package:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.9.1</version>
<version>3.9.2</version>
</dependency>
```
@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
```
compile 'com.google.protobuf:protobuf-java:3.9.1'
compile 'com.google.protobuf:protobuf-java:3.9.2'
```
Again, be sure to check that the version number maches (or is newer than) the version number of protoc that you are using.

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name>
@ -29,8 +29,8 @@
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>3-Clause BSD License</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
</license>
</licenses>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
</parent>
<artifactId>protobuf-java</artifactId>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
</parent>
<artifactId>protobuf-javalite</artifactId>

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
</parent>
<artifactId>protobuf-java-util</artifactId>

@ -1,6 +1,6 @@
{
"name": "google-protobuf",
"version": "3.9.1",
"version": "3.11.0-rc.0",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [

@ -93,14 +93,22 @@ static int8_t ReadRawByte(GPBCodedInputStreamState *state) {
static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int32_t));
int32_t value = OSReadLittleInt32(state->bytes, state->bufferPos);
// Not using OSReadLittleInt32 because it has undocumented dependency
// on reads being aligned.
int32_t value;
memcpy(&value, state->bytes + state->bufferPos, sizeof(int32_t));
value = OSSwapLittleToHostInt32(value);
state->bufferPos += sizeof(int32_t);
return value;
}
static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
CheckSize(state, sizeof(int64_t));
int64_t value = OSReadLittleInt64(state->bytes, state->bufferPos);
// Not using OSReadLittleInt64 because it has undocumented dependency
// on reads being aligned.
int64_t value;
memcpy(&value, state->bytes + state->bufferPos, sizeof(int64_t));
value = OSSwapLittleToHostInt64(value);
state->bufferPos += sizeof(int64_t);
return value;
}

@ -71,27 +71,31 @@ GPB_INLINE void GPBDebugCheckRuntimeVersion() {
// Conversion functions for de/serializing floating point types.
GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) {
union { double f; int64_t i; } u;
u.f = v;
return u.i;
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
int64_t result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE int32_t GPBConvertFloatToInt32(float v) {
union { float f; int32_t i; } u;
u.f = v;
return u.i;
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
int32_t result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE double GPBConvertInt64ToDouble(int64_t v) {
union { double f; int64_t i; } u;
u.i = v;
return u.f;
GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits);
double result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE float GPBConvertInt32ToFloat(int32_t v) {
union { float f; int32_t i; } u;
u.i = v;
return u.f;
GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits);
float result;
memcpy(&result, &v, sizeof(result));
return result;
}
GPB_INLINE int32_t GPBLogicalRightShift32(int32_t value, int32_t spaces) {

@ -95,3 +95,45 @@ Known Issues
* HHVM not tested.
* C extension not tested on windows, mac, php 7.0.
* Message name cannot be Empty.
## Development
### Docker Image
We provide a docker image for php development, which is also used in our automatic tests:
```
docker run --security-opt seccomp=unconfined -it protobuftesting/php_8dbe419c6df1a8b3af0ae3a267c112efb436b45c
```
### Test Native PHP
```
# Download protobuf
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
# Build protoc
./autogen.sh
./configure
make -j4
# Test native php
cd php
composer install
composer test
```
### Test C Extension
After you have finished testing the native php, you can test the c extension:
```
cd tests
./test.sh 5.6 # The php runtime version.
# We provide 5.5, 5.5-zts, 5.6, 5.6-zts, 7.0, 7.0-zts, 7.1, 7.1-zts, 7.2, 7.2-zts, 7.3 and 7.3-zts
# ls /usr/local for more details
```
If you want to use gdb to debug the c extension, you can do:
```
./gdb_test.sh
```

@ -337,7 +337,6 @@ static void new_php_string(zval** value_ptr, const char* str, size_t len) {
!IS_INTERNED(Z_STRVAL_PP(value_ptr))) {
FREE(Z_STRVAL_PP(value_ptr));
}
ZVAL_EMPTY_STRING(*value_ptr);
ZVAL_STRINGL(*value_ptr, str, len, 1);
}
#else
@ -459,6 +458,7 @@ static void *submsg_handler(void *closure, const void *hd) {
// Handler data for startmap/endmap handlers.
typedef struct {
size_t ofs;
const upb_msgdef* value_md;
upb_fieldtype_t key_field_type;
upb_fieldtype_t value_field_type;
} map_handlerdata_t;
@ -485,7 +485,9 @@ PHP_PROTO_WRAP_OBJECT_START(map_parse_frame_t)
PHP_PROTO_WRAP_OBJECT_END
typedef struct map_parse_frame_t map_parse_frame_t;
static void map_slot_init(void* memory, upb_fieldtype_t type, zval* cache) {
static void map_slot_init(
void* memory, upb_fieldtype_t type, zval* cache,
const upb_msgdef* value_msg PHP_PROTO_TSRMLS_DC) {
switch (type) {
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
@ -505,16 +507,24 @@ static void map_slot_init(void* memory, upb_fieldtype_t type, zval* cache) {
break;
}
case UPB_TYPE_MESSAGE: {
Descriptor* subdesc =
UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(value_msg));
zend_class_entry* subklass = subdesc->klass;
MessageHeader* submsg;
#if PHP_MAJOR_VERSION < 7
zval** holder = ALLOC(zval*);
zval* tmp;
MAKE_STD_ZVAL(tmp);
ZVAL_NULL(tmp);
ZVAL_OBJ(tmp, subklass->create_object(subklass TSRMLS_CC));
submsg = UNBOX(MessageHeader, tmp);
custom_data_init(subklass, submsg PHP_PROTO_TSRMLS_CC);
*holder = tmp;
*(zval***)memory = holder;
#else
*(zval**)memory = cache;
ZVAL_NULL(*(zval**)memory);
ZVAL_OBJ(*(zval**)memory, subklass->create_object(subklass TSRMLS_CC));
submsg = UNBOX(MessageHeader, cache);
custom_data_init(subklass, submsg PHP_PROTO_TSRMLS_CC);
#endif
break;
}
@ -585,8 +595,10 @@ static void map_slot_value(upb_fieldtype_t type, const void* from,
zend_string_addref(*(zend_string**)to);
break;
case UPB_TYPE_MESSAGE:
*(zend_object**)to = Z_OBJ_P(*(zval**)from);
GC_ADDREF(*(zend_object**)to);
if (!ZVAL_IS_NULL(*(zval**)from)) {
*(zend_object**)to = Z_OBJ_P(*(zval**)from);
GC_ADDREF(*(zend_object**)to);
}
break;
#endif
default:
@ -600,6 +612,7 @@ static void map_slot_value(upb_fieldtype_t type, const void* from,
static void *startmapentry_handler(void *closure, const void *hd) {
MessageHeader* msg = closure;
const map_handlerdata_t* mapdata = hd;
TSRMLS_FETCH();
zval* map = CACHED_PTR_TO_ZVAL_PTR(
DEREF(message_data(msg), mapdata->ofs, CACHED_VALUE*));
@ -608,9 +621,9 @@ static void *startmapentry_handler(void *closure, const void *hd) {
frame->map = map;
map_slot_init(&frame->data->key_storage, mapdata->key_field_type,
&frame->key_zval);
&frame->key_zval, NULL PHP_PROTO_TSRMLS_CC);
map_slot_init(&frame->data->value_storage, mapdata->value_field_type,
&frame->value_zval);
&frame->value_zval, mapdata->value_md PHP_PROTO_TSRMLS_CC);
return frame;
}
@ -665,6 +678,11 @@ static map_handlerdata_t* new_map_handlerdata(
value_field = upb_msgdef_itof(mapentry_def, MAP_VALUE_FIELD);
PHP_PROTO_ASSERT(value_field != NULL);
hd->value_field_type = upb_fielddef_type(value_field);
if (upb_fielddef_type(value_field) == UPB_TYPE_MESSAGE) {
hd->value_md = upb_fielddef_msgsubdef(value_field);
} else {
hd->value_md = NULL;
}
return hd;
}

@ -1770,19 +1770,19 @@ zend_class_entry* api_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Api",
Api, api)
zend_declare_property_null(api_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(api_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "methods", strlen("methods"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "version", strlen("version"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(api_type, "version", strlen("version"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "source_context", strlen("source_context"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "mixins", strlen("mixins"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(api_type, "syntax", strlen("syntax"),
zend_declare_property_long(api_type, "syntax", strlen("syntax"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -1816,7 +1816,7 @@ zend_class_entry* bool_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BoolValue",
BoolValue, bool_value)
zend_declare_property_null(bool_value_type, "value", strlen("value"),
zend_declare_property_bool(bool_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -1844,8 +1844,8 @@ zend_class_entry* bytes_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BytesValue",
BytesValue, bytes_value)
zend_declare_property_null(bytes_value_type, "value", strlen("value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(bytes_value_type, "value", strlen("value"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(BytesValue, __construct) {
@ -1872,8 +1872,8 @@ zend_class_entry* double_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\DoubleValue",
DoubleValue, double_value)
zend_declare_property_null(double_value_type, "value", strlen("value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_double(double_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(DoubleValue, __construct) {
@ -1908,15 +1908,15 @@ zend_class_entry* enum_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Enum",
Enum, enum)
zend_declare_property_null(enum_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(enum_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_type, "enumvalue", strlen("enumvalue"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_type, "source_context", strlen("source_context"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_type, "syntax", strlen("syntax"),
zend_declare_property_long(enum_type, "syntax", strlen("syntax"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -1952,9 +1952,9 @@ zend_class_entry* enum_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\EnumValue",
EnumValue, enum_value)
zend_declare_property_null(enum_value_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_value_type, "number", strlen("number"),
zend_declare_property_string(enum_value_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(enum_value_type, "number", strlen("number"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(enum_value_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
@ -2032,26 +2032,27 @@ zend_class_entry* field_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Field",
Field, field)
zend_declare_property_null(field_type, "kind", strlen("kind"),
zend_declare_property_long(field_type, "kind", strlen("kind"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "cardinality", strlen("cardinality"),
zend_declare_property_long(field_type, "cardinality", strlen("cardinality"),
0, ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(field_type, "number", strlen("number"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "number", strlen("number"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "type_url", strlen("type_url"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "oneof_index", strlen("oneof_index"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "packed", strlen("packed"),
zend_declare_property_string(field_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(field_type, "type_url", strlen("type_url"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_long(field_type, "oneof_index", strlen("oneof_index"),
0, ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_bool(field_type, "packed", strlen("packed"), false,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "json_name", strlen("json_name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(field_type, "default_value", strlen("default_value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(field_type, "json_name", strlen("json_name"),
"", ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(field_type, "default_value",
strlen("default_value"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(Field, __construct) {
@ -2087,8 +2088,8 @@ zend_class_entry* float_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\FloatValue",
FloatValue, float_value)
zend_declare_property_null(float_value_type, "value", strlen("value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_double(float_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(FloatValue, __construct) {
@ -2138,7 +2139,7 @@ zend_class_entry* int32_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int32Value",
Int32Value, int32_value)
zend_declare_property_null(int32_value_type, "value", strlen("value"),
zend_declare_property_long(int32_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2166,7 +2167,7 @@ zend_class_entry* int64_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int64Value",
Int64Value, int64_value)
zend_declare_property_null(int64_value_type, "value", strlen("value"),
zend_declare_property_long(int64_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2234,19 +2235,23 @@ zend_class_entry* method_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Method",
Method, method)
zend_declare_property_null(method_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "request_type_url", strlen("request_type_url"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "request_streaming", strlen("request_streaming"),
zend_declare_property_string(method_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(method_type, "request_type_url",
strlen("request_type_url"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_bool(method_type, "request_streaming",
strlen("request_streaming"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "response_type_url", strlen("response_type_url"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "response_streaming", strlen("response_streaming"),
zend_declare_property_string(method_type, "response_type_url",
strlen("response_type_url"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_bool(method_type, "response_streaming",
strlen("response_streaming"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(method_type, "syntax", strlen("syntax"),
zend_declare_property_long(method_type, "syntax", strlen("syntax"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2282,10 +2287,10 @@ zend_class_entry* mixin_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Mixin",
Mixin, mixin)
zend_declare_property_null(mixin_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(mixin_type, "root", strlen("root"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(mixin_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(mixin_type, "root", strlen("root"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(Mixin, __construct) {
@ -2315,8 +2320,8 @@ zend_class_entry* option_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Option",
Option, option)
zend_declare_property_null(option_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(option_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(option_type, "value", strlen("value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2346,8 +2351,9 @@ zend_class_entry* source_context_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\SourceContext",
SourceContext, source_context)
zend_declare_property_null(source_context_type, "file_name", strlen("file_name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(source_context_type, "file_name",
strlen("file_name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(SourceContext, __construct) {
@ -2374,8 +2380,8 @@ zend_class_entry* string_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\StringValue",
StringValue, string_value)
zend_declare_property_null(string_value_type, "value", strlen("value"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(string_value_type, "value", strlen("value"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(StringValue, __construct) {
@ -2440,17 +2446,17 @@ zend_class_entry* type_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Type",
Type, type)
zend_declare_property_null(type_type, "name", strlen("name"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(type_type, "name", strlen("name"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(type_type, "fields", strlen("fields"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(type_type, "oneofs", strlen("oneofs"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_string(type_type, "oneofs", strlen("oneofs"), "",
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(type_type, "options", strlen("options"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(type_type, "source_context", strlen("source_context"),
ZEND_ACC_PRIVATE TSRMLS_CC);
zend_declare_property_null(type_type, "syntax", strlen("syntax"),
zend_declare_property_long(type_type, "syntax", strlen("syntax"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2483,7 +2489,7 @@ zend_class_entry* u_int32_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt32Value",
UInt32Value, u_int32_value)
zend_declare_property_null(u_int32_value_type, "value", strlen("value"),
zend_declare_property_long(u_int32_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
@ -2511,7 +2517,7 @@ zend_class_entry* u_int64_value_type;
// Init class entry.
PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt64Value",
UInt64Value, u_int64_value)
zend_declare_property_null(u_int64_value_type, "value", strlen("value"),
zend_declare_property_long(u_int64_value_type, "value", strlen("value"), 0,
ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END

@ -10,15 +10,15 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
<date>2019-08-02</date>
<time>15:59:08</time>
<date>2019-10-03</date>
<time>14:24:03</time>
<version>
<release>3.9.1</release>
<api>3.9.1</api>
<release>3.11.0RC0</release>
<api>3.11.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
@ -389,5 +389,47 @@ G A release.
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.10.0RC1</release>
<api>3.10.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2019-09-04</date>
<time>13:24:25</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.10.0RC1</release>
<api>3.10.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2019-09-05</date>
<time>10:12:46</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.10.0</release>
<api>3.10.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-09-12</date>
<time>13:48:02</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
</changelog>
</package>

@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
#define PHP_PROTOBUF_VERSION "3.9.1"
#define PHP_PROTOBUF_VERSION "3.11.0RC0"
#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8

@ -28,6 +28,60 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// The Zend Engine License, version 2.00
// Copyright (c) 1999-2002 Zend Technologies Ltd. All rights reserved.
// --------------------------------------------------------------------
//
// Redistribution and use in source and binary forms, with or without
// modification, is permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. The names "Zend" and "Zend Engine" must not be used to endorse
// or promote products derived from this software without prior
// permission from Zend Technologies Ltd. For written permission,
// please contact license@zend.com.
//
// 4. Zend Technologies Ltd. may publish revised and/or new versions
// of the license from time to time. Each version will be given a
// distinguishing version number.
// Once covered code has been published under a particular version
// of the license, you may always continue to use it under the
// terms of that version. You may also choose to use such covered
// code under the terms of any subsequent version of the license
// published by Zend Technologies Ltd. No one other than Zend
// Technologies Ltd. has the right to modify the terms applicable
// to covered code created under this License.
//
// 5. Redistributions of any form whatsoever must retain the following
// acknowledgment:
// "This product includes the Zend Engine, freely available at
// http://www.zend.com"
//
// 6. All advertising materials mentioning features or use of this
// software must display the following acknowledgment:
// "The Zend Engine is freely available at http://www.zend.com"
//
// THIS SOFTWARE IS PROVIDED BY ZEND TECHNOLOGIES LTD. ``AS IS'' AND
// ANY EXPRESSED 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 ZEND
// TECHNOLOGIES LTD. 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.
#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>

@ -10131,32 +10131,28 @@ const unsigned short int __mon_yday[2][13] = {
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
int64_t epoch(int year, int yday, int hour, int min, int sec) {
int64_t years = year - EPOCH_YEAR;
int64_t leap_days = years / 4 - years / 100 + years / 400;
int64_t days = years * 365 + yday + leap_days;
int64_t hours = days * 24 + hour;
int64_t mins = hours * 60 + min;
int64_t secs = mins * 60 + sec;
return secs;
}
static int64_t upb_mktime(const struct tm *tp) {
int sec = tp->tm_sec;
int min = tp->tm_min;
int hour = tp->tm_hour;
int mday = tp->tm_mday;
int mon = tp->tm_mon;
int year = tp->tm_year + TM_YEAR_BASE;
/* Calculate day of year from year, month, and day of month. */
int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1);
int yday = mon_yday + mday;
return epoch(year, yday, hour, min, sec);
/* epoch_days(1970, 1, 1) == 1970-01-01 == 0. */
static int epoch_days(int year, int month, int day) {
static const uint16_t month_yday[12] = {0, 31, 59, 90, 120, 151,
181, 212, 243, 273, 304, 334};
int febs_since_0 = month > 2 ? year + 1 : year;
int leap_days_since_0 = div_round_up(febs_since_0, 4) -
div_round_up(febs_since_0, 100) +
div_round_up(febs_since_0, 400);
int days_since_0 =
365 * year + month_yday[month - 1] + (day - 1) + leap_days_since_0;
/* Convert from 0-epoch (0001-01-01 BC) to Unix Epoch (1970-01-01 AD).
* Since the "BC" system does not have a year zero, 1 BC == year zero. */
return days_since_0 - 719528;
}
static int64_t upb_timegm(const struct tm *tp) {
int64_t ret = epoch_days(tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday);
ret = (ret * 24) + tp->tm_hour;
ret = (ret * 60) + tp->tm_min;
ret = (ret * 60) + tp->tm_sec;
return ret;
}
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
@ -10186,7 +10182,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
}
/* Normalize tm */
seconds = upb_mktime(&p->tm);
seconds = upb_timegm(&p->tm);
/* Check timestamp boundary */
if (seconds < -62135596800) {

@ -5,6 +5,7 @@ require_once('test_util.php');
use Google\Protobuf\RepeatedField;
use Google\Protobuf\GPBType;
use Foo\TestStringValue;
use Foo\TestAny;
use Foo\TestEnum;
use Foo\TestMessage;
@ -167,6 +168,14 @@ class EncodeDecodeTest extends TestBase
$this->assertSame("\"a\"", $m->serializeToJsonString());
}
public function testEncodeStringValue()
{
$m = new TestStringValue(['field' => new StringValue(['value' => ''])]);
var_dump($m->getField());
var_dump($m->serializeToJsonString());
$this->assertSame("{\"field\":\"\"}", $m->serializeToJsonString());
}
public function testDecodeTopLevelBytesValue()
{
$m = new BytesValue();
@ -1189,4 +1198,36 @@ class EncodeDecodeTest extends TestBase
$n->mergeFromJsonString($data);
}
public function testMessageMapNoValue()
{
$m = new TestMessage();
$m->mergeFromString(hex2bin("CA0700"));
$m->serializeToString();
$this->assertTrue(true);
}
public function testAnyMapNoValue()
{
$m = new TestMessage();
$m->mergeFromString(hex2bin("D20700"));
$m->serializeToString();
$this->assertTrue(true);
}
public function testListValueMapNoValue()
{
$m = new TestMessage();
$m->mergeFromString(hex2bin("DA0700"));
$m->serializeToString();
$this->assertTrue(true);
}
public function testStructMapNoValue()
{
$m = new TestMessage();
$m->mergeFromString(hex2bin("E20700"));
$m->serializeToString();
$this->assertTrue(true);
}
}

@ -31,6 +31,7 @@ require_once('generated/Foo/TestPackedMessage.php');
require_once('generated/Foo/TestPhpDoc.php');
require_once('generated/Foo/TestRandomFieldOrder.php');
require_once('generated/Foo/TestReverseFieldOrder.php');
require_once('generated/Foo/TestStringValue.php');
require_once('generated/Foo/TestUnpackedMessage.php');
require_once('generated/Foo/testLowerCaseMessage.php');
require_once('generated/Foo/testLowerCaseEnum.php');

@ -1,6 +1,7 @@
syntax = "proto3";
import 'google/protobuf/any.proto';
import 'google/protobuf/wrappers.proto';
import 'google/protobuf/struct.proto';
import 'proto/test_include.proto';
import 'proto/test_no_namespace.proto';
@ -119,6 +120,12 @@ message TestMessage {
}
reserved 111;
// Test map with missing message value
map<string, TestMessage> map_string_message = 121;
map<string, google.protobuf.Any> map_string_any = 122;
map<string, google.protobuf.ListValue> map_string_list = 123;
map<string, google.protobuf.Struct> map_string_struct = 124;
}
enum TestEnum {
@ -207,3 +214,7 @@ enum testLowerCaseEnum {
message TestAny {
google.protobuf.Any any = 1;
}
message TestStringValue {
google.protobuf.StringValue field = 1;
}

@ -8,7 +8,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>3.9.1</version>
<version>3.11.0-rc-0</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>

@ -30,7 +30,7 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '3.9.1'
__version__ = '3.11.0rc0'
if __name__ != '__main__':
try:

@ -10117,46 +10117,28 @@ static void start_timestamp_zone(upb_json_parser *p, const char *ptr) {
capture_begin(p, ptr);
}
#define EPOCH_YEAR 1970
#define TM_YEAR_BASE 1900
static bool isleap(int year) {
return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0);
}
const unsigned short int __mon_yday[2][13] = {
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
int64_t epoch(int year, int yday, int hour, int min, int sec) {
int64_t years = year - EPOCH_YEAR;
int64_t leap_days = years / 4 - years / 100 + years / 400;
int64_t days = years * 365 + yday + leap_days;
int64_t hours = days * 24 + hour;
int64_t mins = hours * 60 + min;
int64_t secs = mins * 60 + sec;
return secs;
}
static int64_t upb_mktime(const struct tm *tp) {
int sec = tp->tm_sec;
int min = tp->tm_min;
int hour = tp->tm_hour;
int mday = tp->tm_mday;
int mon = tp->tm_mon;
int year = tp->tm_year + TM_YEAR_BASE;
/* Calculate day of year from year, month, and day of month. */
int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1);
int yday = mon_yday + mday;
return epoch(year, yday, hour, min, sec);
/* epoch_days(1970, 1, 1) == 1970-01-01 == 0. */
static int epoch_days(int year, int month, int day) {
static const uint16_t month_yday[12] = {0, 31, 59, 90, 120, 151,
181, 212, 243, 273, 304, 334};
int febs_since_0 = month > 2 ? year + 1 : year;
int leap_days_since_0 = div_round_up(febs_since_0, 4) -
div_round_up(febs_since_0, 100) +
div_round_up(febs_since_0, 400);
int days_since_0 =
365 * year + month_yday[month - 1] + (day - 1) + leap_days_since_0;
/* Convert from 0-epoch (0001-01-01 BC) to Unix Epoch (1970-01-01 AD).
* Since the "BC" system does not have a year zero, 1 BC == year zero. */
return days_since_0 - 719528;
}
static int64_t upb_timegm(const struct tm *tp) {
int64_t ret = epoch_days(tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday);
ret = (ret * 24) + tp->tm_hour;
ret = (ret * 60) + tp->tm_min;
ret = (ret * 60) + tp->tm_sec;
return ret;
}
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
@ -10186,7 +10168,7 @@ static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
}
/* Normalize tm */
seconds = upb_mktime(&p->tm);
seconds = upb_timegm(&p->tm);
/* Check timestamp boundary */
if (seconds < -62135596800) {

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.9.1"
s.version = "3.11.0.rc.0"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"

@ -1462,6 +1462,18 @@ module CommonTests
assert_raise(Google::Protobuf::TypeError) { m.timestamp = 2.4 }
assert_raise(Google::Protobuf::TypeError) { m.timestamp = '4' }
assert_raise(Google::Protobuf::TypeError) { m.timestamp = proto_module::TimeMessage.new }
def test_time(year, month, day)
str = ("\"%04d-%02d-%02dT00:00:00.000+00:00\"" % [year, month, day])
t = Google::Protobuf::Timestamp.decode_json(str)
time = Time.new(year, month, day, 0, 0, 0, "+00:00")
assert_equal t.seconds, time.to_i
end
(1970..2010).each do |year|
test_time(year, 2, 28)
test_time(year, 3, 01)
end
end
def test_converts_duration

@ -18,7 +18,7 @@ else
PTHREAD_DEF =
endif
PROTOBUF_VERSION = 20:1:0
PROTOBUF_VERSION = 22:0:0
if GCC
# Turn on all warnings except for sign comparison (we ignore sign comparison

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -952,7 +952,7 @@ TEST_F(CommandLineInterfaceTest, ReportsTransitiveMisingImports_LeafFirst) {
Run("protocol_compiler --test_out=$tmpdir "
"--proto_path=$tmpdir bar.proto foo.proto");
ExpectWarningSubstring(
"bar.proto:2:1: warning: Import unused.proto but not used.");
"bar.proto:2:1: warning: Import unused.proto is unused.");
}
TEST_F(CommandLineInterfaceTest, ReportsTransitiveMisingImports_LeafLast) {
@ -973,7 +973,7 @@ TEST_F(CommandLineInterfaceTest, ReportsTransitiveMisingImports_LeafLast) {
Run("protocol_compiler --test_out=$tmpdir "
"--proto_path=$tmpdir foo.proto bar.proto");
ExpectWarningSubstring(
"bar.proto:2:1: warning: Import unused.proto but not used.");
"bar.proto:2:1: warning: Import unused.proto is unused.");
}
TEST_F(CommandLineInterfaceTest, CreateDirectory) {

@ -1018,7 +1018,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
" static bool ValidateKey(std::string* s) {\n"
" return ::$proto_ns$::internal::WireFormatLite::"
"VerifyUtf8String(s->data(), s->size(), "
"VerifyUtf8String(s->data(), static_cast<int>(s->size()), "
"::$proto_ns$::internal::WireFormatLite::PARSE, \"$1$\");\n"
" }\n",
descriptor_->field(0)->full_name());
@ -1028,7 +1028,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" static bool ValidateKey(std::string* s) {\n"
"#ifndef NDEBUG\n"
" ::$proto_ns$::internal::WireFormatLite::VerifyUtf8String(\n"
" s->data(), s->size(), ::$proto_ns$::internal::"
" s->data(), static_cast<int>(s->size()), ::$proto_ns$::internal::"
"WireFormatLite::PARSE, \"$1$\");\n"
"#endif\n"
" return true;\n"
@ -1044,7 +1044,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
" static bool ValidateValue(std::string* s) {\n"
" return ::$proto_ns$::internal::WireFormatLite::"
"VerifyUtf8String(s->data(), s->size(), "
"VerifyUtf8String(s->data(), static_cast<int>(s->size()), "
"::$proto_ns$::internal::WireFormatLite::PARSE, \"$1$\");\n"
" }\n",
descriptor_->field(1)->full_name());
@ -1054,7 +1054,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" static bool ValidateValue(std::string* s) {\n"
"#ifndef NDEBUG\n"
" ::$proto_ns$::internal::WireFormatLite::VerifyUtf8String(\n"
" s->data(), s->size(), ::$proto_ns$::internal::"
" s->data(), static_cast<int>(s->size()), ::$proto_ns$::internal::"
"WireFormatLite::PARSE, \"$1$\");\n"
"#endif\n"
" return true;\n"

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -7174,7 +7174,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
unused_dependency_.begin();
it != unused_dependency_.end(); ++it) {
// Log warnings for unused imported files.
std::string error_message = "Import " + (*it)->name() + " but not used.";
std::string error_message = "Import " + (*it)->name() + " is unused.";
AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
error_message);
}

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -116,7 +116,7 @@ class PROTOBUF_EXPORT DescriptorDatabase {
//
// This method has a default implementation that always returns
// false.
virtual bool FindAllFileNames(std::vector<std::string>* output) {
virtual bool FindAllFileNames(std::vector<std::string>* /*output*/) {
return false;
}

@ -3479,7 +3479,7 @@ TEST(CustomOptions, UnusedImportWarning) {
EXPECT_EQ(
"custom_options_import.proto: "
"google/protobuf/unittest_custom_options.proto: IMPORT: Import "
"google/protobuf/unittest_custom_options.proto but not used.\n",
"google/protobuf/unittest_custom_options.proto is unused.\n",
error_collector.warning_text_);
EXPECT_EQ("", error_collector.text_);
}
@ -5795,7 +5795,7 @@ TEST_F(ValidationErrorTest, UnusedImportWarning) {
" field { name:\"base\" number:1 label:LABEL_OPTIONAL "
"type_name:\"Base\" }"
"}",
"forward.proto: bar.proto: IMPORT: Import bar.proto but not used.\n");
"forward.proto: bar.proto: IMPORT: Import bar.proto is unused.\n");
}
namespace {

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -44,6 +44,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/message.h>
#include <google/protobuf/reflection.h>
#include <google/protobuf/stubs/mutex.h>
#include <google/protobuf/reflection.h>
#include <google/protobuf/repeated_field.h>

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -146,8 +146,15 @@
#define PROTOBUF_NAMESPACE_CLOSE \
} /* namespace protobuf */ \
} /* namespace google */
#define PROTOBUF_DEPRECATED
#define PROTOBUF_DEPRECATED_MSG(x)
#if defined(__GNUC__) || defined(__clang__)
#define PROTOBUF_DEPRECATED __attribute__((deprecated))
#define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER)
#define PROTOBUF_DEPRECATED __declspec(deprecated)
#define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#endif
#define PROTOBUF_SECTION_VARIABLE(x)
#define PROTOBUF_MUST_USE_RESULT
@ -288,14 +295,14 @@
// Shared google3/opensource definitions. //////////////////////////////////////
#define PROTOBUF_VERSION 3009001
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3009000
#define PROTOBUF_MIN_PROTOC_VERSION 3009000
#define PROTOBUF_VERSION 3011000
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3011000
#define PROTOBUF_MIN_PROTOC_VERSION 3011000
#define PROTOBUF_VERSION_SUFFIX ""
// The minimum library version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3009000
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3011000
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
#define PROTOBUF_RTTI 0
@ -334,20 +341,28 @@
#if defined(PROTOBUF_USE_DLLS)
#if defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __declspec(dllexport)
#define PROTOBUF_EXPORT __declspec(dllexport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
#else
#define PROTOBUF_EXPORT __declspec(dllimport)
#define PROTOBUF_EXPORT __declspec(dllimport)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __declspec(dllexport)
#define PROTOC_EXPORT __declspec(dllexport)
#else
#define PROTOC_EXPORT __declspec(dllimport)
#define PROTOC_EXPORT __declspec(dllimport)
#endif
#else // defined(_MSC_VER)
#ifdef LIBPROTOBUF_EXPORTS
#define PROTOBUF_EXPORT __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#else
#define PROTOBUF_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif
#ifdef LIBPROTOC_EXPORTS
#define PROTOC_EXPORT __attribute__((visibility("default")))
@ -358,168 +373,10 @@
#else // defined(PROTOBUF_USE_DLLS)
#define PROTOBUF_EXPORT
#define PROTOC_EXPORT
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE
#endif
// This portion provides macros for using FOO_EXPORT macros with explicit
// template instantiation declarations and definitions.
// Generally, the FOO_EXPORT macros are used at declarations,
// and GCC requires them to be used at explicit instantiation declarations,
// but MSVC requires __declspec(dllexport) to be used at the explicit
// instantiation definitions instead.
// Usage
//
// In a header file, write:
//
// extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(FOO_EXPORT) foo<bar>;
//
// In a source file, write:
//
// template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(FOO_EXPORT) foo<bar>;
//
// Where FOO_EXPORT is either PROTOBUF_EXPORT or PROTOC_EXPORT
// Implementation notes
//
// The implementation of these macros uses some subtle macro semantics to
// detect what the provided FOO_EXPORT value was defined as and then
// to dispatch to appropriate macro definitions. Unfortunately,
// MSVC's C preprocessor is rather non-compliant and requires special
// care to make it work.
//
// Issue 1.
//
// #define F(x)
// F()
//
// MSVC emits warning C4003 ("not enough actual parameters for macro
// 'F'), even though it's a valid macro invocation. This affects the
// macros below that take just an "export" parameter, because export
// may be empty.
//
// As a workaround, we can add a dummy parameter and arguments:
//
// #define F(x,_)
// F(,)
//
// Issue 2.
//
// #define F(x) G##x
// #define Gj() ok
// F(j())
//
// The correct replacement for "F(j())" is "ok", but MSVC replaces it
// with "Gj()". As a workaround, we can pass the result to an
// identity macro to force MSVC to look for replacements again. (This
// is why PROTOBUF_EXPORT_TEMPLATE_STYLE_3 exists.)
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE(export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
DECLARE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export)
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE(export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
DEFINE, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), export)
// INVOKE is an internal helper macro to perform parameter replacements
// and token pasting to chain invoke another macro. E.g.,
// PROTOBUF_EXPORT_TEMPLATE_INVOKE(DECLARE, DEFAULT, FOO_EXPORT)
// will export to call
// PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(FOO_EXPORT, )
// (but with FOO_EXPORT expanded too).
#define PROTOBUF_EXPORT_TEMPLATE_INVOKE(which, style, export) \
PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export)
#define PROTOBUF_EXPORT_TEMPLATE_INVOKE_2(which, style, export) \
PROTOBUF_EXPORT_TEMPLATE_##which##_##style(export, )
// Default style is to apply the FOO_EXPORT macro at declaration sites.
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT(export, _) export
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT(export, _)
// The "MSVC hack" style is used when FOO_EXPORT is defined
// as __declspec(dllexport), which MSVC requires to be used at
// definition sites instead.
#define PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK(export, _)
#define PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK(export, _) export
// PROTOBUF_EXPORT_TEMPLATE_STYLE is an internal helper macro that identifies
// which export style needs to be used for the provided FOO_EXPORT macro
// definition. "", "__attribute__(...)", and "__declspec(dllimport)" are
// mapped to "DEFAULT"; while "__declspec(dllexport)" is mapped to "MSVC_HACK".
//
// It's implemented with token pasting to transform the __attribute__ and
// __declspec annotations into macro invocations. E.g., if FOO_EXPORT is
// defined as "__declspec(dllimport)", it undergoes the following sequence of
// macro substitutions:
// PROTOBUF_EXPORT_TEMPLATE_STYLE(FOO_EXPORT, )
// PROTOBUF_EXPORT_TEMPLATE_STYLE_2(__declspec(dllimport), )
// PROTOBUF_EXPORT_TEMPLATE_STYLE_3(
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport))
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport)
// PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport
// DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE(export, _) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, )
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_2(export, _) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_3( \
PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA##export)
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_3(style) style
// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE.
//
// XXX: C++ reserves all identifiers containing "__" for the implementation,
// but "__attribute__" and "__declspec" already contain "__" and the token-paste
// operator can only add characters; not remove them. To minimize the risk of
// conflict with implementations, we include "foj3FJo5StF0OvIzl7oMxA" (a random
// 128-bit string, encoded in Base64) in the macro name.
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__(...) \
DEFAULT
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec(arg) \
PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_##arg
// Internal helper macros for PROTOBUF_EXPORT_TEMPLATE_STYLE.
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport MSVC_HACK
#define PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport DEFAULT
// Sanity checks.
//
// PROTOBUF_EXPORT_TEMPLATE_TEST uses the same macro invocation pattern as
// PROTOBUF_EXPORT_TEMPLATE_DECLARE and PROTOBUF_EXPORT_TEMPLATE_DEFINE do to
// check that they're working correctly. When they're working correctly, the
// sequence of macro replacements should go something like:
//
// PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport));
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT,
// PROTOBUF_EXPORT_TEMPLATE_STYLE(__declspec(dllimport), ),
// __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT,
// DEFAULT, __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(
// __declspec(dllimport)), "__declspec(dllimport)");
//
// static_assert(true, "__declspec(dllimport)");
//
// When they're not working correctly, a syntax error should occur instead.
#define PROTOBUF_EXPORT_TEMPLATE_TEST(want, export) \
static_assert(PROTOBUF_EXPORT_TEMPLATE_INVOKE( \
TEST_##want, PROTOBUF_EXPORT_TEMPLATE_STYLE(export, ), \
export), #export)
#define PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(...) true
#define PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK(...) true
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, );
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default"))));
PROTOBUF_EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport));
PROTOBUF_EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport));
#undef PROTOBUF_EXPORT_TEMPLATE_TEST
#undef PROTOBUF_EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK
// Windows declares several inconvenient macro names. We #undef them and then
// restore them in port_undef.inc.
#ifdef _MSC_VER

@ -67,20 +67,6 @@
#undef PROTOBUF_ASSUME
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE
#undef PROTOBUF_EXPORT_TEMPLATE_INVOKE
#undef PROTOBUF_EXPORT_TEMPLATE_INVOKE_2
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_DEFAULT
#undef PROTOBUF_EXPORT_TEMPLATE_DECLARE_MSVC_HACK
#undef PROTOBUF_EXPORT_TEMPLATE_DEFINE_MSVC_HACK
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_2
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_3
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport
#undef PROTOBUF_EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport
// Restore macro that may have been #undef'd in port_def.inc.
#ifdef _MSC_VER

@ -123,22 +123,14 @@ MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
} // namespace internal
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<bool>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<int32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<uint32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<int64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<uint64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<float>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedField<double>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE(PROTOBUF_EXPORT)
RepeatedPtrField<std::string>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<bool>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint32>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<int64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<uint64>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>;
template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField<std::string>;
} // namespace protobuf
} // namespace google

@ -2653,21 +2653,14 @@ UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(
}
// Extern declarations of common instantiations to reduce libray bloat.
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<bool>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<int32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<uint32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<int64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<uint64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<float>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
RepeatedField<double>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE(PROTOBUF_EXPORT)
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<bool>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint32>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint64>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>;
extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE
RepeatedPtrField<std::string>;
} // namespace protobuf

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -274,7 +274,7 @@ class PROTOBUF_EXPORT StringByteSink : public ByteSink {
class PROTOBUF_EXPORT NullByteSink : public ByteSink {
public:
NullByteSink() {}
virtual void Append(const char *data, size_t n) override {}
virtual void Append(const char* /*data*/, size_t /*n*/) override {}
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NullByteSink);

@ -81,7 +81,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 3009001
#define GOOGLE_PROTOBUF_VERSION 3011000
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@ -89,15 +89,15 @@ namespace internal {
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
static const int kMinHeaderVersionForLibrary = 3009000;
static const int kMinHeaderVersionForLibrary = 3011000;
// The minimum protoc version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3009000
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3011000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
static const int kMinHeaderVersionForProtoc = 3009000;
static const int kMinHeaderVersionForProtoc = 3011000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.

@ -103,8 +103,9 @@
#define LIBPROTOC_EXPORT
#endif
#define PROTOBUF_RUNTIME_DEPRECATED(message)
#define GOOGLE_PROTOBUF_RUNTIME_DEPRECATED(message)
#define PROTOBUF_RUNTIME_DEPRECATED(message) PROTOBUF_DEPRECATED_MSG(message)
#define GOOGLE_PROTOBUF_RUNTIME_DEPRECATED(message) \
PROTOBUF_DEPRECATED_MSG(message)
// ===================================================================
// from google3/base/port.h

@ -80,21 +80,6 @@ inline bool isprint(char c) {
return c >= 0x20 && c <= 0x7E;
}
// ----------------------------------------------------------------------
// StripString
// Replaces any occurrence of the character 'remove' (or the characters
// in 'remove') with the character 'replacewith'.
// ----------------------------------------------------------------------
void StripString(string* s, const char* remove, char replacewith) {
const char * str_start = s->c_str();
const char * str = str_start;
for (str = strpbrk(str, remove);
str != nullptr;
str = strpbrk(str + 1, remove)) {
(*s)[str - str_start] = replacewith;
}
}
// ----------------------------------------------------------------------
// ReplaceCharacters
// Replaces any occurrence of the character 'remove' (or the characters

@ -159,8 +159,6 @@ inline string StripSuffixString(const string& str, const string& suffix) {
// ----------------------------------------------------------------------
PROTOBUF_EXPORT void ReplaceCharacters(string* s, const char* remove,
char replacewith);
PROTOBUF_EXPORT void StripString(string* s, const char* remove,
char replacewith);
PROTOBUF_EXPORT void StripWhitespace(string* s);

@ -836,6 +836,50 @@ TEST(StrCat, Ints) {
EXPECT_EQ(answer, "130");
}
class ReplaceChars : public ::testing::TestWithParam<std::tuple<string, string, const char*, char>> {
};
TEST_P(ReplaceChars, ReplacesAllOccurencesOfAnyCharInReplaceWithAReplaceChar) {
string expected = std::get<0>(GetParam());
string string_to_replace_in = std::get<1>(GetParam());
const char* what_to_replace = std::get<2>(GetParam());
char replacement = std::get<3>(GetParam());
ReplaceCharacters(&string_to_replace_in, what_to_replace, replacement);
ASSERT_EQ(expected, string_to_replace_in);
}
INSTANTIATE_TEST_CASE_P(Replace,
ReplaceChars,
::testing::Values(
std::make_tuple("", "", "", '_'), // empty string should remain empty
std::make_tuple(" ", " ", "", '_'), // no replacement string
std::make_tuple(" ", " ", "_-abcedf", '*'), // replacement character not in string
std::make_tuple("replace", "Replace", "R", 'r'), // replace one character
std::make_tuple("not_spaces__", "not\nspaces\t ", " \t\r\n", '_'), // replace some special characters
std::make_tuple("c++", "cxx", "x", '+'), // same character multiple times
std::make_tuple("qvvvvvng v T", "queueing a T", "aeiou", 'v'))); // replace all voewls
class StripWs: public ::testing::TestWithParam<std::tuple<string, string>> {
};
TEST_P(StripWs, AlwaysStripsLeadingAndTrailingWhitespace) {
string expected = std::get<0>(GetParam());
string string_to_strip = std::get<1>(GetParam());
StripWhitespace(&string_to_strip);
ASSERT_EQ(expected, string_to_strip);
}
INSTANTIATE_TEST_CASE_P(Strip,
StripWs,
::testing::Values(
std::make_tuple("", ""), // empty string should remain empty
std::make_tuple("", " "), // only ws should become empty
std::make_tuple("no whitespace", " no whitespace"), // leading ws removed
std::make_tuple("no whitespace", "no whitespace "), // trailing ws removed
std::make_tuple("no whitespace", " no whitespace "), // same nb. of leading and trailing
std::make_tuple("no whitespace", " no whitespace "), // different nb. of leading/trailing
std::make_tuple("no whitespace", " no whitespace "))); // more trailing than leading
} // anonymous namespace
} // namespace protobuf
} // namespace google

@ -157,6 +157,7 @@ class PROTOBUF_EXPORT TextFormat {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastFieldValuePrinter);
};
// Deprecated: please use FastFieldValuePrinter instead.
class PROTOBUF_EXPORT FieldValuePrinter {
public:
FieldValuePrinter();

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -8,12 +8,12 @@
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3009000
#if PROTOBUF_VERSION < 3011000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3009001 < PROTOBUF_MIN_PROTOC_VERSION
#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

1
third_party/BUILD vendored

@ -0,0 +1 @@
exports_files(["six.BUILD", "zlib.BUILD"])

@ -24,7 +24,7 @@ Example:
exit(1)
NEW_VERSION = sys.argv[1]
NEW_VERSION_INFO = NEW_VERSION.split('.')
NEW_VERSION_INFO = [int(x) for x in NEW_VERSION.split('.')]
if len(NEW_VERSION_INFO) != 3:
print """
[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO>
@ -34,7 +34,7 @@ Example:
"""
exit(1)
RC_VERSION = 0
RC_VERSION = -1
if len(sys.argv) > 2:
RC_VERSION = int(sys.argv[2])
@ -55,7 +55,7 @@ def ReplaceText(elem, text):
def GetFullVersion(rc_suffix = '-rc-'):
if RC_VERSION == 0:
if RC_VERSION < 0:
return NEW_VERSION
else:
return '%s%s%s' % (NEW_VERSION, rc_suffix, RC_VERSION)
@ -99,7 +99,7 @@ def UpdateConfigure():
def UpdateCpp():
cpp_version = '%s00%s00%s' % (
cpp_version = '%d%03d%03d' % (
NEW_VERSION_INFO[0], NEW_VERSION_INFO[1], NEW_VERSION_INFO[2])
def RewriteCommon(line):
line = re.sub(
@ -110,7 +110,7 @@ def UpdateCpp():
r'^#define PROTOBUF_VERSION .*$',
'#define PROTOBUF_VERSION %s' % cpp_version,
line)
if NEW_VERSION_INFO[2] == '0':
if NEW_VERSION_INFO[2] == 0:
line = re.sub(
r'^#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC .*$',
'#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC %s' % cpp_version,
@ -128,12 +128,13 @@ def UpdateCpp():
'static const int kMinHeaderVersionForProtoc = %s;' % cpp_version,
line)
return line
def RewritePortDef(line):
line = re.sub(
r'^#define PROTOBUF_VERSION .*$',
'#define PROTOBUF_VERSION %s' % cpp_version,
line)
if NEW_VERSION_INFO[2] == '0':
if NEW_VERSION_INFO[2] == 0:
line = re.sub(
r'^#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC .*$',
'#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC %s' % cpp_version,
@ -148,8 +149,31 @@ def UpdateCpp():
line)
return line
def RewritePbH(line):
line = re.sub(
r'^#if PROTOBUF_VERSION < .*$',
'#if PROTOBUF_VERSION < %s' % cpp_version,
line)
line = re.sub(
r'^#if .* < PROTOBUF_MIN_PROTOC_VERSION$',
'#if %s < PROTOBUF_MIN_PROTOC_VERSION' % cpp_version,
line)
return line
RewriteTextFile('src/google/protobuf/stubs/common.h', RewriteCommon)
RewriteTextFile('src/google/protobuf/port_def.inc', RewritePortDef)
RewriteTextFile('src/google/protobuf/any.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/api.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/descriptor.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/duration.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/empty.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/field_mask.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/source_context.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/struct.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/timestamp.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/type.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/wrappers.pb.h', RewritePbH)
RewriteTextFile('src/google/protobuf/compiler/plugin.pb.h', RewritePbH)
def UpdateCsharp():
@ -204,7 +228,7 @@ def UpdateJavaScript():
def UpdateMakefile():
protobuf_version_offset = 11
expected_major_version = '3'
expected_major_version = 3
if NEW_VERSION_INFO[0] != expected_major_version:
print """[ERROR] Major protobuf version has changed. Please update
update_version.py to readjust the protobuf_version_offset and
@ -213,8 +237,8 @@ always increasing.
"""
exit(1)
protobuf_version_info = '%s:%s:0' % (
int(NEW_VERSION_INFO[1]) + protobuf_version_offset, NEW_VERSION_INFO[2])
protobuf_version_info = '%d:%d:0' % (
NEW_VERSION_INFO[1] + protobuf_version_offset, NEW_VERSION_INFO[2])
RewriteTextFile('src/Makefile.am',
lambda line : re.sub(
r'^PROTOBUF_VERSION = .*$',
@ -256,31 +280,32 @@ def UpdatePhp():
ReplaceText(Find(version, 'api'), NEW_VERSION)
stability = Find(root, 'stability')
ReplaceText(Find(stability, 'release'),
'stable' if RC_VERSION == 0 else 'beta')
ReplaceText(Find(stability, 'api'), 'stable' if RC_VERSION == 0 else 'beta')
'stable' if RC_VERSION < 0 else 'beta')
ReplaceText(Find(stability, 'api'), 'stable' if RC_VERSION < 0 else 'beta')
changelog = Find(root, 'changelog')
for old_version in changelog.getElementsByTagName('version'):
if Find(old_version, 'release').firstChild.nodeValue == NEW_VERSION:
print ('[WARNING] Version %s already exists in the change log.'
% NEW_VERSION)
return
changelog.appendChild(document.createTextNode(' '))
release = CreateNode('release', 2, [
CreateNode('version', 3, [
FindAndClone(version, 'release'),
FindAndClone(version, 'api')
]),
CreateNode('stability', 3, [
FindAndClone(stability, 'release'),
FindAndClone(stability, 'api')
]),
FindAndClone(root, 'date'),
FindAndClone(root, 'time'),
FindAndClone(root, 'license'),
FindAndClone(root, 'notes')
])
changelog.appendChild(release)
changelog.appendChild(document.createTextNode('\n '))
if RC_VERSION != 0:
changelog.appendChild(document.createTextNode(' '))
release = CreateNode('release', 2, [
CreateNode('version', 3, [
FindAndClone(version, 'release'),
FindAndClone(version, 'api')
]),
CreateNode('stability', 3, [
FindAndClone(stability, 'release'),
FindAndClone(stability, 'api')
]),
FindAndClone(root, 'date'),
FindAndClone(root, 'time'),
FindAndClone(root, 'license'),
FindAndClone(root, 'notes')
])
changelog.appendChild(release)
changelog.appendChild(document.createTextNode('\n '))
RewriteXml('php/ext/google/protobuf/package.xml', Callback)
RewriteTextFile('php/ext/google/protobuf/protobuf.h',
lambda line : re.sub(

Loading…
Cancel
Save