PROTOBUF_SYNC_PIPER
pull/7698/head
Joshua Haberman 4 years ago
parent 6ba52411d0
commit 95e6c5b474
  1. 16
      .github/workflows/codespell.yml
  2. 7
      .gitignore
  3. 89
      BUILD
  4. 13
      CHANGES.txt
  5. 2
      Protobuf.podspec
  6. 1
      cmake/libprotobuf-lite.cmake
  7. 56
      conformance/failure_list_php.txt
  8. 56
      conformance/failure_list_php_c.txt
  9. 56
      conformance/failure_list_php_c_32.txt
  10. 6
      conformance/third_party/jsoncpp/json.h
  11. 2
      conformance/third_party/jsoncpp/jsoncpp.cpp
  12. 2
      csharp/Google.Protobuf.Tools.nuspec
  13. 1
      csharp/generate_protos.sh
  14. 5
      csharp/protos/unittest_issues.proto
  15. 2
      csharp/src/AddressBook/Program.cs
  16. 233
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs
  17. 2
      csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs
  18. 2
      csharp/src/Google.Protobuf.Test/IssuesTest.cs
  19. 10
      csharp/src/Google.Protobuf.Test/Proto3OptionalTest.cs
  20. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  21. 2
      csharp/src/Google.Protobuf/ByteString.cs
  22. 2
      csharp/src/Google.Protobuf/CodedInputStream.cs
  23. 3
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  24. 2
      csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs
  25. 2
      csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
  26. 10
      csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
  27. 2
      docs/csharp/proto2.md
  28. 2
      docs/field_presence.md
  29. 2
      docs/implementing_proto3_presence.md
  30. 4
      docs/options.md
  31. 12
      docs/third_party.md
  32. 4
      java/README.md
  33. 2
      java/bom/pom.xml
  34. 2
      java/core/pom.xml
  35. 31
      java/core/src/main/java/com/google/protobuf/DynamicMessage.java
  36. 6
      java/core/src/main/java/com/google/protobuf/MessageSchema.java
  37. 2
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  38. 14
      java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  39. 3
      java/lite/pom.xml
  40. 40
      java/lite/src/test/java/com/google/protobuf/LiteTest.java
  41. 2
      java/pom.xml
  42. 4
      java/util/BUILD
  43. 2
      java/util/pom.xml
  44. 11
      java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
  45. 28
      js/experimental/runtime/kernel/kernel_test.js
  46. 4
      js/experimental/runtime/kernel/tag_test.js
  47. 96
      kokoro/linux/dockerfile/test/php80/Dockerfile
  48. 18
      kokoro/linux/php80/build.sh
  49. 11
      kokoro/linux/php80/continuous.cfg
  50. 11
      kokoro/linux/php80/presubmit.cfg
  51. 2
      kokoro/macos/prepare_build_macos_rc
  52. 2
      kokoro/release/collect_all_artifacts.sh
  53. 19
      kokoro/release/python/macos/config.sh
  54. 90
      objectivec/BUILD
  55. 2
      objectivec/DevTools/compile_testing_protos.sh
  56. 2
      objectivec/DevTools/full_mac_build.sh
  57. 2
      objectivec/DevTools/pddm.py
  58. 4
      objectivec/GPBExtensionInternals.m
  59. 2
      objectivec/GPBMessage.m
  60. 11
      objectivec/GPBTimestamp.pbobjc.h
  61. 2
      objectivec/GPBUtilities.m
  62. 2
      objectivec/GPBUtilities_PackagePrivate.h
  63. 2
      objectivec/README.md
  64. 2
      objectivec/Tests/CocoaPods/run_tests.sh
  65. 2
      objectivec/Tests/GPBCodedInputStreamTests.m
  66. 2
      objectivec/Tests/GPBCodedOuputStreamTests.m
  67. 18
      php/ext/google/protobuf/array.c
  68. 61
      php/ext/google/protobuf/convert.c
  69. 24
      php/ext/google/protobuf/def.c
  70. 16
      php/ext/google/protobuf/map.c
  71. 159
      php/ext/google/protobuf/message.c
  72. 66
      php/ext/google/protobuf/package.xml
  73. 215
      php/ext/google/protobuf/php-upb.c
  74. 21
      php/ext/google/protobuf/php-upb.h
  75. 7
      php/ext/google/protobuf/protobuf.c
  76. 28
      php/ext/google/protobuf/protobuf.h
  77. 20
      php/phpunit.xml
  78. 25
      php/src/GPBMetadata/Google/Protobuf/Struct.php
  79. 8
      php/src/Google/Protobuf/Descriptor.php
  80. 8
      php/src/Google/Protobuf/FieldDescriptor.php
  81. 96
      php/src/Google/Protobuf/Internal/DescriptorProto.php
  82. 61
      php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
  83. 42
      php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
  84. 61
      php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
  85. 42
      php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
  86. 49
      php/src/Google/Protobuf/Internal/EnumOptions.php
  87. 61
      php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
  88. 28
      php/src/Google/Protobuf/Internal/EnumValueOptions.php
  89. 7
      php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
  90. 12
      php/src/Google/Protobuf/Internal/FieldDescriptor.php
  91. 229
      php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
  92. 133
      php/src/Google/Protobuf/Internal/FieldOptions.php
  93. 150
      php/src/Google/Protobuf/Internal/FileDescriptorProto.php
  94. 7
      php/src/Google/Protobuf/Internal/FileDescriptorSet.php
  95. 427
      php/src/Google/Protobuf/Internal/FileOptions.php
  96. 7
      php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
  97. 70
      php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
  98. 26
      php/src/Google/Protobuf/Internal/Message.php
  99. 91
      php/src/Google/Protobuf/Internal/MessageOptions.php
  100. 124
      php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,16 @@
# GitHub Action to automate the identification of common misspellings in text files.
# https://github.com/codespell-project/actions-codespell
# https://github.com/codespell-project/codespell
name: codespell
on: [push, pull_request]
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: codespell-project/actions-codespell@master
with:
check_filenames: true
skip: ./.git,./conformance/third_party,*.snk,*.pb,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,fo,fundementals,hel,importd,inout,leapyear,nd,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od"

7
.gitignore vendored

@ -104,7 +104,7 @@ build_msvc
# needed to trigger "pod install" to rerun the preinstall commands. # needed to trigger "pod install" to rerun the preinstall commands.
Pods/ Pods/
# Comformance test output # Conformance test output
conformance/.libs/ conformance/.libs/
conformance/com/ conformance/com/
conformance/conformance-cpp conformance/conformance-cpp
@ -137,19 +137,24 @@ conformance/*.class
# php test output # php test output
composer.lock composer.lock
php/tests/.phpunit.result.cache
php/tests/generated/ php/tests/generated/
php/tests/old_protoc php/tests/old_protoc
php/tests/phpunit-9.phar
php/tests/protobuf/ php/tests/protobuf/
php/tests/core php/tests/core
php/tests/vgcore* php/tests/vgcore*
php/tests/multirequest.result php/tests/multirequest.result
php/tests/nohup.out php/tests/nohup.out
php/tests/.phpunit.result.cache
php/tests/phpunit-*
php/ext/google/protobuf/.libs/ php/ext/google/protobuf/.libs/
php/ext/google/protobuf/Makefile.fragments php/ext/google/protobuf/Makefile.fragments
php/ext/google/protobuf/Makefile.global php/ext/google/protobuf/Makefile.global
php/ext/google/protobuf/Makefile.objects php/ext/google/protobuf/Makefile.objects
php/ext/google/protobuf/acinclude.m4 php/ext/google/protobuf/acinclude.m4
php/ext/google/protobuf/build/ php/ext/google/protobuf/build/
php/ext/google/protobuf/bundled_php.c
php/ext/google/protobuf/config.h php/ext/google/protobuf/config.h
php/ext/google/protobuf/config.h.in~ php/ext/google/protobuf/config.h.in~
php/ext/google/protobuf/config.nice php/ext/google/protobuf/config.nice

89
BUILD

@ -954,96 +954,13 @@ proto_lang_toolchain(
alias( alias(
name = "objectivec", name = "objectivec",
actual = ":protobuf_objc", actual = "//objectivec",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
objc_library( alias(
name = "protobuf_objc", name = "protobuf_objc",
hdrs = [ actual = "//objectivec",
"objectivec/GPBAny.pbobjc.h",
"objectivec/GPBApi.pbobjc.h",
"objectivec/GPBDuration.pbobjc.h",
"objectivec/GPBEmpty.pbobjc.h",
"objectivec/GPBFieldMask.pbobjc.h",
"objectivec/GPBSourceContext.pbobjc.h",
"objectivec/GPBStruct.pbobjc.h",
"objectivec/GPBTimestamp.pbobjc.h",
"objectivec/GPBType.pbobjc.h",
"objectivec/GPBWrappers.pbobjc.h",
"objectivec/GPBArray.h",
"objectivec/GPBBootstrap.h",
"objectivec/GPBCodedInputStream.h",
"objectivec/GPBCodedOutputStream.h",
"objectivec/GPBDescriptor.h",
"objectivec/GPBDictionary.h",
"objectivec/GPBExtensionInternals.h",
"objectivec/GPBExtensionRegistry.h",
"objectivec/GPBMessage.h",
"objectivec/GPBProtocolBuffers.h",
"objectivec/GPBProtocolBuffers_RuntimeSupport.h",
"objectivec/GPBRootObject.h",
"objectivec/GPBRuntimeTypes.h",
"objectivec/GPBUnknownField.h",
"objectivec/GPBUnknownFieldSet.h",
"objectivec/GPBUtilities.h",
"objectivec/GPBWellKnownTypes.h",
"objectivec/GPBWireFormat.h",
"objectivec/google/protobuf/Any.pbobjc.h",
"objectivec/google/protobuf/Api.pbobjc.h",
"objectivec/google/protobuf/Duration.pbobjc.h",
"objectivec/google/protobuf/Empty.pbobjc.h",
"objectivec/google/protobuf/FieldMask.pbobjc.h",
"objectivec/google/protobuf/SourceContext.pbobjc.h",
"objectivec/google/protobuf/Struct.pbobjc.h",
"objectivec/google/protobuf/Timestamp.pbobjc.h",
"objectivec/google/protobuf/Type.pbobjc.h",
"objectivec/google/protobuf/Wrappers.pbobjc.h",
# Package private headers, but exposed because the generated sources
# need to use them.
"objectivec/GPBArray_PackagePrivate.h",
"objectivec/GPBCodedInputStream_PackagePrivate.h",
"objectivec/GPBCodedOutputStream_PackagePrivate.h",
"objectivec/GPBDescriptor_PackagePrivate.h",
"objectivec/GPBDictionary_PackagePrivate.h",
"objectivec/GPBMessage_PackagePrivate.h",
"objectivec/GPBRootObject_PackagePrivate.h",
"objectivec/GPBUnknownFieldSet_PackagePrivate.h",
"objectivec/GPBUnknownField_PackagePrivate.h",
"objectivec/GPBUtilities_PackagePrivate.h",
],
copts = [
"-Wno-vla",
],
includes = [
"objectivec",
],
non_arc_srcs = [
"objectivec/GPBAny.pbobjc.m",
"objectivec/GPBApi.pbobjc.m",
"objectivec/GPBDuration.pbobjc.m",
"objectivec/GPBEmpty.pbobjc.m",
"objectivec/GPBFieldMask.pbobjc.m",
"objectivec/GPBSourceContext.pbobjc.m",
"objectivec/GPBStruct.pbobjc.m",
"objectivec/GPBTimestamp.pbobjc.m",
"objectivec/GPBType.pbobjc.m",
"objectivec/GPBWrappers.pbobjc.m",
"objectivec/GPBArray.m",
"objectivec/GPBCodedInputStream.m",
"objectivec/GPBCodedOutputStream.m",
"objectivec/GPBDescriptor.m",
"objectivec/GPBDictionary.m",
"objectivec/GPBExtensionInternals.m",
"objectivec/GPBExtensionRegistry.m",
"objectivec/GPBMessage.m",
"objectivec/GPBRootObject.m",
"objectivec/GPBUnknownField.m",
"objectivec/GPBUnknownFieldSet.m",
"objectivec/GPBUtilities.m",
"objectivec/GPBWellKnownTypes.m",
"objectivec/GPBWireFormat.m",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

@ -1,4 +1,4 @@
Unreleased Changes 2020-07-14 version 3.13.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++: C++:
* Removed deprecated unsafe arena string accessors * Removed deprecated unsafe arena string accessors
@ -37,10 +37,19 @@ Unreleased Changes
type internally. (#7351) type internally. (#7351)
* Add `ParseFrom(ReadOnlySequence<byte>)` method to enable GC friendly * Add `ParseFrom(ReadOnlySequence<byte>)` method to enable GC friendly
parsing with reduced allocations and buffer copies. (#7351) parsing with reduced allocations and buffer copies. (#7351)
* Add support for serialization directly to a `IBufferWriter<byte>` or
to a `Span<byte>` to enable GC friendly serialization.
The new API is available as extension methods on the `IMessage` type. (#7576)
* Add `GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE` define to make * Add `GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE` define to make
generated code compatible with old C# compilers (pre-roslyn compilers generated code compatible with old C# compilers (pre-roslyn compilers
from .NET framework and old versions of mono) that do not support from .NET framework and old versions of mono) that do not support
ref structs. (#7490) ref structs. Users that are still on a legacy stack that does
not support C# 7.2 compiler might need to use the new define
in their projects to be able to build the newly generated code. (#7490)
* Due to the major overhaul of parsing and serialization internals (#7351 and #7576),
it is recommended to regenerate your generated code to achieve the best
performance (the legacy generated code will still work, but might incur
a slight performance penalty).
2020-06-01 version 3.12.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2020-06-01 version 3.12.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)

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

@ -12,6 +12,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${protobuf_source_dir}/src/google/protobuf/map.cc
${protobuf_source_dir}/src/google/protobuf/message_lite.cc ${protobuf_source_dir}/src/google/protobuf/message_lite.cc
${protobuf_source_dir}/src/google/protobuf/parse_context.cc ${protobuf_source_dir}/src/google/protobuf/parse_context.cc
${protobuf_source_dir}/src/google/protobuf/repeated_field.cc ${protobuf_source_dir}/src/google/protobuf/repeated_field.cc

@ -6,62 +6,6 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataOneofBinary.MESSAGE.Merge.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator
Required.Proto3.JsonInput.DoubleFieldTooSmall Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooLarge

@ -1,58 +1,2 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

@ -1,58 +1,2 @@
Recommended.Proto2.JsonInput.FieldNameExtension.Validator Recommended.Proto2.JsonInput.FieldNameExtension.Validator
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput
Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput
Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator Required.Proto2.JsonInput.StoresDefaultPrimitive.Validator

@ -1371,7 +1371,7 @@ public:
*/ */
std::string getFormattedErrorMessages() const; std::string getFormattedErrorMessages() const;
/** \brief Returns a vector of structured errors encounted while parsing. /** \brief Returns a vector of structured errors encountered while parsing.
* \return A (possibly empty) vector of StructuredError objects. Currently * \return A (possibly empty) vector of StructuredError objects. Currently
* only one error can be returned, but the caller should tolerate * only one error can be returned, but the caller should tolerate
* multiple * multiple
@ -1867,7 +1867,7 @@ private:
* - otherwise, it the values do not fit on one line, or the array contains * - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line. * object or non empty array, then print one value per line.
* *
* If the Value have comments then they are outputed according to their * If the Value have comments then they are outputted according to their
*#CommentPlacement. *#CommentPlacement.
* *
* \sa Reader, Value, Value::setComment() * \sa Reader, Value, Value::setComment()
@ -1928,7 +1928,7 @@ private:
* - otherwise, it the values do not fit on one line, or the array contains * - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line. * object or non empty array, then print one value per line.
* *
* If the Value have comments then they are outputed according to their * If the Value have comments then they are outputted according to their
#CommentPlacement. #CommentPlacement.
* *
* \param indentation Each level will be indented by this amount extra. * \param indentation Each level will be indented by this amount extra.

@ -142,7 +142,7 @@ enum {
typedef char UIntToStringBuffer[uintToStringBufferSize]; typedef char UIntToStringBuffer[uintToStringBufferSize];
/** Converts an unsigned integer to string. /** Converts an unsigned integer to string.
* @param value Unsigned interger to convert to string * @param value Unsigned integer to convert to string
* @param current Input/Output string buffer. * @param current Input/Output string buffer.
* Must have at least uintToStringBufferSize chars free. * Must have at least uintToStringBufferSize chars free.
*/ */

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

@ -45,6 +45,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
# and old_extensions2.proto, which are generated with an older version # and old_extensions2.proto, which are generated with an older version
# of protoc. # of protoc.
$PROTOC -Isrc -Icsharp/protos \ $PROTOC -Isrc -Icsharp/protos \
--experimental_allow_proto3_optional \
--csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \ --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
--include_source_info \ --include_source_info \

@ -151,3 +151,8 @@ message NullValueOutsideStruct {
message NullValueNotInOneof { message NullValueNotInOneof {
google.protobuf.NullValue null_value = 2; google.protobuf.NullValue null_value = 2;
} }
message MixedRegularAndOptional {
string regular_field = 1;
optional string optional_field = 2;
}

@ -37,7 +37,7 @@ namespace Google.Protobuf.Examples.AddressBook
/// <summary> /// <summary>
/// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour /// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour
/// to individual actions. Each action has its own Main method, so that it can be used as an /// to individual actions. Each action has its own Main method, so that it can be used as an
/// invidual complete program. /// individual complete program.
/// </summary> /// </summary>
internal class Program internal class Program
{ {

@ -52,11 +52,13 @@ namespace UnitTest.Issues.TestProtos {
"bmdfdmFsdWUYASABKAlIABIwCgpudWxsX3ZhbHVlGAIgASgOMhouZ29vZ2xl", "bmdfdmFsdWUYASABKAlIABIwCgpudWxsX3ZhbHVlGAIgASgOMhouZ29vZ2xl",
"LnByb3RvYnVmLk51bGxWYWx1ZUgAQgcKBXZhbHVlIkUKE051bGxWYWx1ZU5v", "LnByb3RvYnVmLk51bGxWYWx1ZUgAQgcKBXZhbHVlIkUKE051bGxWYWx1ZU5v",
"dEluT25lb2YSLgoKbnVsbF92YWx1ZRgCIAEoDjIaLmdvb2dsZS5wcm90b2J1", "dEluT25lb2YSLgoKbnVsbF92YWx1ZRgCIAEoDjIaLmdvb2dsZS5wcm90b2J1",
"Zi5OdWxsVmFsdWUqVQoMTmVnYXRpdmVFbnVtEhYKEk5FR0FUSVZFX0VOVU1f", "Zi5OdWxsVmFsdWUiYAoXTWl4ZWRSZWd1bGFyQW5kT3B0aW9uYWwSFQoNcmVn",
"WkVSTxAAEhYKCUZpdmVCZWxvdxD7//////////8BEhUKCE1pbnVzT25lEP//", "dWxhcl9maWVsZBgBIAEoCRIbCg5vcHRpb25hbF9maWVsZBgCIAEoCUgAiAEB",
"/////////wEqLgoORGVwcmVjYXRlZEVudW0SEwoPREVQUkVDQVRFRF9aRVJP", "QhEKD19vcHRpb25hbF9maWVsZCpVCgxOZWdhdGl2ZUVudW0SFgoSTkVHQVRJ",
"EAASBwoDb25lEAFCHaoCGlVuaXRUZXN0Lklzc3Vlcy5UZXN0UHJvdG9zYgZw", "VkVfRU5VTV9aRVJPEAASFgoJRml2ZUJlbG93EPv//////////wESFQoITWlu",
"cm90bzM=")); "dXNPbmUQ////////////ASouCg5EZXByZWNhdGVkRW51bRITCg9ERVBSRUNB",
"VEVEX1pFUk8QABIHCgNvbmUQAUIdqgIaVW5pdFRlc3QuSXNzdWVzLlRlc3RQ",
"cm90b3NiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, }, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, null, new pbr::GeneratedClrTypeInfo[] {
@ -70,7 +72,8 @@ namespace UnitTest.Issues.TestProtos {
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonName), global::UnitTest.Issues.TestProtos.TestJsonName.Parser, new[]{ "Name", "Description", "Guid" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestJsonName), global::UnitTest.Issues.TestProtos.TestJsonName.Parser, new[]{ "Name", "Description", "Guid" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging), global::UnitTest.Issues.TestProtos.OneofMerging.Parser, new[]{ "Text", "Nested" }, new[]{ "Value" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested), global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested.Parser, new[]{ "X", "Y" }, null, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging), global::UnitTest.Issues.TestProtos.OneofMerging.Parser, new[]{ "Text", "Nested" }, new[]{ "Value" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested), global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested.Parser, new[]{ "X", "Y" }, null, null, null, null)}),
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NullValueOutsideStruct), global::UnitTest.Issues.TestProtos.NullValueOutsideStruct.Parser, new[]{ "StringValue", "NullValue" }, new[]{ "Value" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NullValueOutsideStruct), global::UnitTest.Issues.TestProtos.NullValueOutsideStruct.Parser, new[]{ "StringValue", "NullValue" }, new[]{ "Value" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NullValueNotInOneof), global::UnitTest.Issues.TestProtos.NullValueNotInOneof.Parser, new[]{ "NullValue" }, null, null, null, null) new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NullValueNotInOneof), global::UnitTest.Issues.TestProtos.NullValueNotInOneof.Parser, new[]{ "NullValue" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.MixedRegularAndOptional), global::UnitTest.Issues.TestProtos.MixedRegularAndOptional.Parser, new[]{ "RegularField", "OptionalField" }, new[]{ "OptionalField" }, null, null, null)
})); }));
} }
#endregion #endregion
@ -3304,6 +3307,224 @@ namespace UnitTest.Issues.TestProtos {
} }
public sealed partial class MixedRegularAndOptional : pb::IMessage<MixedRegularAndOptional>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<MixedRegularAndOptional> _parser = new pb::MessageParser<MixedRegularAndOptional>(() => new MixedRegularAndOptional());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<MixedRegularAndOptional> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::UnitTest.Issues.TestProtos.UnittestIssuesReflection.Descriptor.MessageTypes[11]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MixedRegularAndOptional() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MixedRegularAndOptional(MixedRegularAndOptional other) : this() {
regularField_ = other.regularField_;
optionalField_ = other.optionalField_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MixedRegularAndOptional Clone() {
return new MixedRegularAndOptional(this);
}
/// <summary>Field number for the "regular_field" field.</summary>
public const int RegularFieldFieldNumber = 1;
private string regularField_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string RegularField {
get { return regularField_; }
set {
regularField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
/// <summary>Field number for the "optional_field" field.</summary>
public const int OptionalFieldFieldNumber = 2;
private string optionalField_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string OptionalField {
get { return optionalField_ ?? ""; }
set {
optionalField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
/// <summary>Gets whether the "optional_field" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool HasOptionalField {
get { return optionalField_ != null; }
}
/// <summary>Clears the value of the "optional_field" field</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void ClearOptionalField() {
optionalField_ = null;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as MixedRegularAndOptional);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(MixedRegularAndOptional other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (RegularField != other.RegularField) return false;
if (OptionalField != other.OptionalField) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (RegularField.Length != 0) hash ^= RegularField.GetHashCode();
if (HasOptionalField) hash ^= OptionalField.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (RegularField.Length != 0) {
output.WriteRawTag(10);
output.WriteString(RegularField);
}
if (HasOptionalField) {
output.WriteRawTag(18);
output.WriteString(OptionalField);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (RegularField.Length != 0) {
output.WriteRawTag(10);
output.WriteString(RegularField);
}
if (HasOptionalField) {
output.WriteRawTag(18);
output.WriteString(OptionalField);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (RegularField.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(RegularField);
}
if (HasOptionalField) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalField);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(MixedRegularAndOptional other) {
if (other == null) {
return;
}
if (other.RegularField.Length != 0) {
RegularField = other.RegularField;
}
if (other.HasOptionalField) {
OptionalField = other.OptionalField;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
RegularField = input.ReadString();
break;
}
case 18: {
OptionalField = input.ReadString();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
RegularField = input.ReadString();
break;
}
case 18: {
OptionalField = input.ReadString();
break;
}
}
}
}
#endif
}
#endregion #endregion
} }

@ -60,7 +60,7 @@ namespace Google.Protobuf.Buffers
} }
/// <summary> /// <summary>
/// Userful for testing writing to buffer writer with a lot of small segments. /// Useful for testing writing to buffer writer with a lot of small segments.
/// If set, it limits the max number of bytes by which the buffer grows by at once. /// If set, it limits the max number of bytes by which the buffer grows by at once.
/// </summary> /// </summary>
public int? MaxGrowBy { get; set; } public int? MaxGrowBy { get; set; }

@ -108,7 +108,7 @@ namespace Google.Protobuf
// we still must read the tag correctly, even though the tag is at the very end of our limited input // we still must read the tag correctly, even though the tag is at the very end of our limited input
// (which is a corner case and will most likely result in an error when trying to read value of the field // (which is a corner case and will most likely result in an error when trying to read value of the field
// decribed by this tag, but it would be a logical error not to read the tag that's actually present). // described by this tag, but it would be a logical error not to read the tag that's actually present).
// See https://github.com/protocolbuffers/protobuf/pull/7289 // See https://github.com/protocolbuffers/protobuf/pull/7289
cis.AssertNextTag(WireFormat.MakeTag(11, WireFormat.WireType.Varint)); cis.AssertNextTag(WireFormat.MakeTag(11, WireFormat.WireType.Varint));
} }

@ -34,6 +34,7 @@ using NUnit.Framework;
using ProtobufUnittest; using ProtobufUnittest;
using System; using System;
using System.IO; using System.IO;
using UnitTest.Issues.TestProtos;
namespace Google.Protobuf.Test namespace Google.Protobuf.Test
{ {
@ -139,5 +140,14 @@ namespace Google.Protobuf.Test
Assert.IsTrue(message1.Equals(message2)); Assert.IsTrue(message1.Equals(message2));
message1.ClearOptionalInt32(); message1.ClearOptionalInt32();
} }
[Test]
public void MixedFields()
{
var descriptor = MixedRegularAndOptional.Descriptor;
Assert.AreEqual(1, descriptor.Oneofs.Count);
Assert.AreEqual(0, descriptor.RealOneofCount);
Assert.True(descriptor.Oneofs[0].IsSynthetic);
}
} }
} }

@ -269,7 +269,7 @@ namespace Google.Protobuf
} }
/// <summary> /// <summary>
/// Retuns the byte at the given index. /// Returns the byte at the given index.
/// </summary> /// </summary>
public byte this[int index] public byte this[int index]
{ {

@ -652,7 +652,7 @@ namespace Google.Protobuf
/// <summary> /// <summary>
/// Called when buffer is empty to read more bytes from the /// Called when buffer is empty to read more bytes from the
/// input. If <paramref name="mustSucceed"/> is true, RefillBuffer() gurantees that /// input. If <paramref name="mustSucceed"/> is true, RefillBuffer() guarantees that
/// either there will be at least one byte in the buffer when it returns /// either there will be at least one byte in the buffer when it returns
/// or it will throw an exception. If <paramref name="mustSucceed"/> is false, /// or it will throw an exception. If <paramref name="mustSucceed"/> is false,
/// RefillBuffer() returns false if no more bytes were available. /// RefillBuffer() returns false if no more bytes were available.

@ -4,8 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright> <Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.12.2</VersionPrefix> <VersionPrefix>3.13.0</VersionPrefix>
<VersionPrefix>3.12.3</VersionPrefix>
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence --> <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
<LangVersion>7.2</LangVersion> <LangVersion>7.2</LangVersion>
<Authors>Google Inc.</Authors> <Authors>Google Inc.</Authors>

@ -63,7 +63,7 @@ namespace Google.Protobuf.Reflection
internal static OneofAccessor ForSyntheticOneof(OneofDescriptor descriptor) internal static OneofAccessor ForSyntheticOneof(OneofDescriptor descriptor)
{ {
// Note: descriptor.Fields will be null when this method is called, because we haven't // Note: descriptor.Fields will be null when this method is called, because we haven't
// cross-linked yet. But by the time the delgates are called by user code, all will be // cross-linked yet. But by the time the delegates are called by user code, all will be
// well. (That's why we capture the descriptor itself rather than a field.) // well. (That's why we capture the descriptor itself rather than a field.)
return new OneofAccessor(descriptor, return new OneofAccessor(descriptor,
message => descriptor.Fields[0].Accessor.HasValue(message) ? descriptor.Fields[0].FieldNumber : 0, message => descriptor.Fields[0].Accessor.HasValue(message) ? descriptor.Fields[0].FieldNumber : 0,

@ -59,7 +59,7 @@ namespace Google.Protobuf.Reflection
// It's useful to determine whether or not this is a synthetic oneof before cross-linking. That means // It's useful to determine whether or not this is a synthetic oneof before cross-linking. That means
// diving into the proto directly rather than using FieldDescriptor, but that's okay. // diving into the proto directly rather than using FieldDescriptor, but that's okay.
var firstFieldInOneof = parent.Proto.Field.FirstOrDefault(fieldProto => fieldProto.OneofIndex == index); var firstFieldInOneof = parent.Proto.Field.FirstOrDefault(fieldProto => fieldProto.HasOneofIndex && fieldProto.OneofIndex == index);
IsSynthetic = firstFieldInOneof?.Proto3Optional ?? false; IsSynthetic = firstFieldInOneof?.Proto3Optional ?? false;
accessor = CreateAccessor(clrName); accessor = CreateAccessor(clrName);

@ -91,7 +91,15 @@ namespace Google.Protobuf.WellKnownTypes {
/// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
/// .setNanos((int) ((millis % 1000) * 1000000)).build(); /// .setNanos((int) ((millis % 1000) * 1000000)).build();
/// ///
/// Example 5: Compute Timestamp from current time in Python. /// Example 5: Compute Timestamp from Java `Instant.now()`.
///
/// Instant now = Instant.now();
///
/// Timestamp timestamp =
/// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
/// .setNanos(now.getNano()).build();
///
/// Example 6: Compute Timestamp from current time in Python.
/// ///
/// timestamp = Timestamp() /// timestamp = Timestamp()
/// timestamp.GetCurrentTime() /// timestamp.GetCurrentTime()

@ -97,7 +97,7 @@ foo.GetOrInitializeExtension(RepeatedFooExt).Add(new Baz());
### Message initialization ### Message initialization
Initialization refers to checking the status of required fields in a proto2 message. If a message is uninitialized, not all required fields are set in either the message itself or any of its submessages. In other languages, missing required fields throw errors depending on the merge method used. This could cause unforseen errors at runtime if the incorrect method is used. Initialization refers to checking the status of required fields in a proto2 message. If a message is uninitialized, not all required fields are set in either the message itself or any of its submessages. In other languages, missing required fields throw errors depending on the merge method used. This could cause unforeseen errors at runtime if the incorrect method is used.
However, in this implementation, parsers and input streams don't check messages for initialization on their own and throw errors. Instead it's up to you to handle messages with missing required fields in whatever way you see fit. However, in this implementation, parsers and input streams don't check messages for initialization on their own and throw errors. Instead it's up to you to handle messages with missing required fields in whatever way you see fit.
Checking message initialization can be done manually via the `IsInitialized` extension method in `MessageExtensions`. Checking message initialization can be done manually via the `IsInitialized` extension method in `MessageExtensions`.

@ -127,7 +127,7 @@ The _no presence_ serialization discipline results in visible differences from t
### Considerations for merging ### Considerations for merging
Under the _no presence_ rules, it is effectively impossible for a target field to merge-from its default value (using the protobuf's API merging functions). This is because default values are skipped, simliar to the _no presence_ serialization discipline. Merging only updates the target (merged-to) message using the non-skipped values from the update (merged-from) message. Under the _no presence_ rules, it is effectively impossible for a target field to merge-from its default value (using the protobuf's API merging functions). This is because default values are skipped, similar to the _no presence_ serialization discipline. Merging only updates the target (merged-to) message using the non-skipped values from the update (merged-from) message.
The difference in merging behavior has further implications for protocols which rely on partial "patch" updates. If field presence is not tracked, then an update patch alone cannot represent an update to the default value, because only non-default values are merged-from. The difference in merging behavior has further implications for protocols which rely on partial "patch" updates. If field presence is not tracked, then an update patch alone cannot represent an update to the default value, because only non-default values are merged-from.

@ -13,7 +13,7 @@ optional fields. First-party code generators developed by Google are being
updated already. However third-party code generators will need to be updated updated already. However third-party code generators will need to be updated
independently by their authors. This includes: independently by their authors. This includes:
- implementations of Protocol Buffers for other languges. - implementations of Protocol Buffers for other languages.
- alternate implementations of Protocol Buffers that target specialized use - alternate implementations of Protocol Buffers that target specialized use
cases. cases.
- RPC code generators that create generated APIs for service calls. - RPC code generators that create generated APIs for service calls.

@ -244,3 +244,7 @@ with info about your project (name and website) so we can add an entry for you.
1. ADLINK EdgeSDK 1. ADLINK EdgeSDK
* Website: https://www.adlinktech.com/en/Edge-SDK-IoT * Website: https://www.adlinktech.com/en/Edge-SDK-IoT
* Extensions: 1086 * Extensions: 1086
1. Wire wire_package
* Website: https://square.github.io/wire/
* Extensions: 1087

@ -26,8 +26,8 @@ These are projects we know about implementing Protocol Buffers for other program
* Clojure: http://github.com/ninjudd/clojure-protobuf * Clojure: http://github.com/ninjudd/clojure-protobuf
* Clojure: https://github.com/clojusc/protobuf * Clojure: https://github.com/clojusc/protobuf
* Clojure: https://protojure.github.io * Clojure: https://protojure.github.io
* Common Lisp: http://github.com/ndantam/s-protobuf
* Common Lisp: http://github.com/brown/protobuf * Common Lisp: http://github.com/brown/protobuf
* Common Lisp: http://github.com/qitab/cl-protobuf
* D: https://github.com/dcarp/protobuf-d * D: https://github.com/dcarp/protobuf-d
* D: https://github.com/msoucy/dproto * D: https://github.com/msoucy/dproto
* D: https://github.com/opticron/ProtocolBuffer * D: https://github.com/opticron/ProtocolBuffer
@ -62,6 +62,8 @@ These are projects we know about implementing Protocol Buffers for other program
* Javascript: https://github.com/dcodeIO/ProtoBuf.js * Javascript: https://github.com/dcodeIO/ProtoBuf.js
* Javascript: http://code.google.com/p/protobuf-for-node/ * Javascript: http://code.google.com/p/protobuf-for-node/
* Javascript: http://code.google.com/p/protostuff/ * Javascript: http://code.google.com/p/protostuff/
* Javascript: https://github.com/seishun/node-protoc-plugin (Node.js port of plugin.h)
* Javascript: https://github.com/seishun/node-protoc-gen-javascript (Node.js port of the Google-official implementation)
* Julia: https://github.com/tanmaykm/ProtoBuf.jl * Julia: https://github.com/tanmaykm/ProtoBuf.jl
* Kotlin: https://github.com/marcoferrer/kroto-plus * Kotlin: https://github.com/marcoferrer/kroto-plus
* Kotlin: https://github.com/Kotlin/kotlinx.serialization * Kotlin: https://github.com/Kotlin/kotlinx.serialization
@ -154,7 +156,7 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
* [Alternate encodings (JSON, XML, HTML) for Java protobufs](http://code.google.com/p/protobuf-java-format/) * [Alternate encodings (JSON, XML, HTML) for Java protobufs](http://code.google.com/p/protobuf-java-format/)
* [Another JSON encoder/decoder for Java](https://github.com/sijuv/protobuf-codec) * [Another JSON encoder/decoder for Java](https://github.com/sijuv/protobuf-codec)
* [Editor for serialized protobufs](http://code.google.com/p/protobufeditor/) * [Editor for serialized protobufs](http://code.google.com/p/protobufeditor/)
* [Intellij IDEA plugin](http://github.com/nnmatveev/idea-plugin-protobuf) * [IntelliJ IDEA plugin](http://github.com/jvolkman/intellij-protobuf-editor)
* [TextMate syntax highlighting](http://github.com/michaeledgar/protobuf-tmbundle) * [TextMate syntax highlighting](http://github.com/michaeledgar/protobuf-tmbundle)
* [Oracle PL SQL plugin](http://code.google.com/p/protocol-buffer-plsql/) * [Oracle PL SQL plugin](http://code.google.com/p/protocol-buffer-plsql/)
* [Eclipse editor for protobuf (from Google)](http://code.google.com/p/protobuf-dt/) * [Eclipse editor for protobuf (from Google)](http://code.google.com/p/protobuf-dt/)
@ -184,3 +186,9 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
* [Protocol Buffer property-based testing utility and example message generator (Python / Hypothesis)](https://github.com/CurataEng/hypothesis-protobuf) * [Protocol Buffer property-based testing utility and example message generator (Python / Hypothesis)](https://github.com/CurataEng/hypothesis-protobuf)
* [Protolock - CLI utility to prevent backward-incompatible changes to .proto files](https://github.com/nilslice/protolock) * [Protolock - CLI utility to prevent backward-incompatible changes to .proto files](https://github.com/nilslice/protolock)
* [Optional GRPC - GRPC for testable microservices (Python)](https://github.com/mattpaletta/optional-grpc.git) * [Optional GRPC - GRPC for testable microservices (Python)](https://github.com/mattpaletta/optional-grpc.git)
* [Protobuf Parser - Yet another Go package which parses a Protocol Buffer file (proto2+proto3)](https://github.com/yoheimuta/go-protoparser)
* [Protolint - A tool to enforce Protocol Buffer style and conventions.](https://github.com/yoheimuta/protolint)
* [vscode-protolint: A protobuf linter for visual studio code](https://github.com/plexsystems/vscode-protolint)
* [intellij-protolint: A protobuf linter for JetBrains IDEs](https://github.com/yoheimuta/intellij-protolint)
* [vim-protolint: A protobuf linter for Vim](https://github.com/yoheimuta/vim-protolint)
* [super-linter: Protocol Buffer lint as GitHub Action](https://github.com/github/super-linter)

@ -47,7 +47,7 @@ If you are using Gradle, add the following to your `build.gradle` file's depende
``` ```
compile 'com.google.protobuf:protobuf-java:3.11.0' compile 'com.google.protobuf:protobuf-java:3.11.0'
``` ```
Again, be sure to check that the version number maches (or is newer than) the version number of protoc that you are using. Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.
### Use Java Protocol Buffers on Android ### Use Java Protocol Buffers on Android
@ -68,7 +68,7 @@ how to use them.
Most users should follow the instructions above to use protobuf Java runtime. Most users should follow the instructions above to use protobuf Java runtime.
If you are contributing code to protobuf or want to use a protobuf version If you are contributing code to protobuf or want to use a protobuf version
that hasn't been officially released yet, you can folllow the instructions that hasn't been officially released yet, you can follow the instructions
below to build protobuf from source code. below to build protobuf from source code.
### Build from Source - With Maven ### Build from Source - With Maven

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId> <artifactId>protobuf-bom</artifactId>
<version>3.12.3</version> <version>3.13.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name> <name>Protocol Buffers [BOM]</name>

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.12.3</version> <version>3.13.0</version>
</parent> </parent>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>

@ -328,20 +328,6 @@ public final class DynamicMessage extends AbstractMessage {
this.fields = FieldSet.newFieldSet(); this.fields = FieldSet.newFieldSet();
this.unknownFields = UnknownFieldSet.getDefaultInstance(); this.unknownFields = UnknownFieldSet.getDefaultInstance();
this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()]; this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()];
// A MapEntry has all of its fields present at all times.
if (type.getOptions().getMapEntry()) {
populateMapEntry();
}
}
private void populateMapEntry() {
for (FieldDescriptor field : type.getFields()) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
fields.setField(field, getDefaultInstance(field.getMessageType()));
} else {
fields.setField(field, field.getDefaultValue());
}
}
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
@ -354,10 +340,6 @@ public final class DynamicMessage extends AbstractMessage {
} else { } else {
fields.clear(); fields.clear();
} }
// A MapEntry has all of its fields present at all times.
if (type.getOptions().getMapEntry()) {
populateMapEntry();
}
unknownFields = UnknownFieldSet.getDefaultInstance(); unknownFields = UnknownFieldSet.getDefaultInstance();
return this; return this;
} }
@ -423,6 +405,19 @@ public final class DynamicMessage extends AbstractMessage {
@Override @Override
public DynamicMessage buildPartial() { public DynamicMessage buildPartial() {
// Set default values for all fields in a MapEntry.
if (type.getOptions().getMapEntry()) {
for (FieldDescriptor field : type.getFields()) {
if (field.isOptional() && !fields.hasField(field)) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
fields.setField(field, getDefaultInstance(field.getMessageType()));
} else {
fields.setField(field, field.getDefaultValue());
}
}
}
}
fields.makeImmutable(); fields.makeImmutable();
DynamicMessage result = DynamicMessage result =
new DynamicMessage( new DynamicMessage(

@ -1402,8 +1402,10 @@ final class MessageSchema<T> implements Schema<T> {
if (!isOneofPresent(other, number, pos)) { if (!isOneofPresent(other, number, pos)) {
return; return;
} }
Object mine = null;
Object mine = UnsafeUtil.getObject(message, offset); if (isOneofPresent(message, number, pos)) {
mine = UnsafeUtil.getObject(message, offset);
}
Object theirs = UnsafeUtil.getObject(other, offset); Object theirs = UnsafeUtil.getObject(other, offset);
if (mine != null && theirs != null) { if (mine != null && theirs != null) {
Object merged = Internal.mergeMessage(mine, theirs); Object merged = Internal.mergeMessage(mine, theirs);

@ -1661,7 +1661,7 @@ public final class TextFormat {
throws IOException { throws IOException {
// Read the entire input to a String then parse that. // Read the entire input to a String then parse that.
// If StreamTokenizer were not quite so crippled, or if there were a kind // If StreamTokenizer was not so limited, or if there were a kind
// of Reader that could read in chunks that match some particular regex, // of Reader that could read in chunks that match some particular regex,
// or if we wanted to write a custom Reader to tokenize our stream, then // or if we wanted to write a custom Reader to tokenize our stream, then
// we would not have to read to one big String. Alas, none of these is // we would not have to read to one big String. Alas, none of these is

@ -1478,11 +1478,23 @@ public class TextFormatTest extends TestCase {
// With overwrite forbidden, same behavior. // With overwrite forbidden, same behavior.
// TODO(b/29122459): Expect parse exception here. // TODO(b/29122459): Expect parse exception here.
TestMap.Builder builder = TestMap.newBuilder(); TestMap.Builder builder = TestMap.newBuilder();
defaultParser.merge(text, builder); parserWithOverwriteForbidden.merge(text, builder);
TestMap map = builder.build(); TestMap map = builder.build();
assertEquals(2, map.getInt32ToInt32Field().size()); assertEquals(2, map.getInt32ToInt32Field().size());
assertEquals(30, map.getInt32ToInt32Field().get(1).intValue()); assertEquals(30, map.getInt32ToInt32Field().get(1).intValue());
} }
{
// With overwrite forbidden and a dynamic message, same behavior.
// TODO(b/29122459): Expect parse exception here.
Message.Builder builder = DynamicMessage.newBuilder(TestMap.getDescriptor());
parserWithOverwriteForbidden.merge(text, builder);
TestMap map =
TestMap.parseFrom(
builder.build().toByteString(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(2, map.getInt32ToInt32Field().size());
assertEquals(30, map.getInt32ToInt32Field().get(1).intValue());
}
} }
// ======================================================================= // =======================================================================

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.12.3</version> <version>3.13.0</version>
</parent> </parent>
<artifactId>protobuf-javalite</artifactId> <artifactId>protobuf-javalite</artifactId>
@ -52,6 +52,7 @@
<includes> <includes>
<include>google/protobuf/any.proto</include> <include>google/protobuf/any.proto</include>
<include>google/protobuf/api.proto</include> <include>google/protobuf/api.proto</include>
<include>google/protobuf/duration.proto</include>
<include>google/protobuf/empty.proto</include> <include>google/protobuf/empty.proto</include>
<include>google/protobuf/field_mask.proto</include> <include>google/protobuf/field_mask.proto</include>
<include>google/protobuf/source_context.proto</include> <include>google/protobuf/source_context.proto</include>

@ -42,6 +42,7 @@ import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite; import com.google.protobuf.UnittestLite.TestAllTypesLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum; import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedEnum;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage; import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage;
import com.google.protobuf.UnittestLite.TestAllTypesLite.NestedMessage2;
import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase; import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase;
import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup; import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup;
import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup; import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup;
@ -1354,6 +1355,45 @@ public class LiteTest extends TestCase {
assertEquals(message.getSerializedSize() * 2, result.getSerializedSize()); assertEquals(message.getSerializedSize() * 2, result.getSerializedSize());
} }
public void testMergeFrom_differentFieldsSetWithinOneField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofNestedMessage2(NestedMessage2.newBuilder().setDd(3))
.build())
.build();
assertToStringEquals("oneof_nested_message2 {\n dd: 3\n}", result);
}
public void testMergeFrom_differentFieldsOfSameTypeSetWithinOneField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofLazyNestedMessage(NestedMessage.newBuilder().setCc(3))
.build())
.build();
assertToStringEquals("oneof_lazy_nested_message {\n cc: 3\n}", result);
}
public void testMergeFrom_sameFieldSetWithinOneofField() throws Exception {
TestAllTypesLite result =
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setBb(2))
.mergeFrom(
TestAllTypesLite.newBuilder()
.setOneofNestedMessage(NestedMessage.newBuilder().setCc(4))
.build())
.build();
assertToStringEquals("oneof_nested_message {\n bb: 2\n cc: 4\n}", result);
}
public void testToStringDefaultInstance() throws Exception { public void testToStringDefaultInstance() throws Exception {
assertToStringEquals("", TestAllTypesLite.getDefaultInstance()); assertToStringEquals("", TestAllTypesLite.getDefaultInstance());
} }

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

@ -5,10 +5,6 @@ java_library(
srcs = glob([ srcs = glob([
"src/main/java/com/google/protobuf/util/*.java", "src/main/java/com/google/protobuf/util/*.java",
]), ]),
javacopts = [
"-source 7",
"-target 7",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//external:error_prone_annotations", "//external:error_prone_annotations",

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.12.3</version> <version>3.13.0</version>
</parent> </parent>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>

@ -328,14 +328,13 @@ public class JsonFormat {
/** /**
* Create a new {@link Printer} that will sort the map keys in the JSON output. * Create a new {@link Printer} that will sort the map keys in the JSON output.
* *
* Use of this modifier is discouraged, the generated JSON messages are equivalent * <p>Use of this modifier is discouraged, the generated JSON messages are equivalent with and
* with and without this option set, but there are some corner caseuse cases that * without this option set, but there are some corner use cases that demand a stable output,
* demand a stable output, while order of map keys is otherwise arbitrary. * while order of map keys is otherwise arbitrary.
* *
* The generated order is not well-defined and should not be depended on, but * <p>The generated order is not well-defined and should not be depended on, but it's stable.
* it's stable.
* *
* This new Printer clones all other configurations from the current {@link Printer}. * <p>This new Printer clones all other configurations from the current {@link Printer}.
*/ */
public Printer sortingMapKeys() { public Printer sortingMapKeys() {
return new Printer( return new Printer(

@ -699,7 +699,7 @@ describe('Bytes access', () => {
expect(accessor.getBytesWithDefault(1)).toEqual(simpleByteString); expect(accessor.getBytesWithDefault(1)).toEqual(simpleByteString);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer( const accessor = Kernel.fromArrayBuffer(
createArrayBuffer(0x0A, 0x01, 0x00, 0x0A, 0x01, 0x01)); createArrayBuffer(0x0A, 0x01, 0x00, 0x0A, 0x01, 0x01));
expect(accessor.getBytesWithDefault(1)).toEqual(simpleByteString); expect(accessor.getBytesWithDefault(1)).toEqual(simpleByteString);
@ -801,7 +801,7 @@ describe('Fixed32 access', () => {
expect(accessor.getFixed32WithDefault(1)).toEqual(1); expect(accessor.getFixed32WithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x0D, 0x01, 0x00, 0x80, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00)); 0x0D, 0x01, 0x00, 0x80, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00));
expect(accessor.getFixed32WithDefault(1)).toEqual(2); expect(accessor.getFixed32WithDefault(1)).toEqual(2);
@ -909,7 +909,7 @@ describe('Fixed64 access', () => {
expect(accessor.getFixed64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getFixed64WithDefault(1)).toEqual(Int64.fromInt(1));
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00)); 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
@ -1008,7 +1008,7 @@ describe('Float access', () => {
expect(accessor.getFloatWithDefault(1)).toEqual(1); expect(accessor.getFloatWithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x0D, 0x00, 0x00, 0x80, 0x3F, 0x0D, 0x00, 0x00, 0x80, 0xBF)); 0x0D, 0x00, 0x00, 0x80, 0x3F, 0x0D, 0x00, 0x00, 0x80, 0xBF));
expect(accessor.getFloatWithDefault(1)).toEqual(-1); expect(accessor.getFloatWithDefault(1)).toEqual(-1);
@ -1110,7 +1110,7 @@ describe('Int32 access', () => {
expect(accessor.getInt32WithDefault(1)).toEqual(1); expect(accessor.getInt32WithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02));
expect(accessor.getInt32WithDefault(1)).toEqual(2); expect(accessor.getInt32WithDefault(1)).toEqual(2);
@ -1207,7 +1207,7 @@ describe('Int64 access', () => {
expect(accessor.getInt64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getInt64WithDefault(1)).toEqual(Int64.fromInt(1));
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02));
expect(accessor.getInt64WithDefault(1)).toEqual(Int64.fromInt(2)); expect(accessor.getInt64WithDefault(1)).toEqual(Int64.fromInt(2));
@ -1306,7 +1306,7 @@ describe('Sfixed32 access', () => {
expect(accessor.getSfixed32WithDefault(1)).toEqual(1); expect(accessor.getSfixed32WithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x0D, 0x01, 0x00, 0x80, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00)); 0x0D, 0x01, 0x00, 0x80, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00));
expect(accessor.getSfixed32WithDefault(1)).toEqual(2); expect(accessor.getSfixed32WithDefault(1)).toEqual(2);
@ -1404,7 +1404,7 @@ describe('Sfixed64 access', () => {
expect(accessor.getSfixed64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getSfixed64WithDefault(1)).toEqual(Int64.fromInt(1));
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00)); 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
@ -1502,7 +1502,7 @@ describe('Sint32 access', () => {
expect(accessor.getSint32WithDefault(1)).toEqual(1); expect(accessor.getSint32WithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x03, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x03, 0x08, 0x02));
expect(accessor.getSint32WithDefault(1)).toEqual(1); expect(accessor.getSint32WithDefault(1)).toEqual(1);
@ -1599,7 +1599,7 @@ describe('SInt64 access', () => {
expect(accessor.getSint64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getSint64WithDefault(1)).toEqual(Int64.fromInt(1));
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02));
expect(accessor.getSint64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getSint64WithDefault(1)).toEqual(Int64.fromInt(1));
@ -1698,7 +1698,7 @@ describe('String access', () => {
expect(accessor.getStringWithDefault(1)).toEqual('a'); expect(accessor.getStringWithDefault(1)).toEqual('a');
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer( const accessor = Kernel.fromArrayBuffer(
createArrayBuffer(0x0A, 0x01, 0x60, 0x0A, 0x01, 0x61)); createArrayBuffer(0x0A, 0x01, 0x60, 0x0A, 0x01, 0x61));
expect(accessor.getStringWithDefault(1)).toEqual('a'); expect(accessor.getStringWithDefault(1)).toEqual('a');
@ -1789,7 +1789,7 @@ describe('Uint32 access', () => {
expect(accessor.getUint32WithDefault(1)).toEqual(1); expect(accessor.getUint32WithDefault(1)).toEqual(1);
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02));
expect(accessor.getUint32WithDefault(1)).toEqual(2); expect(accessor.getUint32WithDefault(1)).toEqual(2);
@ -1896,7 +1896,7 @@ describe('Uint64 access', () => {
expect(accessor.getUint64WithDefault(1)).toEqual(Int64.fromInt(1)); expect(accessor.getUint64WithDefault(1)).toEqual(Int64.fromInt(1));
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = const accessor =
Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02)); Kernel.fromArrayBuffer(createArrayBuffer(0x08, 0x01, 0x08, 0x02));
expect(accessor.getUint64WithDefault(1)).toEqual(Int64.fromInt(2)); expect(accessor.getUint64WithDefault(1)).toEqual(Int64.fromInt(2));
@ -1996,7 +1996,7 @@ describe('Double access', () => {
}); });
it('decodes value from wire with multple values being present', () => { it('decodes value from wire with multiple values being present', () => {
const accessor = Kernel.fromArrayBuffer(createArrayBuffer( const accessor = Kernel.fromArrayBuffer(createArrayBuffer(
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x09, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x09, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xF0, 0xBF)); 0x00, 0x00, 0x00, 0x00, 0xF0, 0xBF));

@ -95,12 +95,12 @@ describe('skipField', () => {
it('skips group in group', () => { it('skips group in group', () => {
const buffer = createArrayBuffer( const buffer = createArrayBuffer(
0x0B, // start outter 0x0B, // start outer
0x10, 0x01, // field: 2, value: 1 0x10, 0x01, // field: 2, value: 1
0x0B, // start inner group 0x0B, // start inner group
0x10, 0x01, // payload inner group 0x10, 0x01, // payload inner group
0x0C, // stop inner group 0x0C, // stop inner group
0x0C // end outter 0x0C // end outer
); );
const bufferDecoder = BufferDecoder.fromArrayBuffer(buffer); const bufferDecoder = BufferDecoder.fromArrayBuffer(buffer);
bufferDecoder.setCursor(1); bufferDecoder.setCursor(1);

@ -0,0 +1,96 @@
FROM debian:jessie
# Install dependencies. We start with the basic ones require to build protoc
# and the C++ build
RUN apt-get update && apt-get install -y \
autoconf \
autotools-dev \
build-essential \
bzip2 \
ccache \
curl \
gcc \
git \
libc6 \
libc6-dbg \
libc6-dev \
libgtest-dev \
libtool \
make \
parallel \
time \
wget \
re2c \
sqlite3 \
vim \
libonig-dev \
libsqlite3-dev \
&& apt-get clean
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
php5 \
libcurl4-openssl-dev \
libgmp-dev \
libgmp3-dev \
libssl-dev \
libxml2-dev \
unzip \
zlib1g-dev \
pkg-config \
&& apt-get clean
# Install other dependencies
RUN ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
RUN wget https://ftp.gnu.org/gnu/bison/bison-3.0.1.tar.gz -O /var/local/bison-3.0.1.tar.gz
RUN cd /var/local \
&& tar -zxvf bison-3.0.1.tar.gz \
&& cd /var/local/bison-3.0.1 \
&& ./configure \
&& make \
&& make install
# Install composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
# Download php source code
RUN git clone https://github.com/php/php-src
# php 8.0
RUN cd php-src \
&& git checkout php-8.0.0alpha3 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--enable-mbstring \
--with-gmp \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-8.0 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--enable-mbstring \
--enable-maintainer-zts \
--with-gmp \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-8.0-zts \
&& make \
&& make install \
&& make clean
RUN wget -O phpunit https://phar.phpunit.de/phpunit-9.phar \
&& chmod +x phpunit \
&& cp phpunit /usr/local/php-8.0/bin \
&& mv phpunit /usr/local/php-8.0-zts/bin
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
valgrind \
&& apt-get clean

@ -0,0 +1,18 @@
#!/bin/bash
#
# This is the top-level script we give to Kokoro as the entry point for
# running the "pull request" project:
#
# This script selects a specific Dockerfile (for building a Docker image) and
# a script to run inside that image. Then we delegate to the general
# build_and_run_docker.sh script.
# Change to repo root
cd $(dirname $0)/../../..
export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput
export TEST_SET="php8.0_all"
./kokoro/linux/build_and_run_docker.sh

@ -0,0 +1,11 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/linux/php80/build.sh"
timeout_mins: 120
action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}

@ -0,0 +1,11 @@
# Config file for running tests in Kokoro
# Location of the build script in repository
build_file: "protobuf/kokoro/linux/php80/build.sh"
timeout_mins: 120
action {
define_artifacts {
regex: "**/sponge_log.xml"
}
}

@ -66,7 +66,7 @@ fi
# Install Tox # Install Tox
if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then
sudo pip install tox==2.4.1 sudo python3 -m pip install --upgrade pip tox
fi fi
## ##

@ -39,7 +39,7 @@ cp ${INPUT_ARTIFACTS_DIR}/build64/Release/protoc.exe protoc/windows_x64/protoc.e
mkdir -p protoc/linux_x86 mkdir -p protoc/linux_x86
mkdir -p protoc/linux_x64 mkdir -p protoc/linux_x64
# Because of maven unrelated reasonse the linux protoc binaries have a dummy .exe extension. # Because of maven unrelated reasonse the linux protoc binaries have a dummy .exe extension.
# For the Google.Protobuf.Tools nuget, we don't want that expection, so we just remove it. # For the Google.Protobuf.Tools nuget, we don't want that exception, so we just remove it.
cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_32/protoc.exe protoc/linux_x86/protoc cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_32/protoc.exe protoc/linux_x86/protoc
cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_64/protoc.exe protoc/linux_x64/protoc cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_64/protoc.exe protoc/linux_x64/protoc

@ -1,6 +1,25 @@
# Define custom utilities # Define custom utilities
# Test for OSX with [ -n "$IS_OSX" ] # Test for OSX with [ -n "$IS_OSX" ]
function remove_travis_ve_pip {
# Removing the system virtualenv or pip can be very problematic for
# macOS on Kokoro, so just leave them be.
:;
}
function install_pip {
check_python
PIP_CMD="sudo $PYTHON_EXE -m pip${pip_args:+ $pip_args}"
$PIP_CMD install --upgrade pip
}
function install_virtualenv {
check_python
check_pip
$PIP_CMD install --upgrade virtualenv
VIRTUALENV_CMD="$PYTHON_EXE -m virtualenv"
}
function pre_build { function pre_build {
# Any stuff that you need to do before you start building the wheels # Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository. # Runs in the root directory of this repository.

@ -0,0 +1,90 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
objc_library(
name = "objectivec",
hdrs = [
"GPBAny.pbobjc.h",
"GPBApi.pbobjc.h",
"GPBDuration.pbobjc.h",
"GPBEmpty.pbobjc.h",
"GPBFieldMask.pbobjc.h",
"GPBSourceContext.pbobjc.h",
"GPBStruct.pbobjc.h",
"GPBTimestamp.pbobjc.h",
"GPBType.pbobjc.h",
"GPBWrappers.pbobjc.h",
"GPBArray.h",
"GPBBootstrap.h",
"GPBCodedInputStream.h",
"GPBCodedOutputStream.h",
"GPBDescriptor.h",
"GPBDictionary.h",
"GPBExtensionInternals.h",
"GPBExtensionRegistry.h",
"GPBMessage.h",
"GPBProtocolBuffers.h",
"GPBProtocolBuffers_RuntimeSupport.h",
"GPBRootObject.h",
"GPBRuntimeTypes.h",
"GPBUnknownField.h",
"GPBUnknownFieldSet.h",
"GPBUtilities.h",
"GPBWellKnownTypes.h",
"GPBWireFormat.h",
"google/protobuf/Any.pbobjc.h",
"google/protobuf/Api.pbobjc.h",
"google/protobuf/Duration.pbobjc.h",
"google/protobuf/Empty.pbobjc.h",
"google/protobuf/FieldMask.pbobjc.h",
"google/protobuf/SourceContext.pbobjc.h",
"google/protobuf/Struct.pbobjc.h",
"google/protobuf/Timestamp.pbobjc.h",
"google/protobuf/Type.pbobjc.h",
"google/protobuf/Wrappers.pbobjc.h",
# Package private headers, but exposed because the generated sources
# need to use them.
"GPBArray_PackagePrivate.h",
"GPBCodedInputStream_PackagePrivate.h",
"GPBCodedOutputStream_PackagePrivate.h",
"GPBDescriptor_PackagePrivate.h",
"GPBDictionary_PackagePrivate.h",
"GPBMessage_PackagePrivate.h",
"GPBRootObject_PackagePrivate.h",
"GPBUnknownFieldSet_PackagePrivate.h",
"GPBUnknownField_PackagePrivate.h",
"GPBUtilities_PackagePrivate.h",
],
copts = [
"-Wno-vla",
],
includes = [
".",
],
non_arc_srcs = [
"GPBAny.pbobjc.m",
"GPBApi.pbobjc.m",
"GPBDuration.pbobjc.m",
"GPBEmpty.pbobjc.m",
"GPBFieldMask.pbobjc.m",
"GPBSourceContext.pbobjc.m",
"GPBStruct.pbobjc.m",
"GPBTimestamp.pbobjc.m",
"GPBType.pbobjc.m",
"GPBWrappers.pbobjc.m",
"GPBArray.m",
"GPBCodedInputStream.m",
"GPBCodedOutputStream.m",
"GPBDescriptor.m",
"GPBDictionary.m",
"GPBExtensionInternals.m",
"GPBExtensionRegistry.m",
"GPBMessage.m",
"GPBRootObject.m",
"GPBUnknownField.m",
"GPBUnknownFieldSet.m",
"GPBUtilities.m",
"GPBWellKnownTypes.m",
"GPBWireFormat.m",
],
visibility = ["//visibility:public"],
)

@ -95,7 +95,7 @@ cd "${SRCROOT}/.."
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
RUN_PROTOC=no RUN_PROTOC=no
# Check to if all the output files exist (incase a new one got added). # Check to if all the output files exist (in case a new one got added).
for PROTO_FILE in "${CORE_PROTO_FILES[@]}" "${OBJC_TEST_PROTO_FILES[@]}"; do for PROTO_FILE in "${CORE_PROTO_FILES[@]}" "${OBJC_TEST_PROTO_FILES[@]}"; do
DIR=${PROTO_FILE%/*} DIR=${PROTO_FILE%/*}

@ -285,7 +285,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit -destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
# 10.x also seems to often fail running destinations in parallel (with # 10.x also seems to often fail running destinations in parallel (with
# 32bit one include atleast) # 32bit one include at least)
-disable-concurrent-destination-testing -disable-concurrent-destination-testing
) )
;; ;;

@ -645,7 +645,7 @@ def main(args):
opts, extra_args = parser.parse_args(args) opts, extra_args = parser.parse_args(args)
if not extra_args: if not extra_args:
parser.error('Need atleast one file to process') parser.error('Need at least one file to process')
result = 0 result = 0
for a_path in extra_args: for a_path in extra_args:

@ -361,8 +361,8 @@ static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
if (existingValue) { if (existingValue) {
message = [existingValue retain]; message = [existingValue retain];
} else { } else {
GPBDescriptor *decriptor = [extension.msgClass descriptor]; GPBDescriptor *descriptor = [extension.msgClass descriptor];
message = [[decriptor.messageClass alloc] init]; message = [[descriptor.messageClass alloc] init];
} }
if (description->dataType == GPBDataTypeGroup) { if (description->dataType == GPBDataTypeGroup) {

@ -3286,7 +3286,7 @@ static void ResolveIvarSet(__unsafe_unretained GPBFieldDescriptor *field,
// if a sub message in a field has extensions, the issue still exists. A // if a sub message in a field has extensions, the issue still exists. A
// recursive check could be done here (like the work in // recursive check could be done here (like the work in
// GPBMessageDropUnknownFieldsRecursively()), but that has the potential to // GPBMessageDropUnknownFieldsRecursively()), but that has the potential to
// be expensive and could slow down serialization in DEBUG enought to cause // be expensive and could slow down serialization in DEBUG enough to cause
// developers other problems. // developers other problems.
NSLog(@"Warning: writing out a GPBMessage (%@) via NSCoding and it" NSLog(@"Warning: writing out a GPBMessage (%@) via NSCoding and it"
@" has %ld extensions; when read back in, those fields will be" @" has %ld extensions; when read back in, those fields will be"

@ -107,7 +107,16 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* .setNanos((int) ((millis % 1000) * 1000000)).build(); * .setNanos((int) ((millis % 1000) * 1000000)).build();
* *
* *
* Example 5: Compute Timestamp from current time in Python. * Example 5: Compute Timestamp from Java `Instant.now()`.
*
* Instant now = Instant.now();
*
* Timestamp timestamp =
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
* .setNanos(now.getNano()).build();
*
*
* Example 6: Compute Timestamp from current time in Python.
* *
* timestamp = Timestamp() * timestamp = Timestamp()
* timestamp.GetCurrentTime() * timestamp.GetCurrentTime()

@ -219,7 +219,7 @@ void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion) {
// Library is too old for headers. // Library is too old for headers.
[NSException raise:NSInternalInconsistencyException [NSException raise:NSInternalInconsistencyException
format:@"Linked to ProtocolBuffer runtime version %d," format:@"Linked to ProtocolBuffer runtime version %d,"
@" but code compiled needing atleast %d!", @" but code compiled needing at least %d!",
GOOGLE_PROTOBUF_OBJC_VERSION, objcRuntimeVersion]; GOOGLE_PROTOBUF_OBJC_VERSION, objcRuntimeVersion];
} }
if (objcRuntimeVersion < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) { if (objcRuntimeVersion < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) {

@ -304,7 +304,7 @@ void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self,
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel); const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel);
// Helper for text format name encoding. // Helper for text format name encoding.
// decodeData is the data describing the sepecial decodes. // decodeData is the data describing the special decodes.
// key and inputString are the input that needs decoding. // key and inputString are the input that needs decoding.
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
NSString *inputString); NSString *inputString);

@ -168,7 +168,7 @@ supported keys are:
Any number of files can be listed for a framework, just separate them with Any number of files can be listed for a framework, just separate them with
commas. commas.
There can be multiple lines listing the same frameworkName incase it has a There can be multiple lines listing the same frameworkName in case it has a
lot of proto files included in it; and having multiple lines makes things lot of proto files included in it; and having multiple lines makes things
easier to read. easier to read.

@ -90,7 +90,7 @@ cleanup() {
echo "Cleaning up..." echo "Cleaning up..."
# Generally don't let things fail, and eat common stdout, but let stderr show # Generally don't let things fail, and eat common stdout, but let stderr show
# incase something does hiccup. # in case something does hiccup.
xcodebuild -workspace "${TEST_NAME}.xcworkspace" -scheme "${TEST_NAME}" clean > /dev/null || true xcodebuild -workspace "${TEST_NAME}.xcworkspace" -scheme "${TEST_NAME}" clean > /dev/null || true
pod deintegrate > /dev/null || true pod deintegrate > /dev/null || true
# Flush the cache so nothing is left behind. # Flush the cache so nothing is left behind.

@ -422,7 +422,7 @@
- (void)testBOMWithinStrings { - (void)testBOMWithinStrings {
// We've seen servers that end up with BOMs within strings (not always at the // We've seen servers that end up with BOMs within strings (not always at the
// start, and sometimes in multiple places), make sure they always parse // start, and sometimes in multiple places), make sure they always parse
// correctly. (Again, this is inpart incase a custom string class is ever // correctly. (Again, this is inpart in case a custom string class is ever
// used again.) // used again.)
const char* strs[] = { const char* strs[] = {
"\xEF\xBB\xBF String with BOM", "\xEF\xBB\xBF String with BOM",

@ -400,7 +400,7 @@
- (void)testWriteStringsWithZeroChar { - (void)testWriteStringsWithZeroChar {
// Unicode allows `\0` as a character, and NSString is a class cluster, so // Unicode allows `\0` as a character, and NSString is a class cluster, so
// there are a few different classes that could end up beind a given string. // there are a few different classes that could end up behind a given string.
// Historically, we've seen differences based on constant strings in code and // Historically, we've seen differences based on constant strings in code and
// strings built via the NSString apis. So this round trips them to ensure // strings built via the NSString apis. So this round trips them to ensure
// they are acting as expected. // they are acting as expected.

@ -94,11 +94,12 @@ static void RepeatedField_destructor(zend_object* obj) {
zend_object_std_dtor(&intern->std); zend_object_std_dtor(&intern->std);
} }
static HashTable *RepeatedField_GetProperties(zval *object TSRMLS_DC) { static HashTable *RepeatedField_GetProperties(PROTO_VAL *object) {
return NULL; // We do not have a properties table. return NULL; // We do not have a properties table.
} }
static zval *RepeatedField_GetPropertyPtrPtr(zval *object, zval *member, static zval *RepeatedField_GetPropertyPtrPtr(PROTO_VAL *object,
PROTO_STR *member,
int type, void **cache_slot) { int type, void **cache_slot) {
return NULL; // We don't offer direct references to our properties. return NULL; // We don't offer direct references to our properties.
} }
@ -392,6 +393,15 @@ PHP_METHOD(RepeatedField, getIterator) {
RETURN_ZVAL(&ret, 0, 1); RETURN_ZVAL(&ret, 0, 1);
} }
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 1)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, class)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_append, 0, 0, 1)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1) ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index) ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
@ -405,8 +415,8 @@ ZEND_BEGIN_ARG_INFO(arginfo_void, 0)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
static zend_function_entry repeated_field_methods[] = { static zend_function_entry repeated_field_methods[] = {
PHP_ME(RepeatedField, __construct, NULL, ZEND_ACC_PUBLIC) PHP_ME(RepeatedField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, append, NULL, ZEND_ACC_PUBLIC) PHP_ME(RepeatedField, append, arginfo_append, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(RepeatedField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(RepeatedField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC) PHP_ME(RepeatedField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)

@ -92,20 +92,55 @@ PHP_METHOD(Util, checkRepeatedField) {
RETURN_ZVAL(val, 1, 0); RETURN_ZVAL(val, 1, 0);
} }
ZEND_BEGIN_ARG_INFO_EX(arginfo_checkPrimitive, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_checkMessage, 0, 0, 2)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, class)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_checkMapField, 0, 0, 3)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, key_type)
ZEND_ARG_INFO(0, value_type)
ZEND_ARG_INFO(0, value_class)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_checkRepeatedField, 0, 0, 2)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, class)
ZEND_END_ARG_INFO()
static zend_function_entry util_methods[] = { static zend_function_entry util_methods[] = {
PHP_ME(Util, checkInt32, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkInt32, arginfo_checkPrimitive,
PHP_ME(Util, checkUint32, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkInt64, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkUint32, arginfo_checkPrimitive,
PHP_ME(Util, checkUint64, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkEnum, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkInt64, arginfo_checkPrimitive,
PHP_ME(Util, checkFloat, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkDouble, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkUint64, arginfo_checkPrimitive,
PHP_ME(Util, checkBool, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkString, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkEnum, arginfo_checkPrimitive,
PHP_ME(Util, checkBytes, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkFloat, arginfo_checkPrimitive,
PHP_ME(Util, checkMapField, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkRepeatedField, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Util, checkDouble, arginfo_checkPrimitive,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkBool, arginfo_checkPrimitive,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkString, arginfo_checkPrimitive,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkBytes, arginfo_checkPrimitive,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkMessage, arginfo_checkMessage,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkMapField, arginfo_checkMapField,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Util, checkRepeatedField, arginfo_checkRepeatedField,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END ZEND_FE_END
}; };

@ -180,8 +180,7 @@ PHP_METHOD(EnumDescriptor, getValue) {
zend_long index; zend_long index;
zval ret; zval ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
FAILURE) {
zend_error(E_USER_ERROR, "Expect integer for index.\n"); zend_error(E_USER_ERROR, "Expect integer for index.\n");
return; return;
} }
@ -284,8 +283,7 @@ PHP_METHOD(OneofDescriptor, getField) {
zend_long index; zend_long index;
zval ret; zval ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
FAILURE) {
zend_error(E_USER_ERROR, "Expect integer for index.\n"); zend_error(E_USER_ERROR, "Expect integer for index.\n");
return; return;
} }
@ -615,8 +613,7 @@ PHP_METHOD(Descriptor, getField) {
zval ret; zval ret;
zend_long index; zend_long index;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
FAILURE) {
zend_error(E_USER_ERROR, "Expect integer for index.\n"); zend_error(E_USER_ERROR, "Expect integer for index.\n");
return; return;
} }
@ -658,8 +655,7 @@ PHP_METHOD(Descriptor, getOneofDecl) {
zend_long index; zend_long index;
zval ret; zval ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
FAILURE) {
zend_error(E_USER_ERROR, "Expect integer for index.\n"); zend_error(E_USER_ERROR, "Expect integer for index.\n");
return; return;
} }
@ -799,8 +795,8 @@ PHP_METHOD(DescriptorPool, getDescriptorByClassName) {
zend_string *str; zend_string *str;
zval ret; zval ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &classname, if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &classname, &classname_len) ==
&classname_len) == FAILURE) { FAILURE) {
return; return;
} }
@ -828,8 +824,8 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) {
zend_string *str; zend_string *str;
zval ret; zval ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &classname, if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &classname, &classname_len) ==
&classname_len) == FAILURE) { FAILURE) {
return; return;
} }
@ -856,8 +852,8 @@ PHP_METHOD(DescriptorPool, getDescriptorByProtoName) {
zend_long protoname_len; zend_long protoname_len;
const upb_msgdef *m; const upb_msgdef *m;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &protoname, if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &protoname, &protoname_len) ==
&protoname_len) == FAILURE) { FAILURE) {
return; return;
} }

@ -90,12 +90,12 @@ static void MapField_destructor(zend_object* obj) {
zend_object_std_dtor(&intern->std); zend_object_std_dtor(&intern->std);
} }
static zval *Map_GetPropertyPtrPtr(zval *object, zval *member, int type, static zval *Map_GetPropertyPtrPtr(PROTO_VAL *object, PROTO_STR *member,
void **cache_slot) { int type, void **cache_slot) {
return NULL; // We don't offer direct references to our properties. return NULL; // We don't offer direct references to our properties.
} }
static HashTable *map_get_properties(zval *object TSRMLS_DC) { static HashTable *Map_GetProperties(PROTO_VAL *object) {
return NULL; // We do not have a properties table. return NULL; // We do not have a properties table.
} }
@ -378,6 +378,12 @@ PHP_METHOD(MapField, getIterator) {
RETURN_ZVAL(&ret, 0, 1); RETURN_ZVAL(&ret, 0, 1);
} }
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2)
ZEND_ARG_INFO(0, key_type)
ZEND_ARG_INFO(0, value_type)
ZEND_ARG_INFO(0, value_class)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1) ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index) ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
@ -391,7 +397,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_void, 0)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
static zend_function_entry MapField_methods[] = { static zend_function_entry MapField_methods[] = {
PHP_ME(MapField, __construct, NULL, ZEND_ACC_PUBLIC) PHP_ME(MapField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(MapField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(MapField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC) PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
@ -572,7 +578,7 @@ void Map_ModuleInit() {
h = &MapField_object_handlers; h = &MapField_object_handlers;
memcpy(h, &std_object_handlers, sizeof(zend_object_handlers)); memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
h->dtor_obj = MapField_destructor; h->dtor_obj = MapField_destructor;
h->get_properties = map_get_properties; h->get_properties = Map_GetProperties;
h->get_property_ptr_ptr = Map_GetPropertyPtrPtr; h->get_property_ptr_ptr = Map_GetPropertyPtrPtr;
INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\MapFieldIter", INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\MapFieldIter",

@ -95,10 +95,10 @@ static void Message_dtor(zend_object* obj) {
* *
* Helper function to look up a field given a member name (as a string). * Helper function to look up a field given a member name (as a string).
*/ */
static const upb_fielddef *get_field(Message *msg, zval *member) { static const upb_fielddef *get_field(Message *msg, PROTO_STR *member) {
const upb_msgdef *m = msg->desc->msgdef; const upb_msgdef *m = msg->desc->msgdef;
const upb_fielddef *f = const upb_fielddef *f =
upb_msgdef_ntof(m, Z_STRVAL_P(member), Z_STRLEN_P(member)); upb_msgdef_ntof(m, PROTO_STRVAL_P(member), PROTO_STRLEN_P(member));
if (!f) { if (!f) {
zend_throw_exception_ex(NULL, 0, "No such property %s.", zend_throw_exception_ex(NULL, 0, "No such property %s.",
@ -108,6 +108,78 @@ static const upb_fielddef *get_field(Message *msg, zval *member) {
return f; return f;
} }
/**
* Message_has_property()
*
* Object handler for testing whether a property exists. Called when PHP code
* does any of:
*
* isset($message->foobar);
* property_exists($message->foobar);
*
* Note that all properties of generated messages are private, so this should
* only be possible to invoke from generated code, which has accessors like this
* (if the field has presence):
*
* public function hasOptionalInt32()
* {
* return isset($this->optional_int32);
* }
*/
static int Message_has_property(PROTO_VAL *obj, PROTO_STR *member,
int has_set_exists,
void **cache_slot) {
Message* intern = PROTO_MSG_P(obj);
const upb_fielddef *f = get_field(intern, member);
if (!f) return 0;
if (!upb_fielddef_haspresence(f)) {
zend_throw_exception_ex(
NULL, 0,
"Cannot call isset() on field %s which does not have presence.",
ZSTR_VAL(intern->desc->class_entry->name));
return 0;
}
return upb_msg_has(intern->msg, f);
}
/**
* Message_unset_property()
*
* Object handler for unsetting a property. Called when PHP code calls:
* does any of:
*
* unset($message->foobar);
*
* Note that all properties of generated messages are private, so this should
* only be possible to invoke from generated code, which has accessors like this
* (if the field has presence):
*
* public function clearOptionalInt32()
* {
* unset($this->optional_int32);
* }
*/
static void Message_unset_property(PROTO_VAL *obj, PROTO_STR *member,
void **cache_slot) {
Message* intern = PROTO_MSG_P(obj);
const upb_fielddef *f = get_field(intern, member);
if (!f) return;
if (!upb_fielddef_haspresence(f)) {
zend_throw_exception_ex(
NULL, 0,
"Cannot call unset() on field %s which does not have presence.",
ZSTR_VAL(intern->desc->class_entry->name));
return;
}
upb_msg_clearfield(intern->msg, f);
}
/** /**
* Message_read_property() * Message_read_property()
* *
@ -126,9 +198,9 @@ static const upb_fielddef *get_field(Message *msg, zval *member) {
* We lookup the field and return the scalar, RepeatedField, or MapField for * We lookup the field and return the scalar, RepeatedField, or MapField for
* this field. * this field.
*/ */
static zval *Message_read_property(zval *obj, zval *member, int type, static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member,
void **cache_slot, zval *rv) { int type, void **cache_slot, zval *rv) {
Message* intern = (Message*)Z_OBJ_P(obj); Message* intern = PROTO_MSG_P(obj);
const upb_fielddef *f = get_field(intern, member); const upb_fielddef *f = get_field(intern, member);
upb_arena *arena = Arena_Get(&intern->arena); upb_arena *arena = Arena_Get(&intern->arena);
@ -170,29 +242,41 @@ static zval *Message_read_property(zval *obj, zval *member, int type,
* The C extension version of checkInt32() doesn't actually check anything, so * The C extension version of checkInt32() doesn't actually check anything, so
* we perform all checking and conversion in this function. * we perform all checking and conversion in this function.
*/ */
static void Message_write_property(zval *obj, zval *member, zval *val, static PROTO_RETURN_VAL Message_write_property(
void **cache_slot) { PROTO_VAL *obj, PROTO_STR *member, zval *val, void **cache_slot) {
Message* intern = (Message*)Z_OBJ_P(obj); Message* intern = PROTO_MSG_P(obj);
const upb_fielddef *f = get_field(intern, member); const upb_fielddef *f = get_field(intern, member);
upb_arena *arena = Arena_Get(&intern->arena); upb_arena *arena = Arena_Get(&intern->arena);
upb_msgval msgval; upb_msgval msgval;
if (!f) return; if (!f) goto error;
if (upb_fielddef_ismap(f)) { if (upb_fielddef_ismap(f)) {
msgval.map_val = MapField_GetUpbMap(val, f, arena); msgval.map_val = MapField_GetUpbMap(val, f, arena);
if (!msgval.map_val) return; if (!msgval.map_val) goto error;
} else if (upb_fielddef_isseq(f)) { } else if (upb_fielddef_isseq(f)) {
msgval.array_val = RepeatedField_GetUpbArray(val, f, arena); msgval.array_val = RepeatedField_GetUpbArray(val, f, arena);
if (!msgval.array_val) return; if (!msgval.array_val) goto error;
} else { } else {
upb_fieldtype_t type = upb_fielddef_type(f); upb_fieldtype_t type = upb_fielddef_type(f);
const Descriptor *subdesc = Descriptor_GetFromFieldDef(f); const Descriptor *subdesc = Descriptor_GetFromFieldDef(f);
bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena); bool ok = Convert_PhpToUpb(val, &msgval, type, subdesc, arena);
if (!ok) return; if (!ok) goto error;
} }
upb_msg_set(intern->msg, f, msgval, arena); upb_msg_set(intern->msg, f, msgval, arena);
#if PHP_VERSION_ID < 704000
return;
#else
return val;
#endif
error:
#if PHP_VERSION_ID < 704000
return;
#else
return &EG(error_zval);
#endif
} }
/** /**
@ -202,7 +286,8 @@ static void Message_write_property(zval *obj, zval *member, zval *val,
* reference to our internal properties. We don't support this, so we return * reference to our internal properties. We don't support this, so we return
* NULL. * NULL.
*/ */
static zval *Message_get_property_ptr_ptr(zval *object, zval *member, int type, static zval *Message_get_property_ptr_ptr(PROTO_VAL *object, PROTO_STR *member,
int type,
void **cache_slot) { void **cache_slot) {
return NULL; // We do not have a properties table. return NULL; // We do not have a properties table.
} }
@ -213,7 +298,7 @@ static zval *Message_get_property_ptr_ptr(zval *object, zval *member, int type,
* Object handler for the get_properties event in PHP. This returns a HashTable * Object handler for the get_properties event in PHP. This returns a HashTable
* of our internal properties. We don't support this, so we return NULL. * of our internal properties. We don't support this, so we return NULL.
*/ */
static HashTable* Message_get_properties(zval* object TSRMLS_DC) { static HashTable *Message_get_properties(PROTO_VAL *object) {
return NULL; // We don't offer direct references to our properties. return NULL; // We don't offer direct references to our properties.
} }
@ -549,7 +634,7 @@ PHP_METHOD(Message, serializeToJsonString) {
zend_bool preserve_proto_fieldnames = false; zend_bool preserve_proto_fieldnames = false;
upb_status status; upb_status status;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b",
&preserve_proto_fieldnames) == FAILURE) { &preserve_proto_fieldnames) == FAILURE) {
return; return;
} }
@ -800,20 +885,36 @@ PHP_METHOD(Message, writeOneof) {
upb_msg_set(intern->msg, f, msgval, arena); upb_msg_set(intern->msg, f, msgval, arena);
} }
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_mergeFrom, 0, 0, 1)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_read, 0, 0, 1)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_write, 0, 0, 2)
ZEND_ARG_INFO(0, field)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
static zend_function_entry Message_methods[] = { static zend_function_entry Message_methods[] = {
PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, clear, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Message, discardUnknownFields, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, discardUnknownFields, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Message, serializeToString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, serializeToString, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFromString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFromString, arginfo_mergeFrom, ZEND_ACC_PUBLIC)
PHP_ME(Message, serializeToJsonString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, serializeToJsonString, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFromJsonString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFromJsonString, arginfo_mergeFrom, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFrom, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFrom, arginfo_mergeFrom, ZEND_ACC_PUBLIC)
PHP_ME(Message, readWrapperValue, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, readWrapperValue, arginfo_read, ZEND_ACC_PROTECTED)
PHP_ME(Message, writeWrapperValue, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, writeWrapperValue, arginfo_write, ZEND_ACC_PROTECTED)
PHP_ME(Message, readOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, readOneof, arginfo_read, ZEND_ACC_PROTECTED)
PHP_ME(Message, writeOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, writeOneof, arginfo_write, ZEND_ACC_PROTECTED)
PHP_ME(Message, whichOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, whichOneof, arginfo_read, ZEND_ACC_PROTECTED)
PHP_ME(Message, __construct, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, __construct, arginfo_void, ZEND_ACC_PROTECTED)
ZEND_FE_END ZEND_FE_END
}; };
@ -836,6 +937,8 @@ void Message_ModuleInit() {
h->dtor_obj = Message_dtor; h->dtor_obj = Message_dtor;
h->read_property = Message_read_property; h->read_property = Message_read_property;
h->write_property = Message_write_property; h->write_property = Message_write_property;
h->has_property = Message_has_property;
h->unset_property = Message_unset_property;
h->get_properties = Message_get_properties; h->get_properties = Message_get_properties;
h->get_property_ptr_ptr = Message_get_property_ptr_ptr; h->get_property_ptr_ptr = Message_get_property_ptr_ptr;
} }

@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email> <email>protobuf-opensource@google.com</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2020-06-01</date> <date>2020-08-14</date>
<time>01:14:10</time> <time>14:07:59</time>
<version> <version>
<release>3.12.3</release> <release>3.13.0</release>
<api>3.12.3</api> <api>3.13.0</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -51,7 +51,7 @@
<dependencies> <dependencies>
<required> <required>
<php> <php>
<min>5.5.9</min> <min>7.0.0</min>
</php> </php>
<pearinstaller> <pearinstaller>
<min>1.4.0</min> <min>1.4.0</min>
@ -619,5 +619,61 @@ G A release.
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license> <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes> <notes>GA release.</notes>
</release> </release>
<release>
<version>
<release>3.13.0RC1</release>
<api>3.13.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2020-08-05</date>
<time>11:21:41</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.13.0RC2</release>
<api>3.13.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2020-08-05</date>
<time>11:22:52</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.13.0RC3</release>
<api>3.13.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2020-08-12</date>
<time>13:46:54</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
<release>
<version>
<release>3.13.0</release>
<api>3.13.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2020-08-14</date>
<time>14:07:59</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>GA release.</notes>
</release>
</changelog> </changelog>
</package> </package>

@ -174,6 +174,11 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
#else #else
#define UPB_INFINITY (1.0 / 0.0) #define UPB_INFINITY (1.0 / 0.0)
#endif #endif
#ifdef NAN
#define UPB_NAN NAN
#else
#define UPB_NAN (0.0 / 0.0)
#endif
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
@ -235,11 +240,13 @@ static const unsigned fixed64_ok = (1 << UPB_DTYPE_DOUBLE) |
(1 << UPB_DTYPE_SFIXED64); (1 << UPB_DTYPE_SFIXED64);
/* Op: an action to be performed for a wire-type/field-type combination. */ /* Op: an action to be performed for a wire-type/field-type combination. */
#define OP_SCALAR_LG2(n) (n) #define OP_SCALAR_LG2(n) (n) /* n in [0, 2, 3] => op in [0, 2, 3] */
#define OP_FIXPCK_LG2(n) (n + 4)
#define OP_VARPCK_LG2(n) (n + 8)
#define OP_STRING 4 #define OP_STRING 4
#define OP_SUBMSG 5 #define OP_BYTES 5
#define OP_SUBMSG 6
/* Ops above are scalar-only. Repeated fields can use any op. */
#define OP_FIXPCK_LG2(n) (n + 5) /* n in [2, 3] => op in [7, 8] */
#define OP_VARPCK_LG2(n) (n + 9) /* n in [0, 2, 3] => op in [9, 11, 12] */
static const int8_t varint_ops[19] = { static const int8_t varint_ops[19] = {
-1, /* field not found */ -1, /* field not found */
@ -277,7 +284,7 @@ static const int8_t delim_ops[37] = {
OP_STRING, /* STRING */ OP_STRING, /* STRING */
-1, /* GROUP */ -1, /* GROUP */
OP_SUBMSG, /* MESSAGE */ OP_SUBMSG, /* MESSAGE */
OP_STRING, /* BYTES */ OP_BYTES, /* BYTES */
-1, /* UINT32 */ -1, /* UINT32 */
-1, /* ENUM */ -1, /* ENUM */
-1, /* SFIXED32 */ -1, /* SFIXED32 */
@ -296,7 +303,7 @@ static const int8_t delim_ops[37] = {
OP_STRING, /* REPEATED STRING */ OP_STRING, /* REPEATED STRING */
OP_SUBMSG, /* REPEATED GROUP */ OP_SUBMSG, /* REPEATED GROUP */
OP_SUBMSG, /* REPEATED MESSAGE */ OP_SUBMSG, /* REPEATED MESSAGE */
OP_STRING, /* REPEATED BYTES */ OP_BYTES, /* REPEATED BYTES */
OP_VARPCK_LG2(2), /* REPEATED UINT32 */ OP_VARPCK_LG2(2), /* REPEATED UINT32 */
OP_VARPCK_LG2(2), /* REPEATED ENUM */ OP_VARPCK_LG2(2), /* REPEATED ENUM */
OP_FIXPCK_LG2(2), /* REPEATED SFIXED32 */ OP_FIXPCK_LG2(2), /* REPEATED SFIXED32 */
@ -328,6 +335,40 @@ static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg,
UPB_NORETURN static void decode_err(upb_decstate *d) { longjmp(d->err, 1); } UPB_NORETURN static void decode_err(upb_decstate *d) { longjmp(d->err, 1); }
void decode_verifyutf8(upb_decstate *d, const char *buf, int len) {
static const uint8_t utf8_offset[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,
};
int i, j;
uint8_t offset;
i = 0;
while (i < len) {
offset = utf8_offset[(uint8_t)buf[i]];
if (offset == 0 || i + offset > len) {
decode_err(d);
}
for (j = i + 1; j < i + offset; j++) {
if ((buf[j] & 0xc0) != 0x80) {
decode_err(d);
}
}
i += offset;
}
if (i != len) decode_err(d);
}
static bool decode_reserve(upb_decstate *d, upb_array *arr, size_t elem) { static bool decode_reserve(upb_decstate *d, upb_array *arr, size_t elem) {
bool need_realloc = arr->size - arr->len < elem; bool need_realloc = arr->size - arr->len < elem;
if (need_realloc && !_upb_array_realloc(arr, arr->len + elem, d->arena)) { if (need_realloc && !_upb_array_realloc(arr, arr->len + elem, d->arena)) {
@ -395,7 +436,7 @@ static void decode_munge(int type, wireval *val) {
static const upb_msglayout_field *upb_find_field(const upb_msglayout *l, static const upb_msglayout_field *upb_find_field(const upb_msglayout *l,
uint32_t field_number) { uint32_t field_number) {
static upb_msglayout_field none = {0}; static upb_msglayout_field none = {0, 0, 0, 0, 0, 0};
/* Lots of optimization opportunities here. */ /* Lots of optimization opportunities here. */
int i; int i;
@ -473,7 +514,10 @@ static const char *decode_toarray(upb_decstate *d, const char *ptr,
memcpy(mem, &val, 1 << op); memcpy(mem, &val, 1 << op);
return ptr; return ptr;
case OP_STRING: case OP_STRING:
/* Append string. */ decode_verifyutf8(d, val.str_val.data, val.str_val.size);
/* Fallthrough. */
case OP_BYTES:
/* Append bytes. */
mem = mem =
UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(upb_strview), void); UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(upb_strview), void);
arr->len++; arr->len++;
@ -607,6 +651,9 @@ static const char *decode_tomsg(upb_decstate *d, const char *ptr, upb_msg *msg,
break; break;
} }
case OP_STRING: case OP_STRING:
decode_verifyutf8(d, val.str_val.data, val.str_val.size);
/* Fallthrough. */
case OP_BYTES:
memcpy(mem, &val, sizeof(upb_strview)); memcpy(mem, &val, sizeof(upb_strview));
break; break;
case OP_SCALAR_LG2(3): case OP_SCALAR_LG2(3):
@ -1892,17 +1939,6 @@ bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val) {
return success; return success;
} }
bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a) {
return upb_inttable_insert2(t, upb_inttable_count(t), val, a);
}
upb_value upb_inttable_pop(upb_inttable *t) {
upb_value val;
bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val);
UPB_ASSERT(ok);
return val;
}
bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
upb_alloc *a) { upb_alloc *a) {
return upb_inttable_insert2(t, (uintptr_t)key, val, a); return upb_inttable_insert2(t, (uintptr_t)key, val, a);
@ -2328,15 +2364,28 @@ struct upb_arena {
static const size_t memblock_reserve = UPB_ALIGN_UP(sizeof(mem_block), 16); static const size_t memblock_reserve = UPB_ALIGN_UP(sizeof(mem_block), 16);
static upb_arena *arena_findroot(upb_arena *a) {
/* Path splitting keeps time complexity down, see:
* https://en.wikipedia.org/wiki/Disjoint-set_data_structure */
while (a->parent != a) {
upb_arena *next = a->parent;
a->parent = next->parent;
a = next;
}
return a;
}
static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size) { static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size) {
mem_block *block = ptr; mem_block *block = ptr;
upb_arena *root = arena_findroot(a);
block->next = a->freelist; /* The block is for arena |a|, but should appear in the freelist of |root|. */
block->next = root->freelist;
block->size = (uint32_t)size; block->size = (uint32_t)size;
block->cleanups = 0; block->cleanups = 0;
a->freelist = block; root->freelist = block;
a->last_size = block->size; a->last_size = block->size;
if (!a->freelist_tail) a->freelist_tail = block; if (!root->freelist_tail) root->freelist_tail = block;
a->head.ptr = UPB_PTR_AT(block, memblock_reserve, char); a->head.ptr = UPB_PTR_AT(block, memblock_reserve, char);
a->head.end = UPB_PTR_AT(block, size, char); a->head.end = UPB_PTR_AT(block, size, char);
@ -2371,17 +2420,6 @@ static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize,
return upb_arena_realloc(a, ptr, oldsize, size); return upb_arena_realloc(a, ptr, oldsize, size);
} }
static upb_arena *arena_findroot(upb_arena *a) {
/* Path splitting keeps time complexity down, see:
* https://en.wikipedia.org/wiki/Disjoint-set_data_structure */
while (a->parent != a) {
upb_arena *next = a->parent;
a->parent = next->parent;
a = next;
}
return a;
}
/* Public Arena API ***********************************************************/ /* Public Arena API ***********************************************************/
upb_arena *arena_initslow(void *mem, size_t n, upb_alloc *alloc) { upb_arena *arena_initslow(void *mem, size_t n, upb_alloc *alloc) {
@ -2540,9 +2578,9 @@ static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6]
}; };
static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = { static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = {
{1, UPB_SIZE(4, 8), 1, 0, 9, 1}, {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
{2, UPB_SIZE(12, 24), 2, 0, 9, 1}, {2, UPB_SIZE(12, 24), 2, 0, 12, 1},
{3, UPB_SIZE(36, 72), 0, 0, 9, 3}, {3, UPB_SIZE(36, 72), 0, 0, 12, 3},
{4, UPB_SIZE(40, 80), 0, 0, 11, 3}, {4, UPB_SIZE(40, 80), 0, 0, 11, 3},
{5, UPB_SIZE(44, 88), 0, 1, 11, 3}, {5, UPB_SIZE(44, 88), 0, 1, 11, 3},
{6, UPB_SIZE(48, 96), 0, 4, 11, 3}, {6, UPB_SIZE(48, 96), 0, 4, 11, 3},
@ -2551,7 +2589,7 @@ static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12]
{9, UPB_SIZE(32, 64), 5, 5, 11, 1}, {9, UPB_SIZE(32, 64), 5, 5, 11, 1},
{10, UPB_SIZE(56, 112), 0, 0, 5, 3}, {10, UPB_SIZE(56, 112), 0, 0, 5, 3},
{11, UPB_SIZE(60, 120), 0, 0, 5, 3}, {11, UPB_SIZE(60, 120), 0, 0, 5, 3},
{12, UPB_SIZE(20, 40), 3, 0, 9, 1}, {12, UPB_SIZE(20, 40), 3, 0, 12, 1},
}; };
const upb_msglayout google_protobuf_FileDescriptorProto_msginit = { const upb_msglayout google_protobuf_FileDescriptorProto_msginit = {
@ -2571,7 +2609,7 @@ static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = {
}; };
static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = { static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = {
{1, UPB_SIZE(4, 8), 1, 0, 9, 1}, {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
{2, UPB_SIZE(16, 32), 0, 4, 11, 3}, {2, UPB_SIZE(16, 32), 0, 4, 11, 3},
{3, UPB_SIZE(20, 40), 0, 0, 11, 3}, {3, UPB_SIZE(20, 40), 0, 0, 11, 3},
{4, UPB_SIZE(24, 48), 0, 3, 11, 3}, {4, UPB_SIZE(24, 48), 0, 3, 11, 3},
@ -2580,7 +2618,7 @@ static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = {
{7, UPB_SIZE(12, 24), 2, 5, 11, 1}, {7, UPB_SIZE(12, 24), 2, 5, 11, 1},
{8, UPB_SIZE(36, 72), 0, 6, 11, 3}, {8, UPB_SIZE(36, 72), 0, 6, 11, 3},
{9, UPB_SIZE(40, 80), 0, 2, 11, 3}, {9, UPB_SIZE(40, 80), 0, 2, 11, 3},
{10, UPB_SIZE(44, 88), 0, 0, 9, 3}, {10, UPB_SIZE(44, 88), 0, 0, 12, 3},
}; };
const upb_msglayout google_protobuf_DescriptorProto_msginit = { const upb_msglayout google_protobuf_DescriptorProto_msginit = {
@ -2635,16 +2673,16 @@ static const upb_msglayout *const google_protobuf_FieldDescriptorProto_submsgs[1
}; };
static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[11] = { static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[11] = {
{1, UPB_SIZE(36, 40), 6, 0, 9, 1}, {1, UPB_SIZE(36, 40), 6, 0, 12, 1},
{2, UPB_SIZE(44, 56), 7, 0, 9, 1}, {2, UPB_SIZE(44, 56), 7, 0, 12, 1},
{3, UPB_SIZE(24, 24), 3, 0, 5, 1}, {3, UPB_SIZE(24, 24), 3, 0, 5, 1},
{4, UPB_SIZE(8, 8), 1, 0, 14, 1}, {4, UPB_SIZE(8, 8), 1, 0, 14, 1},
{5, UPB_SIZE(16, 16), 2, 0, 14, 1}, {5, UPB_SIZE(16, 16), 2, 0, 14, 1},
{6, UPB_SIZE(52, 72), 8, 0, 9, 1}, {6, UPB_SIZE(52, 72), 8, 0, 12, 1},
{7, UPB_SIZE(60, 88), 9, 0, 9, 1}, {7, UPB_SIZE(60, 88), 9, 0, 12, 1},
{8, UPB_SIZE(76, 120), 11, 0, 11, 1}, {8, UPB_SIZE(76, 120), 11, 0, 11, 1},
{9, UPB_SIZE(28, 28), 4, 0, 5, 1}, {9, UPB_SIZE(28, 28), 4, 0, 5, 1},
{10, UPB_SIZE(68, 104), 10, 0, 9, 1}, {10, UPB_SIZE(68, 104), 10, 0, 12, 1},
{17, UPB_SIZE(32, 32), 5, 0, 8, 1}, {17, UPB_SIZE(32, 32), 5, 0, 8, 1},
}; };
@ -2659,7 +2697,7 @@ static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1
}; };
static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = { static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = {
{1, UPB_SIZE(4, 8), 1, 0, 9, 1}, {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
{2, UPB_SIZE(12, 24), 2, 0, 11, 1}, {2, UPB_SIZE(12, 24), 2, 0, 11, 1},
}; };
@ -2676,11 +2714,11 @@ static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3]
}; };
static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = { static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = {
{1, UPB_SIZE(4, 8), 1, 0, 9, 1}, {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
{2, UPB_SIZE(16, 32), 0, 2, 11, 3}, {2, UPB_SIZE(16, 32), 0, 2, 11, 3},
{3, UPB_SIZE(12, 24), 2, 1, 11, 1}, {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
{4, UPB_SIZE(20, 40), 0, 0, 11, 3}, {4, UPB_SIZE(20, 40), 0, 0, 11, 3},
{5, UPB_SIZE(24, 48), 0, 0, 9, 3}, {5, UPB_SIZE(24, 48), 0, 0, 12, 3},
}; };
const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = { const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = {
@ -2705,7 +2743,7 @@ static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_subms
}; };
static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = { static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = {
{1, UPB_SIZE(8, 8), 2, 0, 9, 1}, {1, UPB_SIZE(8, 8), 2, 0, 12, 1},
{2, UPB_SIZE(4, 4), 1, 0, 5, 1}, {2, UPB_SIZE(4, 4), 1, 0, 5, 1},
{3, UPB_SIZE(16, 24), 3, 0, 11, 1}, {3, UPB_SIZE(16, 24), 3, 0, 11, 1},
}; };
@ -2722,7 +2760,7 @@ static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs
}; };
static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = { static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = {
{1, UPB_SIZE(4, 8), 1, 0, 9, 1}, {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
{2, UPB_SIZE(16, 32), 0, 0, 11, 3}, {2, UPB_SIZE(16, 32), 0, 0, 11, 3},
{3, UPB_SIZE(12, 24), 2, 1, 11, 1}, {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
}; };
@ -2738,9 +2776,9 @@ static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[
}; };
static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = { static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = {
{1, UPB_SIZE(4, 8), 3, 0, 9, 1}, {1, UPB_SIZE(4, 8), 3, 0, 12, 1},
{2, UPB_SIZE(12, 24), 4, 0, 9, 1}, {2, UPB_SIZE(12, 24), 4, 0, 12, 1},
{3, UPB_SIZE(20, 40), 5, 0, 9, 1}, {3, UPB_SIZE(20, 40), 5, 0, 12, 1},
{4, UPB_SIZE(28, 56), 6, 0, 11, 1}, {4, UPB_SIZE(28, 56), 6, 0, 11, 1},
{5, UPB_SIZE(1, 1), 1, 0, 8, 1}, {5, UPB_SIZE(1, 1), 1, 0, 8, 1},
{6, UPB_SIZE(2, 2), 2, 0, 8, 1}, {6, UPB_SIZE(2, 2), 2, 0, 8, 1},
@ -2757,11 +2795,11 @@ static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = {
}; };
static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = { static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = {
{1, UPB_SIZE(28, 32), 11, 0, 9, 1}, {1, UPB_SIZE(28, 32), 11, 0, 12, 1},
{8, UPB_SIZE(36, 48), 12, 0, 9, 1}, {8, UPB_SIZE(36, 48), 12, 0, 12, 1},
{9, UPB_SIZE(8, 8), 1, 0, 14, 1}, {9, UPB_SIZE(8, 8), 1, 0, 14, 1},
{10, UPB_SIZE(16, 16), 2, 0, 8, 1}, {10, UPB_SIZE(16, 16), 2, 0, 8, 1},
{11, UPB_SIZE(44, 64), 13, 0, 9, 1}, {11, UPB_SIZE(44, 64), 13, 0, 12, 1},
{16, UPB_SIZE(17, 17), 3, 0, 8, 1}, {16, UPB_SIZE(17, 17), 3, 0, 8, 1},
{17, UPB_SIZE(18, 18), 4, 0, 8, 1}, {17, UPB_SIZE(18, 18), 4, 0, 8, 1},
{18, UPB_SIZE(19, 19), 5, 0, 8, 1}, {18, UPB_SIZE(19, 19), 5, 0, 8, 1},
@ -2769,14 +2807,14 @@ static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = {
{23, UPB_SIZE(21, 21), 7, 0, 8, 1}, {23, UPB_SIZE(21, 21), 7, 0, 8, 1},
{27, UPB_SIZE(22, 22), 8, 0, 8, 1}, {27, UPB_SIZE(22, 22), 8, 0, 8, 1},
{31, UPB_SIZE(23, 23), 9, 0, 8, 1}, {31, UPB_SIZE(23, 23), 9, 0, 8, 1},
{36, UPB_SIZE(52, 80), 14, 0, 9, 1}, {36, UPB_SIZE(52, 80), 14, 0, 12, 1},
{37, UPB_SIZE(60, 96), 15, 0, 9, 1}, {37, UPB_SIZE(60, 96), 15, 0, 12, 1},
{39, UPB_SIZE(68, 112), 16, 0, 9, 1}, {39, UPB_SIZE(68, 112), 16, 0, 12, 1},
{40, UPB_SIZE(76, 128), 17, 0, 9, 1}, {40, UPB_SIZE(76, 128), 17, 0, 12, 1},
{41, UPB_SIZE(84, 144), 18, 0, 9, 1}, {41, UPB_SIZE(84, 144), 18, 0, 12, 1},
{42, UPB_SIZE(24, 24), 10, 0, 8, 1}, {42, UPB_SIZE(24, 24), 10, 0, 8, 1},
{44, UPB_SIZE(92, 160), 19, 0, 9, 1}, {44, UPB_SIZE(92, 160), 19, 0, 12, 1},
{45, UPB_SIZE(100, 176), 20, 0, 9, 1}, {45, UPB_SIZE(100, 176), 20, 0, 12, 1},
{999, UPB_SIZE(108, 192), 0, 0, 11, 3}, {999, UPB_SIZE(108, 192), 0, 0, 11, 3},
}; };
@ -2906,12 +2944,12 @@ static const upb_msglayout *const google_protobuf_UninterpretedOption_submsgs[1]
static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7] = { static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7] = {
{2, UPB_SIZE(56, 80), 0, 0, 11, 3}, {2, UPB_SIZE(56, 80), 0, 0, 11, 3},
{3, UPB_SIZE(32, 32), 4, 0, 9, 1}, {3, UPB_SIZE(32, 32), 4, 0, 12, 1},
{4, UPB_SIZE(8, 8), 1, 0, 4, 1}, {4, UPB_SIZE(8, 8), 1, 0, 4, 1},
{5, UPB_SIZE(16, 16), 2, 0, 3, 1}, {5, UPB_SIZE(16, 16), 2, 0, 3, 1},
{6, UPB_SIZE(24, 24), 3, 0, 1, 1}, {6, UPB_SIZE(24, 24), 3, 0, 1, 1},
{7, UPB_SIZE(40, 48), 5, 0, 12, 1}, {7, UPB_SIZE(40, 48), 5, 0, 12, 1},
{8, UPB_SIZE(48, 64), 6, 0, 9, 1}, {8, UPB_SIZE(48, 64), 6, 0, 12, 1},
}; };
const upb_msglayout google_protobuf_UninterpretedOption_msginit = { const upb_msglayout google_protobuf_UninterpretedOption_msginit = {
@ -2921,7 +2959,7 @@ const upb_msglayout google_protobuf_UninterpretedOption_msginit = {
}; };
static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = { static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = {
{1, UPB_SIZE(4, 8), 2, 0, 9, 2}, {1, UPB_SIZE(4, 8), 2, 0, 12, 2},
{2, UPB_SIZE(1, 1), 1, 0, 8, 2}, {2, UPB_SIZE(1, 1), 1, 0, 8, 2},
}; };
@ -2948,9 +2986,9 @@ const upb_msglayout google_protobuf_SourceCodeInfo_msginit = {
static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = { static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = {
{1, UPB_SIZE(20, 40), 0, 0, 5, _UPB_LABEL_PACKED}, {1, UPB_SIZE(20, 40), 0, 0, 5, _UPB_LABEL_PACKED},
{2, UPB_SIZE(24, 48), 0, 0, 5, _UPB_LABEL_PACKED}, {2, UPB_SIZE(24, 48), 0, 0, 5, _UPB_LABEL_PACKED},
{3, UPB_SIZE(4, 8), 1, 0, 9, 1}, {3, UPB_SIZE(4, 8), 1, 0, 12, 1},
{4, UPB_SIZE(12, 24), 2, 0, 9, 1}, {4, UPB_SIZE(12, 24), 2, 0, 12, 1},
{6, UPB_SIZE(28, 56), 0, 0, 9, 3}, {6, UPB_SIZE(28, 56), 0, 0, 12, 3},
}; };
const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = { const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = {
@ -2975,7 +3013,7 @@ const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit = {
static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = { static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = {
{1, UPB_SIZE(20, 32), 0, 0, 5, _UPB_LABEL_PACKED}, {1, UPB_SIZE(20, 32), 0, 0, 5, _UPB_LABEL_PACKED},
{2, UPB_SIZE(12, 16), 3, 0, 9, 1}, {2, UPB_SIZE(12, 16), 3, 0, 12, 1},
{3, UPB_SIZE(4, 4), 1, 0, 5, 1}, {3, UPB_SIZE(4, 4), 1, 0, 5, 1},
{4, UPB_SIZE(8, 8), 2, 0, 5, 1}, {4, UPB_SIZE(8, 8), 2, 0, 5, 1},
}; };
@ -4383,6 +4421,13 @@ static bool make_layout(const upb_symtab *symtab, const upb_msgdef *m) {
field->descriptortype = upb_fielddef_descriptortype(f); field->descriptortype = upb_fielddef_descriptortype(f);
field->label = upb_fielddef_label(f); field->label = upb_fielddef_label(f);
if (field->descriptortype == UPB_DTYPE_STRING &&
f->file->syntax == UPB_SYNTAX_PROTO2) {
/* See TableDescriptorType() in upbc/generator.cc for details and
* rationale. */
field->descriptortype = UPB_DTYPE_BYTES;
}
if (upb_fielddef_ismap(f)) { if (upb_fielddef_ismap(f)) {
field->label = _UPB_LABEL_MAP; field->label = _UPB_LABEL_MAP;
} else if (upb_fielddef_packed(f)) { } else if (upb_fielddef_packed(f)) {
@ -4918,13 +4963,21 @@ static bool create_fielddef(
f->oneof = NULL; f->oneof = NULL;
} }
if (google_protobuf_FieldDescriptorProto_has_options(field_proto)) { options = google_protobuf_FieldDescriptorProto_has_options(field_proto) ?
options = google_protobuf_FieldDescriptorProto_options(field_proto); google_protobuf_FieldDescriptorProto_options(field_proto) : NULL;
f->lazy_ = google_protobuf_FieldOptions_lazy(options);
if (options && google_protobuf_FieldOptions_has_packed(options)) {
f->packed_ = google_protobuf_FieldOptions_packed(options); f->packed_ = google_protobuf_FieldOptions_packed(options);
} else {
/* Repeated fields default to packed for proto3 only. */
f->packed_ = upb_fielddef_isprimitive(f) &&
f->label_ == UPB_LABEL_REPEATED && f->file->syntax == UPB_SYNTAX_PROTO3;
}
if (options) {
f->lazy_ = google_protobuf_FieldOptions_lazy(options);
} else { } else {
f->lazy_ = false; f->lazy_ = false;
f->packed_ = false;
} }
return true; return true;
@ -5188,7 +5241,7 @@ static bool build_filedef(
const google_protobuf_FieldDescriptorProto *const *exts; const google_protobuf_FieldDescriptorProto *const *exts;
const upb_strview* strs; const upb_strview* strs;
size_t i, n; size_t i, n;
decl_counts counts = {0}; decl_counts counts = {0, 0, 0};
count_types_in_file(file_proto, &counts); count_types_in_file(file_proto, &counts);
@ -5612,7 +5665,11 @@ const upb_fielddef *upb_msg_whichoneof(const upb_msg *msg,
if (upb_oneof_done(&i)) return false; if (upb_oneof_done(&i)) return false;
f = upb_oneof_iter_field(&i); f = upb_oneof_iter_field(&i);
field = upb_fielddef_layout(f); field = upb_fielddef_layout(f);
oneof_case = _upb_getoneofcase_field(msg, field); if (in_oneof(field)) {
oneof_case = _upb_getoneofcase_field(msg, field);
} else {
return _upb_hasbit_field(msg, field) ? f : NULL;
}
return oneof_case ? upb_msgdef_itof(m, oneof_case) : NULL; return oneof_case ? upb_msgdef_itof(m, oneof_case) : NULL;
} }
@ -6341,6 +6398,7 @@ static upb_strview jsondec_string(jsondec *d) {
upb_strview ret; upb_strview ret;
ret.data = buf; ret.data = buf;
ret.size = end - buf; ret.size = end - buf;
*end = '\0'; /* Needed for possible strtod(). */
return ret; return ret;
} }
case '\\': case '\\':
@ -6665,7 +6723,7 @@ static upb_msgval jsondec_double(jsondec *d, const upb_fielddef *f) {
case JD_STRING: case JD_STRING:
str = jsondec_string(d); str = jsondec_string(d);
if (jsondec_streql(str, "NaN")) { if (jsondec_streql(str, "NaN")) {
val.double_val = 0.0 / 0.0; val.double_val = UPB_NAN;
} else if (jsondec_streql(str, "Infinity")) { } else if (jsondec_streql(str, "Infinity")) {
val.double_val = UPB_INFINITY; val.double_val = UPB_INFINITY;
} else if (jsondec_streql(str, "-Infinity")) { } else if (jsondec_streql(str, "-Infinity")) {
@ -6822,7 +6880,7 @@ static void jsondec_field(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
return; return;
} }
if (upb_fielddef_containingoneof(f) && if (upb_fielddef_realcontainingoneof(f) &&
upb_msg_whichoneof(msg, upb_fielddef_containingoneof(f))) { upb_msg_whichoneof(msg, upb_fielddef_containingoneof(f))) {
jsondec_err(d, "More than one field for this oneof."); jsondec_err(d, "More than one field for this oneof.");
} }
@ -7655,7 +7713,7 @@ static const upb_msgdef *jsonenc_getanymsg(jsonenc *e, upb_strview type_url) {
ret = upb_symtab_lookupmsg2(e->ext_pool, ptr, end - ptr); ret = upb_symtab_lookupmsg2(e->ext_pool, ptr, end - ptr);
if (!ret) { if (!ret) {
jsonenc_errf(e, "Couldn't find Any type: %.*s (full URL: " UPB_STRVIEW_FORMAT ")", (int)(end - ptr), ptr, UPB_STRVIEW_ARGS(type_url)); jsonenc_errf(e, "Couldn't find Any type: %.*s", (int)(end - ptr), ptr);
} }
return ret; return ret;
@ -8071,6 +8129,7 @@ size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
#undef UPB_ASSERT_DEBUGVAR #undef UPB_ASSERT_DEBUGVAR
#undef UPB_UNREACHABLE #undef UPB_UNREACHABLE
#undef UPB_INFINITY #undef UPB_INFINITY
#undef UPB_NAN
#undef UPB_MSVC_VSNPRINTF #undef UPB_MSVC_VSNPRINTF
#undef _upb_snprintf #undef _upb_snprintf
#undef _upb_vsnprintf #undef _upb_vsnprintf

@ -173,6 +173,11 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
#else #else
#define UPB_INFINITY (1.0 / 0.0) #define UPB_INFINITY (1.0 / 0.0)
#endif #endif
#ifdef NAN
#define UPB_NAN NAN
#else
#define UPB_NAN (0.0 / 0.0)
#endif
/* /*
** upb_decode: parsing into a upb_msg using a upb_msglayout. ** upb_decode: parsing into a upb_msg using a upb_msglayout.
*/ */
@ -208,7 +213,7 @@ int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg);
** store pointers or integers of at least 32 bits (upb isn't really useful on ** store pointers or integers of at least 32 bits (upb isn't really useful on
** systems where sizeof(void*) < 4). ** 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. ** mode, we check this on insert and lookup.
*/ */
@ -799,15 +804,6 @@ UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
* invalidate iterators. */ * invalidate iterators. */
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val); bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
/* Handy routines for treating an inttable like a stack. May not be mixed with
* other insert/remove calls. */
bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a);
upb_value upb_inttable_pop(upb_inttable *t);
UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) {
return upb_inttable_push2(t, val, &upb_alloc_global);
}
/* Convenience routines for inttables with pointer keys. */ /* Convenience routines for inttables with pointer keys. */
bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
upb_alloc *a); upb_alloc *a);
@ -1072,7 +1068,7 @@ UPB_INLINE uint32_t _upb_getoneofcase(const void *msg, size_t case_ofs) {
UPB_INLINE size_t _upb_oneofcase_ofs(const upb_msglayout_field *f) { UPB_INLINE size_t _upb_oneofcase_ofs(const upb_msglayout_field *f) {
UPB_ASSERT(f->presence < 0); UPB_ASSERT(f->presence < 0);
return ~(int64_t)f->presence; return ~(ptrdiff_t)f->presence;
} }
UPB_INLINE uint32_t *_upb_oneofcase_field(upb_msg *msg, UPB_INLINE uint32_t *_upb_oneofcase_field(upb_msg *msg,
@ -3831,7 +3827,7 @@ extern "C" {
#endif #endif
enum { 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, UPB_JSONENC_EMITDEFAULTS = 1,
/* When set, use normal (snake_caes) field names instead of JSON (camelCase) /* When set, use normal (snake_caes) field names instead of JSON (camelCase)
@ -3879,6 +3875,7 @@ size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
#undef UPB_ASSERT_DEBUGVAR #undef UPB_ASSERT_DEBUGVAR
#undef UPB_UNREACHABLE #undef UPB_UNREACHABLE
#undef UPB_INFINITY #undef UPB_INFINITY
#undef UPB_NAN
#undef UPB_MSVC_VSNPRINTF #undef UPB_MSVC_VSNPRINTF
#undef _upb_snprintf #undef _upb_snprintf
#undef _upb_vsnprintf #undef _upb_vsnprintf

@ -273,11 +273,18 @@ const upb_msgdef *NameMap_GetMessage(zend_class_entry *ce) {
zend_hash_find_ptr(&PROTOBUF_G(name_msg_cache), ce->name); zend_hash_find_ptr(&PROTOBUF_G(name_msg_cache), ce->name);
if (!ret && ce->create_object) { if (!ret && ce->create_object) {
#if PHP_VERSION_ID < 80000
zval tmp; zval tmp;
zval zv; zval zv;
ZVAL_OBJ(&tmp, ce->create_object(ce)); ZVAL_OBJ(&tmp, ce->create_object(ce));
zend_call_method_with_0_params(&tmp, ce, NULL, "__construct", &zv); zend_call_method_with_0_params(&tmp, ce, NULL, "__construct", &zv);
zval_ptr_dtor(&tmp); zval_ptr_dtor(&tmp);
#else
zval zv;
zend_object *tmp = ce->create_object(ce);
zend_call_method_with_0_params(tmp, ce, NULL, "__construct", &zv);
OBJ_RELEASE(tmp);
#endif
zval_ptr_dtor(&zv); zval_ptr_dtor(&zv);
ret = zend_hash_find_ptr(&PROTOBUF_G(name_msg_cache), ce->name); ret = zend_hash_find_ptr(&PROTOBUF_G(name_msg_cache), ce->name);
} }

@ -43,6 +43,34 @@ const zval *get_generated_pool();
#define GC_DELREF(h) --GC_REFCOUNT(h) #define GC_DELREF(h) --GC_REFCOUNT(h)
#endif #endif
// Since php 7.4, the write_property() object handler now returns the assigned
// value (after possible type coercions) rather than void.
// https://github.com/php/php-src/blob/PHP-7.4.0/UPGRADING.INTERNALS#L171-L173
#if PHP_VERSION_ID < 70400
#define PROTO_RETURN_VAL void
#else
#define PROTO_RETURN_VAL zval*
#endif
// Sine php 8.0, the Object Handlers API was changed to receive zend_object*
// instead of zval* and zend_string* instead of zval* for property names.
// https://github.com/php/php-src/blob/php-8.0.0beta1/UPGRADING.INTERNALS#L37-L39
#if PHP_VERSION_ID < 80000
#define PROTO_VAL zval
#define PROTO_STR zval
#define PROTO_MSG_P(obj) (Message*)Z_OBJ_P(obj)
#define PROTO_STRVAL_P(obj) Z_STRVAL_P(obj)
#define PROTO_STRLEN_P(obj) Z_STRLEN_P(obj)
#else
#define PROTO_VAL zend_object
#define PROTO_STR zend_string
#define PROTO_MSG_P(obj) (Message*)(obj)
#define PROTO_STRVAL_P(obj) ZSTR_VAL(obj)
#define PROTO_STRLEN_P(obj) ZSTR_LEN(obj)
#endif
#define PHP_PROTOBUF_VERSION "3.13.0"
// ptr -> PHP object cache. This is a weak map that caches lazily-created // ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types: // wrapper objects around upb types:
// * upb_msg* -> Message // * upb_msg* -> Message

@ -3,16 +3,16 @@
colors="true"> colors="true">
<testsuites> <testsuites>
<testsuite name="protobuf-tests"> <testsuite name="protobuf-tests">
<file>tests/php_implementation_test.php</file> <file>tests/PhpImplementationTest.php</file>
<file>tests/array_test.php</file> <file>tests/ArrayTest.php</file>
<file>tests/encode_decode_test.php</file> <file>tests/EncodeDecodeTest.php</file>
<file>tests/generated_class_test.php</file> <file>tests/GeneratedClassTest.php</file>
<file>tests/generated_phpdoc_test.php</file> <file>tests/GeneratedPhpdocTest.php</file>
<file>tests/map_field_test.php</file> <file>tests/MapFieldTest.php</file>
<file>tests/well_known_test.php</file> <file>tests/WellKnownTest.php</file>
<file>tests/descriptors_test.php</file> <file>tests/DescriptorsTest.php</file>
<file>tests/generated_service_test.php</file> <file>tests/GeneratedServiceTest.php</file>
<file>tests/wrapper_type_setters_test.php</file> <file>tests/WrapperTypeSettersTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>

@ -15,29 +15,8 @@ class Struct
return; return;
} }
$pool->internalAddGeneratedFile(hex2bin( $pool->internalAddGeneratedFile(hex2bin(
"0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e7072" . "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e70726f746f120f676f6f676c652e70726f746f6275662284010a0653747275637412330a066669656c647318012003280b32232e676f6f676c652e70726f746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669656c6473456e747279120b0a036b657918012001280912250a0576616c756518022001280b32162e676f6f676c652e70726f746f6275662e56616c75653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c56616c7565480012160a0c6e756d6265725f76616c7565180220012801480012160a0c737472696e675f76616c7565180320012809480012140a0a626f6f6c5f76616c75651804200128084800122f0a0c7374727563745f76616c756518052001280b32172e676f6f676c652e70726f746f6275662e537472756374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f676c652e70726f746f6275662e4c69737456616c7565480042060a046b696e6422330a094c69737456616c756512260a0676616c75657318012003280b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a13636f6d2e676f6f676c652e70726f746f627566420b53747275637450726f746f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065732f7374727563743b7374727563747062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
"6f746f120f676f6f676c652e70726f746f6275662284010a065374727563" . ), true);
"7412330a066669656c647318012003280b32232e676f6f676c652e70726f" .
"746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669" .
"656c6473456e747279120b0a036b657918012001280912250a0576616c75" .
"6518022001280b32162e676f6f676c652e70726f746f6275662e56616c75" .
"653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518" .
"012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c5661" .
"6c7565480012160a0c6e756d6265725f76616c7565180220012801480012" .
"160a0c737472696e675f76616c7565180320012809480012140a0a626f6f" .
"6c5f76616c75651804200128084800122f0a0c7374727563745f76616c75" .
"6518052001280b32172e676f6f676c652e70726f746f6275662e53747275" .
"6374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f" .
"676c652e70726f746f6275662e4c69737456616c7565480042060a046b69" .
"6e6422330a094c69737456616c756512260a0676616c7565731801200328" .
"0b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e" .
"756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a1363" .
"6f6d2e676f6f676c652e70726f746f627566420b53747275637450726f74" .
"6f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275" .
"662f7074797065732f7374727563743b7374727563747062f80101a20203" .
"475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" .
"6e5479706573620670726f746f33"
));
static::$is_initialized = true; static::$is_initialized = true;
} }

@ -97,4 +97,12 @@ class Descriptor
{ {
return count($this->internal_desc->getOneofDecl()); return count($this->internal_desc->getOneofDecl());
} }
/**
* @return int Number of real oneofs in message
*/
public function getRealOneofDeclCount()
{
return $this->internal_desc->getRealOneofDeclCount();
}
} }

@ -114,4 +114,12 @@ class FieldDescriptor
{ {
return $this->internal_desc->isMap(); return $this->internal_desc->isMap();
} }
/**
* @return boolean
*/
public function hasOptionalKeyword()
{
return $this->internal_desc->hasOptionalKeyword();
}
} }

@ -20,48 +20,39 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
/** /**
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
*/ */
private $field; private $field;
private $has_field = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
*/ */
private $extension; private $extension;
private $has_extension = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
*/ */
private $nested_type; private $nested_type;
private $has_nested_type = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
*/ */
private $enum_type; private $enum_type;
private $has_enum_type = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
*/ */
private $extension_range; private $extension_range;
private $has_extension_range = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code> * Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
*/ */
private $oneof_decl; private $oneof_decl;
private $has_oneof_decl = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code> * Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
*/ */
private $reserved_range; private $reserved_range;
private $has_reserved_range = false;
/** /**
* Reserved field names, which may not be used by fields in the same message. * Reserved field names, which may not be used by fields in the same message.
* A given name may only be reserved once. * A given name may only be reserved once.
@ -69,7 +60,6 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated string reserved_name = 10;</code> * Generated from protobuf field <code>repeated string reserved_name = 10;</code>
*/ */
private $reserved_name; private $reserved_name;
private $has_reserved_name = false;
/** /**
* Constructor. * Constructor.
@ -102,7 +92,17 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -114,16 +114,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -142,16 +136,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->field = $arr; $this->field = $arr;
$this->has_field = true;
return $this; return $this;
} }
public function hasField()
{
return $this->has_field;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -170,16 +158,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->extension = $arr; $this->extension = $arr;
$this->has_extension = true;
return $this; return $this;
} }
public function hasExtension()
{
return $this->has_extension;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -198,16 +180,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
$this->nested_type = $arr; $this->nested_type = $arr;
$this->has_nested_type = true;
return $this; return $this;
} }
public function hasNestedType()
{
return $this->has_nested_type;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -226,16 +202,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
$this->enum_type = $arr; $this->enum_type = $arr;
$this->has_enum_type = true;
return $this; return $this;
} }
public function hasEnumType()
{
return $this->has_enum_type;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -254,16 +224,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ExtensionRange::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ExtensionRange::class);
$this->extension_range = $arr; $this->extension_range = $arr;
$this->has_extension_range = true;
return $this; return $this;
} }
public function hasExtensionRange()
{
return $this->has_extension_range;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code> * Generated from protobuf field <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -282,23 +246,27 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class);
$this->oneof_decl = $arr; $this->oneof_decl = $arr;
$this->has_oneof_decl = true;
return $this; return $this;
} }
public function hasOneofDecl()
{
return $this->has_oneof_decl;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code> * Generated from protobuf field <code>optional .google.protobuf.MessageOptions options = 7;</code>
* @return \Google\Protobuf\Internal\MessageOptions * @return \Google\Protobuf\Internal\MessageOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -310,16 +278,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -338,16 +300,10 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ReservedRange::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto\ReservedRange::class);
$this->reserved_range = $arr; $this->reserved_range = $arr;
$this->has_reserved_range = true;
return $this; return $this;
} }
public function hasReservedRange()
{
return $this->has_reserved_range;
}
/** /**
* Reserved field names, which may not be used by fields in the same message. * Reserved field names, which may not be used by fields in the same message.
* A given name may only be reserved once. * A given name may only be reserved once.
@ -372,15 +328,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->reserved_name = $arr; $this->reserved_name = $arr;
$this->has_reserved_name = true;
return $this; return $this;
} }
public function hasReservedName()
{
return $this->has_reserved_name;
}
} }

@ -20,20 +20,17 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
*/ */
protected $start = 0; protected $start = null;
private $has_start = false;
/** /**
* Exclusive. * Exclusive.
* *
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
*/ */
protected $end = 0; protected $end = null;
private $has_end = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* Constructor. * Constructor.
@ -61,7 +58,17 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
*/ */
public function getStart() public function getStart()
{ {
return $this->start; return isset($this->start) ? $this->start : 0;
}
public function hasStart()
{
return isset($this->start);
}
public function clearStart()
{
unset($this->start);
} }
/** /**
@ -75,16 +82,10 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->start = $var; $this->start = $var;
$this->has_start = true;
return $this; return $this;
} }
public function hasStart()
{
return $this->has_start;
}
/** /**
* Exclusive. * Exclusive.
* *
@ -93,7 +94,17 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
*/ */
public function getEnd() public function getEnd()
{ {
return $this->end; return isset($this->end) ? $this->end : 0;
}
public function hasEnd()
{
return isset($this->end);
}
public function clearEnd()
{
unset($this->end);
} }
/** /**
@ -107,23 +118,27 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->end = $var; $this->end = $var;
$this->has_end = true;
return $this; return $this;
} }
public function hasEnd()
{
return $this->has_end;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.ExtensionRangeOptions options = 3;</code>
* @return \Google\Protobuf\Internal\ExtensionRangeOptions * @return \Google\Protobuf\Internal\ExtensionRangeOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -135,16 +150,10 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ExtensionRangeOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ExtensionRangeOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
} }
// Adding a class alias for backwards compatibility with the previous class name. // Adding a class alias for backwards compatibility with the previous class name.

@ -24,15 +24,13 @@ class ReservedRange extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
*/ */
protected $start = 0; protected $start = null;
private $has_start = false;
/** /**
* Exclusive. * Exclusive.
* *
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
*/ */
protected $end = 0; protected $end = null;
private $has_end = false;
/** /**
* Constructor. * Constructor.
@ -59,7 +57,17 @@ class ReservedRange extends \Google\Protobuf\Internal\Message
*/ */
public function getStart() public function getStart()
{ {
return $this->start; return isset($this->start) ? $this->start : 0;
}
public function hasStart()
{
return isset($this->start);
}
public function clearStart()
{
unset($this->start);
} }
/** /**
@ -73,16 +81,10 @@ class ReservedRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->start = $var; $this->start = $var;
$this->has_start = true;
return $this; return $this;
} }
public function hasStart()
{
return $this->has_start;
}
/** /**
* Exclusive. * Exclusive.
* *
@ -91,7 +93,17 @@ class ReservedRange extends \Google\Protobuf\Internal\Message
*/ */
public function getEnd() public function getEnd()
{ {
return $this->end; return isset($this->end) ? $this->end : 0;
}
public function hasEnd()
{
return isset($this->end);
}
public function clearEnd()
{
unset($this->end);
} }
/** /**
@ -105,16 +117,10 @@ class ReservedRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->end = $var; $this->end = $var;
$this->has_end = true;
return $this; return $this;
} }
public function hasEnd()
{
return $this->has_end;
}
} }
// Adding a class alias for backwards compatibility with the previous class name. // Adding a class alias for backwards compatibility with the previous class name.

@ -20,18 +20,15 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
/** /**
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
*/ */
private $value; private $value;
private $has_value = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* Range of reserved numeric values. Reserved numeric values may not be used * Range of reserved numeric values. Reserved numeric values may not be used
* by enum values in the same enum declaration. Reserved ranges may not * by enum values in the same enum declaration. Reserved ranges may not
@ -40,7 +37,6 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4;</code>
*/ */
private $reserved_range; private $reserved_range;
private $has_reserved_range = false;
/** /**
* Reserved enum value names, which may not be reused. A given name may only * Reserved enum value names, which may not be reused. A given name may only
* be reserved once. * be reserved once.
@ -48,7 +44,6 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated string reserved_name = 5;</code> * Generated from protobuf field <code>repeated string reserved_name = 5;</code>
*/ */
private $reserved_name; private $reserved_name;
private $has_reserved_name = false;
/** /**
* Constructor. * Constructor.
@ -79,7 +74,17 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -91,16 +96,10 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -119,23 +118,27 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
$this->value = $arr; $this->value = $arr;
$this->has_value = true;
return $this; return $this;
} }
public function hasValue()
{
return $this->has_value;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.EnumOptions options = 3;</code>
* @return \Google\Protobuf\Internal\EnumOptions * @return \Google\Protobuf\Internal\EnumOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -147,16 +150,10 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
/** /**
* Range of reserved numeric values. Reserved numeric values may not be used * Range of reserved numeric values. Reserved numeric values may not be used
* by enum values in the same enum declaration. Reserved ranges may not * by enum values in the same enum declaration. Reserved ranges may not
@ -183,16 +180,10 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange::class);
$this->reserved_range = $arr; $this->reserved_range = $arr;
$this->has_reserved_range = true;
return $this; return $this;
} }
public function hasReservedRange()
{
return $this->has_reserved_range;
}
/** /**
* Reserved enum value names, which may not be reused. A given name may only * Reserved enum value names, which may not be reused. A given name may only
* be reserved once. * be reserved once.
@ -217,15 +208,9 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->reserved_name = $arr; $this->reserved_name = $arr;
$this->has_reserved_name = true;
return $this; return $this;
} }
public function hasReservedName()
{
return $this->has_reserved_name;
}
} }

@ -26,15 +26,13 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional int32 start = 1;</code> * Generated from protobuf field <code>optional int32 start = 1;</code>
*/ */
protected $start = 0; protected $start = null;
private $has_start = false;
/** /**
* Inclusive. * Inclusive.
* *
* Generated from protobuf field <code>optional int32 end = 2;</code> * Generated from protobuf field <code>optional int32 end = 2;</code>
*/ */
protected $end = 0; protected $end = null;
private $has_end = false;
/** /**
* Constructor. * Constructor.
@ -61,7 +59,17 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message
*/ */
public function getStart() public function getStart()
{ {
return $this->start; return isset($this->start) ? $this->start : 0;
}
public function hasStart()
{
return isset($this->start);
}
public function clearStart()
{
unset($this->start);
} }
/** /**
@ -75,16 +83,10 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->start = $var; $this->start = $var;
$this->has_start = true;
return $this; return $this;
} }
public function hasStart()
{
return $this->has_start;
}
/** /**
* Inclusive. * Inclusive.
* *
@ -93,7 +95,17 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message
*/ */
public function getEnd() public function getEnd()
{ {
return $this->end; return isset($this->end) ? $this->end : 0;
}
public function hasEnd()
{
return isset($this->end);
}
public function clearEnd()
{
unset($this->end);
} }
/** /**
@ -107,16 +119,10 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->end = $var; $this->end = $var;
$this->has_end = true;
return $this; return $this;
} }
public function hasEnd()
{
return $this->has_end;
}
} }
// Adding a class alias for backwards compatibility with the previous class name. // Adding a class alias for backwards compatibility with the previous class name.

@ -21,8 +21,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool allow_alias = 2;</code> * Generated from protobuf field <code>optional bool allow_alias = 2;</code>
*/ */
protected $allow_alias = false; protected $allow_alias = null;
private $has_allow_alias = false;
/** /**
* Is this enum deprecated? * Is this enum deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -31,15 +30,13 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code> * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
*/ */
protected $deprecated = false; protected $deprecated = null;
private $has_deprecated = false;
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -73,7 +70,17 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getAllowAlias() public function getAllowAlias()
{ {
return $this->allow_alias; return isset($this->allow_alias) ? $this->allow_alias : false;
}
public function hasAllowAlias()
{
return isset($this->allow_alias);
}
public function clearAllowAlias()
{
unset($this->allow_alias);
} }
/** /**
@ -88,16 +95,10 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->allow_alias = $var; $this->allow_alias = $var;
$this->has_allow_alias = true;
return $this; return $this;
} }
public function hasAllowAlias()
{
return $this->has_allow_alias;
}
/** /**
* Is this enum deprecated? * Is this enum deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -109,7 +110,17 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getDeprecated() public function getDeprecated()
{ {
return $this->deprecated; return isset($this->deprecated) ? $this->deprecated : false;
}
public function hasDeprecated()
{
return isset($this->deprecated);
}
public function clearDeprecated()
{
unset($this->deprecated);
} }
/** /**
@ -126,16 +137,10 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->deprecated = $var; $this->deprecated = $var;
$this->has_deprecated = true;
return $this; return $this;
} }
public function hasDeprecated()
{
return $this->has_deprecated;
}
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
@ -158,15 +163,9 @@ class EnumOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -20,18 +20,15 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
/** /**
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* Generated from protobuf field <code>optional int32 number = 2;</code> * Generated from protobuf field <code>optional int32 number = 2;</code>
*/ */
protected $number = 0; protected $number = null;
private $has_number = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* Constructor. * Constructor.
@ -55,7 +52,17 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -67,23 +74,27 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* Generated from protobuf field <code>optional int32 number = 2;</code> * Generated from protobuf field <code>optional int32 number = 2;</code>
* @return int * @return int
*/ */
public function getNumber() public function getNumber()
{ {
return $this->number; return isset($this->number) ? $this->number : 0;
}
public function hasNumber()
{
return isset($this->number);
}
public function clearNumber()
{
unset($this->number);
} }
/** /**
@ -95,23 +106,27 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->number = $var; $this->number = $var;
$this->has_number = true;
return $this; return $this;
} }
public function hasNumber()
{
return $this->has_number;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code> * Generated from protobuf field <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
* @return \Google\Protobuf\Internal\EnumValueOptions * @return \Google\Protobuf\Internal\EnumValueOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -123,15 +138,9 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
} }

@ -23,15 +23,13 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool deprecated = 1 [default = false];</code> * Generated from protobuf field <code>optional bool deprecated = 1 [default = false];</code>
*/ */
protected $deprecated = false; protected $deprecated = null;
private $has_deprecated = false;
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -64,7 +62,17 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getDeprecated() public function getDeprecated()
{ {
return $this->deprecated; return isset($this->deprecated) ? $this->deprecated : false;
}
public function hasDeprecated()
{
return isset($this->deprecated);
}
public function clearDeprecated()
{
unset($this->deprecated);
} }
/** /**
@ -81,16 +89,10 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->deprecated = $var; $this->deprecated = $var;
$this->has_deprecated = true;
return $this; return $this;
} }
public function hasDeprecated()
{
return $this->has_deprecated;
}
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
@ -113,15 +115,9 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -21,7 +21,6 @@ class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -60,15 +59,9 @@ class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -229,7 +229,17 @@ class FieldDescriptor
} }
$oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1;
$packed = false; // TODO: once proto2 is supported, this default should be false
// for proto2.
if ($proto->getLabel() === GPBLabel::REPEATED &&
$proto->getType() !== GPBType::MESSAGE &&
$proto->getType() !== GPBType::GROUP &&
$proto->getType() !== GPBType::STRING &&
$proto->getType() !== GPBType::BYTES) {
$packed = true;
} else {
$packed = false;
}
$options = $proto->getOptions(); $options = $proto->getOptions();
if ($options !== null) { if ($options !== null) {
$packed = $options->getPacked(); $packed = $options->getPacked();

@ -20,26 +20,22 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
/** /**
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* Generated from protobuf field <code>optional int32 number = 3;</code> * Generated from protobuf field <code>optional int32 number = 3;</code>
*/ */
protected $number = 0; protected $number = null;
private $has_number = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code> * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
*/ */
protected $label = 0; protected $label = null;
private $has_label = false;
/** /**
* If type_name is set, this need not be set. If both this and type_name * If type_name is set, this need not be set. If both this and type_name
* are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
* *
* Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code> * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code>
*/ */
protected $type = 0; protected $type = null;
private $has_type = false;
/** /**
* For message and enum types, this is the name of the type. If the name * For message and enum types, this is the name of the type. If the name
* starts with a '.', it is fully-qualified. Otherwise, C++-like scoping * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
@ -49,16 +45,14 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string type_name = 6;</code> * Generated from protobuf field <code>optional string type_name = 6;</code>
*/ */
protected $type_name = ''; protected $type_name = null;
private $has_type_name = false;
/** /**
* For extensions, this is the name of the type being extended. It is * For extensions, this is the name of the type being extended. It is
* resolved in the same manner as type_name. * resolved in the same manner as type_name.
* *
* Generated from protobuf field <code>optional string extendee = 2;</code> * Generated from protobuf field <code>optional string extendee = 2;</code>
*/ */
protected $extendee = ''; protected $extendee = null;
private $has_extendee = false;
/** /**
* For numeric types, contains the original text representation of the value. * For numeric types, contains the original text representation of the value.
* For booleans, "true" or "false". * For booleans, "true" or "false".
@ -68,16 +62,14 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string default_value = 7;</code> * Generated from protobuf field <code>optional string default_value = 7;</code>
*/ */
protected $default_value = ''; protected $default_value = null;
private $has_default_value = false;
/** /**
* If set, gives the index of a oneof in the containing type's oneof_decl * If set, gives the index of a oneof in the containing type's oneof_decl
* list. This field is a member of that oneof. * list. This field is a member of that oneof.
* *
* Generated from protobuf field <code>optional int32 oneof_index = 9;</code> * Generated from protobuf field <code>optional int32 oneof_index = 9;</code>
*/ */
protected $oneof_index = 0; protected $oneof_index = null;
private $has_oneof_index = false;
/** /**
* JSON name of this field. The value is set by protocol compiler. If the * JSON name of this field. The value is set by protocol compiler. If the
* user has set a "json_name" option on this field, that option's value * user has set a "json_name" option on this field, that option's value
@ -86,13 +78,11 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string json_name = 10;</code> * Generated from protobuf field <code>optional string json_name = 10;</code>
*/ */
protected $json_name = ''; protected $json_name = null;
private $has_json_name = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code> * Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* If true, this is a proto3 "optional". When a proto3 field is optional, it * If true, this is a proto3 "optional". When a proto3 field is optional, it
* tracks presence regardless of field type. * tracks presence regardless of field type.
@ -115,8 +105,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool proto3_optional = 17;</code> * Generated from protobuf field <code>optional bool proto3_optional = 17;</code>
*/ */
protected $proto3_optional = false; protected $proto3_optional = null;
private $has_proto3_optional = false;
/** /**
* Constructor. * Constructor.
@ -186,7 +175,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -198,23 +197,27 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* Generated from protobuf field <code>optional int32 number = 3;</code> * Generated from protobuf field <code>optional int32 number = 3;</code>
* @return int * @return int
*/ */
public function getNumber() public function getNumber()
{ {
return $this->number; return isset($this->number) ? $this->number : 0;
}
public function hasNumber()
{
return isset($this->number);
}
public function clearNumber()
{
unset($this->number);
} }
/** /**
@ -226,23 +229,27 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->number = $var; $this->number = $var;
$this->has_number = true;
return $this; return $this;
} }
public function hasNumber()
{
return $this->has_number;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code> * Generated from protobuf field <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
* @return int * @return int
*/ */
public function getLabel() public function getLabel()
{ {
return $this->label; return isset($this->label) ? $this->label : 0;
}
public function hasLabel()
{
return isset($this->label);
}
public function clearLabel()
{
unset($this->label);
} }
/** /**
@ -254,16 +261,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Label::class); GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Label::class);
$this->label = $var; $this->label = $var;
$this->has_label = true;
return $this; return $this;
} }
public function hasLabel()
{
return $this->has_label;
}
/** /**
* If type_name is set, this need not be set. If both this and type_name * If type_name is set, this need not be set. If both this and type_name
* are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
@ -273,7 +274,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getType() public function getType()
{ {
return $this->type; return isset($this->type) ? $this->type : 0;
}
public function hasType()
{
return isset($this->type);
}
public function clearType()
{
unset($this->type);
} }
/** /**
@ -288,16 +299,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Type::class); GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto\Type::class);
$this->type = $var; $this->type = $var;
$this->has_type = true;
return $this; return $this;
} }
public function hasType()
{
return $this->has_type;
}
/** /**
* For message and enum types, this is the name of the type. If the name * For message and enum types, this is the name of the type. If the name
* starts with a '.', it is fully-qualified. Otherwise, C++-like scoping * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
@ -310,7 +315,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getTypeName() public function getTypeName()
{ {
return $this->type_name; return isset($this->type_name) ? $this->type_name : '';
}
public function hasTypeName()
{
return isset($this->type_name);
}
public function clearTypeName()
{
unset($this->type_name);
} }
/** /**
@ -328,16 +343,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->type_name = $var; $this->type_name = $var;
$this->has_type_name = true;
return $this; return $this;
} }
public function hasTypeName()
{
return $this->has_type_name;
}
/** /**
* For extensions, this is the name of the type being extended. It is * For extensions, this is the name of the type being extended. It is
* resolved in the same manner as type_name. * resolved in the same manner as type_name.
@ -347,7 +356,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getExtendee() public function getExtendee()
{ {
return $this->extendee; return isset($this->extendee) ? $this->extendee : '';
}
public function hasExtendee()
{
return isset($this->extendee);
}
public function clearExtendee()
{
unset($this->extendee);
} }
/** /**
@ -362,16 +381,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->extendee = $var; $this->extendee = $var;
$this->has_extendee = true;
return $this; return $this;
} }
public function hasExtendee()
{
return $this->has_extendee;
}
/** /**
* For numeric types, contains the original text representation of the value. * For numeric types, contains the original text representation of the value.
* For booleans, "true" or "false". * For booleans, "true" or "false".
@ -384,7 +397,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getDefaultValue() public function getDefaultValue()
{ {
return $this->default_value; return isset($this->default_value) ? $this->default_value : '';
}
public function hasDefaultValue()
{
return isset($this->default_value);
}
public function clearDefaultValue()
{
unset($this->default_value);
} }
/** /**
@ -402,16 +425,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->default_value = $var; $this->default_value = $var;
$this->has_default_value = true;
return $this; return $this;
} }
public function hasDefaultValue()
{
return $this->has_default_value;
}
/** /**
* If set, gives the index of a oneof in the containing type's oneof_decl * If set, gives the index of a oneof in the containing type's oneof_decl
* list. This field is a member of that oneof. * list. This field is a member of that oneof.
@ -421,7 +438,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getOneofIndex() public function getOneofIndex()
{ {
return $this->oneof_index; return isset($this->oneof_index) ? $this->oneof_index : 0;
}
public function hasOneofIndex()
{
return isset($this->oneof_index);
}
public function clearOneofIndex()
{
unset($this->oneof_index);
} }
/** /**
@ -436,16 +463,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->oneof_index = $var; $this->oneof_index = $var;
$this->has_oneof_index = true;
return $this; return $this;
} }
public function hasOneofIndex()
{
return $this->has_oneof_index;
}
/** /**
* JSON name of this field. The value is set by protocol compiler. If the * JSON name of this field. The value is set by protocol compiler. If the
* user has set a "json_name" option on this field, that option's value * user has set a "json_name" option on this field, that option's value
@ -457,7 +478,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getJsonName() public function getJsonName()
{ {
return $this->json_name; return isset($this->json_name) ? $this->json_name : '';
}
public function hasJsonName()
{
return isset($this->json_name);
}
public function clearJsonName()
{
unset($this->json_name);
} }
/** /**
@ -474,23 +505,27 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->json_name = $var; $this->json_name = $var;
$this->has_json_name = true;
return $this; return $this;
} }
public function hasJsonName()
{
return $this->has_json_name;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code> * Generated from protobuf field <code>optional .google.protobuf.FieldOptions options = 8;</code>
* @return \Google\Protobuf\Internal\FieldOptions * @return \Google\Protobuf\Internal\FieldOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -502,16 +537,10 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
/** /**
* If true, this is a proto3 "optional". When a proto3 field is optional, it * If true, this is a proto3 "optional". When a proto3 field is optional, it
* tracks presence regardless of field type. * tracks presence regardless of field type.
@ -537,7 +566,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getProto3Optional() public function getProto3Optional()
{ {
return $this->proto3_optional; return isset($this->proto3_optional) ? $this->proto3_optional : false;
}
public function hasProto3Optional()
{
return isset($this->proto3_optional);
}
public function clearProto3Optional()
{
unset($this->proto3_optional);
} }
/** /**
@ -568,15 +607,9 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->proto3_optional = $var; $this->proto3_optional = $var;
$this->has_proto3_optional = true;
return $this; return $this;
} }
public function hasProto3Optional()
{
return $this->has_proto3_optional;
}
} }

@ -23,8 +23,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code> * Generated from protobuf field <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code>
*/ */
protected $ctype = 0; protected $ctype = null;
private $has_ctype = false;
/** /**
* The packed option can be enabled for repeated primitive fields to enable * The packed option can be enabled for repeated primitive fields to enable
* a more efficient representation on the wire. Rather than repeatedly * a more efficient representation on the wire. Rather than repeatedly
@ -34,8 +33,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool packed = 2;</code> * Generated from protobuf field <code>optional bool packed = 2;</code>
*/ */
protected $packed = false; protected $packed = null;
private $has_packed = false;
/** /**
* The jstype option determines the JavaScript type used for values of the * The jstype option determines the JavaScript type used for values of the
* field. The option is permitted only for 64 bit integral and fixed types * field. The option is permitted only for 64 bit integral and fixed types
@ -50,8 +48,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code> * Generated from protobuf field <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code>
*/ */
protected $jstype = 0; protected $jstype = null;
private $has_jstype = false;
/** /**
* Should this field be parsed lazily? Lazy applies only to message-type * Should this field be parsed lazily? Lazy applies only to message-type
* fields. It means that when the outer message is initially parsed, the * fields. It means that when the outer message is initially parsed, the
@ -80,8 +77,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool lazy = 5 [default = false];</code> * Generated from protobuf field <code>optional bool lazy = 5 [default = false];</code>
*/ */
protected $lazy = false; protected $lazy = null;
private $has_lazy = false;
/** /**
* Is this field deprecated? * Is this field deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -90,22 +86,19 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code> * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
*/ */
protected $deprecated = false; protected $deprecated = null;
private $has_deprecated = false;
/** /**
* For Google-internal migration only. Do not use. * For Google-internal migration only. Do not use.
* *
* Generated from protobuf field <code>optional bool weak = 10 [default = false];</code> * Generated from protobuf field <code>optional bool weak = 10 [default = false];</code>
*/ */
protected $weak = false; protected $weak = null;
private $has_weak = false;
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -187,7 +180,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getCtype() public function getCtype()
{ {
return $this->ctype; return isset($this->ctype) ? $this->ctype : 0;
}
public function hasCtype()
{
return isset($this->ctype);
}
public function clearCtype()
{
unset($this->ctype);
} }
/** /**
@ -204,16 +207,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\CType::class); GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\CType::class);
$this->ctype = $var; $this->ctype = $var;
$this->has_ctype = true;
return $this; return $this;
} }
public function hasCtype()
{
return $this->has_ctype;
}
/** /**
* The packed option can be enabled for repeated primitive fields to enable * The packed option can be enabled for repeated primitive fields to enable
* a more efficient representation on the wire. Rather than repeatedly * a more efficient representation on the wire. Rather than repeatedly
@ -226,7 +223,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getPacked() public function getPacked()
{ {
return $this->packed; return isset($this->packed) ? $this->packed : false;
}
public function hasPacked()
{
return isset($this->packed);
}
public function clearPacked()
{
unset($this->packed);
} }
/** /**
@ -244,16 +251,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->packed = $var; $this->packed = $var;
$this->has_packed = true;
return $this; return $this;
} }
public function hasPacked()
{
return $this->has_packed;
}
/** /**
* The jstype option determines the JavaScript type used for values of the * The jstype option determines the JavaScript type used for values of the
* field. The option is permitted only for 64 bit integral and fixed types * field. The option is permitted only for 64 bit integral and fixed types
@ -271,7 +272,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJstype() public function getJstype()
{ {
return $this->jstype; return isset($this->jstype) ? $this->jstype : 0;
}
public function hasJstype()
{
return isset($this->jstype);
}
public function clearJstype()
{
unset($this->jstype);
} }
/** /**
@ -294,16 +305,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\JSType::class); GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions\JSType::class);
$this->jstype = $var; $this->jstype = $var;
$this->has_jstype = true;
return $this; return $this;
} }
public function hasJstype()
{
return $this->has_jstype;
}
/** /**
* Should this field be parsed lazily? Lazy applies only to message-type * Should this field be parsed lazily? Lazy applies only to message-type
* fields. It means that when the outer message is initially parsed, the * fields. It means that when the outer message is initially parsed, the
@ -335,7 +340,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getLazy() public function getLazy()
{ {
return $this->lazy; return isset($this->lazy) ? $this->lazy : false;
}
public function hasLazy()
{
return isset($this->lazy);
}
public function clearLazy()
{
unset($this->lazy);
} }
/** /**
@ -372,16 +387,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->lazy = $var; $this->lazy = $var;
$this->has_lazy = true;
return $this; return $this;
} }
public function hasLazy()
{
return $this->has_lazy;
}
/** /**
* Is this field deprecated? * Is this field deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -393,7 +402,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getDeprecated() public function getDeprecated()
{ {
return $this->deprecated; return isset($this->deprecated) ? $this->deprecated : false;
}
public function hasDeprecated()
{
return isset($this->deprecated);
}
public function clearDeprecated()
{
unset($this->deprecated);
} }
/** /**
@ -410,16 +429,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->deprecated = $var; $this->deprecated = $var;
$this->has_deprecated = true;
return $this; return $this;
} }
public function hasDeprecated()
{
return $this->has_deprecated;
}
/** /**
* For Google-internal migration only. Do not use. * For Google-internal migration only. Do not use.
* *
@ -428,7 +441,17 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getWeak() public function getWeak()
{ {
return $this->weak; return isset($this->weak) ? $this->weak : false;
}
public function hasWeak()
{
return isset($this->weak);
}
public function clearWeak()
{
unset($this->weak);
} }
/** /**
@ -442,16 +465,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->weak = $var; $this->weak = $var;
$this->has_weak = true;
return $this; return $this;
} }
public function hasWeak()
{
return $this->has_weak;
}
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
@ -474,15 +491,9 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -22,29 +22,25 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* e.g. "foo", "foo.bar", etc. * e.g. "foo", "foo.bar", etc.
* *
* Generated from protobuf field <code>optional string package = 2;</code> * Generated from protobuf field <code>optional string package = 2;</code>
*/ */
protected $package = ''; protected $package = null;
private $has_package = false;
/** /**
* Names of files imported by this file. * Names of files imported by this file.
* *
* Generated from protobuf field <code>repeated string dependency = 3;</code> * Generated from protobuf field <code>repeated string dependency = 3;</code>
*/ */
private $dependency; private $dependency;
private $has_dependency = false;
/** /**
* Indexes of the public imported files in the dependency list above. * Indexes of the public imported files in the dependency list above.
* *
* Generated from protobuf field <code>repeated int32 public_dependency = 10;</code> * Generated from protobuf field <code>repeated int32 public_dependency = 10;</code>
*/ */
private $public_dependency; private $public_dependency;
private $has_public_dependency = false;
/** /**
* Indexes of the weak imported files in the dependency list. * Indexes of the weak imported files in the dependency list.
* For Google-internal migration only. Do not use. * For Google-internal migration only. Do not use.
@ -52,34 +48,28 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated int32 weak_dependency = 11;</code> * Generated from protobuf field <code>repeated int32 weak_dependency = 11;</code>
*/ */
private $weak_dependency; private $weak_dependency;
private $has_weak_dependency = false;
/** /**
* All top-level definitions in this file. * All top-level definitions in this file.
* *
* Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code> * Generated from protobuf field <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code>
*/ */
private $message_type; private $message_type;
private $has_message_type = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
*/ */
private $enum_type; private $enum_type;
private $has_enum_type = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code> * Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
*/ */
private $service; private $service;
private $has_service = false;
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
*/ */
private $extension; private $extension;
private $has_extension = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code> * Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* This field contains optional information about the original source code. * This field contains optional information about the original source code.
* You may safely remove this entire field without harming runtime * You may safely remove this entire field without harming runtime
@ -89,15 +79,13 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code> * Generated from protobuf field <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
*/ */
protected $source_code_info = null; protected $source_code_info = null;
private $has_source_code_info = false;
/** /**
* The syntax of the proto file. * The syntax of the proto file.
* The supported values are "proto2" and "proto3". * The supported values are "proto2" and "proto3".
* *
* Generated from protobuf field <code>optional string syntax = 12;</code> * Generated from protobuf field <code>optional string syntax = 12;</code>
*/ */
protected $syntax = ''; protected $syntax = null;
private $has_syntax = false;
/** /**
* Constructor. * Constructor.
@ -145,7 +133,17 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -159,16 +157,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* e.g. "foo", "foo.bar", etc. * e.g. "foo", "foo.bar", etc.
* *
@ -177,7 +169,17 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getPackage() public function getPackage()
{ {
return $this->package; return isset($this->package) ? $this->package : '';
}
public function hasPackage()
{
return isset($this->package);
}
public function clearPackage()
{
unset($this->package);
} }
/** /**
@ -191,16 +193,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->package = $var; $this->package = $var;
$this->has_package = true;
return $this; return $this;
} }
public function hasPackage()
{
return $this->has_package;
}
/** /**
* Names of files imported by this file. * Names of files imported by this file.
* *
@ -223,16 +219,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
$this->dependency = $arr; $this->dependency = $arr;
$this->has_dependency = true;
return $this; return $this;
} }
public function hasDependency()
{
return $this->has_dependency;
}
/** /**
* Indexes of the public imported files in the dependency list above. * Indexes of the public imported files in the dependency list above.
* *
@ -255,16 +245,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->public_dependency = $arr; $this->public_dependency = $arr;
$this->has_public_dependency = true;
return $this; return $this;
} }
public function hasPublicDependency()
{
return $this->has_public_dependency;
}
/** /**
* Indexes of the weak imported files in the dependency list. * Indexes of the weak imported files in the dependency list.
* For Google-internal migration only. Do not use. * For Google-internal migration only. Do not use.
@ -289,16 +273,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->weak_dependency = $arr; $this->weak_dependency = $arr;
$this->has_weak_dependency = true;
return $this; return $this;
} }
public function hasWeakDependency()
{
return $this->has_weak_dependency;
}
/** /**
* All top-level definitions in this file. * All top-level definitions in this file.
* *
@ -321,16 +299,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
$this->message_type = $arr; $this->message_type = $arr;
$this->has_message_type = true;
return $this; return $this;
} }
public function hasMessageType()
{
return $this->has_message_type;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code> * Generated from protobuf field <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -349,16 +321,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
$this->enum_type = $arr; $this->enum_type = $arr;
$this->has_enum_type = true;
return $this; return $this;
} }
public function hasEnumType()
{
return $this->has_enum_type;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code> * Generated from protobuf field <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -377,16 +343,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class);
$this->service = $arr; $this->service = $arr;
$this->has_service = true;
return $this; return $this;
} }
public function hasService()
{
return $this->has_service;
}
/** /**
* Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code> * Generated from protobuf field <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
* @return \Google\Protobuf\Internal\RepeatedField * @return \Google\Protobuf\Internal\RepeatedField
@ -405,23 +365,27 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
$this->extension = $arr; $this->extension = $arr;
$this->has_extension = true;
return $this; return $this;
} }
public function hasExtension()
{
return $this->has_extension;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code> * Generated from protobuf field <code>optional .google.protobuf.FileOptions options = 8;</code>
* @return \Google\Protobuf\Internal\FileOptions * @return \Google\Protobuf\Internal\FileOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -433,16 +397,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
/** /**
* This field contains optional information about the original source code. * This field contains optional information about the original source code.
* You may safely remove this entire field without harming runtime * You may safely remove this entire field without harming runtime
@ -454,7 +412,17 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getSourceCodeInfo() public function getSourceCodeInfo()
{ {
return $this->source_code_info; return isset($this->source_code_info) ? $this->source_code_info : null;
}
public function hasSourceCodeInfo()
{
return isset($this->source_code_info);
}
public function clearSourceCodeInfo()
{
unset($this->source_code_info);
} }
/** /**
@ -471,16 +439,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class);
$this->source_code_info = $var; $this->source_code_info = $var;
$this->has_source_code_info = true;
return $this; return $this;
} }
public function hasSourceCodeInfo()
{
return $this->has_source_code_info;
}
/** /**
* The syntax of the proto file. * The syntax of the proto file.
* The supported values are "proto2" and "proto3". * The supported values are "proto2" and "proto3".
@ -490,7 +452,17 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getSyntax() public function getSyntax()
{ {
return $this->syntax; return isset($this->syntax) ? $this->syntax : '';
}
public function hasSyntax()
{
return isset($this->syntax);
}
public function clearSyntax()
{
unset($this->syntax);
} }
/** /**
@ -505,15 +477,9 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->syntax = $var; $this->syntax = $var;
$this->has_syntax = true;
return $this; return $this;
} }
public function hasSyntax()
{
return $this->has_syntax;
}
} }

@ -22,7 +22,6 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code> * Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
*/ */
private $file; private $file;
private $has_file = false;
/** /**
* Constructor. * Constructor.
@ -56,15 +55,9 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class);
$this->file = $arr; $this->file = $arr;
$this->has_file = true;
return $this; return $this;
} }
public function hasFile()
{
return $this->has_file;
}
} }

@ -23,8 +23,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string java_package = 1;</code> * Generated from protobuf field <code>optional string java_package = 1;</code>
*/ */
protected $java_package = ''; protected $java_package = null;
private $has_java_package = false;
/** /**
* If set, all the classes from the .proto file are wrapped in a single * If set, all the classes from the .proto file are wrapped in a single
* outer class with the given name. This applies to both Proto1 * outer class with the given name. This applies to both Proto1
@ -34,8 +33,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string java_outer_classname = 8;</code> * Generated from protobuf field <code>optional string java_outer_classname = 8;</code>
*/ */
protected $java_outer_classname = ''; protected $java_outer_classname = null;
private $has_java_outer_classname = false;
/** /**
* If set true, then the Java code generator will generate a separate .java * If set true, then the Java code generator will generate a separate .java
* file for each top-level message, enum, and service defined in the .proto * file for each top-level message, enum, and service defined in the .proto
@ -46,15 +44,13 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool java_multiple_files = 10 [default = false];</code> * Generated from protobuf field <code>optional bool java_multiple_files = 10 [default = false];</code>
*/ */
protected $java_multiple_files = false; protected $java_multiple_files = null;
private $has_java_multiple_files = false;
/** /**
* This option does nothing. * This option does nothing.
* *
* Generated from protobuf field <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code> * Generated from protobuf field <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code>
*/ */
protected $java_generate_equals_and_hash = false; protected $java_generate_equals_and_hash = null;
private $has_java_generate_equals_and_hash = false;
/** /**
* If set true, then the Java2 code generator will generate code that * If set true, then the Java2 code generator will generate code that
* throws an exception whenever an attempt is made to assign a non-UTF-8 * throws an exception whenever an attempt is made to assign a non-UTF-8
@ -65,13 +61,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool java_string_check_utf8 = 27 [default = false];</code> * Generated from protobuf field <code>optional bool java_string_check_utf8 = 27 [default = false];</code>
*/ */
protected $java_string_check_utf8 = false; protected $java_string_check_utf8 = null;
private $has_java_string_check_utf8 = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code> * Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
*/ */
protected $optimize_for = 0; protected $optimize_for = null;
private $has_optimize_for = false;
/** /**
* Sets the Go package where structs generated from this .proto will be * Sets the Go package where structs generated from this .proto will be
* placed. If omitted, the Go package will be derived from the following: * placed. If omitted, the Go package will be derived from the following:
@ -81,8 +75,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string go_package = 11;</code> * Generated from protobuf field <code>optional string go_package = 11;</code>
*/ */
protected $go_package = ''; protected $go_package = null;
private $has_go_package = false;
/** /**
* Should generic services be generated in each language? "Generic" services * Should generic services be generated in each language? "Generic" services
* are not specific to any particular RPC system. They are generated by the * are not specific to any particular RPC system. They are generated by the
@ -96,23 +89,19 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool cc_generic_services = 16 [default = false];</code> * Generated from protobuf field <code>optional bool cc_generic_services = 16 [default = false];</code>
*/ */
protected $cc_generic_services = false; protected $cc_generic_services = null;
private $has_cc_generic_services = false;
/** /**
* Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code> * Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code>
*/ */
protected $java_generic_services = false; protected $java_generic_services = null;
private $has_java_generic_services = false;
/** /**
* Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code> * Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code>
*/ */
protected $py_generic_services = false; protected $py_generic_services = null;
private $has_py_generic_services = false;
/** /**
* Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code> * Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code>
*/ */
protected $php_generic_services = false; protected $php_generic_services = null;
private $has_php_generic_services = false;
/** /**
* Is this file deprecated? * Is this file deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -121,31 +110,27 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool deprecated = 23 [default = false];</code> * Generated from protobuf field <code>optional bool deprecated = 23 [default = false];</code>
*/ */
protected $deprecated = false; protected $deprecated = null;
private $has_deprecated = false;
/** /**
* Enables the use of arenas for the proto messages in this file. This applies * Enables the use of arenas for the proto messages in this file. This applies
* only to generated classes for C++. * only to generated classes for C++.
* *
* Generated from protobuf field <code>optional bool cc_enable_arenas = 31 [default = true];</code> * Generated from protobuf field <code>optional bool cc_enable_arenas = 31 [default = true];</code>
*/ */
protected $cc_enable_arenas = false; protected $cc_enable_arenas = null;
private $has_cc_enable_arenas = false;
/** /**
* Sets the objective c class prefix which is prepended to all objective c * Sets the objective c class prefix which is prepended to all objective c
* generated classes from this .proto. There is no default. * generated classes from this .proto. There is no default.
* *
* Generated from protobuf field <code>optional string objc_class_prefix = 36;</code> * Generated from protobuf field <code>optional string objc_class_prefix = 36;</code>
*/ */
protected $objc_class_prefix = ''; protected $objc_class_prefix = null;
private $has_objc_class_prefix = false;
/** /**
* Namespace for generated classes; defaults to the package. * Namespace for generated classes; defaults to the package.
* *
* Generated from protobuf field <code>optional string csharp_namespace = 37;</code> * Generated from protobuf field <code>optional string csharp_namespace = 37;</code>
*/ */
protected $csharp_namespace = ''; protected $csharp_namespace = null;
private $has_csharp_namespace = false;
/** /**
* By default Swift generators will take the proto package and CamelCase it * By default Swift generators will take the proto package and CamelCase it
* replacing '.' with underscore and use that to prefix the types/symbols * replacing '.' with underscore and use that to prefix the types/symbols
@ -154,16 +139,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string swift_prefix = 39;</code> * Generated from protobuf field <code>optional string swift_prefix = 39;</code>
*/ */
protected $swift_prefix = ''; protected $swift_prefix = null;
private $has_swift_prefix = false;
/** /**
* Sets the php class prefix which is prepended to all php generated classes * Sets the php class prefix which is prepended to all php generated classes
* from this .proto. Default is empty. * from this .proto. Default is empty.
* *
* Generated from protobuf field <code>optional string php_class_prefix = 40;</code> * Generated from protobuf field <code>optional string php_class_prefix = 40;</code>
*/ */
protected $php_class_prefix = ''; protected $php_class_prefix = null;
private $has_php_class_prefix = false;
/** /**
* Use this option to change the namespace of php generated classes. Default * Use this option to change the namespace of php generated classes. Default
* is empty. When this option is empty, the package name will be used for * is empty. When this option is empty, the package name will be used for
@ -171,8 +154,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string php_namespace = 41;</code> * Generated from protobuf field <code>optional string php_namespace = 41;</code>
*/ */
protected $php_namespace = ''; protected $php_namespace = null;
private $has_php_namespace = false;
/** /**
* Use this option to change the namespace of php generated metadata classes. * Use this option to change the namespace of php generated metadata classes.
* Default is empty. When this option is empty, the proto file name will be * Default is empty. When this option is empty, the proto file name will be
@ -180,8 +162,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string php_metadata_namespace = 44;</code> * Generated from protobuf field <code>optional string php_metadata_namespace = 44;</code>
*/ */
protected $php_metadata_namespace = ''; protected $php_metadata_namespace = null;
private $has_php_metadata_namespace = false;
/** /**
* Use this option to change the package of ruby generated classes. Default * Use this option to change the package of ruby generated classes. Default
* is empty. When this option is not set, the package name will be used for * is empty. When this option is not set, the package name will be used for
@ -189,8 +170,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional string ruby_package = 45;</code> * Generated from protobuf field <code>optional string ruby_package = 45;</code>
*/ */
protected $ruby_package = ''; protected $ruby_package = null;
private $has_ruby_package = false;
/** /**
* The parser stores options it doesn't recognize here. * The parser stores options it doesn't recognize here.
* See the documentation for the "Options" section above. * See the documentation for the "Options" section above.
@ -198,7 +178,6 @@ class FileOptions extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -307,7 +286,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJavaPackage() public function getJavaPackage()
{ {
return $this->java_package; return isset($this->java_package) ? $this->java_package : '';
}
public function hasJavaPackage()
{
return isset($this->java_package);
}
public function clearJavaPackage()
{
unset($this->java_package);
} }
/** /**
@ -324,16 +313,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->java_package = $var; $this->java_package = $var;
$this->has_java_package = true;
return $this; return $this;
} }
public function hasJavaPackage()
{
return $this->has_java_package;
}
/** /**
* If set, all the classes from the .proto file are wrapped in a single * If set, all the classes from the .proto file are wrapped in a single
* outer class with the given name. This applies to both Proto1 * outer class with the given name. This applies to both Proto1
@ -346,7 +329,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJavaOuterClassname() public function getJavaOuterClassname()
{ {
return $this->java_outer_classname; return isset($this->java_outer_classname) ? $this->java_outer_classname : '';
}
public function hasJavaOuterClassname()
{
return isset($this->java_outer_classname);
}
public function clearJavaOuterClassname()
{
unset($this->java_outer_classname);
} }
/** /**
@ -364,16 +357,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->java_outer_classname = $var; $this->java_outer_classname = $var;
$this->has_java_outer_classname = true;
return $this; return $this;
} }
public function hasJavaOuterClassname()
{
return $this->has_java_outer_classname;
}
/** /**
* If set true, then the Java code generator will generate a separate .java * If set true, then the Java code generator will generate a separate .java
* file for each top-level message, enum, and service defined in the .proto * file for each top-level message, enum, and service defined in the .proto
@ -387,7 +374,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJavaMultipleFiles() public function getJavaMultipleFiles()
{ {
return $this->java_multiple_files; return isset($this->java_multiple_files) ? $this->java_multiple_files : false;
}
public function hasJavaMultipleFiles()
{
return isset($this->java_multiple_files);
}
public function clearJavaMultipleFiles()
{
unset($this->java_multiple_files);
} }
/** /**
@ -406,16 +403,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->java_multiple_files = $var; $this->java_multiple_files = $var;
$this->has_java_multiple_files = true;
return $this; return $this;
} }
public function hasJavaMultipleFiles()
{
return $this->has_java_multiple_files;
}
/** /**
* This option does nothing. * This option does nothing.
* *
@ -424,7 +415,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJavaGenerateEqualsAndHash() public function getJavaGenerateEqualsAndHash()
{ {
return $this->java_generate_equals_and_hash; return isset($this->java_generate_equals_and_hash) ? $this->java_generate_equals_and_hash : false;
}
public function hasJavaGenerateEqualsAndHash()
{
return isset($this->java_generate_equals_and_hash);
}
public function clearJavaGenerateEqualsAndHash()
{
unset($this->java_generate_equals_and_hash);
} }
/** /**
@ -438,16 +439,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->java_generate_equals_and_hash = $var; $this->java_generate_equals_and_hash = $var;
$this->has_java_generate_equals_and_hash = true;
return $this; return $this;
} }
public function hasJavaGenerateEqualsAndHash()
{
return $this->has_java_generate_equals_and_hash;
}
/** /**
* If set true, then the Java2 code generator will generate code that * If set true, then the Java2 code generator will generate code that
* throws an exception whenever an attempt is made to assign a non-UTF-8 * throws an exception whenever an attempt is made to assign a non-UTF-8
@ -461,7 +456,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getJavaStringCheckUtf8() public function getJavaStringCheckUtf8()
{ {
return $this->java_string_check_utf8; return isset($this->java_string_check_utf8) ? $this->java_string_check_utf8 : false;
}
public function hasJavaStringCheckUtf8()
{
return isset($this->java_string_check_utf8);
}
public function clearJavaStringCheckUtf8()
{
unset($this->java_string_check_utf8);
} }
/** /**
@ -480,23 +485,27 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->java_string_check_utf8 = $var; $this->java_string_check_utf8 = $var;
$this->has_java_string_check_utf8 = true;
return $this; return $this;
} }
public function hasJavaStringCheckUtf8()
{
return $this->has_java_string_check_utf8;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code> * Generated from protobuf field <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
* @return int * @return int
*/ */
public function getOptimizeFor() public function getOptimizeFor()
{ {
return $this->optimize_for; return isset($this->optimize_for) ? $this->optimize_for : 0;
}
public function hasOptimizeFor()
{
return isset($this->optimize_for);
}
public function clearOptimizeFor()
{
unset($this->optimize_for);
} }
/** /**
@ -508,16 +517,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions\OptimizeMode::class); GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions\OptimizeMode::class);
$this->optimize_for = $var; $this->optimize_for = $var;
$this->has_optimize_for = true;
return $this; return $this;
} }
public function hasOptimizeFor()
{
return $this->has_optimize_for;
}
/** /**
* Sets the Go package where structs generated from this .proto will be * Sets the Go package where structs generated from this .proto will be
* placed. If omitted, the Go package will be derived from the following: * placed. If omitted, the Go package will be derived from the following:
@ -530,7 +533,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getGoPackage() public function getGoPackage()
{ {
return $this->go_package; return isset($this->go_package) ? $this->go_package : '';
}
public function hasGoPackage()
{
return isset($this->go_package);
}
public function clearGoPackage()
{
unset($this->go_package);
} }
/** /**
@ -548,16 +561,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->go_package = $var; $this->go_package = $var;
$this->has_go_package = true;
return $this; return $this;
} }
public function hasGoPackage()
{
return $this->has_go_package;
}
/** /**
* Should generic services be generated in each language? "Generic" services * Should generic services be generated in each language? "Generic" services
* are not specific to any particular RPC system. They are generated by the * are not specific to any particular RPC system. They are generated by the
@ -574,7 +581,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getCcGenericServices() public function getCcGenericServices()
{ {
return $this->cc_generic_services; return isset($this->cc_generic_services) ? $this->cc_generic_services : false;
}
public function hasCcGenericServices()
{
return isset($this->cc_generic_services);
}
public function clearCcGenericServices()
{
unset($this->cc_generic_services);
} }
/** /**
@ -596,23 +613,27 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->cc_generic_services = $var; $this->cc_generic_services = $var;
$this->has_cc_generic_services = true;
return $this; return $this;
} }
public function hasCcGenericServices()
{
return $this->has_cc_generic_services;
}
/** /**
* Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code> * Generated from protobuf field <code>optional bool java_generic_services = 17 [default = false];</code>
* @return bool * @return bool
*/ */
public function getJavaGenericServices() public function getJavaGenericServices()
{ {
return $this->java_generic_services; return isset($this->java_generic_services) ? $this->java_generic_services : false;
}
public function hasJavaGenericServices()
{
return isset($this->java_generic_services);
}
public function clearJavaGenericServices()
{
unset($this->java_generic_services);
} }
/** /**
@ -624,23 +645,27 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->java_generic_services = $var; $this->java_generic_services = $var;
$this->has_java_generic_services = true;
return $this; return $this;
} }
public function hasJavaGenericServices()
{
return $this->has_java_generic_services;
}
/** /**
* Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code> * Generated from protobuf field <code>optional bool py_generic_services = 18 [default = false];</code>
* @return bool * @return bool
*/ */
public function getPyGenericServices() public function getPyGenericServices()
{ {
return $this->py_generic_services; return isset($this->py_generic_services) ? $this->py_generic_services : false;
}
public function hasPyGenericServices()
{
return isset($this->py_generic_services);
}
public function clearPyGenericServices()
{
unset($this->py_generic_services);
} }
/** /**
@ -652,23 +677,27 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->py_generic_services = $var; $this->py_generic_services = $var;
$this->has_py_generic_services = true;
return $this; return $this;
} }
public function hasPyGenericServices()
{
return $this->has_py_generic_services;
}
/** /**
* Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code> * Generated from protobuf field <code>optional bool php_generic_services = 42 [default = false];</code>
* @return bool * @return bool
*/ */
public function getPhpGenericServices() public function getPhpGenericServices()
{ {
return $this->php_generic_services; return isset($this->php_generic_services) ? $this->php_generic_services : false;
}
public function hasPhpGenericServices()
{
return isset($this->php_generic_services);
}
public function clearPhpGenericServices()
{
unset($this->php_generic_services);
} }
/** /**
@ -680,16 +709,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->php_generic_services = $var; $this->php_generic_services = $var;
$this->has_php_generic_services = true;
return $this; return $this;
} }
public function hasPhpGenericServices()
{
return $this->has_php_generic_services;
}
/** /**
* Is this file deprecated? * Is this file deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -701,7 +724,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getDeprecated() public function getDeprecated()
{ {
return $this->deprecated; return isset($this->deprecated) ? $this->deprecated : false;
}
public function hasDeprecated()
{
return isset($this->deprecated);
}
public function clearDeprecated()
{
unset($this->deprecated);
} }
/** /**
@ -718,16 +751,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->deprecated = $var; $this->deprecated = $var;
$this->has_deprecated = true;
return $this; return $this;
} }
public function hasDeprecated()
{
return $this->has_deprecated;
}
/** /**
* Enables the use of arenas for the proto messages in this file. This applies * Enables the use of arenas for the proto messages in this file. This applies
* only to generated classes for C++. * only to generated classes for C++.
@ -737,7 +764,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getCcEnableArenas() public function getCcEnableArenas()
{ {
return $this->cc_enable_arenas; return isset($this->cc_enable_arenas) ? $this->cc_enable_arenas : false;
}
public function hasCcEnableArenas()
{
return isset($this->cc_enable_arenas);
}
public function clearCcEnableArenas()
{
unset($this->cc_enable_arenas);
} }
/** /**
@ -752,16 +789,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->cc_enable_arenas = $var; $this->cc_enable_arenas = $var;
$this->has_cc_enable_arenas = true;
return $this; return $this;
} }
public function hasCcEnableArenas()
{
return $this->has_cc_enable_arenas;
}
/** /**
* Sets the objective c class prefix which is prepended to all objective c * Sets the objective c class prefix which is prepended to all objective c
* generated classes from this .proto. There is no default. * generated classes from this .proto. There is no default.
@ -771,7 +802,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getObjcClassPrefix() public function getObjcClassPrefix()
{ {
return $this->objc_class_prefix; return isset($this->objc_class_prefix) ? $this->objc_class_prefix : '';
}
public function hasObjcClassPrefix()
{
return isset($this->objc_class_prefix);
}
public function clearObjcClassPrefix()
{
unset($this->objc_class_prefix);
} }
/** /**
@ -786,16 +827,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->objc_class_prefix = $var; $this->objc_class_prefix = $var;
$this->has_objc_class_prefix = true;
return $this; return $this;
} }
public function hasObjcClassPrefix()
{
return $this->has_objc_class_prefix;
}
/** /**
* Namespace for generated classes; defaults to the package. * Namespace for generated classes; defaults to the package.
* *
@ -804,7 +839,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getCsharpNamespace() public function getCsharpNamespace()
{ {
return $this->csharp_namespace; return isset($this->csharp_namespace) ? $this->csharp_namespace : '';
}
public function hasCsharpNamespace()
{
return isset($this->csharp_namespace);
}
public function clearCsharpNamespace()
{
unset($this->csharp_namespace);
} }
/** /**
@ -818,16 +863,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->csharp_namespace = $var; $this->csharp_namespace = $var;
$this->has_csharp_namespace = true;
return $this; return $this;
} }
public function hasCsharpNamespace()
{
return $this->has_csharp_namespace;
}
/** /**
* By default Swift generators will take the proto package and CamelCase it * By default Swift generators will take the proto package and CamelCase it
* replacing '.' with underscore and use that to prefix the types/symbols * replacing '.' with underscore and use that to prefix the types/symbols
@ -839,7 +878,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getSwiftPrefix() public function getSwiftPrefix()
{ {
return $this->swift_prefix; return isset($this->swift_prefix) ? $this->swift_prefix : '';
}
public function hasSwiftPrefix()
{
return isset($this->swift_prefix);
}
public function clearSwiftPrefix()
{
unset($this->swift_prefix);
} }
/** /**
@ -856,16 +905,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->swift_prefix = $var; $this->swift_prefix = $var;
$this->has_swift_prefix = true;
return $this; return $this;
} }
public function hasSwiftPrefix()
{
return $this->has_swift_prefix;
}
/** /**
* Sets the php class prefix which is prepended to all php generated classes * Sets the php class prefix which is prepended to all php generated classes
* from this .proto. Default is empty. * from this .proto. Default is empty.
@ -875,7 +918,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getPhpClassPrefix() public function getPhpClassPrefix()
{ {
return $this->php_class_prefix; return isset($this->php_class_prefix) ? $this->php_class_prefix : '';
}
public function hasPhpClassPrefix()
{
return isset($this->php_class_prefix);
}
public function clearPhpClassPrefix()
{
unset($this->php_class_prefix);
} }
/** /**
@ -890,16 +943,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->php_class_prefix = $var; $this->php_class_prefix = $var;
$this->has_php_class_prefix = true;
return $this; return $this;
} }
public function hasPhpClassPrefix()
{
return $this->has_php_class_prefix;
}
/** /**
* Use this option to change the namespace of php generated classes. Default * Use this option to change the namespace of php generated classes. Default
* is empty. When this option is empty, the package name will be used for * is empty. When this option is empty, the package name will be used for
@ -910,7 +957,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getPhpNamespace() public function getPhpNamespace()
{ {
return $this->php_namespace; return isset($this->php_namespace) ? $this->php_namespace : '';
}
public function hasPhpNamespace()
{
return isset($this->php_namespace);
}
public function clearPhpNamespace()
{
unset($this->php_namespace);
} }
/** /**
@ -926,16 +983,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->php_namespace = $var; $this->php_namespace = $var;
$this->has_php_namespace = true;
return $this; return $this;
} }
public function hasPhpNamespace()
{
return $this->has_php_namespace;
}
/** /**
* Use this option to change the namespace of php generated metadata classes. * Use this option to change the namespace of php generated metadata classes.
* Default is empty. When this option is empty, the proto file name will be * Default is empty. When this option is empty, the proto file name will be
@ -946,7 +997,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getPhpMetadataNamespace() public function getPhpMetadataNamespace()
{ {
return $this->php_metadata_namespace; return isset($this->php_metadata_namespace) ? $this->php_metadata_namespace : '';
}
public function hasPhpMetadataNamespace()
{
return isset($this->php_metadata_namespace);
}
public function clearPhpMetadataNamespace()
{
unset($this->php_metadata_namespace);
} }
/** /**
@ -962,16 +1023,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->php_metadata_namespace = $var; $this->php_metadata_namespace = $var;
$this->has_php_metadata_namespace = true;
return $this; return $this;
} }
public function hasPhpMetadataNamespace()
{
return $this->has_php_metadata_namespace;
}
/** /**
* Use this option to change the package of ruby generated classes. Default * Use this option to change the package of ruby generated classes. Default
* is empty. When this option is not set, the package name will be used for * is empty. When this option is not set, the package name will be used for
@ -982,7 +1037,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getRubyPackage() public function getRubyPackage()
{ {
return $this->ruby_package; return isset($this->ruby_package) ? $this->ruby_package : '';
}
public function hasRubyPackage()
{
return isset($this->ruby_package);
}
public function clearRubyPackage()
{
unset($this->ruby_package);
} }
/** /**
@ -998,16 +1063,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->ruby_package = $var; $this->ruby_package = $var;
$this->has_ruby_package = true;
return $this; return $this;
} }
public function hasRubyPackage()
{
return $this->has_ruby_package;
}
/** /**
* The parser stores options it doesn't recognize here. * The parser stores options it doesn't recognize here.
* See the documentation for the "Options" section above. * See the documentation for the "Options" section above.
@ -1032,15 +1091,9 @@ class FileOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -26,7 +26,6 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code> * Generated from protobuf field <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code>
*/ */
private $annotation; private $annotation;
private $has_annotation = false;
/** /**
* Constructor. * Constructor.
@ -68,15 +67,9 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo\Annotation::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo\Annotation::class);
$this->annotation = $arr; $this->annotation = $arr;
$this->has_annotation = true;
return $this; return $this;
} }
public function hasAnnotation()
{
return $this->has_annotation;
}
} }

@ -22,22 +22,19 @@ class Annotation extends \Google\Protobuf\Internal\Message
* Generated from protobuf field <code>repeated int32 path = 1 [packed = true];</code> * Generated from protobuf field <code>repeated int32 path = 1 [packed = true];</code>
*/ */
private $path; private $path;
private $has_path = false;
/** /**
* Identifies the filesystem path to the original source .proto. * Identifies the filesystem path to the original source .proto.
* *
* Generated from protobuf field <code>optional string source_file = 2;</code> * Generated from protobuf field <code>optional string source_file = 2;</code>
*/ */
protected $source_file = ''; protected $source_file = null;
private $has_source_file = false;
/** /**
* Identifies the starting offset in bytes in the generated code * Identifies the starting offset in bytes in the generated code
* that relates to the identified object. * that relates to the identified object.
* *
* Generated from protobuf field <code>optional int32 begin = 3;</code> * Generated from protobuf field <code>optional int32 begin = 3;</code>
*/ */
protected $begin = 0; protected $begin = null;
private $has_begin = false;
/** /**
* Identifies the ending offset in bytes in the generated code that * Identifies the ending offset in bytes in the generated code that
* relates to the identified offset. The end offset should be one past * relates to the identified offset. The end offset should be one past
@ -45,8 +42,7 @@ class Annotation extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional int32 end = 4;</code> * Generated from protobuf field <code>optional int32 end = 4;</code>
*/ */
protected $end = 0; protected $end = null;
private $has_end = false;
/** /**
* Constructor. * Constructor.
@ -97,16 +93,10 @@ class Annotation extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
$this->path = $arr; $this->path = $arr;
$this->has_path = true;
return $this; return $this;
} }
public function hasPath()
{
return $this->has_path;
}
/** /**
* Identifies the filesystem path to the original source .proto. * Identifies the filesystem path to the original source .proto.
* *
@ -115,7 +105,17 @@ class Annotation extends \Google\Protobuf\Internal\Message
*/ */
public function getSourceFile() public function getSourceFile()
{ {
return $this->source_file; return isset($this->source_file) ? $this->source_file : '';
}
public function hasSourceFile()
{
return isset($this->source_file);
}
public function clearSourceFile()
{
unset($this->source_file);
} }
/** /**
@ -129,16 +129,10 @@ class Annotation extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->source_file = $var; $this->source_file = $var;
$this->has_source_file = true;
return $this; return $this;
} }
public function hasSourceFile()
{
return $this->has_source_file;
}
/** /**
* Identifies the starting offset in bytes in the generated code * Identifies the starting offset in bytes in the generated code
* that relates to the identified object. * that relates to the identified object.
@ -148,7 +142,17 @@ class Annotation extends \Google\Protobuf\Internal\Message
*/ */
public function getBegin() public function getBegin()
{ {
return $this->begin; return isset($this->begin) ? $this->begin : 0;
}
public function hasBegin()
{
return isset($this->begin);
}
public function clearBegin()
{
unset($this->begin);
} }
/** /**
@ -163,16 +167,10 @@ class Annotation extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->begin = $var; $this->begin = $var;
$this->has_begin = true;
return $this; return $this;
} }
public function hasBegin()
{
return $this->has_begin;
}
/** /**
* Identifies the ending offset in bytes in the generated code that * Identifies the ending offset in bytes in the generated code that
* relates to the identified offset. The end offset should be one past * relates to the identified offset. The end offset should be one past
@ -183,7 +181,17 @@ class Annotation extends \Google\Protobuf\Internal\Message
*/ */
public function getEnd() public function getEnd()
{ {
return $this->end; return isset($this->end) ? $this->end : 0;
}
public function hasEnd()
{
return isset($this->end);
}
public function clearEnd()
{
unset($this->end);
} }
/** /**
@ -199,16 +207,10 @@ class Annotation extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->end = $var; $this->end = $var;
$this->has_end = true;
return $this; return $this;
} }
public function hasEnd()
{
return $this->has_end;
}
} }
// Adding a class alias for backwards compatibility with the previous class name. // Adding a class alias for backwards compatibility with the previous class name.

@ -225,6 +225,15 @@ class Message
} }
} }
protected function hasOneof($number)
{
$field = $this->desc->getFieldByNumber($number);
$oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()];
$oneof_name = $oneof->getName();
$oneof_field = $this->$oneof_name;
return $number === $oneof_field->getNumber();
}
protected function writeOneof($number, $value) protected function writeOneof($number, $value)
{ {
$field = $this->desc->getFieldByNumber($number); $field = $this->desc->getFieldByNumber($number);
@ -1559,14 +1568,19 @@ class Message
*/ */
private function existField($field) private function existField($field)
{ {
$oneof_index = $field->getOneofIndex(); $getter = $field->getGetter();
if ($oneof_index !== -1) { $hazzer = "has" . substr($getter, 3);
$oneof = $this->desc->getOneofDecl()[$oneof_index];
$oneof_name = $oneof->getName(); if (method_exists($this, $hazzer)) {
return $this->$oneof_name->getNumber() === $field->getNumber(); return $this->$hazzer();
} else if ($field->getOneofIndex() !== -1) {
// For old generated code, which does not have hazzers for oneof
// fields.
$oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()];
$oneof_name = $oneof->getName();
return $this->$oneof_name->getNumber() === $field->getNumber();
} }
$getter = $field->getGetter();
$values = $this->$getter(); $values = $this->$getter();
if ($field->isMap()) { if ($field->isMap()) {
return count($values) !== 0; return count($values) !== 0;

@ -34,8 +34,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool message_set_wire_format = 1 [default = false];</code> * Generated from protobuf field <code>optional bool message_set_wire_format = 1 [default = false];</code>
*/ */
protected $message_set_wire_format = false; protected $message_set_wire_format = null;
private $has_message_set_wire_format = false;
/** /**
* Disables the generation of the standard "descriptor()" accessor, which can * Disables the generation of the standard "descriptor()" accessor, which can
* conflict with a field of the same name. This is meant to make migration * conflict with a field of the same name. This is meant to make migration
@ -43,8 +42,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code> * Generated from protobuf field <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code>
*/ */
protected $no_standard_descriptor_accessor = false; protected $no_standard_descriptor_accessor = null;
private $has_no_standard_descriptor_accessor = false;
/** /**
* Is this message deprecated? * Is this message deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -53,8 +51,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code> * Generated from protobuf field <code>optional bool deprecated = 3 [default = false];</code>
*/ */
protected $deprecated = false; protected $deprecated = null;
private $has_deprecated = false;
/** /**
* Whether the message is an automatically generated map entry type for the * Whether the message is an automatically generated map entry type for the
* maps field. * maps field.
@ -77,15 +74,13 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* *
* Generated from protobuf field <code>optional bool map_entry = 7;</code> * Generated from protobuf field <code>optional bool map_entry = 7;</code>
*/ */
protected $map_entry = false; protected $map_entry = null;
private $has_map_entry = false;
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
*/ */
private $uninterpreted_option; private $uninterpreted_option;
private $has_uninterpreted_option = false;
/** /**
* Constructor. * Constructor.
@ -168,7 +163,17 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getMessageSetWireFormat() public function getMessageSetWireFormat()
{ {
return $this->message_set_wire_format; return isset($this->message_set_wire_format) ? $this->message_set_wire_format : false;
}
public function hasMessageSetWireFormat()
{
return isset($this->message_set_wire_format);
}
public function clearMessageSetWireFormat()
{
unset($this->message_set_wire_format);
} }
/** /**
@ -196,16 +201,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->message_set_wire_format = $var; $this->message_set_wire_format = $var;
$this->has_message_set_wire_format = true;
return $this; return $this;
} }
public function hasMessageSetWireFormat()
{
return $this->has_message_set_wire_format;
}
/** /**
* Disables the generation of the standard "descriptor()" accessor, which can * Disables the generation of the standard "descriptor()" accessor, which can
* conflict with a field of the same name. This is meant to make migration * conflict with a field of the same name. This is meant to make migration
@ -216,7 +215,17 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getNoStandardDescriptorAccessor() public function getNoStandardDescriptorAccessor()
{ {
return $this->no_standard_descriptor_accessor; return isset($this->no_standard_descriptor_accessor) ? $this->no_standard_descriptor_accessor : false;
}
public function hasNoStandardDescriptorAccessor()
{
return isset($this->no_standard_descriptor_accessor);
}
public function clearNoStandardDescriptorAccessor()
{
unset($this->no_standard_descriptor_accessor);
} }
/** /**
@ -232,16 +241,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->no_standard_descriptor_accessor = $var; $this->no_standard_descriptor_accessor = $var;
$this->has_no_standard_descriptor_accessor = true;
return $this; return $this;
} }
public function hasNoStandardDescriptorAccessor()
{
return $this->has_no_standard_descriptor_accessor;
}
/** /**
* Is this message deprecated? * Is this message deprecated?
* Depending on the target platform, this can emit Deprecated annotations * Depending on the target platform, this can emit Deprecated annotations
@ -253,7 +256,17 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getDeprecated() public function getDeprecated()
{ {
return $this->deprecated; return isset($this->deprecated) ? $this->deprecated : false;
}
public function hasDeprecated()
{
return isset($this->deprecated);
}
public function clearDeprecated()
{
unset($this->deprecated);
} }
/** /**
@ -270,16 +283,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->deprecated = $var; $this->deprecated = $var;
$this->has_deprecated = true;
return $this; return $this;
} }
public function hasDeprecated()
{
return $this->has_deprecated;
}
/** /**
* Whether the message is an automatically generated map entry type for the * Whether the message is an automatically generated map entry type for the
* maps field. * maps field.
@ -305,7 +312,17 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/ */
public function getMapEntry() public function getMapEntry()
{ {
return $this->map_entry; return isset($this->map_entry) ? $this->map_entry : false;
}
public function hasMapEntry()
{
return isset($this->map_entry);
}
public function clearMapEntry()
{
unset($this->map_entry);
} }
/** /**
@ -336,16 +353,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->map_entry = $var; $this->map_entry = $var;
$this->has_map_entry = true;
return $this; return $this;
} }
public function hasMapEntry()
{
return $this->has_map_entry;
}
/** /**
* The parser stores options it doesn't recognize here. See above. * The parser stores options it doesn't recognize here. See above.
* *
@ -368,15 +379,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
{ {
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
$this->uninterpreted_option = $arr; $this->uninterpreted_option = $arr;
$this->has_uninterpreted_option = true;
return $this; return $this;
} }
public function hasUninterpretedOption()
{
return $this->has_uninterpreted_option;
}
} }

@ -20,40 +20,34 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
/** /**
* Generated from protobuf field <code>optional string name = 1;</code> * Generated from protobuf field <code>optional string name = 1;</code>
*/ */
protected $name = ''; protected $name = null;
private $has_name = false;
/** /**
* Input and output type names. These are resolved in the same way as * Input and output type names. These are resolved in the same way as
* FieldDescriptorProto.type_name, but must refer to a message type. * FieldDescriptorProto.type_name, but must refer to a message type.
* *
* Generated from protobuf field <code>optional string input_type = 2;</code> * Generated from protobuf field <code>optional string input_type = 2;</code>
*/ */
protected $input_type = ''; protected $input_type = null;
private $has_input_type = false;
/** /**
* Generated from protobuf field <code>optional string output_type = 3;</code> * Generated from protobuf field <code>optional string output_type = 3;</code>
*/ */
protected $output_type = ''; protected $output_type = null;
private $has_output_type = false;
/** /**
* Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code> * Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code>
*/ */
protected $options = null; protected $options = null;
private $has_options = false;
/** /**
* Identifies if client streams multiple client messages * Identifies if client streams multiple client messages
* *
* Generated from protobuf field <code>optional bool client_streaming = 5 [default = false];</code> * Generated from protobuf field <code>optional bool client_streaming = 5 [default = false];</code>
*/ */
protected $client_streaming = false; protected $client_streaming = null;
private $has_client_streaming = false;
/** /**
* Identifies if server streams multiple server messages * Identifies if server streams multiple server messages
* *
* Generated from protobuf field <code>optional bool server_streaming = 6 [default = false];</code> * Generated from protobuf field <code>optional bool server_streaming = 6 [default = false];</code>
*/ */
protected $server_streaming = false; protected $server_streaming = null;
private $has_server_streaming = false;
/** /**
* Constructor. * Constructor.
@ -84,7 +78,17 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getName() public function getName()
{ {
return $this->name; return isset($this->name) ? $this->name : '';
}
public function hasName()
{
return isset($this->name);
}
public function clearName()
{
unset($this->name);
} }
/** /**
@ -96,16 +100,10 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->name = $var; $this->name = $var;
$this->has_name = true;
return $this; return $this;
} }
public function hasName()
{
return $this->has_name;
}
/** /**
* Input and output type names. These are resolved in the same way as * Input and output type names. These are resolved in the same way as
* FieldDescriptorProto.type_name, but must refer to a message type. * FieldDescriptorProto.type_name, but must refer to a message type.
@ -115,7 +113,17 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getInputType() public function getInputType()
{ {
return $this->input_type; return isset($this->input_type) ? $this->input_type : '';
}
public function hasInputType()
{
return isset($this->input_type);
}
public function clearInputType()
{
unset($this->input_type);
} }
/** /**
@ -130,23 +138,27 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->input_type = $var; $this->input_type = $var;
$this->has_input_type = true;
return $this; return $this;
} }
public function hasInputType()
{
return $this->has_input_type;
}
/** /**
* Generated from protobuf field <code>optional string output_type = 3;</code> * Generated from protobuf field <code>optional string output_type = 3;</code>
* @return string * @return string
*/ */
public function getOutputType() public function getOutputType()
{ {
return $this->output_type; return isset($this->output_type) ? $this->output_type : '';
}
public function hasOutputType()
{
return isset($this->output_type);
}
public function clearOutputType()
{
unset($this->output_type);
} }
/** /**
@ -158,23 +170,27 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->output_type = $var; $this->output_type = $var;
$this->has_output_type = true;
return $this; return $this;
} }
public function hasOutputType()
{
return $this->has_output_type;
}
/** /**
* Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code> * Generated from protobuf field <code>optional .google.protobuf.MethodOptions options = 4;</code>
* @return \Google\Protobuf\Internal\MethodOptions * @return \Google\Protobuf\Internal\MethodOptions
*/ */
public function getOptions() public function getOptions()
{ {
return $this->options; return isset($this->options) ? $this->options : null;
}
public function hasOptions()
{
return isset($this->options);
}
public function clearOptions()
{
unset($this->options);
} }
/** /**
@ -186,16 +202,10 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class); GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
$this->options = $var; $this->options = $var;
$this->has_options = true;
return $this; return $this;
} }
public function hasOptions()
{
return $this->has_options;
}
/** /**
* Identifies if client streams multiple client messages * Identifies if client streams multiple client messages
* *
@ -204,7 +214,17 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getClientStreaming() public function getClientStreaming()
{ {
return $this->client_streaming; return isset($this->client_streaming) ? $this->client_streaming : false;
}
public function hasClientStreaming()
{
return isset($this->client_streaming);
}
public function clearClientStreaming()
{
unset($this->client_streaming);
} }
/** /**
@ -218,16 +238,10 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->client_streaming = $var; $this->client_streaming = $var;
$this->has_client_streaming = true;
return $this; return $this;
} }
public function hasClientStreaming()
{
return $this->has_client_streaming;
}
/** /**
* Identifies if server streams multiple server messages * Identifies if server streams multiple server messages
* *
@ -236,7 +250,17 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
*/ */
public function getServerStreaming() public function getServerStreaming()
{ {
return $this->server_streaming; return isset($this->server_streaming) ? $this->server_streaming : false;
}
public function hasServerStreaming()
{
return isset($this->server_streaming);
}
public function clearServerStreaming()
{
unset($this->server_streaming);
} }
/** /**
@ -250,15 +274,9 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->server_streaming = $var; $this->server_streaming = $var;
$this->has_server_streaming = true;
return $this; return $this;
} }
public function hasServerStreaming()
{
return $this->has_server_streaming;
}
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save