瀏覽代碼

Merge branch 'master' into php-internaladd

Joshua Haberman 4 年之前
父節點
當前提交
e8a442f97c
共有 100 個文件被更改,包括 5250 次插入1585 次删除
  1. 1 0
      BUILD
  2. 17 0
      CHANGES.txt
  3. 6 2
      Makefile.am
  4. 0 2
      cmake/extract_includes.bat.in
  5. 1 0
      cmake/libprotobuf-lite.cmake
  6. 12 0
      cmake/protobuf-module.cmake.in
  7. 17 6
      conformance/Makefile.am
  8. 0 1
      conformance/failure_list_js.txt
  9. 0 2
      conformance/failure_list_php_c.txt
  10. 0 4
      conformance/failure_list_php_c_32.txt
  11. 78 0
      conformance/text_format_conformance_suite.cc
  12. 20 0
      conformance/text_format_failure_list_cpp.txt
  13. 7 0
      conformance/text_format_failure_list_java.txt
  14. 29 0
      conformance/text_format_failure_list_python.txt
  15. 36 0
      conformance/text_format_failure_list_python_2.7.txt
  16. 28 0
      conformance/text_format_failure_list_python_cpp.txt
  17. 30 0
      conformance/text_format_failure_list_python_cpp_2.7.txt
  18. 12 0
      csharp/src/Google.Protobuf.Test/ByteStringTest.cs
  19. 1 0
      csharp/src/Google.Protobuf/ByteString.cs
  20. 1 1
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  21. 2 2
      docs/options.md
  22. 4 4
      editors/proto.vim
  23. 6 1
      java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java
  24. 0 14
      java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
  25. 9 8
      java/core/src/main/java/com/google/protobuf/CodedInputStream.java
  26. 4 1
      java/core/src/main/java/com/google/protobuf/Descriptors.java
  27. 0 14
      java/core/src/main/java/com/google/protobuf/DoubleArrayList.java
  28. 0 2
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java
  29. 0 2
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
  30. 0 2
      java/core/src/main/java/com/google/protobuf/FieldType.java
  31. 0 14
      java/core/src/main/java/com/google/protobuf/FloatArrayList.java
  32. 0 14
      java/core/src/main/java/com/google/protobuf/IntArrayList.java
  33. 0 1
      java/core/src/main/java/com/google/protobuf/Internal.java
  34. 0 14
      java/core/src/main/java/com/google/protobuf/LongArrayList.java
  35. 1 1
      java/core/src/main/java/com/google/protobuf/MessageSchema.java
  36. 4 3
      java/core/src/main/java/com/google/protobuf/NioByteString.java
  37. 2 5
      java/core/src/main/java/com/google/protobuf/Protobuf.java
  38. 11 3
      java/core/src/main/java/com/google/protobuf/RopeByteString.java
  39. 69 0
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  40. 0 1
      java/core/src/main/java/com/google/protobuf/TypeRegistry.java
  41. 14 7
      java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
  42. 14 0
      java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java
  43. 83 82
      java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
  44. 59 59
      java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
  45. 90 89
      java/core/src/test/java/com/google/protobuf/MapLiteTest.java
  46. 96 94
      java/core/src/test/java/com/google/protobuf/MapTest.java
  47. 88 0
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  48. 3 2
      java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java
  49. 1 1
      java/pom.xml
  50. 42 26
      java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java
  51. 7 1
      java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java
  52. 0 1
      java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
  53. 18 6
      java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java
  54. 1 1
      java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java
  55. 2 2
      java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
  56. 1 0
      js/binary/constants.js
  57. 1 0
      js/binary/decoder.js
  58. 1 0
      js/binary/reader.js
  59. 1 0
      js/binary/utils.js
  60. 1 0
      js/binary/writer.js
  61. 5 0
      js/map.js
  62. 1 0
      js/message.js
  63. 2 4
      objectivec/DevTools/full_mac_build.sh
  64. 77 48
      objectivec/GPBMessage.m
  65. 0 9
      objectivec/GPBUtilities.m
  66. 0 4
      objectivec/GPBUtilities_PackagePrivate.h
  67. 2 6
      objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
  68. 1 1
      objectivec/Tests/GPBTestUtilities.m
  69. 0 46
      php/ext/google/protobuf/bundled_php.h
  70. 2 2
      php/ext/google/protobuf/config.m4
  71. 83 23
      php/ext/google/protobuf/def.c
  72. 6 0
      php/ext/google/protobuf/def.h
  73. 0 62
      php/ext/google/protobuf/make-preload.php
  74. 344 42
      php/ext/google/protobuf/message.c
  75. 2 0
      php/ext/google/protobuf/package.xml
  76. 422 313
      php/ext/google/protobuf/php-upb.c
  77. 40 234
      php/ext/google/protobuf/php-upb.h
  78. 0 34
      php/ext/google/protobuf/protobuf.c
  79. 3232 0
      php/ext/google/protobuf/wkt.inc
  80. 13 0
      php/generate_descriptor_protos.sh
  81. 6 0
      php/prepare_c_extension.sh
  82. 2 8
      php/src/GPBMetadata/Google/Protobuf/Any.php
  83. 2 25
      php/src/GPBMetadata/Google/Protobuf/Api.php
  84. 2 9
      php/src/GPBMetadata/Google/Protobuf/Duration.php
  85. 2 9
      php/src/GPBMetadata/Google/Protobuf/FieldMask.php
  86. 2 8
      php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php
  87. 2 10
      php/src/GPBMetadata/Google/Protobuf/SourceContext.php
  88. 1 1
      php/src/GPBMetadata/Google/Protobuf/Struct.php
  89. 2 9
      php/src/GPBMetadata/Google/Protobuf/Timestamp.php
  90. 0 54
      php/src/GPBMetadata/Google/Protobuf/Type.php
  91. 2 16
      php/src/GPBMetadata/Google/Protobuf/Wrappers.php
  92. 16 85
      php/src/Google/Protobuf/Any.php
  93. 15 5
      php/src/Google/Protobuf/Api.php
  94. 1 1
      php/src/Google/Protobuf/BoolValue.php
  95. 1 1
      php/src/Google/Protobuf/BytesValue.php
  96. 1 1
      php/src/Google/Protobuf/DoubleValue.php
  97. 3 3
      php/src/Google/Protobuf/Duration.php
  98. 14 4
      php/src/Google/Protobuf/Enum.php
  99. 2 2
      php/src/Google/Protobuf/EnumValue.php
  100. 11 11
      php/src/Google/Protobuf/Field.php

+ 1 - 0
BUILD

@@ -164,6 +164,7 @@ cc_library(
         # AUTOGEN(protobuf_lite_srcs)
         "src/google/protobuf/any_lite.cc",
         "src/google/protobuf/arena.cc",
+        "src/google/protobuf/arenastring.cc",
         "src/google/protobuf/extension_set.cc",
         "src/google/protobuf/generated_enum_util.cc",
         "src/google/protobuf/generated_message_table_driven_lite.cc",

+ 17 - 0
CHANGES.txt

@@ -3,10 +3,13 @@ Unreleased Changes
   Protocol Compiler
   * The proto compiler no longer requires a .proto filename when it is not
     generating code.
+  * Added flag `--deterministic_output` to `protoc --encode=...`.
+  * Fixed deadlock when using google.protobuf.Any embedded in aggregate options.
 
   C++
   * Arenas are now unconditionally enabled. cc_enable_arenas no longer has
     any effect.
+  * Removed inlined string support, which is incompatible with arenas.
   * Fix a memory corruption bug in reflection when mixing optional and
     non-optional fields.
   * Make SpaceUsed() calculation more thorough for map fields.
@@ -20,9 +23,23 @@ Unreleased Changes
   * When running under ASAN, skip a test that makes huge allocations.
   * Fixed a crash that could happen when creating more than 256 extensions in
     a single message.
+  * Fix a crash in BuildFile when passing in invalid descriptor proto.
+  * Parser security fix when operating with CodedInputStream.
+  * Warn against the use of AllowUnknownExtension.
+  * Migrated to C++11 for-range loops instead of index-based loops where
+    possible. This fixes a lot of warnings when compiling with -Wsign-compare.
 
   Java
   * Bugfix in mergeFrom() when a oneof has multiple message fields.
+  * Fix RopeByteString.RopeInputStream.read() returning -1 when told to read
+    0 bytes when not at EOF.
+  * Redefine remove(Object) on primitive repeated field Lists to avoid
+    autoboxing.
+  * Support "\u" escapes in textformat string literals.
+  * Trailing empty spaces are no longer ignored for FieldMask.
+  * Fix FieldMaskUtil.subtract to recursively remove mask.
+  * Mark enums with `@java.lang.Deprecated` if the proto enum has option
+    `deprecated = true;`.
 
   Python
   * Print google.protobuf.NullValue as null instead of "NULL_VALUE" when it is

+ 6 - 2
Makefile.am

@@ -772,13 +772,11 @@ php_EXTRA_DIST=                                                       \
   php/ext/google/protobuf/arena.h                                     \
   php/ext/google/protobuf/array.c                                     \
   php/ext/google/protobuf/array.h                                     \
-  php/ext/google/protobuf/bundled_php.h                               \
   php/ext/google/protobuf/config.m4                                   \
   php/ext/google/protobuf/convert.c                                   \
   php/ext/google/protobuf/convert.h                                   \
   php/ext/google/protobuf/def.c                                       \
   php/ext/google/protobuf/def.h                                       \
-  php/ext/google/protobuf/make-preload.php                            \
   php/ext/google/protobuf/map.c                                       \
   php/ext/google/protobuf/map.h                                       \
   php/ext/google/protobuf/message.c                                   \
@@ -790,8 +788,10 @@ php_EXTRA_DIST=                                                       \
   php/ext/google/protobuf/php-upb.h                                   \
   php/ext/google/protobuf/protobuf.c                                  \
   php/ext/google/protobuf/protobuf.h                                  \
+  php/ext/google/protobuf/wkt.inc                                     \
   php/generate_descriptor_protos.sh                                   \
   php/phpunit.xml                                                     \
+  php/prepare_c_extension.sh                                          \
   php/release.sh                                                      \
   php/src/GPBMetadata/Google/Protobuf/Any.php                         \
   php/src/GPBMetadata/Google/Protobuf/Api.php                         \
@@ -827,6 +827,7 @@ php_EXTRA_DIST=                                                       \
   php/src/Google/Protobuf/GPBEmpty.php                                \
   php/src/Google/Protobuf/Int32Value.php                              \
   php/src/Google/Protobuf/Int64Value.php                              \
+  php/src/Google/Protobuf/Internal/AnyBase.php                        \
   php/src/Google/Protobuf/Internal/CodedInputStream.php               \
   php/src/Google/Protobuf/Internal/CodedOutputStream.php              \
   php/src/Google/Protobuf/Internal/Descriptor.php                     \
@@ -886,6 +887,7 @@ php_EXTRA_DIST=                                                       \
   php/src/Google/Protobuf/Internal/ServiceOptions.php                 \
   php/src/Google/Protobuf/Internal/SourceCodeInfo.php                 \
   php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php        \
+  php/src/Google/Protobuf/Internal/TimestampBase.php                  \
   php/src/Google/Protobuf/Internal/UninterpretedOption.php            \
   php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php   \
   php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \
@@ -1390,6 +1392,8 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST)   \
   python/release/wheel/README.md         \
   third_party/six.BUILD                  \
   third_party/zlib.BUILD                 \
+  third_party/wyhash/LICENSE             \
+  third_party/wyhash/wyhash.h            \
   util/python/BUILD
 
 

+ 0 - 2
cmake/extract_includes.bat.in

@@ -53,7 +53,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tab
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h
-copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\inlined_string_field.h" include\google\protobuf\inlined_string_field.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\io_win32.h" include\google\protobuf\io\io_win32.h
@@ -88,7 +87,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h" i
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h" include\google\protobuf\stubs\callback.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h" include\google\protobuf\stubs\casts.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h" include\google\protobuf\stubs\common.h
-copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h" include\google\protobuf\stubs\fastmem.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h" include\google\protobuf\stubs\hash.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.h
 copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h" include\google\protobuf\stubs\macros.h

+ 1 - 0
cmake/libprotobuf-lite.cmake

@@ -1,6 +1,7 @@
 set(libprotobuf_lite_files
   ${protobuf_source_dir}/src/google/protobuf/any_lite.cc
   ${protobuf_source_dir}/src/google/protobuf/arena.cc
+  ${protobuf_source_dir}/src/google/protobuf/arenastring.cc
   ${protobuf_source_dir}/src/google/protobuf/extension_set.cc
   ${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc
   ${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc

+ 12 - 0
cmake/protobuf-module.cmake.in

@@ -97,6 +97,10 @@ function(_protobuf_find_libraries name filename)
   else()
     get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename}
       LOCATION_RELEASE)
+    get_target_property(${name}_LIBRARY_RELWITHDEBINFO protobuf::lib${filename}
+      LOCATION_RELWITHDEBINFO)
+    get_target_property(${name}_LIBRARY_MINSIZEREL protobuf::lib${filename}
+      LOCATION_MINSIZEREL)
     get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename}
       LOCATION_DEBUG)
 
@@ -146,6 +150,14 @@ get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
 # Set the protoc Executable
 get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
   IMPORTED_LOCATION_RELEASE)
+if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
+  get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
+    IMPORTED_LOCATION_RELWITHDEBINFO)
+endif()
+if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
+  get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
+    IMPORTED_LOCATION_MINSIZEREL)
+endif()
 if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
   get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
     IMPORTED_LOCATION_DEBUG)

+ 17 - 6
conformance/Makefile.am

@@ -333,7 +333,7 @@ conformance-php-c:
 
 # Targets for actually running tests.
 test_cpp: protoc_middleman conformance-test-runner conformance-cpp
-	./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp
+	./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt --text_format_failure_list text_format_failure_list_cpp.txt ./conformance-cpp
 
 test_java: protoc_middleman conformance-test-runner conformance-java
 	./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt --text_format_failure_list text_format_failure_list_java.txt ./conformance-java
@@ -353,16 +353,27 @@ test_php: protoc_middleman conformance-test-runner conformance-php $(other_langu
 test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
 	./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
 
-test_php_c_32: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
-	./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c_32.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c
-
 # These depend on library paths being properly set up.  The easiest way to
 # run them is to just use "tox" from the python dir.
 test_python: protoc_middleman conformance-test-runner
-	./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py
+	VERSION="$(shell python --version 2>&1)"; \
+	if [[ "$$VERSION"  == "Python 2.7"* ]]; then \
+	  echo "Using Python 2.7 failure list."; \
+	  ./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python_2.7.txt ./conformance_python.py; \
+	else \
+	  echo "Using Python >2.7 failure list."; \
+	  ./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt --text_format_failure_list text_format_failure_list_python.txt ./conformance_python.py; \
+	fi
 
 test_python_cpp: protoc_middleman conformance-test-runner
-	./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py
+	VERSION="$(shell python --version 2>&1)"; \
+	if [[ "$$VERSION"  == "Python 2.7"* ]]; then \
+	  echo "Using Python 2.7 failure list."; \
+	  ./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt --text_format_failure_list text_format_failure_list_python_cpp_2.7.txt ./conformance_python.py; \
+	else \
+	  echo "Using Python >2.7 failure list."; \
+	  ./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt --text_format_failure_list text_format_failure_list_python_cpp.txt ./conformance_python.py; \
+	fi
 
 test_nodejs: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
 	NODE_PATH=../js:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_js.txt ./conformance_nodejs.js

+ 0 - 1
conformance/failure_list_js.txt

@@ -1 +0,0 @@
-

+ 0 - 2
conformance/failure_list_php_c.txt

@@ -1,4 +1,2 @@
 Recommended.Proto2.JsonInput.FieldNameExtension.Validator
-Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator
-Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator
 Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

+ 0 - 4
conformance/failure_list_php_c_32.txt

@@ -1,4 +0,0 @@
-Recommended.Proto2.JsonInput.FieldNameExtension.Validator
-Recommended.Proto3.JsonInput.NullValueInOtherOneofNewFormat.Validator
-Recommended.Proto3.JsonInput.NullValueInOtherOneofOldFormat.Validator
-Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

+ 78 - 0
conformance/text_format_conformance_suite.cc

@@ -258,6 +258,84 @@ void TextFormatConformanceTestSuite::RunSuiteImpl() {
   RunValidTextFormatTest("FloatFieldLargerThanUint64", REQUIRED,
                          "optional_float: 18446744073709551616");
 
+  // String literals x {Strings, Bytes}
+  for (const auto& field_type : std::vector<std::string>{"String", "Bytes"}) {
+    const std::string field_name =
+        field_type == "String" ? "optional_string" : "optional_bytes";
+    RunValidTextFormatTest(
+        StrCat("StringLiteralConcat", field_type), REQUIRED,
+        StrCat(field_name, ": 'first' \"second\"\n'third'"));
+    RunValidTextFormatTest(
+        StrCat("StringLiteralBasicEscapes", field_type), REQUIRED,
+        StrCat(field_name, ": '\\a\\b\\f\\n\\r\\t\\v\\?\\\\\\'\\\"'"));
+    RunValidTextFormatTest(
+        StrCat("StringLiteralOctalEscapes", field_type), REQUIRED,
+        StrCat(field_name, ": '\\341\\210\\264'"));
+    RunValidTextFormatTest(StrCat("StringLiteralHexEscapes", field_type),
+                           REQUIRED,
+                           StrCat(field_name, ": '\\xe1\\x88\\xb4'"));
+    RunValidTextFormatTest(
+        StrCat("StringLiteralShortUnicodeEscape", field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\u1234'"));
+    RunValidTextFormatTest(
+        StrCat("StringLiteralLongUnicodeEscapes", field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\U00001234\\U00010437'"));
+    // String literals don't include line feeds.
+    ExpectParseFailure(StrCat("StringLiteralIncludesLF", field_type),
+                       REQUIRED,
+                       StrCat(field_name, ": 'first line\nsecond line'"));
+    // Unicode escapes don't include code points that lie beyond the planes
+    // (> 0x10ffff).
+    ExpectParseFailure(
+        StrCat("StringLiteralLongUnicodeEscapeTooLarge", field_type),
+        REQUIRED, StrCat(field_name, ": '\\U00110000'"));
+    // Unicode escapes don't include surrogates.
+    ExpectParseFailure(
+        StrCat("StringLiteralShortUnicodeEscapeSurrogatePair",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\ud801\\udc37'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralShortUnicodeEscapeSurrogateFirstOnly",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\ud800'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralShortUnicodeEscapeSurrogateSecondOnly",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\udc00'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralLongUnicodeEscapeSurrogateFirstOnly",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\U0000d800'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralLongUnicodeEscapeSurrogateSecondOnly",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\U0000dc00'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralLongUnicodeEscapeSurrogatePair", field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\U0000d801\\U00000dc37'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralUnicodeEscapeSurrogatePairLongShort",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\U0000d801\\udc37'"));
+    ExpectParseFailure(
+        StrCat("StringLiteralUnicodeEscapeSurrogatePairShortLong",
+                     field_type),
+        RECOMMENDED, StrCat(field_name, ": '\\ud801\\U0000dc37'"));
+
+    // The following method depend on the type of field, as strings have extra
+    // validation.
+    const auto test_method =
+        field_type == "String"
+            ? &TextFormatConformanceTestSuite::ExpectParseFailure
+            : &TextFormatConformanceTestSuite::RunValidTextFormatTest;
+
+    // String fields reject invalid UTF-8 byte sequences; bytes fields don't.
+    (this->*test_method)(StrCat(field_type, "FieldBadUTF8Octal"),
+                         REQUIRED, StrCat(field_name, ": '\\300'"));
+    (this->*test_method)(StrCat(field_type, "FieldBadUTF8Hex"), REQUIRED,
+                         StrCat(field_name, ": '\\xc0'"));
+  }
+
   // Group fields
   RunValidTextFormatTestProto2("GroupFieldNoColon", REQUIRED,
                                "Data { group_int32: 1 }");

+ 20 - 0
conformance/text_format_failure_list_cpp.txt

@@ -0,0 +1,20 @@
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString
+Required.Proto3.TextFormatInput.StringFieldBadUTF8Hex
+Required.Proto3.TextFormatInput.StringFieldBadUTF8Octal
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeBytes
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeString

+ 7 - 0
conformance/text_format_failure_list_java.txt

@@ -4,3 +4,10 @@ Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput
 Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput
 Required.Proto3.TextFormatInput.AnyField.ProtobufOutput
 Required.Proto3.TextFormatInput.AnyField.TextFormatOutput
+
+Required.Proto3.TextFormatInput.StringFieldBadUTF8Hex
+Required.Proto3.TextFormatInput.StringFieldBadUTF8Octal
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput

+ 29 - 0
conformance/text_format_failure_list_python.txt

@@ -3,3 +3,32 @@
 # TODO: These should be fixed.
 Required.Proto3.TextFormatInput.FloatFieldMaxValue.ProtobufOutput
 Required.Proto3.TextFormatInput.FloatFieldMaxValue.TextFormatOutput
+
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput

+ 36 - 0
conformance/text_format_failure_list_python_2.7.txt

@@ -0,0 +1,36 @@
+# This is the list of text format conformance tests that are known to fail right
+# now.
+# TODO: These should be fixed.
+Required.Proto3.TextFormatInput.FloatFieldMaxValue.ProtobufOutput
+Required.Proto3.TextFormatInput.FloatFieldMaxValue.TextFormatOutput
+
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeBytes
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeString

+ 28 - 0
conformance/text_format_failure_list_python_cpp.txt

@@ -0,0 +1,28 @@
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput

+ 30 - 0
conformance/text_format_failure_list_python_cpp_2.7.txt

@@ -0,0 +1,30 @@
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapesString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeBytes.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.ProtobufOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeString.TextFormatOutput
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateFirstOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogatePairString
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyBytes
+Recommended.Proto3.TextFormatInput.StringLiteralShortUnicodeEscapeSurrogateSecondOnlyString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairLongShortString
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongBytes
+Recommended.Proto3.TextFormatInput.StringLiteralUnicodeEscapeSurrogatePairShortLongString
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
+Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeBytes
+Required.Proto3.TextFormatInput.StringLiteralLongUnicodeEscapeTooLargeString

+ 12 - 0
csharp/src/Google.Protobuf.Test/ByteStringTest.cs

@@ -110,6 +110,18 @@ namespace Google.Protobuf
             Assert.AreEqual(10, bs[0]);
         }
 
+        [Test]
+        public void CopyFromReadOnlySpanCopiesContents()
+        {
+            byte[] data = new byte[1];
+            data[0] = 10;
+            ReadOnlySpan<byte> byteSpan = data;
+            var bs = ByteString.CopyFrom(byteSpan);
+            Assert.AreEqual(10, bs[0]);
+            data[0] = 5;
+            Assert.AreEqual(10, bs[0]);
+        }
+
         [Test]
         public void ToByteArrayCopiesContents()
         {

+ 1 - 0
csharp/src/Google.Protobuf/ByteString.cs

@@ -245,6 +245,7 @@ namespace Google.Protobuf
         /// are copied, so further modifications to the span will not
         /// be reflected in the returned <see cref="ByteString" />.
         /// </summary>
+        [SecuritySafeCritical]
         public static ByteString CopyFrom(ReadOnlySpan<byte> bytes)
         {
             return new ByteString(bytes.ToArray());

+ 1 - 1
csharp/src/Google.Protobuf/Google.Protobuf.csproj

@@ -30,7 +30,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="System.Memory" Version="4.5.2"/>
+    <PackageReference Include="System.Memory" Version="4.5.3"/>
     <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0"/>
     <!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
     <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0"/>

+ 2 - 2
docs/options.md

@@ -93,8 +93,8 @@ with info about your project (name and website) so we can add an entry for you.
    * Website: https://github.com/protobuf-c/protobuf-c
    * Extensions: 1019
 
-1. ScalePB
-   * Website: http://trueaccord.github.io/ScalaPB/
+1. ScalaPB
+   * Website: https://scalapb.github.io/
    * Extensions: 1020
 
 1. protoc-gen-bq-schema

+ 4 - 4
editors/proto.vim

@@ -69,10 +69,10 @@ syn keyword pbBool      true false
 syn match   pbInt     /-\?\<\d\+\>/
 syn match   pbInt     /\<0[xX]\x+\>/
 syn match   pbFloat   /\<-\?\d*\(\.\d*\)\?/
-syn region  pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp
-syn region  pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp
-syn region  pbString  start=/"/ skip=/\\./ end=/"/
-syn region  pbString  start=/'/ skip=/\\./ end=/'/
+syn region  pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp,@Spell
+syn region  pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp,@Spell
+syn region  pbString  start=/"/ skip=/\\./ end=/"/ contains=@Spell
+syn region  pbString  start=/'/ skip=/\\./ end=/'/ contains=@Spell
 
 if version >= 508 || !exists("did_proto_syn_inits")
   if version < 508

+ 6 - 1
java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java

@@ -142,7 +142,12 @@ abstract class AbstractProtobufList<E> extends AbstractList<E> implements Protob
   @Override
   public boolean remove(Object o) {
     ensureIsMutable();
-    return super.remove(o);
+    int index = indexOf(o);
+    if (index == -1) {
+      return false;
+    }
+    remove(index);
+    return true;
   }
 
   @Override

+ 0 - 14
java/core/src/main/java/com/google/protobuf/BooleanArrayList.java

@@ -267,20 +267,6 @@ final class BooleanArrayList extends AbstractProtobufList<Boolean>
     return true;
   }
 
-  @Override
-  public boolean remove(Object o) {
-    ensureIsMutable();
-    for (int i = 0; i < size; i++) {
-      if (o.equals(array[i])) {
-        System.arraycopy(array, i + 1, array, i, size - i - 1);
-        size--;
-        modCount++;
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public Boolean remove(int index) {
     ensureIsMutable();

+ 9 - 8
java/core/src/main/java/com/google/protobuf/CodedInputStream.java

@@ -41,6 +41,7 @@ import static com.google.protobuf.WireFormat.MAX_VARINT_SIZE;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -2009,14 +2010,14 @@ public abstract class CodedInputStream {
       int prevPos = buffer.position();
       int prevLimit = buffer.limit();
       try {
-        buffer.position(bufferPos(begin));
-        buffer.limit(bufferPos(end));
+        ((Buffer) buffer).position(bufferPos(begin));
+        ((Buffer) buffer).limit(bufferPos(end));
         return buffer.slice();
       } catch (IllegalArgumentException e) {
         throw InvalidProtocolBufferException.truncatedMessage();
       } finally {
-        buffer.position(prevPos);
-        buffer.limit(prevLimit);
+        ((Buffer) buffer).position(prevPos);
+        ((Buffer) buffer).limit(prevLimit);
       }
     }
   }
@@ -3910,14 +3911,14 @@ public abstract class CodedInputStream {
       int prevPos = currentByteBuffer.position();
       int prevLimit = currentByteBuffer.limit();
       try {
-        currentByteBuffer.position(begin);
-        currentByteBuffer.limit(end);
+        ((Buffer) currentByteBuffer).position(begin);
+        ((Buffer) currentByteBuffer).limit(end);
         return currentByteBuffer.slice();
       } catch (IllegalArgumentException e) {
         throw InvalidProtocolBufferException.truncatedMessage();
       } finally {
-        currentByteBuffer.position(prevPos);
-        currentByteBuffer.limit(prevLimit);
+        ((Buffer) currentByteBuffer).position(prevPos);
+        ((Buffer) currentByteBuffer).limit(prevLimit);
       }
     }
   }

+ 4 - 1
java/core/src/main/java/com/google/protobuf/Descriptors.java

@@ -764,7 +764,10 @@ public final class Descriptors {
     /**
      * Finds a field by name.
      *
-     * @param name The unqualified name of the field (e.g. "foo").
+     * @param name The unqualified name of the field (e.g. "foo"). For protocol buffer messages that
+     *     follow <a
+     *     href=https://developers.google.com/protocol-buffers/docs/style#message_and_field_names>Google's
+     *     guidance on naming</a> this will be a snake case string, such as <pre>song_name</pre>.
      * @return The field's descriptor, or {@code null} if not found.
      */
     public FieldDescriptor findFieldByName(final String name) {

+ 0 - 14
java/core/src/main/java/com/google/protobuf/DoubleArrayList.java

@@ -267,20 +267,6 @@ final class DoubleArrayList extends AbstractProtobufList<Double>
     return true;
   }
 
-  @Override
-  public boolean remove(Object o) {
-    ensureIsMutable();
-    for (int i = 0; i < size; i++) {
-      if (o.equals(array[i])) {
-        System.arraycopy(array, i + 1, array, i, size - i - 1);
-        size--;
-        modCount++;
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public Double remove(int index) {
     ensureIsMutable();

+ 0 - 2
java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java

@@ -46,7 +46,6 @@ final class ExtensionRegistryFactory {
   @Nullable */
   static final Class<?> EXTENSION_REGISTRY_CLASS = reflectExtensionRegistry();
 
-  /* @Nullable */
   static Class<?> reflectExtensionRegistry() {
     try {
       return Class.forName(FULL_REGISTRY_CLASS_NAME);
@@ -77,7 +76,6 @@ final class ExtensionRegistryFactory {
         && EXTENSION_REGISTRY_CLASS.isAssignableFrom(registry.getClass());
   }
 
-  /* @Nullable */
   private static final ExtensionRegistryLite invokeSubclassFactory(String methodName) {
     if (EXTENSION_REGISTRY_CLASS == null) {
       return null;

+ 0 - 2
java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java

@@ -84,10 +84,8 @@ public class ExtensionRegistryLite {
   static final String EXTENSION_CLASS_NAME = "com.google.protobuf.Extension";
 
   private static class ExtensionClassHolder {
-    /* @Nullable */
     static final Class<?> INSTANCE = resolveExtensionClass();
 
-    /* @Nullable */
     static Class<?> resolveExtensionClass() {
       try {
         return Class.forName(EXTENSION_CLASS_NAME);

+ 0 - 2
java/core/src/main/java/com/google/protobuf/FieldType.java

@@ -204,7 +204,6 @@ public enum FieldType {
    *
    * @return the {@link FieldType} or {@code null} if not found.
    */
-  /* @Nullable */
   public static FieldType forId(int id) {
     if (id < 0 || id >= VALUES.length) {
       return null;
@@ -228,7 +227,6 @@ public enum FieldType {
    *
    * @return the generic super class/interface, or {@code null} if not found.
    */
-  /* @Nullable */
   private static Type getGenericSuperList(Class<?> clazz) {
     // First look at interfaces.
     Type[] genericInterfaces = clazz.getGenericInterfaces();

+ 0 - 14
java/core/src/main/java/com/google/protobuf/FloatArrayList.java

@@ -266,20 +266,6 @@ final class FloatArrayList extends AbstractProtobufList<Float>
     return true;
   }
 
-  @Override
-  public boolean remove(Object o) {
-    ensureIsMutable();
-    for (int i = 0; i < size; i++) {
-      if (o.equals(array[i])) {
-        System.arraycopy(array, i + 1, array, i, size - i - 1);
-        size--;
-        modCount++;
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public Float remove(int index) {
     ensureIsMutable();

+ 0 - 14
java/core/src/main/java/com/google/protobuf/IntArrayList.java

@@ -266,20 +266,6 @@ final class IntArrayList extends AbstractProtobufList<Integer>
     return true;
   }
 
-  @Override
-  public boolean remove(Object o) {
-    ensureIsMutable();
-    for (int i = 0; i < size; i++) {
-      if (o.equals(array[i])) {
-        System.arraycopy(array, i + 1, array, i, size - i - 1);
-        size--;
-        modCount++;
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public Integer remove(int index) {
     ensureIsMutable();

+ 0 - 1
java/core/src/main/java/com/google/protobuf/Internal.java

@@ -30,7 +30,6 @@
 
 package com.google.protobuf;
 
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;

+ 0 - 14
java/core/src/main/java/com/google/protobuf/LongArrayList.java

@@ -266,20 +266,6 @@ final class LongArrayList extends AbstractProtobufList<Long>
     return true;
   }
 
-  @Override
-  public boolean remove(Object o) {
-    ensureIsMutable();
-    for (int i = 0; i < size; i++) {
-      if (o.equals(array[i])) {
-        System.arraycopy(array, i + 1, array, i, size - i - 1);
-        size--;
-        modCount++;
-        return true;
-      }
-    }
-    return false;
-  }
-
   @Override
   public Long remove(int index) {
     ensureIsMutable();

+ 1 - 1
java/core/src/main/java/com/google/protobuf/MessageSchema.java

@@ -2572,7 +2572,7 @@ final class MessageSchema<T> implements Schema<T> {
 
       int presenceMaskAndOffset = 0;
       int presenceMask = 0;
-      if (!proto3 && fieldType <= 17) {
+      if (fieldType <= 17) {
         presenceMaskAndOffset = buffer[pos + 2];
         final int presenceFieldOffset = presenceMaskAndOffset & OFFSET_MASK;
         if (presenceFieldOffset != currentPresenceFieldOffset) {

+ 4 - 3
java/core/src/main/java/com/google/protobuf/NioByteString.java

@@ -37,6 +37,7 @@ import java.io.InputStream;
 import java.io.InvalidObjectException;
 import java.io.ObjectInputStream;
 import java.io.OutputStream;
+import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.InvalidMarkException;
@@ -109,7 +110,7 @@ final class NioByteString extends ByteString.LeafByteString {
   protected void copyToInternal(
       byte[] target, int sourceOffset, int targetOffset, int numberToCopy) {
     ByteBuffer slice = buffer.slice();
-    slice.position(sourceOffset);
+    ((Buffer) slice).position(sourceOffset);
     slice.get(target, targetOffset, numberToCopy);
   }
 
@@ -285,8 +286,8 @@ final class NioByteString extends ByteString.LeafByteString {
     }
 
     ByteBuffer slice = buffer.slice();
-    slice.position(beginIndex - buffer.position());
-    slice.limit(endIndex - buffer.position());
+    ((Buffer) slice).position(beginIndex - buffer.position());
+    ((Buffer) slice).limit(endIndex - buffer.position());
     return slice;
   }
 }

+ 2 - 5
java/core/src/main/java/com/google/protobuf/Protobuf.java

@@ -76,11 +76,8 @@ final class Protobuf {
     schemaFor(message).makeImmutable(message);
   }
 
-  /**
-   * Checks if all required fields are set. TODO(xiaofeng): Make this package private when the tests
-   * are moved to protobuf package.
-   */
-  public <T> boolean isInitialized(T message) {
+  /** Checks if all required fields are set. */
+  <T> boolean isInitialized(T message) {
     return schemaFor(message).isInitialized(message);
   }
 

+ 11 - 3
java/core/src/main/java/com/google/protobuf/RopeByteString.java

@@ -845,7 +845,10 @@ final class RopeByteString extends ByteString {
         throw new IndexOutOfBoundsException();
       }
       int bytesRead = readSkipInternal(b, offset, length);
-      if (bytesRead == 0) {
+      if (bytesRead == 0 && (length > 0 || availableInternal() == 0)) {
+        // Modeling ByteArrayInputStream.read(byte[], int, int) behavior noted above:
+        // It's ok to read 0 bytes on purpose (length == 0) from a stream that isn't at EOF.
+        // It's not ok to try to read bytes (even 0 bytes) from a stream that is at EOF.
         return -1;
       } else {
         return bytesRead;
@@ -905,8 +908,7 @@ final class RopeByteString extends ByteString {
 
     @Override
     public int available() throws IOException {
-      int bytesRead = currentPieceOffsetInRope + currentPieceIndex;
-      return RopeByteString.this.size() - bytesRead;
+      return availableInternal();
     }
 
     @Override
@@ -955,5 +957,11 @@ final class RopeByteString extends ByteString {
         }
       }
     }
+
+    /** Computes the number of bytes still available to read. */
+    private int availableInternal() {
+      int bytesRead = currentPieceOffsetInRope + currentPieceIndex;
+      return RopeByteString.this.size() - bytesRead;
+    }
   }
 }

+ 69 - 0
java/core/src/main/java/com/google/protobuf/TextFormat.java

@@ -30,6 +30,8 @@
 
 package com.google.protobuf;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import com.google.protobuf.Descriptors.Descriptor;
 import com.google.protobuf.Descriptors.EnumDescriptor;
 import com.google.protobuf.Descriptors.EnumValueDescriptor;
@@ -2375,6 +2377,73 @@ public final class TextFormat {
                 result[pos++] = (byte) code;
                 break;
 
+              case 'u':
+                // Unicode escape
+                ++i;
+                if (i + 3 < input.size()
+                    && isHex(input.byteAt(i))
+                    && isHex(input.byteAt(i + 1))
+                    && isHex(input.byteAt(i + 2))
+                    && isHex(input.byteAt(i + 3))) {
+                  char ch =
+                      (char)
+                          (digitValue(input.byteAt(i)) << 12
+                              | digitValue(input.byteAt(i + 1)) << 8
+                              | digitValue(input.byteAt(i + 2)) << 4
+                              | digitValue(input.byteAt(i + 3)));
+                  if (Character.isSurrogate(ch)) {
+                    throw new InvalidEscapeSequenceException(
+                        "Invalid escape sequence: '\\u' refers to a surrogate");
+                  }
+                  byte[] chUtf8 = Character.toString(ch).getBytes(UTF_8);
+                  System.arraycopy(chUtf8, 0, result, pos, chUtf8.length);
+                  pos += chUtf8.length;
+                  i += 3;
+                } else {
+                  throw new InvalidEscapeSequenceException(
+                      "Invalid escape sequence: '\\u' with too few hex chars");
+                }
+                break;
+
+              case 'U':
+                // Unicode escape
+                ++i;
+                if (i + 7 >= input.size()) {
+                  throw new InvalidEscapeSequenceException(
+                      "Invalid escape sequence: '\\U' with too few hex chars");
+                }
+                int codepoint = 0;
+                for (int offset = i; offset < i + 8; offset++) {
+                  byte b = input.byteAt(offset);
+                  if (!isHex(b)) {
+                    throw new InvalidEscapeSequenceException(
+                        "Invalid escape sequence: '\\U' with too few hex chars");
+                  }
+                  codepoint = (codepoint << 4) | digitValue(b);
+                }
+                if (!Character.isValidCodePoint(codepoint)) {
+                  throw new InvalidEscapeSequenceException(
+                      "Invalid escape sequence: '\\U"
+                          + input.substring(i, i + 8).toStringUtf8()
+                          + "' is not a valid code point value");
+                }
+                Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint);
+                if (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
+                    || unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
+                    || unicodeBlock.equals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES)) {
+                  throw new InvalidEscapeSequenceException(
+                      "Invalid escape sequence: '\\U"
+                          + input.substring(i, i + 8).toStringUtf8()
+                          + "' refers to a surrogate code unit");
+                }
+                int[] codepoints = new int[1];
+                codepoints[0] = codepoint;
+                byte[] chUtf8 = new String(codepoints, 0, 1).getBytes(UTF_8);
+                System.arraycopy(chUtf8, 0, result, pos, chUtf8.length);
+                pos += chUtf8.length;
+                i += 7;
+                break;
+
               default:
                 throw new InvalidEscapeSequenceException(
                     "Invalid escape sequence: '\\" + (char) c + '\'');

+ 0 - 1
java/core/src/main/java/com/google/protobuf/TypeRegistry.java

@@ -70,7 +70,6 @@ public class TypeRegistry {
   /**
    * Find a type by its typeUrl. Returns null if it cannot be found in this {@link TypeRegistry}.
    */
-  /* @Nullable */
   public final Descriptor getDescriptorForTypeUrl(String typeUrl)
       throws InvalidProtocolBufferException {
     return find(getTypeName(typeUrl));

+ 14 - 7
java/core/src/main/java/com/google/protobuf/UnsafeUtil.java

@@ -41,7 +41,6 @@ import java.util.logging.Logger;
 
 /** Utility class for working with unsafe operations. */
 final class UnsafeUtil {
-  private static final Logger logger = Logger.getLogger(UnsafeUtil.class.getName());
   private static final sun.misc.Unsafe UNSAFE = getUnsafe();
   private static final Class<?> MEMORY_CLASS = Android.getMemoryClass();
   private static final boolean IS_ANDROID_64 = determineAndroidSupportByAddressSize(long.class);
@@ -363,9 +362,13 @@ final class UnsafeUtil {
 
       return true;
     } catch (Throwable e) {
-      logger.log(
-          Level.WARNING,
-          "platform method missing - proto runtime falling back to safer methods: " + 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;
   }
@@ -397,9 +400,13 @@ final class UnsafeUtil {
       clazz.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);
       return true;
     } catch (Throwable e) {
-      logger.log(
-          Level.WARNING,
-          "platform method missing - proto runtime falling back to safer methods: " + 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;
   }

+ 14 - 0
java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java

@@ -514,6 +514,20 @@ public class LiteralByteStringTest extends TestCase {
     assertEquals(classUnderTest + " InputStream must now be exhausted", -1, input.read());
   }
 
+  public void testNewInput_readZeroBytes() throws IOException {
+    InputStream input = stringUnderTest.newInput();
+    assertEquals(
+        classUnderTest + " InputStream.read() returns 0 when told to read 0 bytes and not at EOF",
+        0,
+        input.read(new byte[0]));
+
+    input.skip(input.available());
+    assertEquals(
+        classUnderTest + " InputStream.read() returns -1 when told to read 0 bytes at EOF",
+        -1,
+        input.read(new byte[0]));
+  }
+
   public void testNewInput_skip() throws IOException {
     InputStream input = stringUnderTest.newInput();
     int stringSize = stringUnderTest.size();

+ 83 - 82
java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java

@@ -77,44 +77,44 @@ public final class MapForProto2LiteTest extends TestCase {
 
   private void copyMapValues(TestMap source, TestMap.Builder destination) {
     destination
-        .putAllInt32ToInt32Field(source.getInt32ToInt32Field())
-        .putAllInt32ToStringField(source.getInt32ToStringField())
-        .putAllInt32ToBytesField(source.getInt32ToBytesField())
-        .putAllInt32ToEnumField(source.getInt32ToEnumField())
-        .putAllInt32ToMessageField(source.getInt32ToMessageField())
-        .putAllStringToInt32Field(source.getStringToInt32Field());
+        .putAllInt32ToInt32Field(source.getInt32ToInt32FieldMap())
+        .putAllInt32ToStringField(source.getInt32ToStringFieldMap())
+        .putAllInt32ToBytesField(source.getInt32ToBytesFieldMap())
+        .putAllInt32ToEnumField(source.getInt32ToEnumFieldMap())
+        .putAllInt32ToMessageField(source.getInt32ToMessageFieldMap())
+        .putAllStringToInt32Field(source.getStringToInt32FieldMap());
   }
 
   private void assertMapValuesSet(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(11, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(22, message.getInt32ToInt32Field().get(2).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(11, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(22, message.getInt32ToInt32FieldMap().get(2).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("11", message.getInt32ToStringField().get(1));
-    assertEquals("22", message.getInt32ToStringField().get(2));
-    assertEquals("33", message.getInt32ToStringField().get(3));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("11", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("22", message.getInt32ToStringFieldMap().get(2));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesField().get(2));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesFieldMap().get(2));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(2));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(2));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(11, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(22, message.getInt32ToMessageField().get(2).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(11, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(22, message.getInt32ToMessageFieldMap().get(2).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(11, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(22, message.getStringToInt32Field().get("2").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(11, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(22, message.getStringToInt32FieldMap().get("2").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
   }
 
   private void updateMapValues(TestMap.Builder builder) {
@@ -152,35 +152,35 @@ public final class MapForProto2LiteTest extends TestCase {
   }
 
   private void assertMapValuesUpdated(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(111, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(4).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(111, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(4).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("111", message.getInt32ToStringField().get(1));
-    assertEquals("33", message.getInt32ToStringField().get(3));
-    assertEquals("44", message.getInt32ToStringField().get(4));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("111", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
+    assertEquals("44", message.getInt32ToStringFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
-    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesField().get(4));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
+    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
-    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumField().get(4));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
+    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(111, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
-    assertEquals(44, message.getInt32ToMessageField().get(4).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(111, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
+    assertEquals(44, message.getInt32ToMessageFieldMap().get(4).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(111, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
-    assertEquals(44, message.getStringToInt32Field().get("4").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(111, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
+    assertEquals(44, message.getStringToInt32FieldMap().get("4").intValue());
   }
 
   private void assertMapValuesCleared(TestMapOrBuilder testMapOrBuilder) {
@@ -206,13 +206,13 @@ public final class MapForProto2LiteTest extends TestCase {
     TestMap.Builder builder = TestMap.newBuilder();
     TestMap message = builder.build();
     builder.putInt32ToInt32Field(1, 2);
-    assertTrue(message.getInt32ToInt32Field().isEmpty());
+    assertTrue(message.getInt32ToInt32FieldMap().isEmpty());
     message = builder.build();
-    assertEquals(newMap(1, 2), message.getInt32ToInt32Field());
-    assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2), message.getInt32ToInt32FieldMap());
+    assertEquals(newMap(1, 2), builder.getInt32ToInt32FieldMap());
     builder.putInt32ToInt32Field(2, 3);
-    assertEquals(newMap(1, 2), message.getInt32ToInt32Field());
-    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2), message.getInt32ToInt32FieldMap());
+    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32FieldMap());
   }
 
   public void testGetMapIsImmutable() {
@@ -254,30 +254,31 @@ public final class MapForProto2LiteTest extends TestCase {
 
   public void testMutableMapLifecycle() {
     TestMap.Builder builder = TestMap.newBuilder().putInt32ToInt32Field(1, 2);
-    assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field());
-    assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2), builder.build().getInt32ToInt32FieldMap());
+    assertEquals(newMap(1, 2), builder.getInt32ToInt32FieldMap());
     builder.putInt32ToInt32Field(2, 3);
-    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32FieldMap());
 
     builder.putInt32ToEnumField(1, TestMap.EnumValue.BAR);
-    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField());
-    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.getInt32ToEnumField());
+    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumFieldMap());
+    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.getInt32ToEnumFieldMap());
     builder.putInt32ToEnumField(2, TestMap.EnumValue.FOO);
     assertEquals(
-        newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO), builder.getInt32ToEnumField());
+        newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO),
+        builder.getInt32ToEnumFieldMap());
 
     builder.putInt32ToStringField(1, "1");
-    assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField());
-    assertEquals(newMap(1, "1"), builder.getInt32ToStringField());
+    assertEquals(newMap(1, "1"), builder.build().getInt32ToStringFieldMap());
+    assertEquals(newMap(1, "1"), builder.getInt32ToStringFieldMap());
     builder.putInt32ToStringField(2, "2");
-    assertEquals(newMap(1, "1", 2, "2"), builder.getInt32ToStringField());
+    assertEquals(newMap(1, "1", 2, "2"), builder.getInt32ToStringFieldMap());
 
     builder.putInt32ToMessageField(1, TestMap.MessageValue.getDefaultInstance());
     assertEquals(
         newMap(1, TestMap.MessageValue.getDefaultInstance()),
-        builder.build().getInt32ToMessageField());
+        builder.build().getInt32ToMessageFieldMap());
     assertEquals(
-        newMap(1, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageField());
+        newMap(1, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageFieldMap());
     builder.putInt32ToMessageField(2, TestMap.MessageValue.getDefaultInstance());
     assertEquals(
         newMap(
@@ -285,7 +286,7 @@ public final class MapForProto2LiteTest extends TestCase {
             TestMap.MessageValue.getDefaultInstance(),
             2,
             TestMap.MessageValue.getDefaultInstance()),
-        builder.getInt32ToMessageField());
+        builder.getInt32ToMessageFieldMap());
   }
 
   public void testGettersAndSetters() throws Exception {
@@ -415,7 +416,7 @@ public final class MapForProto2LiteTest extends TestCase {
     } catch (InvalidProtocolBufferException expected) {
       assertTrue(expected.getUnfinishedMessage() instanceof TestMap);
       map = (TestMap) expected.getUnfinishedMessage();
-      assertTrue(map.getInt32ToMessageField().isEmpty());
+      assertTrue(map.getInt32ToMessageFieldMap().isEmpty());
     }
 
     map =
@@ -476,14 +477,14 @@ public final class MapForProto2LiteTest extends TestCase {
     TestMap message = TestMap.parseFrom(data);
     // Entries with unknown enum values will be stored into UnknownFieldSet so
     // there is only one entry in the map.
-    assertEquals(1, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
+    assertEquals(1, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
     // Serializing and parsing should preserve the unknown entry.
     data = message.toByteString();
     TestUnknownEnumValue messageWithUnknownEnums = TestUnknownEnumValue.parseFrom(data);
-    assertEquals(2, messageWithUnknownEnums.getInt32ToInt32Field().size());
-    assertEquals(1, messageWithUnknownEnums.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue());
+    assertEquals(2, messageWithUnknownEnums.getInt32ToInt32FieldMap().size());
+    assertEquals(1, messageWithUnknownEnums.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32FieldMap().get(2).intValue());
   }
 
   public void testIterationOrder() throws Exception {
@@ -493,7 +494,7 @@ public final class MapForProto2LiteTest extends TestCase {
 
     assertEquals(
         Arrays.asList("1", "2", "3"),
-        new ArrayList<String>(message.getStringToInt32Field().keySet()));
+        new ArrayList<String>(message.getStringToInt32FieldMap().keySet()));
   }
 
   private static <K, V> Map<K, V> newMap(K key1, V value1) {
@@ -513,10 +514,10 @@ public final class MapForProto2LiteTest extends TestCase {
     TestMap.Builder builder = TestMap.newBuilder();
     setMapValues(builder);
     TestMap message = builder.build();
-    assertEquals(message.getStringToInt32Field(), message.getStringToInt32FieldMap());
-    assertEquals(message.getInt32ToBytesField(), message.getInt32ToBytesFieldMap());
-    assertEquals(message.getInt32ToEnumField(), message.getInt32ToEnumFieldMap());
-    assertEquals(message.getInt32ToMessageField(), message.getInt32ToMessageFieldMap());
+    assertEquals(message.getStringToInt32FieldMap(), message.getStringToInt32FieldMap());
+    assertEquals(message.getInt32ToBytesFieldMap(), message.getInt32ToBytesFieldMap());
+    assertEquals(message.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
+    assertEquals(message.getInt32ToMessageFieldMap(), message.getInt32ToMessageFieldMap());
   }
 
   public void testContains() {

+ 59 - 59
java/core/src/test/java/com/google/protobuf/MapForProto2Test.java

@@ -119,12 +119,12 @@ public class MapForProto2Test extends TestCase {
 
   private void copyMapValues(TestMap source, TestMap.Builder destination) {
     destination
-        .putAllInt32ToInt32Field(source.getInt32ToInt32Field())
-        .putAllInt32ToStringField(source.getInt32ToStringField())
-        .putAllInt32ToBytesField(source.getInt32ToBytesField())
-        .putAllInt32ToEnumField(source.getInt32ToEnumField())
-        .putAllInt32ToMessageField(source.getInt32ToMessageField())
-        .putAllStringToInt32Field(source.getStringToInt32Field());
+        .putAllInt32ToInt32Field(source.getInt32ToInt32FieldMap())
+        .putAllInt32ToStringField(source.getInt32ToStringFieldMap())
+        .putAllInt32ToBytesField(source.getInt32ToBytesFieldMap())
+        .putAllInt32ToEnumField(source.getInt32ToEnumFieldMap())
+        .putAllInt32ToMessageField(source.getInt32ToMessageFieldMap())
+        .putAllStringToInt32Field(source.getStringToInt32FieldMap());
   }
 
   private void assertMapValuesSet(TestMapOrBuilder message) {
@@ -236,35 +236,35 @@ public class MapForProto2Test extends TestCase {
   }
 
   private void assertMapValuesUpdated(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(111, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(4).intValue());
-
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("111", message.getInt32ToStringField().get(1));
-    assertEquals("33", message.getInt32ToStringField().get(3));
-    assertEquals("44", message.getInt32ToStringField().get(4));
-
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
-    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesField().get(4));
-
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
-    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumField().get(4));
-
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(111, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
-    assertEquals(44, message.getInt32ToMessageField().get(4).getValue());
-
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(111, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
-    assertEquals(44, message.getStringToInt32Field().get("4").intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(111, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(4).intValue());
+
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("111", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
+    assertEquals("44", message.getInt32ToStringFieldMap().get(4));
+
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
+    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesFieldMap().get(4));
+
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
+    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumFieldMap().get(4));
+
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(111, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
+    assertEquals(44, message.getInt32ToMessageFieldMap().get(4).getValue());
+
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(111, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
+    assertEquals(44, message.getStringToInt32FieldMap().get("4").intValue());
   }
 
   private void assertMapValuesCleared(TestMapOrBuilder testMapOrBuilder) {
@@ -563,7 +563,7 @@ public class MapForProto2Test extends TestCase {
     } catch (InvalidProtocolBufferException expected) {
       assertTrue(expected.getUnfinishedMessage() instanceof TestMap);
       map = (TestMap) expected.getUnfinishedMessage();
-      assertTrue(map.getInt32ToMessageField().isEmpty());
+      assertTrue(map.getInt32ToMessageFieldMap().isEmpty());
     }
 
     map =
@@ -698,8 +698,8 @@ public class MapForProto2Test extends TestCase {
     builder.clearField(f("int32_to_int32_field"));
     builder.clearField(f("int32_to_message_field"));
     message = builder.build();
-    assertEquals(0, message.getInt32ToInt32Field().size());
-    assertEquals(0, message.getInt32ToMessageField().size());
+    assertEquals(0, message.getInt32ToInt32FieldMap().size());
+    assertEquals(0, message.getInt32ToMessageFieldMap().size());
 
     // Test setField()
     setMapValues(builder, "int32_to_int32_field", mapForValues(11, 22, 33, 44));
@@ -710,10 +710,10 @@ public class MapForProto2Test extends TestCase {
             111, MessageValue.newBuilder().setValue(222).build(),
             333, MessageValue.newBuilder().setValue(444).build()));
     message = builder.build();
-    assertEquals(22, message.getInt32ToInt32Field().get(11).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(33).intValue());
-    assertEquals(222, message.getInt32ToMessageField().get(111).getValue());
-    assertEquals(444, message.getInt32ToMessageField().get(333).getValue());
+    assertEquals(22, message.getInt32ToInt32FieldMap().get(11).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(33).intValue());
+    assertEquals(222, message.getInt32ToMessageFieldMap().get(111).getValue());
+    assertEquals(444, message.getInt32ToMessageFieldMap().get(333).getValue());
 
     // Test addRepeatedField
     builder.addRepeatedField(
@@ -726,8 +726,8 @@ public class MapForProto2Test extends TestCase {
             555,
             MessageValue.newBuilder().setValue(666).build()));
     message = builder.build();
-    assertEquals(66, message.getInt32ToInt32Field().get(55).intValue());
-    assertEquals(666, message.getInt32ToMessageField().get(555).getValue());
+    assertEquals(66, message.getInt32ToInt32FieldMap().get(55).intValue());
+    assertEquals(666, message.getInt32ToMessageFieldMap().get(555).getValue());
 
     // Test addRepeatedField (overriding existing values)
     builder.addRepeatedField(
@@ -740,8 +740,8 @@ public class MapForProto2Test extends TestCase {
             555,
             MessageValue.newBuilder().setValue(555).build()));
     message = builder.build();
-    assertEquals(55, message.getInt32ToInt32Field().get(55).intValue());
-    assertEquals(555, message.getInt32ToMessageField().get(555).getValue());
+    assertEquals(55, message.getInt32ToInt32FieldMap().get(55).intValue());
+    assertEquals(555, message.getInt32ToMessageFieldMap().get(555).getValue());
 
     // Test setRepeatedField
     for (int i = 0; i < builder.getRepeatedFieldCount(f("int32_to_int32_field")); i++) {
@@ -755,9 +755,9 @@ public class MapForProto2Test extends TestCase {
       builder.setRepeatedField(f("int32_to_int32_field"), i, mapEntryBuilder.build());
     }
     message = builder.build();
-    assertEquals(11, message.getInt32ToInt32Field().get(22).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(44).intValue());
-    assertEquals(55, message.getInt32ToInt32Field().get(55).intValue());
+    assertEquals(11, message.getInt32ToInt32FieldMap().get(22).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(44).intValue());
+    assertEquals(55, message.getInt32ToInt32FieldMap().get(55).intValue());
   }
 
   // See additional coverage in TextFormatTest.java.
@@ -844,16 +844,16 @@ public class MapForProto2Test extends TestCase {
     TestMap message = TestMap.parseFrom(data);
     // Entries with unknown enum values will be stored into UnknownFieldSet so
     // there is only one entry in the map.
-    assertEquals(1, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
+    assertEquals(1, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
     // UnknownFieldSet should not be empty.
     assertFalse(message.getUnknownFields().asMap().isEmpty());
     // Serializing and parsing should preserve the unknown entry.
     data = message.toByteString();
     TestUnknownEnumValue messageWithUnknownEnums = TestUnknownEnumValue.parseFrom(data);
-    assertEquals(2, messageWithUnknownEnums.getInt32ToInt32Field().size());
-    assertEquals(1, messageWithUnknownEnums.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue());
+    assertEquals(2, messageWithUnknownEnums.getInt32ToInt32FieldMap().size());
+    assertEquals(1, messageWithUnknownEnums.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32FieldMap().get(2).intValue());
   }
 
   public void testRequiredMessage() throws Exception {
@@ -885,7 +885,7 @@ public class MapForProto2Test extends TestCase {
 
     assertEquals(
         Arrays.asList("1", "2", "3"),
-        new ArrayList<String>(message.getStringToInt32Field().keySet()));
+        new ArrayList<String>(message.getStringToInt32FieldMap().keySet()));
   }
 
   public void testContains() {
@@ -1172,9 +1172,9 @@ public class MapForProto2Test extends TestCase {
     setMapValuesUsingAccessors(builder);
     assertMapValuesSet(builder);
     TestMap message = builder.build();
-    assertEquals(message.getStringToInt32Field(), message.getStringToInt32FieldMap());
-    assertEquals(message.getInt32ToBytesField(), message.getInt32ToBytesFieldMap());
-    assertEquals(message.getInt32ToEnumField(), message.getInt32ToEnumFieldMap());
-    assertEquals(message.getInt32ToMessageField(), message.getInt32ToMessageFieldMap());
+    assertEquals(message.getStringToInt32FieldMap(), message.getStringToInt32FieldMap());
+    assertEquals(message.getInt32ToBytesFieldMap(), message.getInt32ToBytesFieldMap());
+    assertEquals(message.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
+    assertEquals(message.getInt32ToMessageFieldMap(), message.getInt32ToMessageFieldMap());
   }
 }

+ 90 - 89
java/core/src/test/java/com/google/protobuf/MapLiteTest.java

@@ -84,44 +84,44 @@ public final class MapLiteTest extends TestCase {
 
   private void copyMapValues(TestMap source, TestMap.Builder destination) {
     destination
-        .putAllInt32ToInt32Field(source.getInt32ToInt32Field())
-        .putAllInt32ToStringField(source.getInt32ToStringField())
-        .putAllInt32ToBytesField(source.getInt32ToBytesField())
-        .putAllInt32ToEnumField(source.getInt32ToEnumField())
-        .putAllInt32ToMessageField(source.getInt32ToMessageField())
-        .putAllStringToInt32Field(source.getStringToInt32Field());
+        .putAllInt32ToInt32Field(source.getInt32ToInt32FieldMap())
+        .putAllInt32ToStringField(source.getInt32ToStringFieldMap())
+        .putAllInt32ToBytesField(source.getInt32ToBytesFieldMap())
+        .putAllInt32ToEnumField(source.getInt32ToEnumFieldMap())
+        .putAllInt32ToMessageField(source.getInt32ToMessageFieldMap())
+        .putAllStringToInt32Field(source.getStringToInt32FieldMap());
   }
 
   private void assertMapValuesSet(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(11, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(22, message.getInt32ToInt32Field().get(2).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(11, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(22, message.getInt32ToInt32FieldMap().get(2).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("11", message.getInt32ToStringField().get(1));
-    assertEquals("22", message.getInt32ToStringField().get(2));
-    assertEquals("33", message.getInt32ToStringField().get(3));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("11", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("22", message.getInt32ToStringFieldMap().get(2));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesField().get(2));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesFieldMap().get(2));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(2));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(2));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(11, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(22, message.getInt32ToMessageField().get(2).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(11, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(22, message.getInt32ToMessageFieldMap().get(2).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(11, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(22, message.getStringToInt32Field().get("2").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(11, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(22, message.getStringToInt32FieldMap().get("2").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
   }
 
   private void updateMapValues(TestMap.Builder builder) {
@@ -159,35 +159,35 @@ public final class MapLiteTest extends TestCase {
   }
 
   private void assertMapValuesUpdated(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(111, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(4).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(111, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(4).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("111", message.getInt32ToStringField().get(1));
-    assertEquals("33", message.getInt32ToStringField().get(3));
-    assertEquals("44", message.getInt32ToStringField().get(4));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("111", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
+    assertEquals("44", message.getInt32ToStringFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
-    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesField().get(4));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
+    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
-    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumField().get(4));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
+    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(111, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
-    assertEquals(44, message.getInt32ToMessageField().get(4).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(111, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
+    assertEquals(44, message.getInt32ToMessageFieldMap().get(4).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(111, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
-    assertEquals(44, message.getStringToInt32Field().get("4").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(111, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
+    assertEquals(44, message.getStringToInt32FieldMap().get("4").intValue());
   }
 
   private void assertMapValuesCleared(TestMapOrBuilder testMapOrBuilder) {
@@ -213,12 +213,12 @@ public final class MapLiteTest extends TestCase {
     TestMap.Builder builder = TestMap.newBuilder();
     TestMap message = builder.build();
     builder.putInt32ToInt32Field(1, 2);
-    assertTrue(message.getInt32ToInt32Field().isEmpty());
-    assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
+    assertTrue(message.getInt32ToInt32FieldMap().isEmpty());
+    assertEquals(newMap(1, 2), builder.getInt32ToInt32FieldMap());
     message = builder.build();
     builder.putInt32ToInt32Field(2, 3);
-    assertEquals(newMap(1, 2), message.getInt32ToInt32Field());
-    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2), message.getInt32ToInt32FieldMap());
+    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32FieldMap());
   }
 
   public void testGetMapIsImmutable() {
@@ -266,30 +266,31 @@ public final class MapLiteTest extends TestCase {
 
   public void testMutableMapLifecycle() {
     TestMap.Builder builder = TestMap.newBuilder().putInt32ToInt32Field(1, 2);
-    assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field());
-    assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2), builder.build().getInt32ToInt32FieldMap());
+    assertEquals(newMap(1, 2), builder.getInt32ToInt32FieldMap());
     builder.putInt32ToInt32Field(2, 3);
-    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
+    assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32FieldMap());
 
     builder.putInt32ToEnumField(1, TestMap.EnumValue.BAR);
-    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField());
-    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.getInt32ToEnumField());
+    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumFieldMap());
+    assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.getInt32ToEnumFieldMap());
     builder.putInt32ToEnumField(2, TestMap.EnumValue.FOO);
     assertEquals(
-        newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO), builder.getInt32ToEnumField());
+        newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO),
+        builder.getInt32ToEnumFieldMap());
 
     builder.putInt32ToStringField(1, "1");
-    assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField());
-    assertEquals(newMap(1, "1"), builder.getInt32ToStringField());
+    assertEquals(newMap(1, "1"), builder.build().getInt32ToStringFieldMap());
+    assertEquals(newMap(1, "1"), builder.getInt32ToStringFieldMap());
     builder.putInt32ToStringField(2, "2");
-    assertEquals(newMap(1, "1", 2, "2"), builder.getInt32ToStringField());
+    assertEquals(newMap(1, "1", 2, "2"), builder.getInt32ToStringFieldMap());
 
     builder.putInt32ToMessageField(1, TestMap.MessageValue.getDefaultInstance());
     assertEquals(
         newMap(1, TestMap.MessageValue.getDefaultInstance()),
-        builder.build().getInt32ToMessageField());
+        builder.build().getInt32ToMessageFieldMap());
     assertEquals(
-        newMap(1, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageField());
+        newMap(1, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageFieldMap());
     builder.putInt32ToMessageField(2, TestMap.MessageValue.getDefaultInstance());
     assertEquals(
         newMap(
@@ -297,7 +298,7 @@ public final class MapLiteTest extends TestCase {
             TestMap.MessageValue.getDefaultInstance(),
             2,
             TestMap.MessageValue.getDefaultInstance()),
-        builder.getInt32ToMessageField());
+        builder.getInt32ToMessageFieldMap());
   }
 
   public void testGettersAndSetters() throws Exception {
@@ -342,12 +343,12 @@ public final class MapLiteTest extends TestCase {
     TestMap source = sourceBuilder.build();
 
     TestMap.Builder destinationBuilder = TestMap.newBuilder();
-    destinationBuilder.putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue());
+    destinationBuilder.putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValueMap());
     TestMap destination = destinationBuilder.build();
 
-    assertEquals(0, destination.getInt32ToEnumFieldValue().get(0).intValue());
-    assertEquals(1, destination.getInt32ToEnumFieldValue().get(1).intValue());
-    assertEquals(1000, destination.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(0, destination.getInt32ToEnumFieldValueMap().get(0).intValue());
+    assertEquals(1, destination.getInt32ToEnumFieldValueMap().get(1).intValue());
+    assertEquals(1000, destination.getInt32ToEnumFieldValueMap().get(2).intValue());
     assertEquals(3, destination.getInt32ToEnumFieldCount());
   }
 
@@ -459,7 +460,7 @@ public final class MapLiteTest extends TestCase {
     } catch (InvalidProtocolBufferException expected) {
       assertTrue(expected.getUnfinishedMessage() instanceof TestMap);
       map = (TestMap) expected.getUnfinishedMessage();
-      assertTrue(map.getInt32ToMessageField().isEmpty());
+      assertTrue(map.getInt32ToMessageFieldMap().isEmpty());
     }
 
     map =
@@ -524,24 +525,24 @@ public final class MapLiteTest extends TestCase {
             .putInt32ToEnumFieldValue(2, 1000); // unknown value.
     TestMap message = builder.build();
 
-    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumField().get(0));
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumField().get(2));
+    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumFieldMap().get(0));
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumFieldMap().get(2));
 
     builder.putAllInt32ToEnumFieldValue(newMap(2, 1000)); // unknown value.
     message = builder.build();
-    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumField().get(2));
+    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumFieldMap().get(2));
 
     // Unknown enum values should be preserved after:
     //   1. Serialization and parsing.
     //   2. toBuild().
     //   3. mergeFrom().
     message = TestMap.parseFrom(message.toByteString());
-    assertEquals(1000, message.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, message.getInt32ToEnumFieldValueMap().get(2).intValue());
     builder = message.toBuilder();
-    assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, builder.getInt32ToEnumFieldValueMap().get(2).intValue());
     builder = TestMap.newBuilder().mergeFrom(message);
-    assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, builder.getInt32ToEnumFieldValueMap().get(2).intValue());
 
     // hashCode()/equals() should take unknown enum values into account.
     builder.putAllInt32ToEnumFieldValue(newMap(2, 1001));
@@ -550,7 +551,7 @@ public final class MapLiteTest extends TestCase {
     assertFalse(message.equals(message2));
     // Unknown values will be converted to UNRECOGNIZED so the resulted enum map
     // should be the same.
-    assertEquals(message2.getInt32ToEnumField(), message.getInt32ToEnumField());
+    assertEquals(message2.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
   }
 
   public void testIterationOrder() throws Exception {
@@ -559,18 +560,18 @@ public final class MapLiteTest extends TestCase {
     TestMap message = builder.build();
 
     assertEquals(
-        Arrays.asList("1", "2", "3"), new ArrayList<>(message.getStringToInt32Field().keySet()));
+        Arrays.asList("1", "2", "3"), new ArrayList<>(message.getStringToInt32FieldMap().keySet()));
   }
 
   public void testGetMap() {
     TestMap.Builder builder = TestMap.newBuilder();
     setMapValues(builder);
     TestMap message = builder.build();
-    assertEquals(message.getStringToInt32Field(), message.getStringToInt32FieldMap());
-    assertEquals(message.getInt32ToBytesField(), message.getInt32ToBytesFieldMap());
-    assertEquals(message.getInt32ToEnumField(), message.getInt32ToEnumFieldMap());
-    assertEquals(message.getInt32ToEnumFieldValue(), message.getInt32ToEnumFieldValueMap());
-    assertEquals(message.getInt32ToMessageField(), message.getInt32ToMessageFieldMap());
+    assertEquals(message.getStringToInt32FieldMap(), message.getStringToInt32FieldMap());
+    assertEquals(message.getInt32ToBytesFieldMap(), message.getInt32ToBytesFieldMap());
+    assertEquals(message.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
+    assertEquals(message.getInt32ToEnumFieldValueMap(), message.getInt32ToEnumFieldValueMap());
+    assertEquals(message.getInt32ToMessageFieldMap(), message.getInt32ToMessageFieldMap());
   }
 
   public void testContains() {

+ 96 - 94
java/core/src/test/java/com/google/protobuf/MapTest.java

@@ -122,44 +122,44 @@ public class MapTest extends TestCase {
 
   private void copyMapValues(TestMap source, TestMap.Builder destination) {
     destination
-        .putAllInt32ToInt32Field(source.getInt32ToInt32Field())
-        .putAllInt32ToStringField(source.getInt32ToStringField())
-        .putAllInt32ToBytesField(source.getInt32ToBytesField())
-        .putAllInt32ToEnumField(source.getInt32ToEnumField())
-        .putAllInt32ToMessageField(source.getInt32ToMessageField())
-        .putAllStringToInt32Field(source.getStringToInt32Field());
+        .putAllInt32ToInt32Field(source.getInt32ToInt32FieldMap())
+        .putAllInt32ToStringField(source.getInt32ToStringFieldMap())
+        .putAllInt32ToBytesField(source.getInt32ToBytesFieldMap())
+        .putAllInt32ToEnumField(source.getInt32ToEnumFieldMap())
+        .putAllInt32ToMessageField(source.getInt32ToMessageFieldMap())
+        .putAllStringToInt32Field(source.getStringToInt32FieldMap());
   }
 
   private void assertMapValuesSet(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(11, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(22, message.getInt32ToInt32Field().get(2).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(11, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(22, message.getInt32ToInt32FieldMap().get(2).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("11", message.getInt32ToStringField().get(1));
-    assertEquals("22", message.getInt32ToStringField().get(2));
-    assertEquals("33", message.getInt32ToStringField().get(3));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("11", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("22", message.getInt32ToStringFieldMap().get(2));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesField().get(2));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("11"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("22"), message.getInt32ToBytesFieldMap().get(2));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(2));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(2));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(11, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(22, message.getInt32ToMessageField().get(2).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(11, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(22, message.getInt32ToMessageFieldMap().get(2).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(11, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(22, message.getStringToInt32Field().get("2").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(11, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(22, message.getStringToInt32FieldMap().get("2").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
   }
 
   private void updateMapValuesUsingMutableMap(TestMap.Builder builder) {
@@ -239,35 +239,35 @@ public class MapTest extends TestCase {
   }
 
   private void assertMapValuesUpdated(TestMap message) {
-    assertEquals(3, message.getInt32ToInt32Field().size());
-    assertEquals(111, message.getInt32ToInt32Field().get(1).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(3).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(4).intValue());
+    assertEquals(3, message.getInt32ToInt32FieldMap().size());
+    assertEquals(111, message.getInt32ToInt32FieldMap().get(1).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(3).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(4).intValue());
 
-    assertEquals(3, message.getInt32ToStringField().size());
-    assertEquals("111", message.getInt32ToStringField().get(1));
-    assertEquals("33", message.getInt32ToStringField().get(3));
-    assertEquals("44", message.getInt32ToStringField().get(4));
+    assertEquals(3, message.getInt32ToStringFieldMap().size());
+    assertEquals("111", message.getInt32ToStringFieldMap().get(1));
+    assertEquals("33", message.getInt32ToStringFieldMap().get(3));
+    assertEquals("44", message.getInt32ToStringFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToBytesField().size());
-    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesField().get(1));
-    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesField().get(3));
-    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesField().get(4));
+    assertEquals(3, message.getInt32ToBytesFieldMap().size());
+    assertEquals(TestUtil.toBytes("111"), message.getInt32ToBytesFieldMap().get(1));
+    assertEquals(TestUtil.toBytes("33"), message.getInt32ToBytesFieldMap().get(3));
+    assertEquals(TestUtil.toBytes("44"), message.getInt32ToBytesFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToEnumField().size());
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumField().get(3));
-    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumField().get(4));
+    assertEquals(3, message.getInt32ToEnumFieldMap().size());
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.BAZ, message.getInt32ToEnumFieldMap().get(3));
+    assertEquals(TestMap.EnumValue.QUX, message.getInt32ToEnumFieldMap().get(4));
 
-    assertEquals(3, message.getInt32ToMessageField().size());
-    assertEquals(111, message.getInt32ToMessageField().get(1).getValue());
-    assertEquals(33, message.getInt32ToMessageField().get(3).getValue());
-    assertEquals(44, message.getInt32ToMessageField().get(4).getValue());
+    assertEquals(3, message.getInt32ToMessageFieldMap().size());
+    assertEquals(111, message.getInt32ToMessageFieldMap().get(1).getValue());
+    assertEquals(33, message.getInt32ToMessageFieldMap().get(3).getValue());
+    assertEquals(44, message.getInt32ToMessageFieldMap().get(4).getValue());
 
-    assertEquals(3, message.getStringToInt32Field().size());
-    assertEquals(111, message.getStringToInt32Field().get("1").intValue());
-    assertEquals(33, message.getStringToInt32Field().get("3").intValue());
-    assertEquals(44, message.getStringToInt32Field().get("4").intValue());
+    assertEquals(3, message.getStringToInt32FieldMap().size());
+    assertEquals(111, message.getStringToInt32FieldMap().get("1").intValue());
+    assertEquals(33, message.getStringToInt32FieldMap().get("3").intValue());
+    assertEquals(44, message.getStringToInt32FieldMap().get("4").intValue());
   }
 
   private void assertMapValuesCleared(TestMapOrBuilder testMapOrBuilder) {
@@ -468,11 +468,13 @@ public class MapTest extends TestCase {
             .build();
 
     TestMap destination =
-        TestMap.newBuilder().putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue()).build();
+        TestMap.newBuilder()
+            .putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValueMap())
+            .build();
 
-    assertEquals(0, destination.getInt32ToEnumFieldValue().get(0).intValue());
-    assertEquals(1, destination.getInt32ToEnumFieldValue().get(1).intValue());
-    assertEquals(1000, destination.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(0, destination.getInt32ToEnumFieldValueMap().get(0).intValue());
+    assertEquals(1, destination.getInt32ToEnumFieldValueMap().get(1).intValue());
+    assertEquals(1000, destination.getInt32ToEnumFieldValueMap().get(2).intValue());
     assertEquals(3, destination.getInt32ToEnumFieldCount());
   }
 
@@ -583,7 +585,7 @@ public class MapTest extends TestCase {
     } catch (InvalidProtocolBufferException expected) {
       assertTrue(expected.getUnfinishedMessage() instanceof TestMap);
       map = (TestMap) expected.getUnfinishedMessage();
-      assertTrue(map.getInt32ToMessageField().isEmpty());
+      assertTrue(map.getInt32ToMessageFieldMap().isEmpty());
     }
 
     map =
@@ -644,14 +646,14 @@ public class MapTest extends TestCase {
     TestOnChangeEventPropagation.Builder parent = TestOnChangeEventPropagation.newBuilder();
     parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 2);
     TestOnChangeEventPropagation message = parent.build();
-    assertEquals(2, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
+    assertEquals(2, message.getOptionalMessage().getInt32ToInt32FieldMap().get(1).intValue());
 
     // Make a change using nested builder.
     parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 3);
 
     // Should be able to observe the change.
     message = parent.build();
-    assertEquals(3, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
+    assertEquals(3, message.getOptionalMessage().getInt32ToInt32FieldMap().get(1).intValue());
 
     // Make another change using mergeFrom()
     TestMap other = TestMap.newBuilder().putInt32ToInt32Field(1, 4).build();
@@ -659,14 +661,14 @@ public class MapTest extends TestCase {
 
     // Should be able to observe the change.
     message = parent.build();
-    assertEquals(4, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
+    assertEquals(4, message.getOptionalMessage().getInt32ToInt32FieldMap().get(1).intValue());
 
     // Make yet another change by clearing the nested builder.
     parent.getOptionalMessageBuilder().clear();
 
     // Should be able to observe the change.
     message = parent.build();
-    assertEquals(0, message.getOptionalMessage().getInt32ToInt32Field().size());
+    assertEquals(0, message.getOptionalMessage().getInt32ToInt32FieldMap().size());
   }
 
   public void testNestedBuilderOnChangeEventPropagationReflection() {
@@ -683,7 +685,7 @@ public class MapTest extends TestCase {
 
     // Should be able to observe the change.
     TestOnChangeEventPropagation message = parentBuilder.build();
-    assertEquals(1, message.getOptionalMessage().getInt32ToInt32Field().size());
+    assertEquals(1, message.getOptionalMessage().getInt32ToInt32FieldMap().size());
 
     // Change the entry value.
     entryBuilder.putInt32ToInt32Field(1, 4);
@@ -692,7 +694,7 @@ public class MapTest extends TestCase {
 
     // Should be able to observe the change.
     message = parentBuilder.build();
-    assertEquals(4, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
+    assertEquals(4, message.getOptionalMessage().getInt32ToInt32FieldMap().get(1).intValue());
 
     // Clear the nested builder.
     testMapBuilder = parentBuilder.getOptionalMessageBuilder();
@@ -700,7 +702,7 @@ public class MapTest extends TestCase {
 
     // Should be able to observe the change.
     message = parentBuilder.build();
-    assertEquals(0, message.getOptionalMessage().getInt32ToInt32Field().size());
+    assertEquals(0, message.getOptionalMessage().getInt32ToInt32FieldMap().size());
   }
 
   // The following methods are used to test reflection API.
@@ -789,8 +791,8 @@ public class MapTest extends TestCase {
     builder.clearField(f("int32_to_int32_field"));
     builder.clearField(f("int32_to_message_field"));
     message = builder.build();
-    assertEquals(0, message.getInt32ToInt32Field().size());
-    assertEquals(0, message.getInt32ToMessageField().size());
+    assertEquals(0, message.getInt32ToInt32FieldMap().size());
+    assertEquals(0, message.getInt32ToMessageFieldMap().size());
 
     // Test setField()
     setMapValues(builder, "int32_to_int32_field", mapForValues(11, 22, 33, 44));
@@ -801,10 +803,10 @@ public class MapTest extends TestCase {
             111, MessageValue.newBuilder().setValue(222).build(),
             333, MessageValue.newBuilder().setValue(444).build()));
     message = builder.build();
-    assertEquals(22, message.getInt32ToInt32Field().get(11).intValue());
-    assertEquals(44, message.getInt32ToInt32Field().get(33).intValue());
-    assertEquals(222, message.getInt32ToMessageField().get(111).getValue());
-    assertEquals(444, message.getInt32ToMessageField().get(333).getValue());
+    assertEquals(22, message.getInt32ToInt32FieldMap().get(11).intValue());
+    assertEquals(44, message.getInt32ToInt32FieldMap().get(33).intValue());
+    assertEquals(222, message.getInt32ToMessageFieldMap().get(111).getValue());
+    assertEquals(444, message.getInt32ToMessageFieldMap().get(333).getValue());
 
     // Test addRepeatedField
     builder.addRepeatedField(
@@ -817,8 +819,8 @@ public class MapTest extends TestCase {
             555,
             MessageValue.newBuilder().setValue(666).build()));
     message = builder.build();
-    assertEquals(66, message.getInt32ToInt32Field().get(55).intValue());
-    assertEquals(666, message.getInt32ToMessageField().get(555).getValue());
+    assertEquals(66, message.getInt32ToInt32FieldMap().get(55).intValue());
+    assertEquals(666, message.getInt32ToMessageFieldMap().get(555).getValue());
 
     // Test addRepeatedField (overriding existing values)
     builder.addRepeatedField(
@@ -831,8 +833,8 @@ public class MapTest extends TestCase {
             555,
             MessageValue.newBuilder().setValue(555).build()));
     message = builder.build();
-    assertEquals(55, message.getInt32ToInt32Field().get(55).intValue());
-    assertEquals(555, message.getInt32ToMessageField().get(555).getValue());
+    assertEquals(55, message.getInt32ToInt32FieldMap().get(55).intValue());
+    assertEquals(555, message.getInt32ToMessageFieldMap().get(555).getValue());
 
     // Test setRepeatedField
     for (int i = 0; i < builder.getRepeatedFieldCount(f("int32_to_int32_field")); i++) {
@@ -846,9 +848,9 @@ public class MapTest extends TestCase {
       builder.setRepeatedField(f("int32_to_int32_field"), i, mapEntryBuilder.build());
     }
     message = builder.build();
-    assertEquals(11, message.getInt32ToInt32Field().get(22).intValue());
-    assertEquals(33, message.getInt32ToInt32Field().get(44).intValue());
-    assertEquals(55, message.getInt32ToInt32Field().get(55).intValue());
+    assertEquals(11, message.getInt32ToInt32FieldMap().get(22).intValue());
+    assertEquals(33, message.getInt32ToInt32FieldMap().get(44).intValue());
+    assertEquals(55, message.getInt32ToInt32FieldMap().get(55).intValue());
   }
 
   // See additional coverage in TextFormatTest.java.
@@ -937,21 +939,21 @@ public class MapTest extends TestCase {
                     2, 1000)); // unknown value.
     TestMap message = builder.build();
 
-    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumField().get(0));
-    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumField().get(1));
-    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumField().get(2));
-    assertEquals(1000, message.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(TestMap.EnumValue.FOO, message.getInt32ToEnumFieldMap().get(0));
+    assertEquals(TestMap.EnumValue.BAR, message.getInt32ToEnumFieldMap().get(1));
+    assertEquals(TestMap.EnumValue.UNRECOGNIZED, message.getInt32ToEnumFieldMap().get(2));
+    assertEquals(1000, message.getInt32ToEnumFieldValueMap().get(2).intValue());
 
     // Unknown enum values should be preserved after:
     //   1. Serialization and parsing.
     //   2. toBuild().
     //   3. mergeFrom().
     message = TestMap.parseFrom(message.toByteString());
-    assertEquals(1000, message.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, message.getInt32ToEnumFieldValueMap().get(2).intValue());
     builder = message.toBuilder();
-    assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, builder.getInt32ToEnumFieldValueMap().get(2).intValue());
     builder = TestMap.newBuilder().mergeFrom(message);
-    assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue());
+    assertEquals(1000, builder.getInt32ToEnumFieldValueMap().get(2).intValue());
 
     // hashCode()/equals() should take unknown enum values into account.
     builder.putAllInt32ToEnumFieldValue(newMap(2, 1001));
@@ -960,7 +962,7 @@ public class MapTest extends TestCase {
     assertFalse(message.equals(message2));
     // Unknown values will be converted to UNRECOGNIZED so the resulted enum map
     // should be the same.
-    assertEquals(message2.getInt32ToEnumField(), message.getInt32ToEnumField());
+    assertEquals(message2.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
   }
 
   public void testUnknownEnumValuesInReflectionApi() throws Exception {
@@ -991,7 +993,7 @@ public class MapTest extends TestCase {
 
     // Verify that enum values have been successfully updated.
     TestMap message = builder.build();
-    for (Map.Entry<Integer, Integer> entry : message.getInt32ToEnumFieldValue().entrySet()) {
+    for (Map.Entry<Integer, Integer> entry : message.getInt32ToEnumFieldValueMap().entrySet()) {
       assertEquals(data.get(entry.getKey()) + 1, entry.getValue().intValue());
     }
   }
@@ -1002,18 +1004,18 @@ public class MapTest extends TestCase {
     TestMap message = builder.build();
 
     assertEquals(
-        Arrays.asList("1", "2", "3"), new ArrayList<>(message.getStringToInt32Field().keySet()));
+        Arrays.asList("1", "2", "3"), new ArrayList<>(message.getStringToInt32FieldMap().keySet()));
   }
 
   public void testGetMap() {
     TestMap.Builder builder = TestMap.newBuilder();
     setMapValuesUsingAccessors(builder);
     TestMap message = builder.build();
-    assertEquals(message.getStringToInt32Field(), message.getStringToInt32FieldMap());
-    assertEquals(message.getInt32ToBytesField(), message.getInt32ToBytesFieldMap());
-    assertEquals(message.getInt32ToEnumField(), message.getInt32ToEnumFieldMap());
-    assertEquals(message.getInt32ToEnumFieldValue(), message.getInt32ToEnumFieldValueMap());
-    assertEquals(message.getInt32ToMessageField(), message.getInt32ToMessageFieldMap());
+    assertEquals(message.getStringToInt32FieldMap(), message.getStringToInt32FieldMap());
+    assertEquals(message.getInt32ToBytesFieldMap(), message.getInt32ToBytesFieldMap());
+    assertEquals(message.getInt32ToEnumFieldMap(), message.getInt32ToEnumFieldMap());
+    assertEquals(message.getInt32ToEnumFieldValueMap(), message.getInt32ToEnumFieldValueMap());
+    assertEquals(message.getInt32ToMessageFieldMap(), message.getInt32ToMessageFieldMap());
   }
 
   public void testContains() {

+ 88 - 0
java/core/src/test/java/com/google/protobuf/TextFormatTest.java

@@ -30,6 +30,7 @@
 
 package com.google.protobuf;
 
+import static com.google.common.truth.Truth.assertThat;
 import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
 import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
 
@@ -866,6 +867,12 @@ public class TextFormatTest extends TestCase {
     assertEquals(bytes(0xe1, 0x88, 0xb4), TextFormat.unescapeBytes("\\341\\210\\264"));
     assertEquals("\u1234", TextFormat.unescapeText("\\xe1\\x88\\xb4"));
     assertEquals(bytes(0xe1, 0x88, 0xb4), TextFormat.unescapeBytes("\\xe1\\x88\\xb4"));
+    assertEquals("\u1234", TextFormat.unescapeText("\\u1234"));
+    assertEquals(bytes(0xe1, 0x88, 0xb4), TextFormat.unescapeBytes("\\u1234"));
+    assertEquals(bytes(0xe1, 0x88, 0xb4), TextFormat.unescapeBytes("\\U00001234"));
+    assertEquals(
+        new String(new int[] {0x10437}, 0, 1), TextFormat.unescapeText("\\xf0\\x90\\x90\\xb7"));
+    assertEquals(bytes(0xf0, 0x90, 0x90, 0xb7), TextFormat.unescapeBytes("\\U00010437"));
 
     // Handling of strings with unescaped Unicode characters > 255.
     final String zh = "\u9999\u6e2f\u4e0a\u6d77\ud84f\udf80\u8c50\u9280\u884c";
@@ -893,6 +900,87 @@ public class TextFormatTest extends TestCase {
     } catch (TextFormat.InvalidEscapeSequenceException e) {
       // success
     }
+
+    try {
+      TextFormat.unescapeText("\\u");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\u' with too few hex chars");
+    }
+
+    try {
+      TextFormat.unescapeText("\\ud800");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\u' refers to a surrogate");
+    }
+
+    try {
+      TextFormat.unescapeText("\\ud800\\u1234");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\u' refers to a surrogate");
+    }
+
+    try {
+      TextFormat.unescapeText("\\udc00");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\u' refers to a surrogate");
+    }
+
+    try {
+      TextFormat.unescapeText("\\ud801\\udc37");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\u' refers to a surrogate");
+    }
+
+    try {
+      TextFormat.unescapeText("\\U1234");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\U' with too few hex chars");
+    }
+
+    try {
+      TextFormat.unescapeText("\\U1234no more hex");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\U' with too few hex chars");
+    }
+
+    try {
+      TextFormat.unescapeText("\\U00110000");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\U00110000' is not a valid code point value");
+    }
+
+    try {
+      TextFormat.unescapeText("\\U0000d801\\U00000dc37");
+      fail("Should have thrown an exception.");
+    } catch (TextFormat.InvalidEscapeSequenceException e) {
+      assertThat(e)
+          .hasMessageThat()
+          .isEqualTo("Invalid escape sequence: '\\U0000d801' refers to a surrogate code unit");
+    }
   }
 
   public void testParseInteger() throws Exception {

+ 3 - 2
java/lite/src/test/java/com/google/protobuf/Proto2MessageLiteInfoFactory.java

@@ -174,8 +174,9 @@ public final class Proto2MessageLiteInfoFactory implements MessageInfoFactory {
           "fieldRequiredSint6487_",
           "fieldRequiredGroup88_",
         };
-    // To update this after a proto change, run protoc on proto2_message_lite.proto and copy over
-    // the content of the generated buildMessageInfo() method here.
+    // To update this after a proto change, run blaze build on proto2_message_lite.proto and copy
+    // over the String info from the proto2_message_lite_proto-lite-src.jar file in the
+    // blaze-genfiles directory.
     java.lang.String info =
         "\u0001U\u0001\u0002\u0001XU\u0000 \u0015\u0001\u1000\u0000\u0002\u1001\u0001\u0003"
             + "\u1002\u0002\u0004\u1003\u0003\u0005\u1004\u0004\u0006\u1005\u0005\u0007\u1006\u0006\b\u1007\u0007"

+ 1 - 1
java/pom.xml

@@ -75,7 +75,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.13</version>
+        <version>4.13.1</version>
         <scope>test</scope>
       </dependency>
       <dependency>

+ 42 - 26
java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java

@@ -137,11 +137,19 @@ final class FieldMaskTree {
   }
 
   /**
-   * Remove {@code path} from the tree.
+   * Removes {@code path} from the tree.
    *
-   * <p>When removing a field path from the tree, all sub-paths will be removed. That is, after
-   * removing "foo.bar" from the tree, "foo.bar.baz" will be removed. Likewise, if the field path to
-   * remove is a non-exist sub-path, nothing will be changed.
+   * <ul>
+   *   When removing a field path from the tree:
+   *   <li>All sub-paths will be removed. That is, after removing "foo.bar" from the tree,
+   *       "foo.bar.baz" will be removed.
+   *   <li>If all children of a node has been removed, the node itself will be removed as well.
+   *       That is, if "foo" only has one child "bar" and "foo.bar" only has one child "baz",
+   *       removing "foo.bar.barz" would remove both "foo" and "foo.bar".
+   *       If "foo" has both "bar" and "qux" as children, removing "foo.bar" would leave the path
+   *       "foo.qux" intact.
+   *   <li>If the field path to remove is a non-exist sub-path, nothing will be changed.
+   * </ul>
    */
   @CanIgnoreReturnValue
   FieldMaskTree removeFieldPath(String path) {
@@ -149,23 +157,35 @@ final class FieldMaskTree {
     if (parts.isEmpty()) {
       return this;
     }
-    Node node = root;
-    for (int i = 0; i < parts.size(); i++) {
-      String key = parts.get(i);
-      if (!node.children.containsKey(key)) {
-        // Path does not exist.
-        return this;
-      }
-      if (i == parts.size() - 1) {
-        // Remove path.
-        node.children.remove(key);
-        return this;
-      }
-      node = node.children.get(key);
-    }
+    removeFieldPath(root, parts, 0);
     return this;
   }
 
+  /**
+   * Removes {@code parts} from {@code node} recursively.
+   *
+   * @return a boolean value indicating whether current {@code node} should be removed.
+   */
+  @CanIgnoreReturnValue
+  private static boolean removeFieldPath(Node node, List<String> parts, int index) {
+    String key = parts.get(index);
+
+    // Base case 1: path not match.
+    if (!node.children.containsKey(key)) {
+      return false;
+    }
+    // Base case 2: last element in parts.
+    if (index == parts.size() - 1) {
+      node.children.remove(key);
+      return node.children.isEmpty();
+    }
+    // Recursive remove sub-path.
+    if (removeFieldPath(node.children.get(key), parts, index + 1)) {
+      node.children.remove(key);
+    }
+    return node.children.isEmpty();
+  }
+
   /** Removes all field paths in {@code mask} from this tree. */
   @CanIgnoreReturnValue
   FieldMaskTree removeFromFieldMask(FieldMask mask) {
@@ -187,10 +207,8 @@ final class FieldMaskTree {
     return FieldMask.newBuilder().addAllPaths(paths).build();
   }
 
-  /**
-   * Gathers all field paths in a sub-tree.
-   */
-  private void getFieldPaths(Node node, String path, List<String> paths) {
+  /** Gathers all field paths in a sub-tree. */
+  private static void getFieldPaths(Node node, String path, List<String> paths) {
     if (node.children.isEmpty()) {
       paths.add(path);
       return;
@@ -247,10 +265,8 @@ final class FieldMaskTree {
     merge(root, "", source, destination, options);
   }
 
-  /**
-   * Merges all fields specified by a sub-tree from {@code source} to {@code destination}.
-   */
-  private void merge(
+  /** Merges all fields specified by a sub-tree from {@code source} to {@code destination}. */
+  private static void merge(
       Node node,
       String path,
       Message source,

+ 7 - 1
java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java

@@ -276,7 +276,13 @@ public final class FieldMaskUtil {
     return maskTree.toFieldMask();
   }
 
-  /** Subtracts {@code secondMask} and {@code otherMasks} from {@code firstMask}. */
+  /**
+   * Subtracts {@code secondMask} and {@code otherMasks} from {@code firstMask}.
+   *
+   * <p>This method disregards proto structure. That is, if {@code firstMask} is "foo" and {@code
+   * secondMask} is "foo.bar", the response will always be "foo" without considering the internal
+   * proto structure of message "foo".
+   */
   public static FieldMask subtract(
       FieldMask firstMask, FieldMask secondMask, FieldMask... otherMasks) {
     FieldMaskTree maskTree = new FieldMaskTree(firstMask).removeFromFieldMask(secondMask);

+ 0 - 1
java/util/src/main/java/com/google/protobuf/util/JsonFormat.java

@@ -525,7 +525,6 @@ public class JsonFormat {
       return types.get(name);
     }
 
-    /* @Nullable */
     Descriptor getDescriptorForTypeUrl(String typeUrl) throws InvalidProtocolBufferException {
       return find(getTypeName(typeUrl));
     }

+ 18 - 6
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java

@@ -77,25 +77,37 @@ public class FieldMaskTreeTest extends TestCase {
 
   public void testRemoveFieldPath() throws Exception {
     String initialTreeString = "bar.baz,bar.quz.bar,foo";
-    FieldMaskTree tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
+    FieldMaskTree tree;
+
     // Empty path.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("");
     assertEquals(initialTreeString, tree.toString());
+
     // Non-exist sub-path of an existing leaf.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("foo.bar");
     assertEquals(initialTreeString, tree.toString());
+
     // Non-exist path.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("bar.foo");
     assertEquals(initialTreeString, tree.toString());
-    // Match an existing leaf node.
+
+    // Match an existing leaf node -> remove leaf node.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("foo");
     assertEquals("bar.baz,bar.quz.bar", tree.toString());
-    // Match sub-path of an existing leaf node.
+
+    // Match sub-path of an existing leaf node -> recursive removal.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("bar.quz.bar");
-    assertEquals("bar.baz,bar.quz", tree.toString());
-    // Match a non-leaf node.
+    assertEquals("bar.baz,foo", tree.toString());
+
+    // Match a non-leaf node -> remove all children.
+    tree = new FieldMaskTree(FieldMaskUtil.fromString(initialTreeString));
     tree.removeFieldPath("bar");
-    assertThat(tree.toString()).isEmpty();
+    assertEquals("foo", tree.toString());
   }
 
   public void testRemoveFromFieldMask() throws Exception {

+ 1 - 1
java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java

@@ -239,7 +239,7 @@ public class FieldMaskUtilTest extends TestCase {
     FieldMask mask3 = FieldMaskUtil.fromString("bar.quz");
     FieldMask mask4 = FieldMaskUtil.fromString("foo,bar.baz");
     FieldMask result = FieldMaskUtil.subtract(mask1, mask2, mask3, mask4);
-    assertEquals("bar", FieldMaskUtil.toString(result));
+    assertThat(FieldMaskUtil.toString(result)).isEmpty();
   }
 
   public void testIntersection() throws Exception {

+ 2 - 2
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java

@@ -722,8 +722,8 @@ public class JsonFormatTest extends TestCase {
     mergeFromJson(
         "{\n" + "  int32ToInt32Map: {1: 2},\n" + "  stringToInt32Map: {hello: 3}\n" + "}", builder);
     TestMap message = builder.build();
-    assertEquals(2, message.getInt32ToInt32Map().get(1).intValue());
-    assertEquals(3, message.getStringToInt32Map().get("hello").intValue());
+    assertEquals(2, message.getInt32ToInt32MapMap().get(1).intValue());
+    assertEquals(3, message.getStringToInt32MapMap().get("hello").intValue());
   }
 
   public void testWrappers() throws Exception {

+ 1 - 0
js/binary/constants.js

@@ -31,6 +31,7 @@
 /**
  * @fileoverview This file contains constants and typedefs used by
  * jspb.BinaryReader and BinaryWriter.
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  *
  * @author aappleby@google.com (Austin Appleby)
  */

+ 1 - 0
js/binary/decoder.js

@@ -40,6 +40,7 @@
  * intact, you _must_ read them using one of the Hash64 methods, which return
  * an 8-character string.
  *
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  * @author aappleby@google.com (Austin Appleby)
  */
 

+ 1 - 0
js/binary/reader.js

@@ -41,6 +41,7 @@
  * using the typed jspb code generator, but if you bypass that you'll need
  * to keep things in sync by hand.
  *
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  * @author aappleby@google.com (Austin Appleby)
  */
 

+ 1 - 0
js/binary/utils.js

@@ -32,6 +32,7 @@
  * @fileoverview This file contains helper code used by jspb.BinaryReader
  * and BinaryWriter.
  *
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  * @author aappleby@google.com (Austin Appleby)
  */
 

+ 1 - 0
js/binary/writer.js

@@ -52,6 +52,7 @@
  * Major caveat 3 - This class uses typed arrays and must not be used on older
  * browsers that do not support them.
  *
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  * @author aappleby@google.com (Austin Appleby)
  */
 

+ 5 - 0
js/map.js

@@ -1,3 +1,4 @@
+
 // Protocol Buffers - Google's data interchange format
 // Copyright 2008 Google Inc.  All rights reserved.
 // https://developers.google.com/protocol-buffers/
@@ -28,6 +29,10 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+/**
+ * @fileoverview
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
+ */
 goog.provide('jspb.Map');
 
 goog.require('goog.asserts');

+ 1 - 0
js/message.js

@@ -31,6 +31,7 @@
 /**
  * @fileoverview Definition of jspb.Message.
  *
+ * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  * @author mwr@google.com (Mark Rawling)
  */
 

+ 2 - 4
objectivec/DevTools/full_mac_build.sh

@@ -289,7 +289,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
           -disable-concurrent-destination-testing
       )
       ;;
-    11.*)
+    11.* | 12.*)
       # Dropped 32bit as Apple doesn't seem support the simulators either.
       XCODEBUILD_TEST_BASE_IOS+=(
           -destination "platform=iOS Simulator,name=iPhone 8,OS=latest" # 64bit
@@ -352,10 +352,8 @@ if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then
       echo "ERROR: Xcode 10.0 or higher is required to build the test suite." 1>&2
       exit 11
       ;;
-    10.* | 11.* )
+    10.* | 11.* | 12.*)
       XCODEBUILD_TEST_BASE_TVOS+=(
-        # Test on the oldest and current.
-        -destination "platform=tvOS Simulator,name=Apple TV,OS=11.0"
         -destination "platform=tvOS Simulator,name=Apple TV 4K,OS=latest"
       )
       ;;

+ 77 - 48
objectivec/GPBMessage.m

@@ -71,6 +71,8 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
  @package
   GPBUnknownFieldSet *unknownFields_;
   NSMutableDictionary *extensionMap_;
+  // Readonly access to autocreatedExtensionMap_ is protected via
+  // readOnlySemaphore_.
   NSMutableDictionary *autocreatedExtensionMap_;
 
   // If the object was autocreated, we remember the creator so that if we get
@@ -79,10 +81,10 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
   GPBFieldDescriptor *autocreatorField_;
   GPBExtensionDescriptor *autocreatorExtension_;
 
-  // A lock to provide mutual exclusion from internal data that can be modified
-  // by *read* operations such as getters (autocreation of message fields and
-  // message extensions, not setting of values). Used to guarantee thread safety
-  // for concurrent reads on the message.
+  // Message can only be mutated from one thread. But some *readonly* operations
+  // modifify internal state because they autocreate things. The
+  // autocreatedExtensionMap_ is one such structure. Access during readonly
+  // operations is protected via this semaphore.
   // NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
   // pointed out that they are vulnerable to live locking on iOS in cases of
   // priority inversion:
@@ -583,19 +585,30 @@ static id GetOrCreateArrayIvarWithField(GPBMessage *self,
 // This is like GPBGetObjectIvarWithField(), but for arrays, it should
 // only be used to wire the method into the class.
 static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
-  id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
-  if (!array) {
-    // Check again after getting the lock.
-    GPBPrepareReadOnlySemaphore(self);
-    dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
-    array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
-    if (!array) {
-      array = CreateArrayForField(field, self);
-      GPBSetAutocreatedRetainedObjectIvarWithField(self, field, array);
-    }
-    dispatch_semaphore_signal(self->readOnlySemaphore_);
+  uint8_t *storage = (uint8_t *)self->messageStorage_;
+  _Atomic(id) *typePtr = (_Atomic(id) *)&storage[field->description_->offset];
+  id array = atomic_load(typePtr);
+  if (array) {
+    return array;
   }
-  return array;
+
+  id expected = nil;
+  id autocreated = CreateArrayForField(field, self);
+  if (atomic_compare_exchange_strong(typePtr, &expected, autocreated)) {
+    // Value was set, return it.
+    return autocreated;
+  }
+
+  // Some other thread set it, release the one created and return what got set.
+  if (GPBFieldDataTypeIsObject(field)) {
+    GPBAutocreatedArray *autoArray = autocreated;
+    autoArray->_autocreator = nil;
+  } else {
+    GPBInt32Array *gpbArray = autocreated;
+    gpbArray->_autocreator = nil;
+  }
+  [autocreated release];
+  return expected;
 }
 
 static id GetOrCreateMapIvarWithField(GPBMessage *self,
@@ -613,19 +626,31 @@ static id GetOrCreateMapIvarWithField(GPBMessage *self,
 // This is like GPBGetObjectIvarWithField(), but for maps, it should
 // only be used to wire the method into the class.
 static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
-  id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
-  if (!dict) {
-    // Check again after getting the lock.
-    GPBPrepareReadOnlySemaphore(self);
-    dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
-    dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
-    if (!dict) {
-      dict = CreateMapForField(field, self);
-      GPBSetAutocreatedRetainedObjectIvarWithField(self, field, dict);
-    }
-    dispatch_semaphore_signal(self->readOnlySemaphore_);
+  uint8_t *storage = (uint8_t *)self->messageStorage_;
+  _Atomic(id) *typePtr = (_Atomic(id) *)&storage[field->description_->offset];
+  id dict = atomic_load(typePtr);
+  if (dict) {
+    return dict;
   }
-  return dict;
+
+  id expected = nil;
+  id autocreated = CreateMapForField(field, self);
+  if (atomic_compare_exchange_strong(typePtr, &expected, autocreated)) {
+    // Value was set, return it.
+    return autocreated;
+  }
+
+  // Some other thread set it, release the one created and return what got set.
+  if ((field.mapKeyDataType == GPBDataTypeString) &&
+      GPBFieldDataTypeIsObject(field)) {
+    GPBAutocreatedDictionary *autoDict = autocreated;
+    autoDict->_autocreator = nil;
+  } else {
+    GPBInt32Int32Dictionary *gpbDict = autocreated;
+    gpbDict->_autocreator = nil;
+  }
+  [autocreated release];
+  return expected;
 }
 
 #endif  // !defined(__clang_analyzer__)
@@ -3337,30 +3362,34 @@ id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) {
 
 id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
   NSCAssert(!GPBFieldIsMapOrArray(field), @"Shouldn't get here");
-  if (GPBGetHasIvarField(self, field)) {
-    uint8_t *storage = (uint8_t *)self->messageStorage_;
-    id *typePtr = (id *)&storage[field->description_->offset];
-    return *typePtr;
-  }
-  // Not set...
-
-  // Non messages (string/data), get their default.
   if (!GPBFieldDataTypeIsMessage(field)) {
+    if (GPBGetHasIvarField(self, field)) {
+      uint8_t *storage = (uint8_t *)self->messageStorage_;
+      id *typePtr = (id *)&storage[field->description_->offset];
+      return *typePtr;
+    }
+    // Not set...non messages (string/data), get their default.
     return field.defaultValue.valueMessage;
   }
 
-  GPBPrepareReadOnlySemaphore(self);
-  dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
-  GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
-  if (!result) {
-    // For non repeated messages, create the object, set it and return it.
-    // This object will not initially be visible via GPBGetHasIvar, so
-    // we save its creator so it can become visible if it's mutated later.
-    result = GPBCreateMessageWithAutocreator(field.msgClass, self, field);
-    GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result);
-  }
-  dispatch_semaphore_signal(self->readOnlySemaphore_);
-  return result;
+  uint8_t *storage = (uint8_t *)self->messageStorage_;
+  _Atomic(id) *typePtr = (_Atomic(id) *)&storage[field->description_->offset];
+  id msg = atomic_load(typePtr);
+  if (msg) {
+    return msg;
+  }
+
+  id expected = nil;
+  id autocreated = GPBCreateMessageWithAutocreator(field.msgClass, self, field);
+  if (atomic_compare_exchange_strong(typePtr, &expected, autocreated)) {
+    // Value was set, return it.
+    return autocreated;
+  }
+
+  // Some other thread set it, release the one created and return what got set.
+  GPBClearMessageAutocreator(autocreated);
+  [autocreated release];
+  return expected;
 }
 
 #pragma clang diagnostic pop

+ 0 - 9
objectivec/GPBUtilities.m

@@ -504,15 +504,6 @@ static void GPBMaybeClearOneofPrivate(GPBMessage *self,
 // Object types are handled slightly differently, they need to be released
 // and retained.
 
-void GPBSetAutocreatedRetainedObjectIvarWithField(
-    GPBMessage *self, GPBFieldDescriptor *field,
-    id __attribute__((ns_consumed)) value) {
-  uint8_t *storage = (uint8_t *)self->messageStorage_;
-  id *typePtr = (id *)&storage[field->description_->offset];
-  NSCAssert(*typePtr == NULL, @"Can't set autocreated object more than once.");
-  *typePtr = value;
-}
-
 void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self,
                                              GPBFieldDescriptor *field) {
   if (GPBGetHasIvarField(self, field)) {

+ 0 - 4
objectivec/GPBUtilities_PackagePrivate.h

@@ -289,10 +289,6 @@ void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self,
 id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self,
                                          GPBFieldDescriptor *field);
 
-void GPBSetAutocreatedRetainedObjectIvarWithField(
-    GPBMessage *self, GPBFieldDescriptor *field,
-    id __attribute__((ns_consumed)) value);
-
 // Clears and releases the autocreated message ivar, if it's autocreated. If
 // it's not set as autocreated, this method does nothing.
 void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self,

+ 2 - 6
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj

@@ -856,13 +856,11 @@
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
 				CLANG_ENABLE_OBJC_WEAK = YES;
-				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
 					"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
 					"$(inherited)",
 				);
 				INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
@@ -889,13 +887,11 @@
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
 				CLANG_ENABLE_OBJC_WEAK = YES;
-				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
 					"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
 					"$(inherited)",
 				);
 				INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
@@ -972,7 +968,7 @@
 				GCC_WARN_UNUSED_PARAMETER = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				GENERATE_PROFILING_CODE = NO;
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
 				ONLY_ACTIVE_ARCH = YES;
 				RUN_CLANG_STATIC_ANALYZER = YES;
 				SDKROOT = iphoneos;
@@ -1041,7 +1037,7 @@
 				GCC_WARN_UNUSED_PARAMETER = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				GENERATE_PROFILING_CODE = NO;
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
 				RUN_CLANG_STATIC_ANALYZER = YES;
 				SDKROOT = iphoneos;
 				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

+ 1 - 1
objectivec/Tests/GPBTestUtilities.m

@@ -779,7 +779,7 @@ const uint32_t kGPBDefaultRepeatCount = 2;
     [message.repeatedSfixed64Array addValue:210 + i * 100];
     [message.repeatedFloatArray addValue:211 + i * 100];
     [message.repeatedDoubleArray addValue:212 + i * 100];
-    [message.repeatedBoolArray addValue:(i % 2)];
+    [message.repeatedBoolArray addValue:(BOOL)(i % 2)];
     NSString *string = [[NSString alloc] initWithFormat:@"%d", 215 + i * 100];
     [message.repeatedStringArray addObject:string];
     [string release];

+ 0 - 46
php/ext/google/protobuf/bundled_php.h

@@ -1,46 +0,0 @@
-// 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 PHP_PROTOBUF_BUNDLED_PHP_H_
-#define PHP_PROTOBUF_BUNDLED_PHP_H_
-
-// We embed PHP source code into the binary for things we don't want to
-// implement in C. This struct serves as a table of contents for all of
-// the embedded files.
-typedef struct {
-  const char *filename;
-  const char *contents;
-} BundledPhp_File;
-
-// An array of all the embedded file structs. This array is terminated with a
-// {NULL, NULL} entry.
-extern BundledPhp_File *bundled_files;
-
-#endif  // PHP_PROTOBUF_BUNDLED_PHP_H_

+ 2 - 2
php/ext/google/protobuf/config.m4

@@ -4,7 +4,7 @@ if test "$PHP_PROTOBUF" != "no"; then
 
   PHP_NEW_EXTENSION(
     protobuf,
-    arena.c array.c bundled_php.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c,
-    $ext_shared)
+    arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c,
+    $ext_shared, , -std=gnu99)
 
 fi

+ 83 - 23
php/ext/google/protobuf/def.c

@@ -772,6 +772,7 @@ upb_symtab *DescriptorPool_GetSymbolTable() {
   return intern->symtab;
 }
 
+
 /*
  * DescriptorPool::getGeneratedPool()
  *
@@ -906,13 +907,38 @@ static void add_name_mappings(const upb_filedef *file) {
   }
 }
 
+static void add_descriptor(DescriptorPool *pool,
+                           const google_protobuf_FileDescriptorProto *file) {
+  upb_strview name = google_protobuf_FileDescriptorProto_name(file);
+  upb_status status;
+  const upb_filedef *file_def;
+  upb_status_clear(&status);
+
+  if (upb_symtab_lookupfile2(pool->symtab, name.data, name.size)) {
+    // Already added.
+    fprintf(stderr, "WARNING: file was already added\n");
+    return;
+  }
+
+  // The PHP code generator currently special-cases descriptor.proto.  It
+  // doesn't add it as a dependency even if the proto file actually does
+  // depend on it.
+  if (depends_on_descriptor(file)) {
+    google_protobuf_FileDescriptorProto_getmsgdef(pool->symtab);
+  }
+
+  file_def = upb_symtab_addfile(pool->symtab, file, &status);
+  CheckUpbStatus(&status, "Unable to load descriptor");
+  add_name_mappings(file_def);
+}
+
 /*
- * add_name_mappings()
+ * add_descriptor()
  *
  * Adds the given descriptor data to this DescriptorPool.
  */
-static void add_descriptor(DescriptorPool *pool, const char *data,
-                           int data_len, upb_arena *arena) {
+static void add_descriptor_set(DescriptorPool *pool, const char *data,
+                               int data_len, upb_arena *arena) {
   size_t i, n;
   google_protobuf_FileDescriptorSet *set;
   const google_protobuf_FileDescriptorProto* const* files;
@@ -928,27 +954,28 @@ static void add_descriptor(DescriptorPool *pool, const char *data,
 
   for (i = 0; i < n; i++) {
     const google_protobuf_FileDescriptorProto* file = files[i];
-    upb_strview name = google_protobuf_FileDescriptorProto_name(file);
-    upb_status status;
-    const upb_filedef *file_def;
-    upb_status_clear(&status);
-
-    if (upb_symtab_lookupfile2(pool->symtab, name.data, name.size)) {
-      // Already added.
-      continue;
-    }
+    add_descriptor(pool, file);
+  }
+}
 
-    // The PHP code generator currently special-cases descriptor.proto.  It
-    // doesn't add it as a dependency even if the proto file actually does
-    // depend on it.
-    if (depends_on_descriptor(file)) {
-      google_protobuf_FileDescriptorProto_getmsgdef(pool->symtab);
-    }
+bool DescriptorPool_HasFile(const char *filename) {
+  DescriptorPool *intern = GetPool(get_generated_pool());
+  return upb_symtab_lookupfile(intern->symtab, filename) != NULL;
+}
+
+void DescriptorPool_AddDescriptor(const char *filename, const char *data,
+                                  int size) {
+  upb_arena *arena = upb_arena_new();
+  const google_protobuf_FileDescriptorProto *file =
+      google_protobuf_FileDescriptorProto_parse(data, size, arena);
 
-    file_def = upb_symtab_addfile(pool->symtab, file, &status);
-    CheckUpbStatus(&status, "Unable to load descriptor");
-    add_name_mappings(file_def);
+  if (!file) {
+    zend_error(E_ERROR, "Failed to parse binary descriptor for %s\n", filename);
+    return;
   }
+
+  add_descriptor(GetPool(get_generated_pool()), file);
+  upb_arena_free(arena);
 }
 
 /*
@@ -969,7 +996,7 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) {
   }
 
   arena = upb_arena_new();
-  add_descriptor(intern, data, data_len, arena);
+  add_descriptor_set(intern, data, data_len, arena);
   upb_arena_free(arena);
 }
 
@@ -983,6 +1010,35 @@ static zend_function_entry DescriptorPool_methods[] = {
   ZEND_FE_END
 };
 
+// -----------------------------------------------------------------------------
+// InternalDescriptorPool
+// -----------------------------------------------------------------------------
+
+// For the C extension, Google\Protobuf\Internal\DescriptorPool is not a
+// separate instantiable object, it just returns a
+// Google\Protobuf\DescriptorPool.
+
+zend_class_entry *InternalDescriptorPool_class_entry;
+
+/*
+ * InternalDescriptorPool::getGeneratedPool()
+ *
+ * Returns the generated DescriptorPool. Note that this is identical to
+ * DescriptorPool::getGeneratedPool(), and in fact returns a DescriptorPool
+ * instance.
+ */
+PHP_METHOD(InternalDescriptorPool, getGeneratedPool) {
+  zval ret;
+  ZVAL_COPY(&ret, get_generated_pool());
+  RETURN_ZVAL(&ret, 0, 1);
+}
+
+static zend_function_entry InternalDescriptorPool_methods[] = {
+  PHP_ME(InternalDescriptorPool, getGeneratedPool, NULL,
+         ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
 // -----------------------------------------------------------------------------
 // GPBType
 // -----------------------------------------------------------------------------
@@ -1044,7 +1100,7 @@ void Def_ModuleInit() {
   h = &FieldDescriptor_object_handlers;
   memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
 
-  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\DescriptorPool",
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DescriptorPool",
                    DescriptorPool_methods);
   DescriptorPool_class_entry = zend_register_internal_class(&tmp_ce);
   DescriptorPool_class_entry->ce_flags |= ZEND_ACC_FINAL;
@@ -1053,6 +1109,10 @@ void Def_ModuleInit() {
   memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
   h->dtor_obj = DescriptorPool_destructor;
 
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\DescriptorPool",
+                   InternalDescriptorPool_methods);
+  InternalDescriptorPool_class_entry = zend_register_internal_class(&tmp_ce);
+
   // GPBType.
 #define STR(str) (str), strlen(str)
   zend_class_entry class_type;

+ 6 - 0
php/ext/google/protobuf/def.h

@@ -49,6 +49,12 @@ upb_symtab *DescriptorPool_Steal(zval *zv);
 
 upb_symtab *DescriptorPool_GetSymbolTable();
 
+// Returns true if the global descriptor pool already has the given filename.
+bool DescriptorPool_HasFile(const char *filename);
+
+// Adds the given descriptor with the given filename to the global pool.
+void DescriptorPool_AddDescriptor(const char *filename, const char *data, int size);
+
 typedef struct Descriptor {
   zend_object std;
   const upb_msgdef *msgdef;

+ 0 - 62
php/ext/google/protobuf/make-preload.php

@@ -1,62 +0,0 @@
-<?php
-
-$cwd = dirname($argv[0]) . "/../../../src";
-chdir($cwd);
-
-$cmd = "grep -r -l 'Generated by the protocol buffer' * | grep 'php$' | grep -v Internal";
-$handle = popen($cmd, 'r');
-$filenames = explode("\n", stream_get_contents($handle));
-array_pop($filenames);  // empty string after last '\n'
-$filenames[] = "Google/Protobuf/DescriptorPool.php";
-$output = "../ext/google/protobuf/bundled_php.c";
-
-function stripSuffix($str, $suffix) {
-  return substr($str, 0, strlen($str) - strlen($suffix));
-}
-
-function toClassName($filename) {
-  # Google/Protobuf/BoolValue.php -> Google\\Protobuf\\BoolValue
-  $ret = stripSuffix($filename, ".php");
-  return str_replace("/", "\\\\", $ret);
-}
-
-function toCSymbolName($filename) {
-  # Google/Protobuf/BoolValue.php -> Google__Protobuf__BoolValue
-  $ret = stripSuffix($filename, ".php");
-  return str_replace("/", "__", $ret);
-}
-
-$f = fopen($output, "w");
-
-fwrite($f, "#include \"bundled_php.h\"\n");
-fwrite($f, "#include \"stdlib.h\"\n");
-
-foreach ($filenames as $filename) {
-  print("Reading $filename...\n");
-  $contents = file_get_contents($filename);
-  $contents = substr($contents, 5);  // Strip <?php
-  $c_symbol_name = toCSymbolName($filename);
-  fwrite($f, "static const char {$c_symbol_name}[] = {");
-  for ($i = 0; $i < strlen($contents); $i++) {
-    if ($i % 10 == 0) {
-      fwrite($f, "\n");
-    }
-    fprintf($f, "  0x%02x,", ord($contents[$i]));
-  }
-  fwrite($f, "0};\n");
-}
-
-fwrite($f, "static BundledPhp_File php[] = {\n");
-foreach ($filenames as $filename) {
-  $class_name = toClassName($filename);
-  $c_symbol_name = toCSymbolName($filename);
-  fwrite($f, "  {\"$class_name\", $c_symbol_name},\n");
-}
-
-fwrite($f, "  {NULL, NULL}\n");
-fwrite($f, "};\n");
-fwrite($f, "BundledPhp_File *bundled_files = &php[0];\n");
-fclose($f);
-
-print("Wrote $output\n");
-?>

+ 344 - 42
php/ext/google/protobuf/message.c

@@ -36,6 +36,7 @@
 
 // This is not self-contained: it must be after other Zend includes.
 #include <Zend/zend_exceptions.h>
+#include <Zend/zend_inheritance.h>
 
 #include "arena.h"
 #include "array.h"
@@ -108,6 +109,43 @@ static const upb_fielddef *get_field(Message *msg, PROTO_STR *member) {
   return f;
 }
 
+static void Message_get(Message *intern, const upb_fielddef *f, zval *rv) {
+  upb_arena *arena = Arena_Get(&intern->arena);
+
+  if (upb_fielddef_ismap(f)) {
+    upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
+    MapField_GetPhpWrapper(rv, msgval.map, f, &intern->arena);
+  } else if (upb_fielddef_isseq(f)) {
+    upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
+    RepeatedField_GetPhpWrapper(rv, msgval.array, f, &intern->arena);
+  } else {
+    upb_msgval msgval = upb_msg_get(intern->msg, f);
+    const Descriptor *subdesc = Descriptor_GetFromFieldDef(f);
+    Convert_UpbToPhp(msgval, rv, upb_fielddef_type(f), subdesc, &intern->arena);
+  }
+}
+
+static bool Message_set(Message *intern, const upb_fielddef *f, zval *val) {
+  upb_arena *arena = Arena_Get(&intern->arena);
+  upb_msgval msgval;
+
+  if (upb_fielddef_ismap(f)) {
+    msgval.map_val = MapField_GetUpbMap(val, f, arena);
+    if (!msgval.map_val) return false;
+  } else if (upb_fielddef_isseq(f)) {
+    msgval.array_val = RepeatedField_GetUpbArray(val, f, arena);
+    if (!msgval.array_val) return false;
+  } else {
+    upb_fieldtype_t type = upb_fielddef_type(f);
+    const Descriptor *subdesc = Descriptor_GetFromFieldDef(f);
+    bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena);
+    if (!ok) return false;
+  }
+
+  upb_msg_set(intern->msg, f, msgval, arena);
+  return true;
+}
+
 static bool MessageEq(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m);
 
 /**
@@ -271,6 +309,7 @@ static void Message_unset_property(PROTO_VAL *obj, PROTO_STR *member,
   upb_msg_clearfield(intern->msg, f);
 }
 
+
 /**
  * Message_read_property()
  *
@@ -293,22 +332,9 @@ static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member,
                                    int type, void **cache_slot, zval *rv) {
   Message* intern = PROTO_MSG_P(obj);
   const upb_fielddef *f = get_field(intern, member);
-  upb_arena *arena = Arena_Get(&intern->arena);
 
   if (!f) return NULL;
-
-  if (upb_fielddef_ismap(f)) {
-    upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
-    MapField_GetPhpWrapper(rv, msgval.map, f, &intern->arena);
-  } else if (upb_fielddef_isseq(f)) {
-    upb_mutmsgval msgval = upb_msg_mutable(intern->msg, f, arena);
-    RepeatedField_GetPhpWrapper(rv, msgval.array, f, &intern->arena);
-  } else {
-    upb_msgval msgval = upb_msg_get(intern->msg, f);
-    const Descriptor *subdesc = Descriptor_GetFromFieldDef(f);
-    Convert_UpbToPhp(msgval, rv, upb_fielddef_type(f), subdesc, &intern->arena);
-  }
-
+  Message_get(intern, f, rv);
   return rv;
 }
 
@@ -337,37 +363,20 @@ static PROTO_RETURN_VAL Message_write_property(
     PROTO_VAL *obj, PROTO_STR *member, zval *val, void **cache_slot) {
   Message* intern = PROTO_MSG_P(obj);
   const upb_fielddef *f = get_field(intern, member);
-  upb_arena *arena = Arena_Get(&intern->arena);
-  upb_msgval msgval;
-
-  if (!f) goto error;
-
-  if (upb_fielddef_ismap(f)) {
-    msgval.map_val = MapField_GetUpbMap(val, f, arena);
-    if (!msgval.map_val) goto error;
-  } else if (upb_fielddef_isseq(f)) {
-    msgval.array_val = RepeatedField_GetUpbArray(val, f, arena);
-    if (!msgval.array_val) goto error;
-  } else {
-    upb_fieldtype_t type = upb_fielddef_type(f);
-    const Descriptor *subdesc = Descriptor_GetFromFieldDef(f);
-    bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena);
-    if (!ok) goto error;
-  }
 
-  upb_msg_set(intern->msg, f, msgval, arena);
+  if (f && Message_set(intern, f, val)) {
 #if PHP_VERSION_ID < 70400
-  return;
+    return;
 #else
-  return val;
+    return val;
 #endif
-
-error:
+  } else {
 #if PHP_VERSION_ID < 70400
-  return;
+    return;
 #else
-  return &EG(error_zval);
+    return &EG(error_zval);
 #endif
+  }
 }
 
 /**
@@ -531,6 +540,12 @@ bool Message_InitFromPhp(upb_msg *msg, const upb_msgdef *m, zval *init,
   }
 }
 
+static void Message_Initialize(Message *intern, const Descriptor *desc) {
+  intern->desc = desc;
+  intern->msg = upb_msg_new(desc->msgdef, Arena_Get(&intern->arena));
+  ObjCache_Add(intern->msg, &intern->std);
+}
+
 /**
  * Message::__construct()
  *
@@ -540,13 +555,10 @@ bool Message_InitFromPhp(upb_msg *msg, const upb_msgdef *m, zval *init,
 PHP_METHOD(Message, __construct) {
   Message* intern = (Message*)Z_OBJ_P(getThis());
   const Descriptor* desc = Descriptor_GetFromClassEntry(Z_OBJCE_P(getThis()));
-  const upb_msgdef *msgdef = desc->msgdef;
   upb_arena *arena = Arena_Get(&intern->arena);
   zval *init_arr = NULL;
 
-  intern->desc = desc;
-  intern->msg = upb_msg_new(msgdef, arena);
-  ObjCache_Add(intern->msg, &intern->std);
+  Message_Initialize(intern, desc);
 
   if (zend_parse_parameters(ZEND_NUM_ARGS(), "|a!", &init_arr) == FAILURE) {
     return;
@@ -892,6 +904,39 @@ PHP_METHOD(Message, whichOneof) {
   RETURN_STRING(field ? upb_fielddef_name(field) : "");
 }
 
+/**
+ * Message::hasOneof()
+ *
+ * Returns the presence of the given oneof field, given a field number. Called
+ * from generated code methods such as:
+ *
+ *    public function hasDoubleValueOneof()
+ *    {
+ *        return $this->hasOneof(10);
+ *    }
+ *
+ * @return boolean
+ */
+PHP_METHOD(Message, hasOneof) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  zend_long field_num;
+  const upb_fielddef* f;
+
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &field_num) == FAILURE) {
+    return;
+  }
+
+  f = upb_msgdef_itof(intern->desc->msgdef, field_num);
+
+  if (!f || !upb_fielddef_realcontainingoneof(f)) {
+    php_error_docref(NULL, E_USER_ERROR,
+                     "Internal error, no such oneof field %d\n",
+                     (int)field_num);
+  }
+
+  RETVAL_BOOL(upb_msg_has(intern->msg, f));
+}
+
 /**
  * Message::readOneof()
  *
@@ -1002,6 +1047,7 @@ static zend_function_entry Message_methods[] = {
   PHP_ME(Message, mergeFrom,             arginfo_mergeFrom, ZEND_ACC_PUBLIC)
   PHP_ME(Message, readWrapperValue,      arginfo_read,      ZEND_ACC_PROTECTED)
   PHP_ME(Message, writeWrapperValue,     arginfo_write,     ZEND_ACC_PROTECTED)
+  PHP_ME(Message, hasOneof,              arginfo_read,      ZEND_ACC_PROTECTED)
   PHP_ME(Message, readOneof,             arginfo_read,      ZEND_ACC_PROTECTED)
   PHP_ME(Message, writeOneof,            arginfo_write,     ZEND_ACC_PROTECTED)
   PHP_ME(Message, whichOneof,            arginfo_read,      ZEND_ACC_PROTECTED)
@@ -1009,6 +1055,260 @@ static zend_function_entry Message_methods[] = {
   ZEND_FE_END
 };
 
+// Well-known types ////////////////////////////////////////////////////////////
+
+static const char TYPE_URL_PREFIX[] = "type.googleapis.com/";
+
+static upb_msgval Message_getval(Message *intern, const char *field_name) {
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name);
+  PBPHP_ASSERT(f);
+  return upb_msg_get(intern->msg, f);
+}
+
+static void Message_setval(Message *intern, const char *field_name,
+                           upb_msgval val) {
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, field_name);
+  PBPHP_ASSERT(f);
+  return upb_msg_set(intern->msg, f, val, Arena_Get(&intern->arena));
+}
+
+static upb_msgval StringVal(upb_strview view) {
+  upb_msgval ret;
+  ret.str_val = view;
+  return ret;
+}
+
+static bool TryStripUrlPrefix(upb_strview *str) {
+  size_t size = strlen(TYPE_URL_PREFIX);
+  if (str->size < size || memcmp(TYPE_URL_PREFIX, str->data, size) != 0) {
+    return false;
+  }
+  str->data += size;
+  str->size -= size;
+  return true;
+}
+
+static bool StrViewEq(upb_strview view, const char *str) {
+  size_t size = strlen(str);
+  return view.size == size && memcmp(view.data, str, size) == 0;
+}
+
+PHP_METHOD(google_protobuf_Any, unpack) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  upb_strview type_url = Message_getval(intern, "type_url").str_val;
+  upb_strview value = Message_getval(intern, "value").str_val;
+  upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_msgdef *m;
+  Descriptor *desc;
+  zval ret;
+
+  // Ensure that type_url has TYPE_URL_PREFIX as a prefix.
+  if (!TryStripUrlPrefix(&type_url)) {
+    zend_throw_exception(
+        NULL, "Type url needs to be type.googleapis.com/fully-qualified",
+        0 TSRMLS_CC);
+    return;
+  }
+
+  m = upb_symtab_lookupmsg2(symtab, type_url.data, type_url.size);
+
+  if (m == NULL) {
+    zend_throw_exception(
+        NULL, "Specified message in any hasn't been added to descriptor pool",
+        0 TSRMLS_CC);
+    return;
+  }
+
+  desc = Descriptor_GetFromMessageDef(m);
+  PBPHP_ASSERT(desc->class_entry->create_object == Message_create);
+  zend_object *obj = Message_create(desc->class_entry);
+  Message *msg = (Message*)obj;
+  Message_Initialize(msg, desc);
+  ZVAL_OBJ(&ret, obj);
+
+  // Get value.
+  if (!upb_decode(value.data, value.size, msg->msg,
+                  upb_msgdef_layout(desc->msgdef), Arena_Get(&msg->arena))) {
+    zend_throw_exception_ex(NULL, 0, "Error occurred during parsing");
+    return;
+  }
+
+  // Fuse since the parsed message could alias "value".
+  upb_arena_fuse(Arena_Get(&intern->arena), Arena_Get(&msg->arena));
+
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+PHP_METHOD(google_protobuf_Any, pack) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  upb_arena *arena = Arena_Get(&intern->arena);
+  zval *val;
+  Message *msg;
+  upb_strview value;
+  upb_strview type_url;
+  const char *full_name;
+  char *buf;
+
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &val) ==
+      FAILURE) {
+    return;
+  }
+
+  if (!instanceof_function(Z_OBJCE_P(val), message_ce)) {
+    zend_error(E_USER_ERROR, "Given value is not an instance of Message.");
+    return;
+  }
+
+  msg = (Message*)Z_OBJ_P(val);
+
+  // Serialize and set value.
+  value.data = upb_encode(msg->msg, upb_msgdef_layout(msg->desc->msgdef), arena,
+                          &value.size);
+  Message_setval(intern, "value", StringVal(value));
+
+  // Set type url: type_url_prefix + fully_qualified_name
+  full_name = upb_msgdef_fullname(msg->desc->msgdef);
+  type_url.size = strlen(TYPE_URL_PREFIX) + strlen(full_name);
+  buf = upb_arena_malloc(arena, type_url.size + 1);
+  memcpy(buf, TYPE_URL_PREFIX, strlen(TYPE_URL_PREFIX));
+  memcpy(buf + strlen(TYPE_URL_PREFIX), full_name, strlen(full_name));
+  type_url.data = buf;
+  Message_setval(intern, "type_url", StringVal(type_url));
+}
+
+PHP_METHOD(google_protobuf_Any, is) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  upb_strview type_url = Message_getval(intern, "type_url").str_val;
+  zend_class_entry *klass = NULL;
+  const upb_msgdef *m;
+
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &klass) ==
+      FAILURE) {
+    return;
+  }
+
+  m = NameMap_GetMessage(klass);
+
+  if (m == NULL) {
+    RETURN_BOOL(false);
+  }
+
+  RETURN_BOOL(TryStripUrlPrefix(&type_url) &&
+              StrViewEq(type_url, upb_msgdef_fullname(m)));
+}
+
+PHP_METHOD(google_protobuf_Timestamp, fromDateTime) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  zval* datetime;
+  const char *classname = "\\DatetimeInterface";
+  zend_string *classname_str = zend_string_init(classname, strlen(classname), 0);
+  zend_class_entry *date_interface_ce = zend_lookup_class(classname_str);
+
+  if (date_interface_ce == NULL) {
+    zend_error(E_ERROR, "Make sure date extension is enabled.");
+    return;
+  }
+
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &datetime,
+                            date_interface_ce) == FAILURE) {
+    zend_error(E_USER_ERROR, "Expect DatetimeInterface.");
+    return;
+  }
+
+  upb_msgval timestamp_seconds;
+  {
+    zval retval;
+    zval function_name;
+
+    ZVAL_STRING(&function_name, "date_timestamp_get");
+
+    if (call_user_function(EG(function_table), NULL, &function_name, &retval, 1,
+                           datetime) == FAILURE ||
+        !Convert_PhpToUpb(&retval, &timestamp_seconds, UPB_TYPE_INT64, NULL,
+                          NULL)) {
+      zend_error(E_ERROR, "Cannot get timestamp from DateTime.");
+      return;
+    }
+
+    zval_dtor(&retval);
+    zval_dtor(&function_name);
+  }
+
+  upb_msgval timestamp_nanos;
+  {
+    zval retval;
+    zval function_name;
+    zval format_string;
+
+    ZVAL_STRING(&function_name, "date_format");
+    ZVAL_STRING(&format_string, "u");
+
+    zval params[2] = {
+        *datetime,
+        format_string,
+    };
+
+    if (call_user_function(EG(function_table), NULL, &function_name, &retval, 2,
+                           params) == FAILURE ||
+        !Convert_PhpToUpb(&retval, &timestamp_nanos, UPB_TYPE_INT32, NULL,
+                          NULL)) {
+      zend_error(E_ERROR, "Cannot format DateTime.");
+      return;
+    }
+
+    timestamp_nanos.int32_val *= 1000;
+
+    zval_dtor(&retval);
+    zval_dtor(&function_name);
+    zval_dtor(&format_string);
+  }
+
+  Message_setval(intern, "seconds", timestamp_seconds);
+  Message_setval(intern, "nanos", timestamp_nanos);
+
+  RETURN_NULL();
+}
+
+PHP_METHOD(google_protobuf_Timestamp, toDateTime) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  upb_msgval seconds = Message_getval(intern, "seconds");
+  upb_msgval nanos = Message_getval(intern, "nanos");
+
+  // Get formatted time string.
+  char formatted_time[32];
+  snprintf(formatted_time, sizeof(formatted_time), "%" PRId64 ".%06" PRId32,
+           seconds.int64_val, nanos.int32_val / 1000);
+
+  // Create Datetime object.
+  zval datetime;
+  zval function_name;
+  zval format_string;
+  zval formatted_time_php;
+
+  ZVAL_STRING(&function_name, "date_create_from_format");
+  ZVAL_STRING(&format_string, "U.u");
+  ZVAL_STRING(&formatted_time_php, formatted_time);
+
+  zval params[2] = {
+    format_string,
+    formatted_time_php,
+  };
+
+  if (call_user_function(EG(function_table), NULL, &function_name, &datetime, 2,
+                         params) == FAILURE) {
+    zend_error(E_ERROR, "Cannot create DateTime.");
+    return;
+  }
+
+  zval_dtor(&function_name);
+  zval_dtor(&format_string);
+  zval_dtor(&formatted_time_php);
+
+  ZVAL_OBJ(return_value, Z_OBJ(datetime));
+}
+
+#include "wkt.inc"
+
 /**
  * Message_ModuleInit()
  *
@@ -1033,4 +1333,6 @@ void Message_ModuleInit() {
   h->unset_property = Message_unset_property;
   h->get_properties = Message_get_properties;
   h->get_property_ptr_ptr = Message_get_property_ptr_ptr;
+
+  WellKnownTypes_ModuleInit();  /* From wkt.inc. */
 }

+ 2 - 0
php/ext/google/protobuf/package.xml

@@ -45,6 +45,8 @@
     <file baseinstalldir="/" name="php-upb.h" role="src"/>
     <file baseinstalldir="/" name="protobuf.c" role="src"/>
     <file baseinstalldir="/" name="protobuf.h" role="src"/>
+    <file baseinstalldir="/" name="third_party/wyhash/wyhash.h" role="src"/>
+    <file baseinstalldir="/" name="third_party/wyhash/LICENSE" role="doc"/>
     <file baseinstalldir="/" name="LICENSE" role="doc"/>
   </dir>
  </contents>

文件差異過大導致無法顯示
+ 422 - 313
php/ext/google/protobuf/php-upb.c


+ 40 - 234
php/ext/google/protobuf/php-upb.h

@@ -1,5 +1,3 @@
-#define NDEBUG
-
 /* Amalgamated source file */
 #include <stdint.h>/*
 * This is where we define macros used across upb.
@@ -23,6 +21,15 @@
 *
 * This file is private and must not be included by users!
 */
+
+#if !(__STDC_VERSION__ >= 199901L || __cplusplus >= 201103L)
+#error upb requires C99 or C++11
+#endif
+
+#if (defined(_MSC_VER) && _MSC_VER < 1900)
+#error upb requires MSVC >= 2015.
+#endif
+
 #include <stdint.h>
 #include <stddef.h>
 
@@ -71,12 +78,6 @@
 #define UPB_UNLIKELY(x) (x)
 #endif
 
-/* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
- * doesn't provide these preprocessor symbols. */
-#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-#define UPB_BIG_ENDIAN
-#endif
-
 /* Macros for function attributes on compilers that support them. */
 #ifdef __GNUC__
 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
@@ -92,49 +93,6 @@
 #define UPB_NORETURN
 #endif
 
-#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
-/* C99/C++11 versions. */
-#include <stdio.h>
-#define _upb_snprintf snprintf
-#define _upb_vsnprintf vsnprintf
-#define _upb_va_copy(a, b) va_copy(a, b)
-#elif defined(_MSC_VER)
-/* Microsoft C/C++ versions. */
-#include <stdarg.h>
-#include <stdio.h>
-#if _MSC_VER < 1900
-int msvc_snprintf(char* s, size_t n, const char* format, ...);
-int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
-#define UPB_MSVC_VSNPRINTF
-#define _upb_snprintf msvc_snprintf
-#define _upb_vsnprintf msvc_vsnprintf
-#else
-#define _upb_snprintf snprintf
-#define _upb_vsnprintf vsnprintf
-#endif
-#define _upb_va_copy(a, b) va_copy(a, b)
-#elif defined __GNUC__
-/* A few hacky workarounds for functions not in C89.
- * For internal use only!
- * TODO(haberman): fix these by including our own implementations, or finding
- * another workaround.
- */
-#define _upb_snprintf __builtin_snprintf
-#define _upb_vsnprintf __builtin_vsnprintf
-#define _upb_va_copy(a, b) __va_copy(a, b)
-#else
-#error Need implementations of [v]snprintf and va_copy
-#endif
-
-#ifdef __cplusplus
-#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || \
-    (defined(_MSC_VER) && _MSC_VER >= 1900)
-/* C++11 is present */
-#else
-#error upb requires C++11 for C++ support
-#endif
-#endif
-
 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
 
@@ -162,29 +120,12 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
 #define UPB_ASSERT(expr) assert(expr)
 #endif
 
-/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
- * exist in debug mode.  This turns into regular assert. */
-#define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
-
 #if defined(__GNUC__) || defined(__clang__)
 #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
 #else
 #define UPB_UNREACHABLE() do { assert(0); } while(0)
 #endif
 
-/* UPB_INFINITY representing floating-point positive infinity. */
-#include <math.h>
-#ifdef INFINITY
-#define UPB_INFINITY INFINITY
-#else
-#define UPB_INFINITY (1.0 / 0.0)
-#endif
-#ifdef NAN
-#define UPB_NAN NAN
-#else
-#define UPB_NAN (0.0 / 0.0)
-#endif
-
 #if defined(__SANITIZE_ADDRESS__)
 #define UPB_ASAN 1
 #ifdef __cplusplus
@@ -241,7 +182,7 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
 ** store pointers or integers of at least 32 bits (upb isn't really useful on
 ** systems where sizeof(void*) < 4).
 **
-** The table must be homogenous (all values of the same type).  In debug
+** The table must be homogeneous (all values of the same type).  In debug
 ** mode, we check this on insert and lookup.
 */
 
@@ -552,7 +493,7 @@ UPB_INLINE uint32_t _upb_be_swap32(uint32_t val) {
     return val;
   } else {
     return ((val & 0xff) << 24) | ((val & 0xff00) << 8) |
-           ((val & 0xff0000ULL) >> 8) | ((val & 0xff000000ULL) >> 24);
+           ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);
   }
 }
 
@@ -560,14 +501,21 @@ UPB_INLINE uint64_t _upb_be_swap64(uint64_t val) {
   if (_upb_isle()) {
     return val;
   } else {
-    return ((val & 0xff) << 56) | ((val & 0xff00) << 40) |
-           ((val & 0xff0000) << 24) | ((val & 0xff000000) << 8) |
-           ((val & 0xff00000000ULL) >> 8) | ((val & 0xff0000000000ULL) >> 24) |
-           ((val & 0xff000000000000ULL) >> 40) |
-           ((val & 0xff00000000000000ULL) >> 56);
+    return ((uint64_t)_upb_be_swap32(val) << 32) | _upb_be_swap32(val >> 32);
   }
 }
 
+UPB_INLINE int _upb_lg2ceil(int x) {
+  if (x <= 1) return 0;
+#ifdef __GNUC__
+  return 32 - __builtin_clz(x - 1);
+#else
+  int lg2 = 0;
+  while (1 << lg2 < x) lg2++;
+  return lg2;
+#endif
+}
+
 
 #ifdef __cplusplus
 }  /* extern "C" */
@@ -1095,7 +1043,8 @@ UPB_INLINE upb_msg *_upb_msg_new_inl(const upb_msglayout *l, upb_arena *a) {
 upb_msg *_upb_msg_new(const upb_msglayout *l, upb_arena *a);
 
 UPB_INLINE upb_msg_internal *upb_msg_getinternal(upb_msg *msg) {
-  return UPB_PTR_AT(msg, -sizeof(upb_msg_internal), upb_msg_internal);
+  ptrdiff_t size = sizeof(upb_msg_internal);
+  return (upb_msg_internal*)((char*)msg - size);
 }
 
 /* Clears the given message. */
@@ -1190,9 +1139,11 @@ typedef struct {
   uintptr_t data;   /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */
   size_t len;   /* Measured in elements. */
   size_t size;  /* Measured in elements. */
+  uint64_t junk;
 } upb_array;
 
 UPB_INLINE const void *_upb_array_constptr(const upb_array *arr) {
+  UPB_ASSERT((arr->data & 7) <= 4);
   return (void*)(arr->data & ~(uintptr_t)7);
 }
 
@@ -1202,15 +1153,17 @@ UPB_INLINE void *_upb_array_ptr(upb_array *arr) {
 
 UPB_INLINE uintptr_t _upb_tag_arrptr(void* ptr, int elem_size_lg2) {
   UPB_ASSERT(elem_size_lg2 <= 4);
+  UPB_ASSERT(((uintptr_t)ptr & 7) == 0);
   return (uintptr_t)ptr | (unsigned)elem_size_lg2;
 }
 
 UPB_INLINE upb_array *_upb_array_new(upb_arena *a, size_t init_size,
                                      int elem_size_lg2) {
+  const size_t arr_size = UPB_ALIGN_UP(sizeof(upb_array), 8);
   const size_t bytes = sizeof(upb_array) + (init_size << elem_size_lg2);
   upb_array *arr = (upb_array*)upb_arena_malloc(a, bytes);
   if (!arr) return NULL;
-  arr->data = _upb_tag_arrptr(arr + 1, elem_size_lg2);
+  arr->data = _upb_tag_arrptr(UPB_PTR_AT(arr, arr_size, void), elem_size_lg2);
   arr->len = 0;
   arr->size = init_size;
   return arr;
@@ -1383,17 +1336,17 @@ UPB_INLINE void _upb_map_fromkey(upb_strview key, void* out, size_t size) {
   }
 }
 
-UPB_INLINE upb_value _upb_map_tovalue(const void *val, size_t size,
-                                      upb_arena *a) {
-  upb_value ret = {0};
+UPB_INLINE bool _upb_map_tovalue(const void *val, size_t size, upb_value *msgval,
+                                 upb_arena *a) {
   if (size == UPB_MAPTYPE_STRING) {
     upb_strview *strp = (upb_strview*)upb_arena_malloc(a, sizeof(*strp));
+    if (!strp) return false;
     *strp = *(upb_strview*)val;
-    ret = upb_value_ptr(strp);
+    *msgval = upb_value_ptr(strp);
   } else {
-    memcpy(&ret, val, size);
+    memcpy(msgval, val, size);
   }
-  return ret;
+  return true;
 }
 
 UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
@@ -1435,7 +1388,8 @@ UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
 UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size,
                              void *val, size_t val_size, upb_arena *arena) {
   upb_strview strkey = _upb_map_tokey(key, key_size);
-  upb_value tabval = _upb_map_tovalue(val, val_size, arena);
+  upb_value tabval = {0};
+  if (!_upb_map_tovalue(val, val_size, &tabval, arena)) return false;
   upb_alloc *a = upb_arena_alloc(arena);
 
   /* TODO(haberman): add overwrite operation to minimize number of lookups. */
@@ -1596,148 +1550,6 @@ char *upb_encode(const void *msg, const upb_msglayout *l, upb_arena *arena,
 #endif
 
 #endif  /* UPB_ENCODE_H_ */
-//Author: Wang Yi <godspeed_china@yeah.net>
-#ifndef wyhash_final_version
-#define wyhash_final_version
-//defines that change behavior
-#ifndef WYHASH_CONDOM
-#define WYHASH_CONDOM 1 //0: read 8 bytes before and after boudaries, dangerous but fastest. 1: normal valid behavior 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication"
-#endif
-#define WYHASH_32BIT_MUM 0	//faster on 32 bit system
-//includes
-#include <stdint.h>
-#include <string.h>
-#if defined(_MSC_VER) && defined(_M_X64)
-  #include <intrin.h>
-  #pragma intrinsic(_umul128)
-#endif
-#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
-  #define _likely_(x)	__builtin_expect(x,1)
-  #define _unlikely_(x)	__builtin_expect(x,0)
-#else
-  #define _likely_(x) (x)
-  #define _unlikely_(x) (x)
-#endif
-//mum function
-static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); }
-static inline void _wymum(uint64_t *A, uint64_t *B){
-#if(WYHASH_32BIT_MUM)
-  uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(unsigned)*B, lh=(unsigned)*A*(*B>>32), ll=(uint64_t)(unsigned)*A*(unsigned)*B;
-  #if(WYHASH_CONDOM>1)
-  *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll;
-  #else
-  *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll;
-  #endif
-#elif defined(__SIZEOF_INT128__)
-  __uint128_t r=*A; r*=*B; 
-  #if(WYHASH_CONDOM>1)
-  *A^=(uint64_t)r; *B^=(uint64_t)(r>>64);
-  #else
-  *A=(uint64_t)r; *B=(uint64_t)(r>>64);
-  #endif
-#elif defined(_MSC_VER) && defined(_M_X64)
-  #if(WYHASH_CONDOM>1)
-  uint64_t  a,  b;
-  a=_umul128(*A,*B,&b);
-  *A^=a;  *B^=b;
-  #else
-  *A=_umul128(*A,*B,B);
-  #endif
-#else
-  uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo;
-  uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl;
-  lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c;
-  #if(WYHASH_CONDOM>1)
-  *A^=lo;  *B^=hi;
-  #else
-  *A=lo;  *B=hi;
-  #endif
-#endif
-}
-static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; }
-//read functions
-#ifndef WYHASH_LITTLE_ENDIAN
-  #if defined(_WIN32) || defined(__LITTLE_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
-    #define WYHASH_LITTLE_ENDIAN 1
-  #elif defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-    #define WYHASH_LITTLE_ENDIAN 0
-  #endif
-#endif
-#if (WYHASH_LITTLE_ENDIAN)
-static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;}
-static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return v;}
-#elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
-static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);}
-static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return __builtin_bswap32(v);}
-#elif defined(_MSC_VER)
-static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);}
-static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return _byteswap_ulong(v);}
-#endif
-static inline uint64_t _wyr3(const uint8_t *p, unsigned k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];}
-//wyhash function
-static inline uint64_t _wyfinish16(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
-#if(WYHASH_CONDOM>0)
-  uint64_t a, b;
-  if(_likely_(i<=8)){
-    if(_likely_(i>=4)){ a=_wyr4(p); b=_wyr4(p+i-4); }
-    else if (_likely_(i)){ a=_wyr3(p,i); b=0; }
-    else a=b=0;
-  } 
-  else{ a=_wyr8(p); b=_wyr8(p+i-8); }
-  return _wymix(secret[1]^len,_wymix(a^secret[1], b^seed));
-#else
-  #define oneshot_shift ((i<8)*((8-i)<<3))
-  return _wymix(secret[1]^len,_wymix((_wyr8(p)<<oneshot_shift)^secret[1],(_wyr8(p+i-8)>>oneshot_shift)^seed));
-#endif
-}
-
-static inline uint64_t _wyfinish(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
-  if(_likely_(i<=16)) return _wyfinish16(p,len,seed,secret,i);
-  return _wyfinish(p+16,len,_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed),secret,i-16);
-}
-
-static inline uint64_t wyhash(const void *key, uint64_t len, uint64_t seed, const uint64_t *secret){
-  const uint8_t *p=(const uint8_t *)key;
-  uint64_t i=len; seed^=*secret;
-  if(_unlikely_(i>64)){
-    uint64_t see1=seed;
-    do{
-      seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed)^_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^seed);
-      see1=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see1)^_wymix(_wyr8(p+48)^secret[4],_wyr8(p+56)^see1);
-      p+=64; i-=64;
-    }while(i>64);
-    seed^=see1;
-  }
-  return _wyfinish(p,len,seed,secret,i);
-}
-//utility functions
-static const uint64_t _wyp[5] = {0xa0761d6478bd642full, 0xe7037ed1a0b428dbull, 0x8ebc6af09c88c6e3ull, 0x589965cc75374cc3ull, 0x1d8e4e27c47d124full};
-static inline uint64_t wyhash64(uint64_t A, uint64_t B){  A^=_wyp[0]; B^=_wyp[1];  _wymum(&A,&B);  return _wymix(A^_wyp[0],B^_wyp[1]);}
-static inline uint64_t wyrand(uint64_t *seed){  *seed+=_wyp[0]; return _wymix(*seed,*seed^_wyp[1]);}
-static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;}
-static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;}
-static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; }
-
-static inline void make_secret(uint64_t seed, uint64_t *secret){
-  uint8_t c[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240 };
-  for(size_t i=0;i<5;i++){
-    uint8_t ok;
-    do{
-      ok=1; secret[i]=0;
-      for(size_t j=0;j<64;j+=8) secret[i]|=((uint64_t)c[wyrand(&seed)%sizeof(c)])<<j;
-      if(secret[i]%2==0){ ok=0; continue; }
-      for(size_t j=0;j<i;j++)
-#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
-        if(__builtin_popcountll(secret[j]^secret[i])!=32){ ok=0; break; }
-#elif defined(_MSC_VER) && defined(_M_X64)
-        if(_mm_popcnt_u64(secret[j]^secret[i])!=32){ ok=0; break; }
-#endif
-       if(!ok)continue;
-       for(uint64_t j=3;j<0x100000000ull;j+=2) if(secret[i]%j==0){ ok=0; break; }
-    }while(!ok);
-  }
-}
-#endif
 /* This file was generated by upbc (the upb compiler) from the input
  * file:
  *
@@ -3746,6 +3558,7 @@ int upb_symtab_filecount(const upb_symtab *s);
 const upb_filedef *upb_symtab_addfile(
     upb_symtab *s, const google_protobuf_FileDescriptorProto *file,
     upb_status *status);
+size_t _upb_symtab_bytesloaded(const upb_symtab *s);
 
 /* For generated code only: loads a generated descriptor. */
 typedef struct upb_def_init {
@@ -4118,7 +3931,7 @@ extern "C" {
 #endif
 
 enum {
-  /* When set, emits 0/default values.  TOOD(haberman): proto3 only? */
+  /* When set, emits 0/default values.  TODO(haberman): proto3 only? */
   UPB_JSONENC_EMITDEFAULTS = 1,
 
   /* When set, use normal (snake_caes) field names instead of JSON (camelCase)
@@ -4163,14 +3976,7 @@ size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
 #undef UPB_UNUSED
 #undef UPB_ASSUME
 #undef UPB_ASSERT
-#undef UPB_ASSERT_DEBUGVAR
 #undef UPB_UNREACHABLE
-#undef UPB_INFINITY
-#undef UPB_NAN
-#undef UPB_MSVC_VSNPRINTF
-#undef _upb_snprintf
-#undef _upb_vsnprintf
-#undef _upb_va_copy
 #undef UPB_POISON_MEMORY_REGION
 #undef UPB_UNPOISON_MEMORY_REGION
 #undef UPB_ASAN

+ 0 - 34
php/ext/google/protobuf/protobuf.c

@@ -35,7 +35,6 @@
 
 #include "arena.h"
 #include "array.h"
-#include "bundled_php.h"
 #include "convert.h"
 #include "def.h"
 #include "map.h"
@@ -162,10 +161,6 @@ static PHP_RINIT_FUNCTION(protobuf) {
   upb_symtab *symtab = PROTOBUF_G(saved_symtab);
   DescriptorPool_CreateWithSymbolTable(&PROTOBUF_G(generated_pool), symtab);
 
-  // Set up autoloader for bundled sources.
-  zend_eval_string("spl_autoload_register('protobuf_internal_loadbundled');",
-                   NULL, "autoload_register.php");
-
   zend_hash_init(&PROTOBUF_G(object_cache), 64, NULL, NULL, 0);
   zend_hash_init(&PROTOBUF_G(name_msg_cache), 64, NULL, NULL, 0);
   zend_hash_init(&PROTOBUF_G(name_enum_cache), 64, NULL, NULL, 0);
@@ -193,34 +188,6 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
   return SUCCESS;
 }
 
-// -----------------------------------------------------------------------------
-// Bundled PHP sources
-// -----------------------------------------------------------------------------
-
-// We bundle PHP sources for well-known types into the C extension. There is no
-// need to implement these in C.
-
-static PHP_FUNCTION(protobuf_internal_loadbundled) {
-  char *name = NULL;
-  zend_long size;
-  BundledPhp_File *file;
-
-  if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &size) != SUCCESS) {
-    return;
-  }
-
-  for (file = bundled_files; file->filename; file++) {
-    if (strcmp(file->filename, name) == 0) {
-      zend_eval_string((char*)file->contents, NULL, (char*)file->filename);
-      return;
-    }
-  }
-}
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_load_bundled_source, 0, 0, 1)
-  ZEND_ARG_INFO(0, class_name)
-ZEND_END_ARG_INFO()
-
 // -----------------------------------------------------------------------------
 // Object Cache.
 // -----------------------------------------------------------------------------
@@ -303,7 +270,6 @@ const upb_enumdef *NameMap_GetEnum(zend_class_entry *ce) {
 // -----------------------------------------------------------------------------
 
 zend_function_entry protobuf_functions[] = {
-  PHP_FE(protobuf_internal_loadbundled, arginfo_load_bundled_source)
   ZEND_FE_END
 };
 

+ 3232 - 0
php/ext/google/protobuf/wkt.inc

@@ -0,0 +1,3232 @@
+// This file is generated from the .proto files for the well-known
+// types. Do not edit!
+static void google_protobuf_any_proto_AddDescriptor();
+static void google_protobuf_api_proto_AddDescriptor();
+static void google_protobuf_duration_proto_AddDescriptor();
+static void google_protobuf_empty_proto_AddDescriptor();
+static void google_protobuf_field_mask_proto_AddDescriptor();
+static void google_protobuf_source_context_proto_AddDescriptor();
+static void google_protobuf_struct_proto_AddDescriptor();
+static void google_protobuf_type_proto_AddDescriptor();
+static void google_protobuf_timestamp_proto_AddDescriptor();
+static void google_protobuf_wrappers_proto_AddDescriptor();
+/* google/protobuf/any.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Any_ce;
+
+const char google_protobuf_any_proto_descriptor [212] = {
+'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', 
+'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '&', '\n', '\003', 'A', 'n', 
+'y', '\022', '\020', '\n', '\010', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\r', '\n', '\005', 'v', 'a', 
+'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\014', 'B', 'v', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 
+'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'n', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', 
+'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 
+'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', 'n', 'y', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 
+'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 
+'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_any_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/any.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/any.proto", google_protobuf_any_proto_descriptor,
+                               sizeof(google_protobuf_any_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Any, initOnce) {
+  google_protobuf_any_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Any_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Any, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Any_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Any",
+                   GPBMetadata_Google_Protobuf_Any_methods);
+
+  GPBMetadata_Google_Protobuf_Any_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Any */
+
+zend_class_entry* google_protobuf_Any_ce;
+
+static PHP_METHOD(google_protobuf_Any, __construct) {
+  google_protobuf_any_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Any, getTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "type_url");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Any, setTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "type_url");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Any, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Any, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Any_phpmethods[] = {
+  PHP_ME(google_protobuf_Any, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, getTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, setTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, setValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, is, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, pack, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Any, unpack, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Any_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Any",
+                   google_protobuf_Any_phpmethods);
+
+  google_protobuf_Any_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Any_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Any_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Any_ce, message_ce);
+}
+
+/* google/protobuf/api.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Api_ce;
+
+const char google_protobuf_api_proto_descriptor [751] = {
+'\n', '\031', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'p', 'i', '.', 'p', 'r', 'o', 
+'t', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '$', 'g', 'o', 'o', 'g', 
+'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 
+'t', '.', 'p', 'r', 'o', 't', 'o', '\032', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 
+'t', 'y', 'p', 'e', '.', 'p', 'r', 'o', 't', 'o', '\"', '\201', '\002', '\n', '\003', 'A', 'p', 'i', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 
+'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '(', '\n', '\007', 'm', 'e', 't', 'h', 'o', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', 
+'\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd', '\022', 
+'(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', 
+'.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 'v', 'e', 'r', 's', 'i', 
+'o', 'n', '\030', '\004', ' ', '\001', '(', '\t', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 
+'t', '\030', '\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 
+'.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '&', '\n', '\006', 'm', 'i', 'x', 'i', 'n', 's', '\030', 
+'\006', ' ', '\003', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 
+'i', 'x', 'i', 'n', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 
+'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '\325', '\001', '\n', '\006', 
+'M', 'e', 't', 'h', 'o', 'd', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\030', '\n', '\020', 'r', 
+'e', 'q', 'u', 'e', 's', 't', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\002', ' ', '\001', '(', '\t', '\022', '\031', '\n', '\021', 
+'r', 'e', 'q', 'u', 'e', 's', 't', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\003', ' ', '\001', '(', '\010', '\022', '\031', 
+'\n', '\021', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 't', 'y', 'p', 'e', '_', 'u', 'r', 'l', '\030', '\004', ' ', '\001', '(', '\t', 
+'\022', '\032', '\n', '\022', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\005', ' ', 
+'\001', '(', '\010', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\006', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 
+'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\'', '\n', '\006', 's', 
+'y', 'n', 't', 'a', 'x', '\030', '\007', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 
+'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', '#', '\n', '\005', 'M', 'i', 'x', 'i', 'n', '\022', '\014', '\n', '\004', 'n', 
+'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\014', '\n', '\004', 'r', 'o', 'o', 't', '\030', '\002', ' ', '\001', '(', '\t', 'B', 'v', 
+'\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\010', 'A', 'p', 
+'i', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', ',', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 
+'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'a', 
+'p', 'i', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 
+'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', 
+'3', 
+};
+
+static void google_protobuf_api_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/api.proto")) return;
+  google_protobuf_source_context_proto_AddDescriptor();
+  google_protobuf_type_proto_AddDescriptor();
+  DescriptorPool_AddDescriptor("google/protobuf/api.proto", google_protobuf_api_proto_descriptor,
+                               sizeof(google_protobuf_api_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Api, initOnce) {
+  google_protobuf_api_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Api_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Api, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Api_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Api",
+                   GPBMetadata_Google_Protobuf_Api_methods);
+
+  GPBMetadata_Google_Protobuf_Api_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Api */
+
+zend_class_entry* google_protobuf_Api_ce;
+
+static PHP_METHOD(google_protobuf_Api, __construct) {
+  google_protobuf_api_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Api, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getMethods) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "methods");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setMethods) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "methods");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getVersion) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "version");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setVersion) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "version");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getMixins) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "mixins");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setMixins) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "mixins");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, getSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Api, setSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Api_phpmethods[] = {
+  PHP_ME(google_protobuf_Api, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getMethods, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setMethods, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getVersion, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setVersion, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getMixins, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setMixins, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, getSyntax, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Api, setSyntax, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Api_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Api",
+                   google_protobuf_Api_phpmethods);
+
+  google_protobuf_Api_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Api_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Api_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Api_ce, message_ce);
+}
+
+/* google_protobuf_Method */
+
+zend_class_entry* google_protobuf_Method_ce;
+
+static PHP_METHOD(google_protobuf_Method, __construct) {
+  google_protobuf_api_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Method, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getRequestTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "request_type_url");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setRequestTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "request_type_url");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getRequestStreaming) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "request_streaming");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setRequestStreaming) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "request_streaming");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getResponseTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "response_type_url");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setResponseTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "response_type_url");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getResponseStreaming) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "response_streaming");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setResponseStreaming) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "response_streaming");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, getSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Method, setSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Method_phpmethods[] = {
+  PHP_ME(google_protobuf_Method, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, getSyntax, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Method, setSyntax, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Method_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Method",
+                   google_protobuf_Method_phpmethods);
+
+  google_protobuf_Method_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Method_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Method_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Method_ce, message_ce);
+}
+
+/* google_protobuf_Mixin */
+
+zend_class_entry* google_protobuf_Mixin_ce;
+
+static PHP_METHOD(google_protobuf_Mixin, __construct) {
+  google_protobuf_api_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Mixin, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Mixin, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Mixin, getRoot) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "root");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Mixin, setRoot) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "root");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Mixin_phpmethods[] = {
+  PHP_ME(google_protobuf_Mixin, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Mixin, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Mixin, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Mixin, getRoot, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Mixin, setRoot, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Mixin_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Mixin",
+                   google_protobuf_Mixin_phpmethods);
+
+  google_protobuf_Mixin_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Mixin_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Mixin_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Mixin_ce, message_ce);
+}
+
+/* google/protobuf/duration.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Duration_ce;
+
+const char google_protobuf_duration_proto_descriptor [235] = {
+'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'u', 'r', 'a', 't', 'i', 'o', 
+'n', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', 
+'*', '\n', '\010', 'D', 'u', 'r', 'a', 't', 'i', 'o', 'n', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', '\001', ' ', 
+'\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\203', '\001', '\n', '\023', 'c', 'o', 
+'m', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'D', 'u', 'r', 'a', 't', 'i', 
+'o', 'n', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 
+'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 
+'d', 'u', 'r', 'a', 't', 'i', 'o', 'n', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 
+'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 
+'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_duration_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/duration.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/duration.proto", google_protobuf_duration_proto_descriptor,
+                               sizeof(google_protobuf_duration_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Duration, initOnce) {
+  google_protobuf_duration_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Duration_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Duration, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Duration_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Duration",
+                   GPBMetadata_Google_Protobuf_Duration_methods);
+
+  GPBMetadata_Google_Protobuf_Duration_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Duration */
+
+zend_class_entry* google_protobuf_Duration_ce;
+
+static PHP_METHOD(google_protobuf_Duration, __construct) {
+  google_protobuf_duration_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Duration, getSeconds) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "seconds");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Duration, setSeconds) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "seconds");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Duration, getNanos) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "nanos");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Duration, setNanos) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "nanos");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Duration_phpmethods[] = {
+  PHP_ME(google_protobuf_Duration, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Duration, getSeconds, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Duration, setSeconds, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Duration, getNanos, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Duration, setNanos, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Duration_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Duration",
+                   google_protobuf_Duration_phpmethods);
+
+  google_protobuf_Duration_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Duration_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Duration_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Duration_ce, message_ce);
+}
+
+/* google/protobuf/empty.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_GPBEmpty_ce;
+
+const char google_protobuf_empty_proto_descriptor [190] = {
+'\n', '\033', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'e', 'm', 'p', 't', 'y', '.', 'p', 
+'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\007', '\n', '\005', 
+'E', 'm', 'p', 't', 'y', 'B', '}', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 
+'b', 'u', 'f', 'B', '\n', 'E', 'm', 'p', 't', 'y', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '.', 'g', 'o', 'o', 'g', 'l', 'e', 
+'.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 
+'s', '/', 'k', 'n', 'o', 'w', 'n', '/', 'e', 'm', 'p', 't', 'y', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', 
+'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 
+'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_empty_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/empty.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/empty.proto", google_protobuf_empty_proto_descriptor,
+                               sizeof(google_protobuf_empty_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce) {
+  google_protobuf_empty_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_GPBEmpty_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_GPBEmpty, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\GPBEmpty",
+                   GPBMetadata_Google_Protobuf_GPBEmpty_methods);
+
+  GPBMetadata_Google_Protobuf_GPBEmpty_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Empty */
+
+zend_class_entry* google_protobuf_Empty_ce;
+
+static PHP_METHOD(google_protobuf_Empty, __construct) {
+  google_protobuf_empty_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static zend_function_entry google_protobuf_Empty_phpmethods[] = {
+  PHP_ME(google_protobuf_Empty, __construct, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Empty_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\GPBEmpty",
+                   google_protobuf_Empty_phpmethods);
+
+  google_protobuf_Empty_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Empty_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Empty_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Empty_ce, message_ce);
+}
+
+/* google/protobuf/field_mask.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_FieldMask_ce;
+
+const char google_protobuf_field_mask_proto_descriptor [223] = {
+'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'f', 'i', 'e', 'l', 'd', '_', 'm', 
+'a', 's', 'k', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 
+'f', '\"', '\032', '\n', '\t', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', '\022', '\r', '\n', '\005', 'p', 'a', 't', 'h', 's', '\030', '\001', 
+' ', '\003', '(', '\t', 'B', '\205', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 
+'b', 'u', 'f', 'B', '\016', 'F', 'i', 'e', 'l', 'd', 'M', 'a', 's', 'k', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 
+'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 
+'t', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'f', 'i', 'e', 'l', 'd', 'm', 'a', 's', 'k', 'p', 'b', '\370', '\001', 
+'\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', 
+'.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_field_mask_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/field_mask.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/field_mask.proto", google_protobuf_field_mask_proto_descriptor,
+                               sizeof(google_protobuf_field_mask_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_FieldMask, initOnce) {
+  google_protobuf_field_mask_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_FieldMask_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_FieldMask, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_FieldMask_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\FieldMask",
+                   GPBMetadata_Google_Protobuf_FieldMask_methods);
+
+  GPBMetadata_Google_Protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_FieldMask */
+
+zend_class_entry* google_protobuf_FieldMask_ce;
+
+static PHP_METHOD(google_protobuf_FieldMask, __construct) {
+  google_protobuf_field_mask_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_FieldMask, getPaths) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "paths");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_FieldMask, setPaths) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "paths");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_FieldMask_phpmethods[] = {
+  PHP_ME(google_protobuf_FieldMask, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_FieldMask_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FieldMask",
+                   google_protobuf_FieldMask_phpmethods);
+
+  google_protobuf_FieldMask_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_FieldMask_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_FieldMask_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_FieldMask_ce, message_ce);
+}
+
+/* google/protobuf/source_context.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_SourceContext_ce;
+
+const char google_protobuf_source_context_proto_descriptor [240] = {
+'\n', '$', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 
+'c', 'o', 'n', 't', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 
+'t', 'o', 'b', 'u', 'f', '\"', '\"', '\n', '\r', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\021', '\n', 
+'\t', 'f', 'i', 'l', 'e', '_', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'B', '\212', '\001', '\n', '\023', 'c', 'o', 'm', '.', 
+'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\022', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 
+'n', 't', 'e', 'x', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '6', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 
+'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 
+'w', 'n', '/', 's', 'o', 'u', 'r', 'c', 'e', 'c', 'o', 'n', 't', 'e', 'x', 't', 'p', 'b', '\242', '\002', '\003', 'G', 'P', 'B', '\252', 
+'\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 
+'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_source_context_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/source_context.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/source_context.proto", google_protobuf_source_context_proto_descriptor,
+                               sizeof(google_protobuf_source_context_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_SourceContext, initOnce) {
+  google_protobuf_source_context_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_SourceContext_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_SourceContext, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_SourceContext_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\SourceContext",
+                   GPBMetadata_Google_Protobuf_SourceContext_methods);
+
+  GPBMetadata_Google_Protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_SourceContext */
+
+zend_class_entry* google_protobuf_SourceContext_ce;
+
+static PHP_METHOD(google_protobuf_SourceContext, __construct) {
+  google_protobuf_source_context_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_SourceContext, getFileName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "file_name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_SourceContext, setFileName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "file_name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_SourceContext_phpmethods[] = {
+  PHP_ME(google_protobuf_SourceContext, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_SourceContext_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\SourceContext",
+                   google_protobuf_SourceContext_phpmethods);
+
+  google_protobuf_SourceContext_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_SourceContext_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_SourceContext_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_SourceContext_ce, message_ce);
+}
+
+/* google/protobuf/struct.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Struct_ce;
+
+const char google_protobuf_struct_proto_descriptor [638] = {
+'\n', '\034', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 't', 'r', 'u', 'c', 't', '.', 
+'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', '\204', '\001', 
+'\n', '\006', 'S', 't', 'r', 'u', 'c', 't', '\022', '3', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', 
+'#', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', '.', 
+'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', 'y', '\032', 'E', '\n', '\013', 'F', 'i', 'e', 'l', 'd', 's', 'E', 'n', 't', 'r', 
+'y', '\022', '\013', '\n', '\003', 'k', 'e', 'y', '\030', '\001', ' ', '\001', '(', '\t', '\022', '%', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', 
+' ', '\001', '(', '\013', '2', '\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', 
+'l', 'u', 'e', ':', '\002', '8', '\001', '\"', '\352', '\001', '\n', '\005', 'V', 'a', 'l', 'u', 'e', '\022', '0', '\n', '\n', 'n', 'u', 'l', 'l', 
+'_', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\016', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 
+'t', 'o', 'b', 'u', 'f', '.', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', 'H', '\000', '\022', '\026', '\n', '\014', 'n', 'u', 'm', 'b', 
+'e', 'r', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\001', 'H', '\000', '\022', '\026', '\n', '\014', 's', 't', 'r', 'i', 'n', 
+'g', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'H', '\000', '\022', '\024', '\n', '\n', 'b', 'o', 'o', 'l', '_', 'v', 
+'a', 'l', 'u', 'e', '\030', '\004', ' ', '\001', '(', '\010', 'H', '\000', '\022', '/', '\n', '\014', 's', 't', 'r', 'u', 'c', 't', '_', 'v', 'a', 
+'l', 'u', 'e', '\030', '\005', ' ', '\001', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 
+'u', 'f', '.', 'S', 't', 'r', 'u', 'c', 't', 'H', '\000', '\022', '0', '\n', '\n', 'l', 'i', 's', 't', '_', 'v', 'a', 'l', 'u', 'e', 
+'\030', '\006', ' ', '\001', '(', '\013', '2', '\032', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 
+'L', 'i', 's', 't', 'V', 'a', 'l', 'u', 'e', 'H', '\000', 'B', '\006', '\n', '\004', 'k', 'i', 'n', 'd', '\"', '3', '\n', '\t', 'L', 'i', 
+'s', 't', 'V', 'a', 'l', 'u', 'e', '\022', '&', '\n', '\006', 'v', 'a', 'l', 'u', 'e', 's', '\030', '\001', ' ', '\003', '(', '\013', '2', '\026', 
+'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'V', 'a', 'l', 'u', 'e', '*', '\033', '\n', 
+'\t', 'N', 'u', 'l', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\016', '\n', '\n', 'N', 'U', 'L', 'L', '_', 'V', 'A', 'L', 'U', 'E', '\020', 
+'\000', 'B', '\177', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', 
+'\013', 'S', 't', 'r', 'u', 'c', 't', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '/', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 
+'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 
+'n', 'o', 'w', 'n', '/', 's', 't', 'r', 'u', 'c', 't', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 
+'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 
+'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_struct_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/struct.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/struct.proto", google_protobuf_struct_proto_descriptor,
+                               sizeof(google_protobuf_struct_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Struct, initOnce) {
+  google_protobuf_struct_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Struct_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Struct, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Struct_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Struct",
+                   GPBMetadata_Google_Protobuf_Struct_methods);
+
+  GPBMetadata_Google_Protobuf_Struct_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Struct */
+
+zend_class_entry* google_protobuf_Struct_ce;
+
+static PHP_METHOD(google_protobuf_Struct, __construct) {
+  google_protobuf_struct_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Struct, getFields) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "fields");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Struct, setFields) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "fields");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Struct_phpmethods[] = {
+  PHP_ME(google_protobuf_Struct, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct, getFields, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct, setFields, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Struct_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct",
+                   google_protobuf_Struct_phpmethods);
+
+  google_protobuf_Struct_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Struct_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Struct_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Struct_ce, message_ce);
+}
+
+/* google_protobuf_Struct_FieldsEntry */
+
+zend_class_entry* google_protobuf_Struct_FieldsEntry_ce;
+
+static PHP_METHOD(google_protobuf_Struct_FieldsEntry, __construct) {
+  google_protobuf_struct_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getKey) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "key");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setKey) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "key");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Struct_FieldsEntry, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Struct_FieldsEntry, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Struct_FieldsEntry_phpmethods[] = {
+  PHP_ME(google_protobuf_Struct_FieldsEntry, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct_FieldsEntry, getKey, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct_FieldsEntry, setKey, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct_FieldsEntry, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Struct_FieldsEntry, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Struct_FieldsEntry_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Struct\\FieldsEntry",
+                   google_protobuf_Struct_FieldsEntry_phpmethods);
+
+  google_protobuf_Struct_FieldsEntry_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Struct_FieldsEntry_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Struct_FieldsEntry_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Struct_FieldsEntry_ce, message_ce);
+}
+
+/* google_protobuf_Value */
+
+zend_class_entry* google_protobuf_Value_ce;
+
+static PHP_METHOD(google_protobuf_Value, __construct) {
+  google_protobuf_struct_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Value, getNullValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "null_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setNullValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "null_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getNumberValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setNumberValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getStringValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "string_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setStringValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "string_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getBoolValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "bool_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setBoolValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "bool_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getStructValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "struct_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setStructValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "struct_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getListValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "list_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, setListValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "list_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Value, getKind) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef,
+                                              "kind");
+  const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof);
+  RETURN_STRING(field ? upb_fielddef_name(field) : "");
+}
+static zend_function_entry google_protobuf_Value_phpmethods[] = {
+  PHP_ME(google_protobuf_Value, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getNullValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setNullValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getNumberValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setNumberValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getStringValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setStringValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getBoolValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setBoolValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getStructValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setStructValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getListValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, setListValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Value, getKind, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Value_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Value",
+                   google_protobuf_Value_phpmethods);
+
+  google_protobuf_Value_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Value_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Value_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Value_ce, message_ce);
+}
+
+/* google_protobuf_ListValue */
+
+zend_class_entry* google_protobuf_ListValue_ce;
+
+static PHP_METHOD(google_protobuf_ListValue, __construct) {
+  google_protobuf_struct_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_ListValue, getValues) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "values");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_ListValue, setValues) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "values");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_ListValue_phpmethods[] = {
+  PHP_ME(google_protobuf_ListValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_ListValue, getValues, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_ListValue, setValues, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_ListValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\ListValue",
+                   google_protobuf_ListValue_phpmethods);
+
+  google_protobuf_ListValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_ListValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_ListValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_ListValue_ce, message_ce);
+}
+
+/* google_protobuf_NullValue */
+
+zend_class_entry* google_protobuf_NullValue_ce;
+
+PHP_METHOD(google_protobuf_NullValue, name) {
+  google_protobuf_struct_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue");
+  const char *name;
+  zend_long value;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) ==
+      FAILURE) {
+    return;
+  }
+  name = upb_enumdef_iton(e, value);
+  if (!name) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\NullValue has no name "
+                            "defined for value " ZEND_LONG_FMT ".",
+                            value);
+    return;
+  }
+  RETURN_STRING(name);
+}
+
+PHP_METHOD(google_protobuf_NullValue, value) {
+  google_protobuf_struct_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.NullValue");
+  char *name = NULL;
+  size_t name_len;
+  int32_t num;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name,
+                            &name_len) == FAILURE) {
+    return;
+  }
+  if (!upb_enumdef_ntoi(e, name, name_len, &num)) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\NullValue has no value "
+                            "defined for name %s.",
+                            name);
+    return;
+  }
+  RETURN_LONG(num);
+}
+
+static zend_function_entry google_protobuf_NullValue_phpmethods[] = {
+  PHP_ME(google_protobuf_NullValue, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  PHP_ME(google_protobuf_NullValue, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_NullValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\NullValue",
+                   google_protobuf_NullValue_phpmethods);
+
+  google_protobuf_NullValue_ce = zend_register_internal_class(&tmp_ce);
+  zend_declare_class_constant_long(google_protobuf_NullValue_ce, "NULL_VALUE",
+                                   strlen("NULL_VALUE"), 0);
+}
+
+/* google/protobuf/type.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Type_ce;
+
+const char google_protobuf_type_proto_descriptor [1592] = {
+'\n', '\032', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', '.', 'p', 'r', 
+'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\032', '\031', 'g', 'o', 'o', 
+'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'a', 'n', 'y', '.', 'p', 'r', 'o', 't', 'o', '\032', '$', 'g', 
+'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 
+'t', 'e', 'x', 't', '.', 'p', 'r', 'o', 't', 'o', '\"', '\327', '\001', '\n', '\004', 'T', 'y', 'p', 'e', '\022', '\014', '\n', '\004', 'n', 'a', 
+'m', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '&', '\n', '\006', 'f', 'i', 'e', 'l', 'd', 's', '\030', '\002', ' ', '\003', '(', '\013', '2', 
+'\026', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', '\022', '\016', 
+'\n', '\006', 'o', 'n', 'e', 'o', 'f', 's', '\030', '\003', ' ', '\003', '(', '\t', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', 
+'\030', '\004', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 
+'O', 'p', 't', 'i', 'o', 'n', '\022', '6', '\n', '\016', 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 't', '\030', 
+'\005', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 
+'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', '\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\006', ' ', 
+'\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 
+'t', 'a', 'x', '\"', '\325', '\005', '\n', '\005', 'F', 'i', 'e', 'l', 'd', '\022', ')', '\n', '\004', 'k', 'i', 'n', 'd', '\030', '\001', ' ', '\001', 
+'(', '\016', '2', '\033', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 
+'d', '.', 'K', 'i', 'n', 'd', '\022', '7', '\n', '\013', 'c', 'a', 'r', 'd', 'i', 'n', 'a', 'l', 'i', 't', 'y', '\030', '\002', ' ', '\001', 
+'(', '\016', '2', '\"', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 
+'d', '.', 'C', 'a', 'r', 'd', 'i', 'n', 'a', 'l', 'i', 't', 'y', '\022', '\016', '\n', '\006', 'n', 'u', 'm', 'b', 'e', 'r', '\030', '\003', 
+' ', '\001', '(', '\005', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\004', ' ', '\001', '(', '\t', '\022', '\020', '\n', '\010', 't', 'y', 'p', 
+'e', '_', 'u', 'r', 'l', '\030', '\006', ' ', '\001', '(', '\t', '\022', '\023', '\n', '\013', 'o', 'n', 'e', 'o', 'f', '_', 'i', 'n', 'd', 'e', 
+'x', '\030', '\007', ' ', '\001', '(', '\005', '\022', '\016', '\n', '\006', 'p', 'a', 'c', 'k', 'e', 'd', '\030', '\010', ' ', '\001', '(', '\010', '\022', '(', 
+'\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\t', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 
+'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\021', '\n', '\t', 'j', 's', 'o', 'n', '_', 'n', 
+'a', 'm', 'e', '\030', '\n', ' ', '\001', '(', '\t', '\022', '\025', '\n', '\r', 'd', 'e', 'f', 'a', 'u', 'l', 't', '_', 'v', 'a', 'l', 'u', 
+'e', '\030', '\013', ' ', '\001', '(', '\t', '\"', '\310', '\002', '\n', '\004', 'K', 'i', 'n', 'd', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 
+'U', 'N', 'K', 'N', 'O', 'W', 'N', '\020', '\000', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'D', 'O', 'U', 'B', 'L', 'E', '\020', 
+'\001', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'F', 'L', 'O', 'A', 'T', '\020', '\002', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', 
+'_', 'I', 'N', 'T', '6', '4', '\020', '\003', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T', '6', '4', '\020', '\004', 
+'\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'I', 'N', 'T', '3', '2', '\020', '\005', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 
+'F', 'I', 'X', 'E', 'D', '6', '4', '\020', '\006', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'F', 'I', 'X', 'E', 'D', '3', '2', 
+'\020', '\007', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'B', 'O', 'O', 'L', '\020', '\010', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', 
+'_', 'S', 'T', 'R', 'I', 'N', 'G', '\020', '\t', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'G', 'R', 'O', 'U', 'P', '\020', '\n', 
+'\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', '\020', '\013', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 
+'E', '_', 'B', 'Y', 'T', 'E', 'S', '\020', '\014', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T', '3', '2', '\020', 
+'\r', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'E', 'N', 'U', 'M', '\020', '\016', '\022', '\021', '\n', '\r', 'T', 'Y', 'P', 'E', '_', 
+'S', 'F', 'I', 'X', 'E', 'D', '3', '2', '\020', '\017', '\022', '\021', '\n', '\r', 'T', 'Y', 'P', 'E', '_', 'S', 'F', 'I', 'X', 'E', 'D', 
+'6', '4', '\020', '\020', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '3', '2', '\020', '\021', '\022', '\017', '\n', '\013', 
+'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '6', '4', '\020', '\022', '\"', 't', '\n', '\013', 'C', 'a', 'r', 'd', 'i', 'n', 'a', 'l', 
+'i', 't', 'y', '\022', '\027', '\n', '\023', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'U', 'N', 'K', 'N', 'O', 'W', 
+'N', '\020', '\000', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'O', 'P', 'T', 'I', 'O', 'N', 
+'A', 'L', '\020', '\001', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'R', 'E', 'Q', 'U', 'I', 
+'R', 'E', 'D', '\020', '\002', '\022', '\030', '\n', '\024', 'C', 'A', 'R', 'D', 'I', 'N', 'A', 'L', 'I', 'T', 'Y', '_', 'R', 'E', 'P', 'E', 
+'A', 'T', 'E', 'D', '\020', '\003', '\"', '\316', '\001', '\n', '\004', 'E', 'n', 'u', 'm', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', 
+' ', '\001', '(', '\t', '\022', '-', '\n', '\t', 'e', 'n', 'u', 'm', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\003', '(', '\013', '2', '\032', 
+'.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'V', 'a', 'l', 'u', 
+'e', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', '2', '\027', '.', 'g', 'o', 'o', 'g', 
+'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', '\022', '6', '\n', '\016', 's', 'o', 'u', 
+'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'x', 't', '\030', '\004', ' ', '\001', '(', '\013', '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 
+'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'n', 't', 'e', 'x', 't', '\022', 
+'\'', '\n', '\006', 's', 'y', 'n', 't', 'a', 'x', '\030', '\005', ' ', '\001', '(', '\016', '2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 
+'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'y', 'n', 't', 'a', 'x', '\"', 'S', '\n', '\t', 'E', 'n', 'u', 'm', 'V', 'a', 
+'l', 'u', 'e', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', '\016', '\n', '\006', 'n', 'u', 'm', 'b', 
+'e', 'r', '\030', '\002', ' ', '\001', '(', '\005', '\022', '(', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\003', '(', '\013', 
+'2', '\027', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'p', 't', 'i', 'o', 'n', 
+'\"', ';', '\n', '\006', 'O', 'p', 't', 'i', 'o', 'n', '\022', '\014', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\022', 
+'#', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\001', '(', '\013', '2', '\024', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 
+'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'A', 'n', 'y', '*', '.', '\n', '\006', 'S', 'y', 'n', 't', 'a', 'x', '\022', '\021', '\n', '\r', 
+'S', 'Y', 'N', 'T', 'A', 'X', '_', 'P', 'R', 'O', 'T', 'O', '2', '\020', '\000', '\022', '\021', '\n', '\r', 'S', 'Y', 'N', 'T', 'A', 'X', 
+'_', 'P', 'R', 'O', 'T', 'O', '3', '\020', '\001', 'B', '{', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 
+'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\t', 'T', 'y', 'p', 'e', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '-', 'g', 'o', 'o', 
+'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 
+'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 't', 'y', 'p', 'e', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 
+'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 
+'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_type_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/type.proto")) return;
+  google_protobuf_any_proto_AddDescriptor();
+  google_protobuf_source_context_proto_AddDescriptor();
+  DescriptorPool_AddDescriptor("google/protobuf/type.proto", google_protobuf_type_proto_descriptor,
+                               sizeof(google_protobuf_type_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Type, initOnce) {
+  google_protobuf_type_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Type_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Type, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Type_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Type",
+                   GPBMetadata_Google_Protobuf_Type_methods);
+
+  GPBMetadata_Google_Protobuf_Type_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Type */
+
+zend_class_entry* google_protobuf_Type_ce;
+
+static PHP_METHOD(google_protobuf_Type, __construct) {
+  google_protobuf_type_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Type, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, getFields) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "fields");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setFields) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "fields");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, getOneofs) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "oneofs");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setOneofs) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "oneofs");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, getSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, getSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Type, setSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Type_phpmethods[] = {
+  PHP_ME(google_protobuf_Type, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getFields, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setFields, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getOneofs, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setOneofs, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, getSyntax, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Type, setSyntax, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Type_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Type",
+                   google_protobuf_Type_phpmethods);
+
+  google_protobuf_Type_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Type_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Type_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Type_ce, message_ce);
+}
+
+/* google_protobuf_Field */
+
+zend_class_entry* google_protobuf_Field_ce;
+
+static PHP_METHOD(google_protobuf_Field, __construct) {
+  google_protobuf_type_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Field, getKind) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "kind");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setKind) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "kind");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getCardinality) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "cardinality");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setCardinality) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "cardinality");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getNumber) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setNumber) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "type_url");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setTypeUrl) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "type_url");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getOneofIndex) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "oneof_index");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setOneofIndex) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "oneof_index");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getPacked) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "packed");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setPacked) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "packed");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getJsonName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "json_name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setJsonName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "json_name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, getDefaultValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "default_value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Field, setDefaultValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "default_value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Field_phpmethods[] = {
+  PHP_ME(google_protobuf_Field, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getKind, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setKind, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getCardinality, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setCardinality, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getNumber, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setNumber, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setTypeUrl, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getOneofIndex, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setOneofIndex, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getPacked, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setPacked, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getJsonName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setJsonName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, getDefaultValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Field, setDefaultValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Field_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field",
+                   google_protobuf_Field_phpmethods);
+
+  google_protobuf_Field_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Field_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Field_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Field_ce, message_ce);
+}
+
+/* google_protobuf_Field_Kind */
+
+zend_class_entry* google_protobuf_Field_Kind_ce;
+
+PHP_METHOD(google_protobuf_Field_Kind, name) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Kind");
+  const char *name;
+  zend_long value;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) ==
+      FAILURE) {
+    return;
+  }
+  name = upb_enumdef_iton(e, value);
+  if (!name) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Field\\Kind has no name "
+                            "defined for value " ZEND_LONG_FMT ".",
+                            value);
+    return;
+  }
+  RETURN_STRING(name);
+}
+
+PHP_METHOD(google_protobuf_Field_Kind, value) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Kind");
+  char *name = NULL;
+  size_t name_len;
+  int32_t num;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name,
+                            &name_len) == FAILURE) {
+    return;
+  }
+  if (!upb_enumdef_ntoi(e, name, name_len, &num)) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Field\\Kind has no value "
+                            "defined for name %s.",
+                            name);
+    return;
+  }
+  RETURN_LONG(num);
+}
+
+static zend_function_entry google_protobuf_Field_Kind_phpmethods[] = {
+  PHP_ME(google_protobuf_Field_Kind, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  PHP_ME(google_protobuf_Field_Kind, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Field_Kind_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field\\Kind",
+                   google_protobuf_Field_Kind_phpmethods);
+
+  google_protobuf_Field_Kind_ce = zend_register_internal_class(&tmp_ce);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UNKNOWN",
+                                   strlen("TYPE_UNKNOWN"), 0);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_DOUBLE",
+                                   strlen("TYPE_DOUBLE"), 1);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FLOAT",
+                                   strlen("TYPE_FLOAT"), 2);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_INT64",
+                                   strlen("TYPE_INT64"), 3);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UINT64",
+                                   strlen("TYPE_UINT64"), 4);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_INT32",
+                                   strlen("TYPE_INT32"), 5);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FIXED64",
+                                   strlen("TYPE_FIXED64"), 6);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_FIXED32",
+                                   strlen("TYPE_FIXED32"), 7);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_BOOL",
+                                   strlen("TYPE_BOOL"), 8);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_STRING",
+                                   strlen("TYPE_STRING"), 9);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_GROUP",
+                                   strlen("TYPE_GROUP"), 10);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_MESSAGE",
+                                   strlen("TYPE_MESSAGE"), 11);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_BYTES",
+                                   strlen("TYPE_BYTES"), 12);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_UINT32",
+                                   strlen("TYPE_UINT32"), 13);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_ENUM",
+                                   strlen("TYPE_ENUM"), 14);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SFIXED32",
+                                   strlen("TYPE_SFIXED32"), 15);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SFIXED64",
+                                   strlen("TYPE_SFIXED64"), 16);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SINT32",
+                                   strlen("TYPE_SINT32"), 17);
+  zend_declare_class_constant_long(google_protobuf_Field_Kind_ce, "TYPE_SINT64",
+                                   strlen("TYPE_SINT64"), 18);
+}
+
+/* google_protobuf_Field_Cardinality */
+
+zend_class_entry* google_protobuf_Field_Cardinality_ce;
+
+PHP_METHOD(google_protobuf_Field_Cardinality, name) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Cardinality");
+  const char *name;
+  zend_long value;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) ==
+      FAILURE) {
+    return;
+  }
+  name = upb_enumdef_iton(e, value);
+  if (!name) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Field\\Cardinality has no name "
+                            "defined for value " ZEND_LONG_FMT ".",
+                            value);
+    return;
+  }
+  RETURN_STRING(name);
+}
+
+PHP_METHOD(google_protobuf_Field_Cardinality, value) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Field.Cardinality");
+  char *name = NULL;
+  size_t name_len;
+  int32_t num;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name,
+                            &name_len) == FAILURE) {
+    return;
+  }
+  if (!upb_enumdef_ntoi(e, name, name_len, &num)) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Field\\Cardinality has no value "
+                            "defined for name %s.",
+                            name);
+    return;
+  }
+  RETURN_LONG(num);
+}
+
+static zend_function_entry google_protobuf_Field_Cardinality_phpmethods[] = {
+  PHP_ME(google_protobuf_Field_Cardinality, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  PHP_ME(google_protobuf_Field_Cardinality, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Field_Cardinality_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Field\\Cardinality",
+                   google_protobuf_Field_Cardinality_phpmethods);
+
+  google_protobuf_Field_Cardinality_ce = zend_register_internal_class(&tmp_ce);
+  zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_UNKNOWN",
+                                   strlen("CARDINALITY_UNKNOWN"), 0);
+  zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_OPTIONAL",
+                                   strlen("CARDINALITY_OPTIONAL"), 1);
+  zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_REQUIRED",
+                                   strlen("CARDINALITY_REQUIRED"), 2);
+  zend_declare_class_constant_long(google_protobuf_Field_Cardinality_ce, "CARDINALITY_REPEATED",
+                                   strlen("CARDINALITY_REPEATED"), 3);
+}
+
+/* google_protobuf_Enum */
+
+zend_class_entry* google_protobuf_Enum_ce;
+
+static PHP_METHOD(google_protobuf_Enum, __construct) {
+  google_protobuf_type_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Enum, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, getEnumvalue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "enumvalue");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, setEnumvalue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "enumvalue");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, getSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, setSourceContext) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "source_context");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, getSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Enum, setSyntax) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "syntax");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Enum_phpmethods[] = {
+  PHP_ME(google_protobuf_Enum, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, getEnumvalue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, setEnumvalue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, setOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, getSyntax, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Enum, setSyntax, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Enum_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Enum",
+                   google_protobuf_Enum_phpmethods);
+
+  google_protobuf_Enum_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Enum_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Enum_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Enum_ce, message_ce);
+}
+
+/* google_protobuf_EnumValue */
+
+zend_class_entry* google_protobuf_EnumValue_ce;
+
+static PHP_METHOD(google_protobuf_EnumValue, __construct) {
+  google_protobuf_type_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, getNumber) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, setNumber) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "number");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, getOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_EnumValue, setOptions) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "options");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_EnumValue_phpmethods[] = {
+  PHP_ME(google_protobuf_EnumValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, getNumber, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, setNumber, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, getOptions, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_EnumValue, setOptions, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_EnumValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\EnumValue",
+                   google_protobuf_EnumValue_phpmethods);
+
+  google_protobuf_EnumValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_EnumValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_EnumValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_EnumValue_ce, message_ce);
+}
+
+/* google_protobuf_Option */
+
+zend_class_entry* google_protobuf_Option_ce;
+
+static PHP_METHOD(google_protobuf_Option, __construct) {
+  google_protobuf_type_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Option, getName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Option, setName) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "name");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Option, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Option, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Option_phpmethods[] = {
+  PHP_ME(google_protobuf_Option, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Option, getName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Option, setName, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Option, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Option, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Option_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Option",
+                   google_protobuf_Option_phpmethods);
+
+  google_protobuf_Option_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Option_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Option_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Option_ce, message_ce);
+}
+
+/* google_protobuf_Syntax */
+
+zend_class_entry* google_protobuf_Syntax_ce;
+
+PHP_METHOD(google_protobuf_Syntax, name) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Syntax");
+  const char *name;
+  zend_long value;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) ==
+      FAILURE) {
+    return;
+  }
+  name = upb_enumdef_iton(e, value);
+  if (!name) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Syntax has no name "
+                            "defined for value " ZEND_LONG_FMT ".",
+                            value);
+    return;
+  }
+  RETURN_STRING(name);
+}
+
+PHP_METHOD(google_protobuf_Syntax, value) {
+  google_protobuf_type_proto_AddDescriptor();
+  const upb_symtab *symtab = DescriptorPool_GetSymbolTable();
+  const upb_enumdef *e = upb_symtab_lookupenum(symtab, "google.protobuf.Syntax");
+  char *name = NULL;
+  size_t name_len;
+  int32_t num;
+  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name,
+                            &name_len) == FAILURE) {
+    return;
+  }
+  if (!upb_enumdef_ntoi(e, name, name_len, &num)) {
+    zend_throw_exception_ex(NULL, 0,
+                            "Google\\Protobuf\\Syntax has no value "
+                            "defined for name %s.",
+                            name);
+    return;
+  }
+  RETURN_LONG(num);
+}
+
+static zend_function_entry google_protobuf_Syntax_phpmethods[] = {
+  PHP_ME(google_protobuf_Syntax, name, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  PHP_ME(google_protobuf_Syntax, value, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Syntax_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Syntax",
+                   google_protobuf_Syntax_phpmethods);
+
+  google_protobuf_Syntax_ce = zend_register_internal_class(&tmp_ce);
+  zend_declare_class_constant_long(google_protobuf_Syntax_ce, "SYNTAX_PROTO2",
+                                   strlen("SYNTAX_PROTO2"), 0);
+  zend_declare_class_constant_long(google_protobuf_Syntax_ce, "SYNTAX_PROTO3",
+                                   strlen("SYNTAX_PROTO3"), 1);
+}
+
+/* google/protobuf/timestamp.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Timestamp_ce;
+
+const char google_protobuf_timestamp_proto_descriptor [239] = {
+'\n', '\037', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 
+'m', 'p', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 
+'\"', '+', '\n', '\t', 'T', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', '\022', '\017', '\n', '\007', 's', 'e', 'c', 'o', 'n', 'd', 's', '\030', 
+'\001', ' ', '\001', '(', '\003', '\022', '\r', '\n', '\005', 'n', 'a', 'n', 'o', 's', '\030', '\002', ' ', '\001', '(', '\005', 'B', '\205', '\001', '\n', '\023', 
+'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\016', 'T', 'i', 'm', 'e', 
+'s', 't', 'a', 'm', 'p', 'P', 'r', 'o', 't', 'o', 'P', '\001', 'Z', '2', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 
+'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 
+'w', 'n', '/', 't', 'i', 'm', 'e', 's', 't', 'a', 'm', 'p', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', 
+'\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 
+'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_timestamp_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/timestamp.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/timestamp.proto", google_protobuf_timestamp_proto_descriptor,
+                               sizeof(google_protobuf_timestamp_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Timestamp, initOnce) {
+  google_protobuf_timestamp_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Timestamp_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Timestamp, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Timestamp_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Timestamp",
+                   GPBMetadata_Google_Protobuf_Timestamp_methods);
+
+  GPBMetadata_Google_Protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_Timestamp */
+
+zend_class_entry* google_protobuf_Timestamp_ce;
+
+static PHP_METHOD(google_protobuf_Timestamp, __construct) {
+  google_protobuf_timestamp_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Timestamp, getSeconds) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "seconds");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Timestamp, setSeconds) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "seconds");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Timestamp, getNanos) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "nanos");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Timestamp, setNanos) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "nanos");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Timestamp_phpmethods[] = {
+  PHP_ME(google_protobuf_Timestamp, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, getSeconds, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, setSeconds, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, getNanos, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, setNanos, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, fromDateTime, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Timestamp, toDateTime, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Timestamp_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Timestamp",
+                   google_protobuf_Timestamp_phpmethods);
+
+  google_protobuf_Timestamp_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Timestamp_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Timestamp_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Timestamp_ce, message_ce);
+}
+
+/* google/protobuf/wrappers.proto */
+
+zend_class_entry* GPBMetadata_Google_Protobuf_Wrappers_ce;
+
+const char google_protobuf_wrappers_proto_descriptor [455] = {
+'\n', '\036', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'w', 'r', 'a', 'p', 'p', 'e', 'r', 
+'s', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '\"', 
+'\034', '\n', '\013', 'D', 'o', 'u', 'b', 'l', 'e', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', 
+' ', '\001', '(', '\001', '\"', '\033', '\n', '\n', 'F', 'l', 'o', 'a', 't', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 
+'u', 'e', '\030', '\001', ' ', '\001', '(', '\002', '\"', '\033', '\n', '\n', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', 
+'\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\003', '\"', '\034', '\n', '\013', 'U', 'I', 'n', 't', '6', '4', 'V', 'a', 'l', 
+'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\004', '\"', '\033', '\n', '\n', 'I', 'n', 't', '3', 
+'2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\005', '\"', '\034', '\n', '\013', 
+'U', 'I', 'n', 't', '3', '2', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', 
+'\r', '\"', '\032', '\n', '\t', 'B', 'o', 'o', 'l', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', 
+' ', '\001', '(', '\010', '\"', '\034', '\n', '\013', 'S', 't', 'r', 'i', 'n', 'g', 'V', 'a', 'l', 'u', 'e', '\022', '\r', '\n', '\005', 'v', 'a', 
+'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\t', '\"', '\033', '\n', '\n', 'B', 'y', 't', 'e', 's', 'V', 'a', 'l', 'u', 'e', '\022', '\r', 
+'\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\001', ' ', '\001', '(', '\014', 'B', '\203', '\001', '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 
+'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\r', 'W', 'r', 'a', 'p', 'p', 'e', 'r', 's', 'P', 'r', 'o', 
+'t', 'o', 'P', '\001', 'Z', '1', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 
+'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's', '/', 'k', 'n', 'o', 'w', 'n', '/', 'w', 'r', 'a', 'p', 'p', 
+'e', 'r', 's', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\036', 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 
+'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'W', 'e', 'l', 'l', 'K', 'n', 'o', 'w', 'n', 'T', 'y', 'p', 'e', 's', 'b', '\006', 'p', 
+'r', 'o', 't', 'o', '3', 
+};
+
+static void google_protobuf_wrappers_proto_AddDescriptor() {
+  if (DescriptorPool_HasFile("google/protobuf/wrappers.proto")) return;
+  DescriptorPool_AddDescriptor("google/protobuf/wrappers.proto", google_protobuf_wrappers_proto_descriptor,
+                               sizeof(google_protobuf_wrappers_proto_descriptor));
+}
+
+static PHP_METHOD(GPBMetadata_Google_Protobuf_Wrappers, initOnce) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+}
+
+static zend_function_entry GPBMetadata_Google_Protobuf_Wrappers_methods[] = {
+  PHP_ME(GPBMetadata_Google_Protobuf_Wrappers, initOnce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+  ZEND_FE_END
+};
+
+static void GPBMetadata_Google_Protobuf_Wrappers_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "GPBMetadata\\Google\\Protobuf\\Wrappers",
+                   GPBMetadata_Google_Protobuf_Wrappers_methods);
+
+  GPBMetadata_Google_Protobuf_Wrappers_ce = zend_register_internal_class(&tmp_ce);
+}
+
+/* google_protobuf_DoubleValue */
+
+zend_class_entry* google_protobuf_DoubleValue_ce;
+
+static PHP_METHOD(google_protobuf_DoubleValue, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_DoubleValue, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_DoubleValue, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_DoubleValue_phpmethods[] = {
+  PHP_ME(google_protobuf_DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_DoubleValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\DoubleValue",
+                   google_protobuf_DoubleValue_phpmethods);
+
+  google_protobuf_DoubleValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_DoubleValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_DoubleValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_DoubleValue_ce, message_ce);
+}
+
+/* google_protobuf_FloatValue */
+
+zend_class_entry* google_protobuf_FloatValue_ce;
+
+static PHP_METHOD(google_protobuf_FloatValue, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_FloatValue, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_FloatValue, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_FloatValue_phpmethods[] = {
+  PHP_ME(google_protobuf_FloatValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_FloatValue, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_FloatValue, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_FloatValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\FloatValue",
+                   google_protobuf_FloatValue_phpmethods);
+
+  google_protobuf_FloatValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_FloatValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_FloatValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_FloatValue_ce, message_ce);
+}
+
+/* google_protobuf_Int64Value */
+
+zend_class_entry* google_protobuf_Int64Value_ce;
+
+static PHP_METHOD(google_protobuf_Int64Value, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Int64Value, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Int64Value, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Int64Value_phpmethods[] = {
+  PHP_ME(google_protobuf_Int64Value, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Int64Value, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Int64Value, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Int64Value_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int64Value",
+                   google_protobuf_Int64Value_phpmethods);
+
+  google_protobuf_Int64Value_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Int64Value_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Int64Value_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Int64Value_ce, message_ce);
+}
+
+/* google_protobuf_UInt64Value */
+
+zend_class_entry* google_protobuf_UInt64Value_ce;
+
+static PHP_METHOD(google_protobuf_UInt64Value, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_UInt64Value, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_UInt64Value, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_UInt64Value_phpmethods[] = {
+  PHP_ME(google_protobuf_UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_UInt64Value_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt64Value",
+                   google_protobuf_UInt64Value_phpmethods);
+
+  google_protobuf_UInt64Value_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_UInt64Value_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_UInt64Value_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_UInt64Value_ce, message_ce);
+}
+
+/* google_protobuf_Int32Value */
+
+zend_class_entry* google_protobuf_Int32Value_ce;
+
+static PHP_METHOD(google_protobuf_Int32Value, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_Int32Value, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_Int32Value, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_Int32Value_phpmethods[] = {
+  PHP_ME(google_protobuf_Int32Value, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Int32Value, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_Int32Value, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_Int32Value_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Int32Value",
+                   google_protobuf_Int32Value_phpmethods);
+
+  google_protobuf_Int32Value_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_Int32Value_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_Int32Value_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_Int32Value_ce, message_ce);
+}
+
+/* google_protobuf_UInt32Value */
+
+zend_class_entry* google_protobuf_UInt32Value_ce;
+
+static PHP_METHOD(google_protobuf_UInt32Value, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_UInt32Value, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_UInt32Value, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_UInt32Value_phpmethods[] = {
+  PHP_ME(google_protobuf_UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_UInt32Value_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\UInt32Value",
+                   google_protobuf_UInt32Value_phpmethods);
+
+  google_protobuf_UInt32Value_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_UInt32Value_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_UInt32Value_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_UInt32Value_ce, message_ce);
+}
+
+/* google_protobuf_BoolValue */
+
+zend_class_entry* google_protobuf_BoolValue_ce;
+
+static PHP_METHOD(google_protobuf_BoolValue, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_BoolValue, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_BoolValue, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_BoolValue_phpmethods[] = {
+  PHP_ME(google_protobuf_BoolValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_BoolValue, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_BoolValue, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_BoolValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BoolValue",
+                   google_protobuf_BoolValue_phpmethods);
+
+  google_protobuf_BoolValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_BoolValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_BoolValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_BoolValue_ce, message_ce);
+}
+
+/* google_protobuf_StringValue */
+
+zend_class_entry* google_protobuf_StringValue_ce;
+
+static PHP_METHOD(google_protobuf_StringValue, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_StringValue, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_StringValue, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_StringValue_phpmethods[] = {
+  PHP_ME(google_protobuf_StringValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_StringValue, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_StringValue, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_StringValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\StringValue",
+                   google_protobuf_StringValue_phpmethods);
+
+  google_protobuf_StringValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_StringValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_StringValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_StringValue_ce, message_ce);
+}
+
+/* google_protobuf_BytesValue */
+
+zend_class_entry* google_protobuf_BytesValue_ce;
+
+static PHP_METHOD(google_protobuf_BytesValue, __construct) {
+  google_protobuf_wrappers_proto_AddDescriptor();
+  zim_Message___construct(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+static PHP_METHOD(google_protobuf_BytesValue, getValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval ret;
+  Message_get(intern, f, &ret);
+  RETURN_ZVAL(&ret, 1, 0);
+}
+
+static PHP_METHOD(google_protobuf_BytesValue, setValue) {
+  Message* intern = (Message*)Z_OBJ_P(getThis());
+  const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,
+                                           "value");
+  zval *val;
+  if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val)
+      == FAILURE) {
+    return;
+  }
+  Message_set(intern, f, val);
+  RETURN_ZVAL(getThis(), 1, 0);
+}
+
+static zend_function_entry google_protobuf_BytesValue_phpmethods[] = {
+  PHP_ME(google_protobuf_BytesValue, __construct, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_BytesValue, getValue, NULL, ZEND_ACC_PUBLIC)
+  PHP_ME(google_protobuf_BytesValue, setValue, NULL, ZEND_ACC_PUBLIC)
+  ZEND_FE_END
+};
+
+static void google_protobuf_BytesValue_ModuleInit() {
+  zend_class_entry tmp_ce;
+
+  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\BytesValue",
+                   google_protobuf_BytesValue_phpmethods);
+
+  google_protobuf_BytesValue_ce = zend_register_internal_class(&tmp_ce);
+  google_protobuf_BytesValue_ce->ce_flags |= ZEND_ACC_FINAL;
+  google_protobuf_BytesValue_ce->create_object = Message_create;
+  zend_do_inheritance(google_protobuf_BytesValue_ce, message_ce);
+}
+
+static void WellKnownTypes_ModuleInit() {
+  GPBMetadata_Google_Protobuf_Any_ModuleInit();
+  google_protobuf_Any_ModuleInit();
+  GPBMetadata_Google_Protobuf_Api_ModuleInit();
+  google_protobuf_Api_ModuleInit();
+  google_protobuf_Method_ModuleInit();
+  google_protobuf_Mixin_ModuleInit();
+  GPBMetadata_Google_Protobuf_Duration_ModuleInit();
+  google_protobuf_Duration_ModuleInit();
+  GPBMetadata_Google_Protobuf_GPBEmpty_ModuleInit();
+  google_protobuf_Empty_ModuleInit();
+  GPBMetadata_Google_Protobuf_FieldMask_ModuleInit();
+  google_protobuf_FieldMask_ModuleInit();
+  GPBMetadata_Google_Protobuf_SourceContext_ModuleInit();
+  google_protobuf_SourceContext_ModuleInit();
+  GPBMetadata_Google_Protobuf_Struct_ModuleInit();
+  google_protobuf_Struct_ModuleInit();
+  google_protobuf_Struct_FieldsEntry_ModuleInit();
+  google_protobuf_Value_ModuleInit();
+  google_protobuf_ListValue_ModuleInit();
+  google_protobuf_NullValue_ModuleInit();
+  GPBMetadata_Google_Protobuf_Type_ModuleInit();
+  google_protobuf_Type_ModuleInit();
+  google_protobuf_Field_ModuleInit();
+  google_protobuf_Field_Kind_ModuleInit();
+  google_protobuf_Field_Cardinality_ModuleInit();
+  google_protobuf_Enum_ModuleInit();
+  google_protobuf_EnumValue_ModuleInit();
+  google_protobuf_Option_ModuleInit();
+  google_protobuf_Syntax_ModuleInit();
+  GPBMetadata_Google_Protobuf_Timestamp_ModuleInit();
+  google_protobuf_Timestamp_ModuleInit();
+  GPBMetadata_Google_Protobuf_Wrappers_ModuleInit();
+  google_protobuf_DoubleValue_ModuleInit();
+  google_protobuf_FloatValue_ModuleInit();
+  google_protobuf_Int64Value_ModuleInit();
+  google_protobuf_UInt64Value_ModuleInit();
+  google_protobuf_Int32Value_ModuleInit();
+  google_protobuf_UInt32Value_ModuleInit();
+  google_protobuf_BoolValue_ModuleInit();
+  google_protobuf_StringValue_ModuleInit();
+  google_protobuf_BytesValue_ModuleInit();
+}

+ 13 - 0
php/generate_descriptor_protos.sh

@@ -3,6 +3,8 @@
 # Run this script to regenerate descriptor protos after the protocol compiler
 # changes.
 
+set -e
+
 if test ! -e src/google/protobuf/stubs/common.h; then
   cat >&2 << __EOF__
 Could not find source code.  Make sure you are running this script from the
@@ -13,4 +15,15 @@ fi
 
 pushd src
 ./protoc --php_out=internal:../php/src google/protobuf/descriptor.proto
+./protoc --php_out=internal_generate_c_wkt:../php/src \
+  google/protobuf/any.proto \
+  google/protobuf/api.proto \
+  google/protobuf/duration.proto \
+  google/protobuf/empty.proto \
+  google/protobuf/field_mask.proto \
+  google/protobuf/source_context.proto \
+  google/protobuf/struct.proto \
+  google/protobuf/type.proto \
+  google/protobuf/timestamp.proto \
+  google/protobuf/wrappers.proto
 popd

+ 6 - 0
php/prepare_c_extension.sh

@@ -0,0 +1,6 @@
+
+# wyhash has to live in the base third_party directory.
+# We copy it into the ext/google/protobuf directory for the build
+# (and for the release to PECL).
+mkdir -p ../ext/google/protobuf/third_party/wyhash
+cp ../../third_party/wyhash/* ../ext/google/protobuf/third_party/wyhash

+ 2 - 8
php/src/GPBMetadata/Google/Protobuf/Any.php

@@ -15,14 +15,8 @@ class Any
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f" .
-            "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479" .
-            "70655f75726c180120012809120d0a0576616c756518022001280c426f0a" .
-            "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f" .
-            "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566" .
-            "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f" .
-            "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0ad4010a19676f6f676c652f70726f746f6275662f616e792e70726f746f120f676f6f676c652e70726f746f62756622260a03416e7912100a08747970655f75726c180120012809120d0a0576616c756518022001280c42760a13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f50015a2c676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f616e797062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 2 - 25
php/src/GPBMetadata/Google/Protobuf/Api.php

@@ -17,31 +17,8 @@ class Api
         \GPBMetadata\Google\Protobuf\SourceContext::initOnce();
         \GPBMetadata\Google\Protobuf\Type::initOnce();
         $pool->internalAddGeneratedFile(hex2bin(
-            "0ac8050a19676f6f676c652f70726f746f6275662f6170692e70726f746f" .
-            "120f676f6f676c652e70726f746f6275661a1a676f6f676c652f70726f74" .
-            "6f6275662f747970652e70726f746f2281020a03417069120c0a046e616d" .
-            "6518012001280912280a076d6574686f647318022003280b32172e676f6f" .
-            "676c652e70726f746f6275662e4d6574686f6412280a076f7074696f6e73" .
-            "18032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" .
-            "6e120f0a0776657273696f6e18042001280912360a0e736f757263655f63" .
-            "6f6e7465787418052001280b321e2e676f6f676c652e70726f746f627566" .
-            "2e536f75726365436f6e7465787412260a066d6978696e7318062003280b" .
-            "32162e676f6f676c652e70726f746f6275662e4d6978696e12270a067379" .
-            "6e74617818072001280e32172e676f6f676c652e70726f746f6275662e53" .
-            "796e74617822d5010a064d6574686f64120c0a046e616d65180120012809" .
-            "12180a10726571756573745f747970655f75726c18022001280912190a11" .
-            "726571756573745f73747265616d696e6718032001280812190a11726573" .
-            "706f6e73655f747970655f75726c180420012809121a0a12726573706f6e" .
-            "73655f73747265616d696e6718052001280812280a076f7074696f6e7318" .
-            "062003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e" .
-            "12270a0673796e74617818072001280e32172e676f6f676c652e70726f74" .
-            "6f6275662e53796e74617822230a054d6978696e120c0a046e616d651801" .
-            "20012809120c0a04726f6f7418022001280942750a13636f6d2e676f6f67" .
-            "6c652e70726f746f627566420841706950726f746f50015a2b676f6f676c" .
-            "652e676f6c616e672e6f72672f67656e70726f746f2f70726f746f627566" .
-            "2f6170693b617069a20203475042aa021e476f6f676c652e50726f746f62" .
-            "75662e57656c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0ac9050a19676f6f676c652f70726f746f6275662f6170692e70726f746f120f676f6f676c652e70726f746f6275661a1a676f6f676c652f70726f746f6275662f747970652e70726f746f2281020a03417069120c0a046e616d6518012001280912280a076d6574686f647318022003280b32172e676f6f676c652e70726f746f6275662e4d6574686f6412280a076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e120f0a0776657273696f6e18042001280912360a0e736f757263655f636f6e7465787418052001280b321e2e676f6f676c652e70726f746f6275662e536f75726365436f6e7465787412260a066d6978696e7318062003280b32162e676f6f676c652e70726f746f6275662e4d6978696e12270a0673796e74617818072001280e32172e676f6f676c652e70726f746f6275662e53796e74617822d5010a064d6574686f64120c0a046e616d6518012001280912180a10726571756573745f747970655f75726c18022001280912190a11726571756573745f73747265616d696e6718032001280812190a11726573706f6e73655f747970655f75726c180420012809121a0a12726573706f6e73655f73747265616d696e6718052001280812280a076f7074696f6e7318062003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12270a0673796e74617818072001280e32172e676f6f676c652e70726f746f6275662e53796e74617822230a054d6978696e120c0a046e616d65180120012809120c0a04726f6f7418022001280942760a13636f6d2e676f6f676c652e70726f746f627566420841706950726f746f50015a2c676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6170697062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 2 - 9
php/src/GPBMetadata/Google/Protobuf/Duration.php

@@ -15,15 +15,8 @@ class Duration
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e" .
-            "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261" .
-            "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73" .
-            "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642" .
-            "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67" .
-            "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e" .
-            "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765" .
-            "6c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0aeb010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e70726f746f120f676f6f676c652e70726f746f627566222a0a084475726174696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f731802200128054283010a13636f6d2e676f6f676c652e70726f746f627566420d4475726174696f6e50726f746f50015a31676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6475726174696f6e7062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 2 - 9
php/src/GPBMetadata/Google/Protobuf/FieldMask.php

@@ -15,15 +15,8 @@ class FieldMask
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173" .
-            "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669" .
-            "656c644d61736b120d0a0570617468731801200328094289010a13636f6d" .
-            "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f" .
-            "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f" .
-            "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d" .
-            "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765" .
-            "6c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0adf010a20676f6f676c652f70726f746f6275662f6669656c645f6d61736b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669656c644d61736b120d0a0570617468731801200328094285010a13636f6d2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f746f50015a32676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f6669656c646d61736b7062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 2 - 8
php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php

@@ -15,14 +15,8 @@ class GPBEmpty
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" .
-            "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" .
-            "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" .
-            "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" .
-            "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" .
-            "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" .
-            "70726f746f33"
-        ));
+            "0abe010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f746f120f676f6f676c652e70726f746f62756622070a05456d707479427d0a13636f6d2e676f6f676c652e70726f746f627566420a456d70747950726f746f50015a2e676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f656d7074797062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 2 - 10
php/src/GPBMetadata/Google/Protobuf/SourceContext.php

@@ -15,16 +15,8 @@ class SourceContext
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f" .
-            "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222" .
-            "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801" .
-            "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212" .
-            "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67" .
-            "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f" .
-            "757263655f636f6e746578743b736f757263655f636f6e74657874a20203" .
-            "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" .
-            "6e5479706573620670726f746f33"
-        ));
+            "0af0010a24676f6f676c652f70726f746f6275662f736f757263655f636f6e746578742e70726f746f120f676f6f676c652e70726f746f62756622220a0d536f75726365436f6e7465787412110a0966696c655f6e616d65180120012809428a010a13636f6d2e676f6f676c652e70726f746f6275664212536f75726365436f6e7465787450726f746f50015a36676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f736f75726365636f6e746578747062a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 1 - 1
php/src/GPBMetadata/Google/Protobuf/Struct.php

@@ -15,7 +15,7 @@ class Struct
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e70726f746f120f676f6f676c652e70726f746f6275662284010a0653747275637412330a066669656c647318012003280b32232e676f6f676c652e70726f746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669656c6473456e747279120b0a036b657918012001280912250a0576616c756518022001280b32162e676f6f676c652e70726f746f6275662e56616c75653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c56616c7565480012160a0c6e756d6265725f76616c7565180220012801480012160a0c737472696e675f76616c7565180320012809480012140a0a626f6f6c5f76616c75651804200128084800122f0a0c7374727563745f76616c756518052001280b32172e676f6f676c652e70726f746f6275662e537472756374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f676c652e70726f746f6275662e4c69737456616c7565480042060a046b696e6422330a094c69737456616c756512260a0676616c75657318012003280b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a13636f6d2e676f6f676c652e70726f746f627566420b53747275637450726f746f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065732f7374727563743b7374727563747062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+            "0afe040a1c676f6f676c652f70726f746f6275662f7374727563742e70726f746f120f676f6f676c652e70726f746f6275662284010a0653747275637412330a066669656c647318012003280b32232e676f6f676c652e70726f746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669656c6473456e747279120b0a036b657918012001280912250a0576616c756518022001280b32162e676f6f676c652e70726f746f6275662e56616c75653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c56616c7565480012160a0c6e756d6265725f76616c7565180220012801480012160a0c737472696e675f76616c7565180320012809480012140a0a626f6f6c5f76616c75651804200128084800122f0a0c7374727563745f76616c756518052001280b32172e676f6f676c652e70726f746f6275662e537472756374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f676c652e70726f746f6275662e4c69737456616c7565480042060a046b696e6422330a094c69737456616c756512260a0676616c75657318012003280b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e756c6c56616c7565120e0a0a4e554c4c5f56414c55451000427f0a13636f6d2e676f6f676c652e70726f746f627566420b53747275637450726f746f50015a2f676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f7374727563747062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
         ), true);
 
         static::$is_initialized = true;

+ 2 - 9
php/src/GPBMetadata/Google/Protobuf/Timestamp.php

@@ -15,15 +15,8 @@ class Timestamp
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70" .
-            "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d" .
-            "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e" .
-            "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275" .
-            "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f" .
-            "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573" .
-            "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275" .
-            "662e57656c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0aef010a1f676f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d657374616d70120f0a077365636f6e6473180120012803120d0a056e616e6f731802200128054285010a13636f6d2e676f6f676c652e70726f746f627566420e54696d657374616d7050726f746f50015a32676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f74696d657374616d707062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

文件差異過大導致無法顯示
+ 0 - 54
php/src/GPBMetadata/Google/Protobuf/Type.php


+ 2 - 16
php/src/GPBMetadata/Google/Protobuf/Wrappers.php

@@ -15,22 +15,8 @@ class Wrappers
           return;
         }
         $pool->internalAddGeneratedFile(hex2bin(
-            "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e" .
-            "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562" .
-            "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61" .
-            "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634" .
-            "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634" .
-            "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256" .
-            "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256" .
-            "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c" .
-            "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c" .
-            "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75" .
-            "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65" .
-            "2e70726f746f627566420d577261707065727350726f746f50015a2a6769" .
-            "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065" .
-            "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50" .
-            "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
-        ));
+            "0ac7030a1e676f6f676c652f70726f746f6275662f77726170706572732e70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f75626c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f617456616c7565120d0a0576616c7565180120012802221b0a0a496e74363456616c7565120d0a0576616c7565180120012803221c0a0b55496e74363456616c7565120d0a0576616c7565180120012804221b0a0a496e74333256616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c7565120d0a0576616c7565180120012809221b0a0a427974657356616c7565120d0a0576616c756518012001280c4283010a13636f6d2e676f6f676c652e70726f746f627566420d577261707065727350726f746f50015a31676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f77726170706572737062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+        ), true);
 
         static::$is_initialized = true;
     }

+ 16 - 85
php/src/Google/Protobuf/Any.php

@@ -5,7 +5,6 @@
 namespace Google\Protobuf;
 
 use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\Message;
 use Google\Protobuf\Internal\RepeatedField;
 use Google\Protobuf\Internal\GPBUtil;
 
@@ -39,10 +38,13 @@ use Google\Protobuf\Internal\GPBUtil;
  *       ...
  *  Example 4: Pack and unpack a message in Go
  *      foo := &pb.Foo{...}
- *      any, err := ptypes.MarshalAny(foo)
+ *      any, err := anypb.New(foo)
+ *      if err != nil {
+ *        ...
+ *      }
  *      ...
  *      foo := &pb.Foo{}
- *      if err := ptypes.UnmarshalAny(any, foo); err != nil {
+ *      if err := any.UnmarshalTo(foo); err != nil {
  *        ...
  *      }
  * The pack methods provided by protobuf library will by default use
@@ -76,11 +78,12 @@ use Google\Protobuf\Internal\GPBUtil;
  *
  * Generated from protobuf message <code>google.protobuf.Any</code>
  */
-class Any extends \Google\Protobuf\Internal\Message
+class Any extends \Google\Protobuf\Internal\AnyBase
 {
     /**
      * A URL/resource name that uniquely identifies the type of the serialized
-     * protocol buffer message. The last segment of the URL's path must represent
+     * protocol buffer message. This string must contain at least
+     * one "/" character. The last segment of the URL's path must represent
      * the fully qualified name of the type (as in
      * `path/google.protobuf.Duration`). The name should be in a canonical form
      * (e.g., leading "." is not accepted).
@@ -104,15 +107,13 @@ class Any extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string type_url = 1;</code>
      */
-    private $type_url = '';
+    protected $type_url = '';
     /**
      * Must be a valid serialized protocol buffer of the above specified type.
      *
      * Generated from protobuf field <code>bytes value = 2;</code>
      */
-    private $value = '';
-
-    const TYPE_URL_PREFIX = 'type.googleapis.com/';
+    protected $value = '';
 
     /**
      * Constructor.
@@ -122,7 +123,8 @@ class Any extends \Google\Protobuf\Internal\Message
      *
      *     @type string $type_url
      *           A URL/resource name that uniquely identifies the type of the serialized
-     *           protocol buffer message. The last segment of the URL's path must represent
+     *           protocol buffer message. This string must contain at least
+     *           one "/" character. The last segment of the URL's path must represent
      *           the fully qualified name of the type (as in
      *           `path/google.protobuf.Duration`). The name should be in a canonical form
      *           (e.g., leading "." is not accepted).
@@ -154,7 +156,8 @@ class Any extends \Google\Protobuf\Internal\Message
 
     /**
      * A URL/resource name that uniquely identifies the type of the serialized
-     * protocol buffer message. The last segment of the URL's path must represent
+     * protocol buffer message. This string must contain at least
+     * one "/" character. The last segment of the URL's path must represent
      * the fully qualified name of the type (as in
      * `path/google.protobuf.Duration`). The name should be in a canonical form
      * (e.g., leading "." is not accepted).
@@ -186,7 +189,8 @@ class Any extends \Google\Protobuf\Internal\Message
 
     /**
      * A URL/resource name that uniquely identifies the type of the serialized
-     * protocol buffer message. The last segment of the URL's path must represent
+     * protocol buffer message. This string must contain at least
+     * one "/" character. The last segment of the URL's path must represent
      * the fully qualified name of the type (as in
      * `path/google.protobuf.Duration`). The name should be in a canonical form
      * (e.g., leading "." is not accepted).
@@ -246,78 +250,5 @@ class Any extends \Google\Protobuf\Internal\Message
         return $this;
     }
 
-    /**
-     * This method will try to resolve the type_url in Any message to get the
-     * targeted message type. If failed, an error will be thrown. Otherwise,
-     * the method will create a message of the targeted type and fill it with
-     * the decoded value in Any.
-     * @return Message unpacked message
-     * @throws \Exception Type url needs to be type.googleapis.com/fully-qualified.
-     * @throws \Exception Class hasn't been added to descriptor pool.
-     * @throws \Exception cannot decode data in value field.
-     */
-    public function unpack()
-    {
-        // Get fully qualified name from type url.
-        $url_prifix_len = strlen(GPBUtil::TYPE_URL_PREFIX);
-        if (substr($this->type_url, 0, $url_prifix_len) !=
-                GPBUtil::TYPE_URL_PREFIX) {
-            throw new \Exception(
-                "Type url needs to be type.googleapis.com/fully-qulified");
-        }
-        $fully_qualifed_name =
-            substr($this->type_url, $url_prifix_len);
-
-        // Create message according to fully qualified name.
-        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
-        $desc = $pool->getDescriptorByProtoName($fully_qualifed_name);
-        if (is_null($desc)) {
-            throw new \Exception("Class ".$fully_qualifed_name
-                                     ." hasn't been added to descriptor pool");
-        }
-        $klass = $desc->getClass();
-        $msg = new $klass();
-
-        // Merge data into message.
-        $msg->mergeFromString($this->value);
-        return $msg;
-    }
-
-    /**
-     * The type_url will be created according to the given message’s type and
-     * the value is encoded data from the given message..
-     * @param message: A proto message.
-     */
-    public function pack($msg)
-    {
-        if (!$msg instanceof Message) {
-            trigger_error("Given parameter is not a message instance.",
-                          E_USER_ERROR);
-            return;
-        }
-
-        // Set value using serialized message.
-        $this->value = $msg->serializeToString();
-
-        // Set type url.
-        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
-        $desc = $pool->getDescriptorByClassName(get_class($msg));
-        $fully_qualifed_name = $desc->getFullName();
-        $this->type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name;
-    }
-
-    /**
-     * This method returns whether the type_url in any_message is corresponded
-     * to the given class.
-     * @param klass: The fully qualified PHP class name of a proto message type.
-     */
-    public function is($klass)
-    {
-        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
-        $desc = $pool->getDescriptorByClassName($klass);
-        $fully_qualifed_name = $desc->getFullName();
-        $type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualifed_name;
-        return $this->type_url === $type_url;
-    }
 }
 

+ 15 - 5
php/src/Google/Protobuf/Api.php

@@ -28,7 +28,7 @@ class Api extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string name = 1;</code>
      */
-    private $name = '';
+    protected $name = '';
     /**
      * The methods of this interface, in unspecified order.
      *
@@ -62,14 +62,14 @@ class Api extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string version = 4;</code>
      */
-    private $version = '';
+    protected $version = '';
     /**
      * Source context for the protocol buffer service represented by this
      * message.
      *
      * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
      */
-    private $source_context = null;
+    protected $source_context = null;
     /**
      * Included interfaces. See [Mixin][].
      *
@@ -81,7 +81,7 @@ class Api extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
      */
-    private $syntax = 0;
+    protected $syntax = 0;
 
     /**
      * Constructor.
@@ -275,7 +275,17 @@ class Api extends \Google\Protobuf\Internal\Message
      */
     public function getSourceContext()
     {
-        return $this->source_context;
+        return isset($this->source_context) ? $this->source_context : null;
+    }
+
+    public function hasSourceContext()
+    {
+        return isset($this->source_context);
+    }
+
+    public function clearSourceContext()
+    {
+        unset($this->source_context);
     }
 
     /**

+ 1 - 1
php/src/Google/Protobuf/BoolValue.php

@@ -21,7 +21,7 @@ class BoolValue extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>bool value = 1;</code>
      */
-    private $value = false;
+    protected $value = false;
 
     /**
      * Constructor.

+ 1 - 1
php/src/Google/Protobuf/BytesValue.php

@@ -21,7 +21,7 @@ class BytesValue extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>bytes value = 1;</code>
      */
-    private $value = '';
+    protected $value = '';
 
     /**
      * Constructor.

+ 1 - 1
php/src/Google/Protobuf/DoubleValue.php

@@ -21,7 +21,7 @@ class DoubleValue extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>double value = 1;</code>
      */
-    private $value = 0.0;
+    protected $value = 0.0;
 
     /**
      * Constructor.

+ 3 - 3
php/src/Google/Protobuf/Duration.php

@@ -25,7 +25,7 @@ use Google\Protobuf\Internal\GPBUtil;
  *     if (duration.seconds < 0 && duration.nanos > 0) {
  *       duration.seconds += 1;
  *       duration.nanos -= 1000000000;
- *     } else if (durations.seconds > 0 && duration.nanos < 0) {
+ *     } else if (duration.seconds > 0 && duration.nanos < 0) {
  *       duration.seconds -= 1;
  *       duration.nanos += 1000000000;
  *     }
@@ -66,7 +66,7 @@ class Duration extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>int64 seconds = 1;</code>
      */
-    private $seconds = 0;
+    protected $seconds = 0;
     /**
      * Signed fractions of a second at nanosecond resolution of the span
      * of time. Durations less than one second are represented with a 0
@@ -77,7 +77,7 @@ class Duration extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>int32 nanos = 2;</code>
      */
-    private $nanos = 0;
+    protected $nanos = 0;
 
     /**
      * Constructor.

+ 14 - 4
php/src/Google/Protobuf/Enum.php

@@ -20,7 +20,7 @@ class Enum extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string name = 1;</code>
      */
-    private $name = '';
+    protected $name = '';
     /**
      * Enum value definitions.
      *
@@ -38,13 +38,13 @@ class Enum extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 4;</code>
      */
-    private $source_context = null;
+    protected $source_context = null;
     /**
      * The source syntax.
      *
      * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 5;</code>
      */
-    private $syntax = 0;
+    protected $syntax = 0;
 
     /**
      * Constructor.
@@ -155,7 +155,17 @@ class Enum extends \Google\Protobuf\Internal\Message
      */
     public function getSourceContext()
     {
-        return $this->source_context;
+        return isset($this->source_context) ? $this->source_context : null;
+    }
+
+    public function hasSourceContext()
+    {
+        return isset($this->source_context);
+    }
+
+    public function clearSourceContext()
+    {
+        unset($this->source_context);
     }
 
     /**

+ 2 - 2
php/src/Google/Protobuf/EnumValue.php

@@ -20,13 +20,13 @@ class EnumValue extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string name = 1;</code>
      */
-    private $name = '';
+    protected $name = '';
     /**
      * Enum value number.
      *
      * Generated from protobuf field <code>int32 number = 2;</code>
      */
-    private $number = 0;
+    protected $number = 0;
     /**
      * Protocol buffer options.
      *

+ 11 - 11
php/src/Google/Protobuf/Field.php

@@ -20,45 +20,45 @@ class Field extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>.google.protobuf.Field.Kind kind = 1;</code>
      */
-    private $kind = 0;
+    protected $kind = 0;
     /**
      * The field cardinality.
      *
      * Generated from protobuf field <code>.google.protobuf.Field.Cardinality cardinality = 2;</code>
      */
-    private $cardinality = 0;
+    protected $cardinality = 0;
     /**
      * The field number.
      *
      * Generated from protobuf field <code>int32 number = 3;</code>
      */
-    private $number = 0;
+    protected $number = 0;
     /**
      * The field name.
      *
      * Generated from protobuf field <code>string name = 4;</code>
      */
-    private $name = '';
+    protected $name = '';
     /**
      * The field type URL, without the scheme, for message or enumeration
      * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
      *
      * Generated from protobuf field <code>string type_url = 6;</code>
      */
-    private $type_url = '';
+    protected $type_url = '';
     /**
      * The index of the field type in `Type.oneofs`, for message or enumeration
      * types. The first type has index 1; zero means the type is not in the list.
      *
      * Generated from protobuf field <code>int32 oneof_index = 7;</code>
      */
-    private $oneof_index = 0;
+    protected $oneof_index = 0;
     /**
      * Whether to use alternative packed wire representation.
      *
      * Generated from protobuf field <code>bool packed = 8;</code>
      */
-    private $packed = false;
+    protected $packed = false;
     /**
      * The protocol buffer options.
      *
@@ -70,13 +70,13 @@ class Field extends \Google\Protobuf\Internal\Message
      *
      * Generated from protobuf field <code>string json_name = 10;</code>
      */
-    private $json_name = '';
+    protected $json_name = '';
     /**
      * The string value of the default value of this field. Proto2 syntax only.
      *
      * Generated from protobuf field <code>string default_value = 11;</code>
      */
-    private $default_value = '';
+    protected $default_value = '';
 
     /**
      * Constructor.
@@ -133,7 +133,7 @@ class Field extends \Google\Protobuf\Internal\Message
      */
     public function setKind($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Field_Kind::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Field\Kind::class);
         $this->kind = $var;
 
         return $this;
@@ -159,7 +159,7 @@ class Field extends \Google\Protobuf\Internal\Message
      */
     public function setCardinality($var)
     {
-        GPBUtil::checkEnum($var, \Google\Protobuf\Field_Cardinality::class);
+        GPBUtil::checkEnum($var, \Google\Protobuf\Field\Cardinality::class);
         $this->cardinality = $var;
 
         return $this;

部分文件因文件數量過多而無法顯示