aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--BUILD4
-rw-r--r--Makefile.am127
-rw-r--r--Protobuf.podspec2
-rw-r--r--configure.ac2
-rw-r--r--csharp/Google.Protobuf.Tools.nuspec2
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.csproj2
-rw-r--r--java/core/pom.xml2
-rw-r--r--java/pom.xml2
-rw-r--r--java/util/pom.xml2
-rw-r--r--js/package.json2
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh6
-rw-r--r--objectivec/GPBDescriptor.m4
-rw-r--r--objectivec/GPBUnknownField.m8
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj10
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme4
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme4
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj10
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme4
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme4
-rw-r--r--objectivec/Tests/GPBArrayTests.m158
-rw-r--r--objectivec/Tests/GPBDescriptorTests.m117
-rw-r--r--objectivec/Tests/GPBUnknownFieldSetTest.m275
-rw-r--r--php/ext/google/protobuf/def.c17
-rw-r--r--php/ext/google/protobuf/encode_decode.c44
-rw-r--r--php/ext/google/protobuf/message.c1409
-rw-r--r--php/ext/google/protobuf/package.xml24
-rw-r--r--php/ext/google/protobuf/protobuf.c71
-rw-r--r--php/ext/google/protobuf/protobuf.h364
-rw-r--r--php/ext/google/protobuf/storage.c44
-rw-r--r--php/ext/google/protobuf/type_check.c37
-rw-r--r--php/ext/google/protobuf/upb.c2004
-rw-r--r--php/ext/google/protobuf/upb.h815
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/Api.php49
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/FieldMask.php31
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php30
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/SourceContext.php32
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/Struct.php45
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/Type.php78
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/Wrappers.php38
-rw-r--r--php/src/Google/Protobuf/Api.php310
-rw-r--r--php/src/Google/Protobuf/BoolValue.php58
-rw-r--r--php/src/Google/Protobuf/BytesValue.php58
-rw-r--r--php/src/Google/Protobuf/DoubleValue.php58
-rw-r--r--php/src/Google/Protobuf/Enum.php185
-rw-r--r--php/src/Google/Protobuf/EnumValue.php121
-rw-r--r--php/src/Google/Protobuf/Field.php351
-rw-r--r--php/src/Google/Protobuf/FieldMask.php209
-rw-r--r--php/src/Google/Protobuf/Field_Cardinality.php39
-rw-r--r--php/src/Google/Protobuf/Field_Kind.php129
-rw-r--r--php/src/Google/Protobuf/FloatValue.php58
-rw-r--r--php/src/Google/Protobuf/GPBEmpty.php31
-rw-r--r--php/src/Google/Protobuf/Int32Value.php58
-rw-r--r--php/src/Google/Protobuf/Int64Value.php58
-rw-r--r--php/src/Google/Protobuf/Internal/CodedInputStream.php7
-rw-r--r--php/src/Google/Protobuf/Internal/CodedOutputStream.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php109
-rw-r--r--php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php64
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php31
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php22
-rw-r--r--php/src/Google/Protobuf/ListValue.php58
-rw-r--r--php/src/Google/Protobuf/Method.php249
-rw-r--r--php/src/Google/Protobuf/Mixin.php153
-rw-r--r--php/src/Google/Protobuf/NullValue.php23
-rw-r--r--php/src/Google/Protobuf/Option.php108
-rw-r--r--php/src/Google/Protobuf/SourceContext.php61
-rw-r--r--php/src/Google/Protobuf/StringValue.php58
-rw-r--r--php/src/Google/Protobuf/Struct.php63
-rw-r--r--php/src/Google/Protobuf/Syntax.php27
-rw-r--r--php/src/Google/Protobuf/Type.php217
-rw-r--r--php/src/Google/Protobuf/UInt32Value.php58
-rw-r--r--php/src/Google/Protobuf/UInt64Value.php58
-rw-r--r--php/src/Google/Protobuf/Value.php194
-rwxr-xr-xphp/tests/compatibility_test.sh1
-rw-r--r--php/tests/encode_decode_test.php27
-rwxr-xr-xphp/tests/gdb_test.sh2
-rw-r--r--php/tests/generated_class_test.php444
-rw-r--r--php/tests/memory_leak_test.php4
-rw-r--r--php/tests/proto/test.proto2
-rw-r--r--php/tests/proto/test_reserved_enum_lower.proto77
-rw-r--r--php/tests/proto/test_reserved_enum_upper.proto77
-rw-r--r--php/tests/proto/test_reserved_enum_value_lower.proto79
-rw-r--r--php/tests/proto/test_reserved_enum_value_upper.proto79
-rw-r--r--php/tests/proto/test_reserved_message_lower.proto77
-rw-r--r--php/tests/proto/test_reserved_message_upper.proto77
-rw-r--r--php/tests/well_known_test.php280
-rw-r--r--protoc-artifacts/pom.xml2
-rwxr-xr-xpython/google/protobuf/__init__.py2
-rwxr-xr-xpython/google/protobuf/internal/decoder.py2
-rwxr-xr-xpython/google/protobuf/internal/encoder.py2
-rw-r--r--ruby/Rakefile8
-rw-r--r--ruby/ext/google/protobuf_c/defs.c17
-rw-r--r--ruby/ext/google/protobuf_c/protobuf.c2
-rw-r--r--ruby/ext/google/protobuf_c/protobuf.h5
-rw-r--r--ruby/google-protobuf.gemspec2
-rw-r--r--ruby/tests/gc_test.rb58
-rwxr-xr-xruby/travis-test.sh1
-rw-r--r--src/Makefile.am10
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc60
-rw-r--r--src/google/protobuf/descriptor.cc6
-rw-r--r--src/google/protobuf/generated_message_table_driven.h3
-rw-r--r--src/google/protobuf/stubs/io_win32.cc4
-rw-r--r--src/google/protobuf/stubs/io_win32_unittest.cc34
-rw-r--r--src/google/protobuf/text_format.cc10
-rw-r--r--src/google/protobuf/util/internal/json_escaping.h2
-rw-r--r--src/google/protobuf/util/json_util.cc8
-rw-r--r--src/google/protobuf/util/json_util.h2
-rwxr-xr-xtests.sh28
108 files changed, 9542 insertions, 1125 deletions
diff --git a/.gitignore b/.gitignore
index fdc52bf7..d5196041 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,3 +171,8 @@ js/testproto_libs2.js
# Ignore the bazel symlinks
/bazel-*
+
+# ruby test output
+ruby/lib/
+ruby/tests/generated_code_pb.rb
+ruby/tests/test_import_pb.rb
diff --git a/BUILD b/BUILD
index 7d80e14f..f9221248 100644
--- a/BUILD
+++ b/BUILD
@@ -44,9 +44,11 @@ config_setting(
},
)
-# Android builds do not need to link in a separate pthread library.
+# Android and Windows builds do not need to link in a separate pthread library.
LINK_OPTS = select({
":android": [],
+ ":windows": [],
+ ":windows_msvc": [],
"//conditions:default": ["-lpthread", "-lm"],
})
diff --git a/Makefile.am b/Makefile.am
index e41bdff9..aaf9e7d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -585,93 +585,136 @@ objectivec_EXTRA_DIST= \
Protobuf.podspec
php_EXTRA_DIST= \
- php/ext/google/protobuf/utf8.h \
- php/ext/google/protobuf/message.c \
- php/ext/google/protobuf/utf8.c \
- php/ext/google/protobuf/package.xml \
- php/ext/google/protobuf/upb.h \
+ composer.json \
+ php/README.md \
+ php/composer.json \
php/ext/google/protobuf/array.c \
+ php/ext/google/protobuf/config.m4 \
+ php/ext/google/protobuf/def.c \
php/ext/google/protobuf/encode_decode.c \
+ php/ext/google/protobuf/map.c \
+ php/ext/google/protobuf/message.c \
+ php/ext/google/protobuf/package.xml \
+ php/ext/google/protobuf/protobuf.c \
php/ext/google/protobuf/protobuf.h \
- php/ext/google/protobuf/type_check.c \
- php/ext/google/protobuf/def.c \
php/ext/google/protobuf/storage.c \
- php/ext/google/protobuf/map.c \
- php/ext/google/protobuf/config.m4 \
+ php/ext/google/protobuf/type_check.c \
php/ext/google/protobuf/upb.c \
- php/ext/google/protobuf/protobuf.c \
- php/src/phpdoc.dist.xml \
+ php/ext/google/protobuf/upb.h \
+ php/ext/google/protobuf/utf8.c \
+ php/ext/google/protobuf/utf8.h \
+ php/generate_descriptor_protos.sh \
+ php/phpunit.xml \
+ php/src/GPBMetadata/Google/Protobuf/Any.php \
+ php/src/GPBMetadata/Google/Protobuf/Api.php \
+ php/src/GPBMetadata/Google/Protobuf/Duration.php \
+ php/src/GPBMetadata/Google/Protobuf/FieldMask.php \
+ php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php \
+ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \
+ php/src/GPBMetadata/Google/Protobuf/SourceContext.php \
+ php/src/GPBMetadata/Google/Protobuf/Struct.php \
+ php/src/GPBMetadata/Google/Protobuf/Timestamp.php \
+ php/src/GPBMetadata/Google/Protobuf/Type.php \
+ php/src/GPBMetadata/Google/Protobuf/Wrappers.php \
php/src/Google/Protobuf/Any.php \
+ php/src/Google/Protobuf/Api.php \
+ php/src/Google/Protobuf/BoolValue.php \
+ php/src/Google/Protobuf/BytesValue.php \
php/src/Google/Protobuf/Descriptor.php \
php/src/Google/Protobuf/DescriptorPool.php \
+ php/src/Google/Protobuf/DoubleValue.php \
php/src/Google/Protobuf/Duration.php \
+ php/src/Google/Protobuf/Enum.php \
php/src/Google/Protobuf/EnumDescriptor.php \
+ php/src/Google/Protobuf/EnumValue.php \
php/src/Google/Protobuf/EnumValueDescriptor.php \
+ php/src/Google/Protobuf/Field.php \
php/src/Google/Protobuf/FieldDescriptor.php \
- php/src/Google/Protobuf/OneofDescriptor.php \
- php/src/Google/Protobuf/Timestamp.php \
+ php/src/Google/Protobuf/FieldMask.php \
+ php/src/Google/Protobuf/Field_Cardinality.php \
+ php/src/Google/Protobuf/Field_Kind.php \
+ php/src/Google/Protobuf/FloatValue.php \
+ php/src/Google/Protobuf/GPBEmpty.php \
+ php/src/Google/Protobuf/Int32Value.php \
+ php/src/Google/Protobuf/Int64Value.php \
php/src/Google/Protobuf/Internal/CodedInputStream.php \
php/src/Google/Protobuf/Internal/CodedOutputStream.php \
+ php/src/Google/Protobuf/Internal/Descriptor.php \
php/src/Google/Protobuf/Internal/DescriptorPool.php \
+ php/src/Google/Protobuf/Internal/DescriptorProto.php \
php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \
php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \
- php/src/Google/Protobuf/Internal/DescriptorProto.php \
- php/src/Google/Protobuf/Internal/Descriptor.php \
php/src/Google/Protobuf/Internal/EnumBuilderContext.php \
php/src/Google/Protobuf/Internal/EnumDescriptor.php \
php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php \
php/src/Google/Protobuf/Internal/EnumOptions.php \
php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \
php/src/Google/Protobuf/Internal/EnumValueOptions.php \
+ php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
php/src/Google/Protobuf/Internal/FieldDescriptor.php \
+ php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \
+ php/src/Google/Protobuf/Internal/FieldOptions.php \
php/src/Google/Protobuf/Internal/FieldOptions_CType.php \
php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \
- php/src/Google/Protobuf/Internal/FieldOptions.php \
+ php/src/Google/Protobuf/Internal/FileDescriptor.php \
php/src/Google/Protobuf/Internal/FileDescriptorProto.php \
php/src/Google/Protobuf/Internal/FileDescriptorSet.php \
- php/src/Google/Protobuf/Internal/FileDescriptor.php \
- php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \
php/src/Google/Protobuf/Internal/FileOptions.php \
- php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \
- php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \
- php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php \
+ php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \
php/src/Google/Protobuf/Internal/GPBDecodeException.php \
php/src/Google/Protobuf/Internal/GPBJsonWire.php \
php/src/Google/Protobuf/Internal/GPBLabel.php \
php/src/Google/Protobuf/Internal/GPBType.php \
php/src/Google/Protobuf/Internal/GPBUtil.php \
- php/src/Google/Protobuf/Internal/GPBWireType.php \
php/src/Google/Protobuf/Internal/GPBWire.php \
+ php/src/Google/Protobuf/Internal/GPBWireType.php \
+ php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \
+ php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \
+ php/src/Google/Protobuf/Internal/GetPublicDescriptorTrait.php \
php/src/Google/Protobuf/Internal/HasPublicDescriptorTrait.php \
php/src/Google/Protobuf/Internal/MapEntry.php \
- php/src/Google/Protobuf/Internal/MapFieldIter.php \
php/src/Google/Protobuf/Internal/MapField.php \
+ php/src/Google/Protobuf/Internal/MapFieldIter.php \
+ php/src/Google/Protobuf/Internal/Message.php \
php/src/Google/Protobuf/Internal/MessageBuilderContext.php \
php/src/Google/Protobuf/Internal/MessageOptions.php \
- php/src/Google/Protobuf/Internal/Message.php \
php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \
- php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \
php/src/Google/Protobuf/Internal/MethodOptions.php \
- php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \
php/src/Google/Protobuf/Internal/OneofDescriptor.php \
+ php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \
php/src/Google/Protobuf/Internal/OneofField.php \
php/src/Google/Protobuf/Internal/OneofOptions.php \
php/src/Google/Protobuf/Internal/RawInputStream.php \
- php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \
php/src/Google/Protobuf/Internal/RepeatedField.php \
+ php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \
php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \
php/src/Google/Protobuf/Internal/ServiceOptions.php \
- php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \
php/src/Google/Protobuf/Internal/SourceCodeInfo.php \
- php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \
+ php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \
php/src/Google/Protobuf/Internal/UninterpretedOption.php \
- php/src/GPBMetadata/Google/Protobuf/Any.php \
- php/src/GPBMetadata/Google/Protobuf/Duration.php \
- php/src/GPBMetadata/Google/Protobuf/Timestamp.php \
- php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \
+ php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \
+ php/src/Google/Protobuf/ListValue.php \
+ php/src/Google/Protobuf/Method.php \
+ php/src/Google/Protobuf/Mixin.php \
+ php/src/Google/Protobuf/NullValue.php \
+ php/src/Google/Protobuf/OneofDescriptor.php \
+ php/src/Google/Protobuf/Option.php \
+ php/src/Google/Protobuf/SourceContext.php \
+ php/src/Google/Protobuf/StringValue.php \
+ php/src/Google/Protobuf/Struct.php \
+ php/src/Google/Protobuf/Syntax.php \
+ php/src/Google/Protobuf/Timestamp.php \
+ php/src/Google/Protobuf/Type.php \
+ php/src/Google/Protobuf/UInt32Value.php \
+ php/src/Google/Protobuf/UInt64Value.php \
+ php/src/Google/Protobuf/Value.php \
+ php/src/phpdoc.dist.xml \
php/tests/array_test.php \
php/tests/autoload.php \
php/tests/bootstrap_phpunit.php \
@@ -685,26 +728,27 @@ php_EXTRA_DIST= \
php/tests/map_field_test.php \
php/tests/memory_leak_test.php \
php/tests/php_implementation_test.php \
+ php/tests/proto/test.proto \
php/tests/proto/test_descriptors.proto \
php/tests/proto/test_empty_php_namespace.proto \
php/tests/proto/test_import_descriptor_proto.proto \
php/tests/proto/test_include.proto \
- php/tests/proto/test.proto \
php/tests/proto/test_no_namespace.proto \
php/tests/proto/test_php_namespace.proto \
php/tests/proto/test_prefix.proto \
+ php/tests/proto/test_reserved_enum_lower.proto \
+ php/tests/proto/test_reserved_enum_upper.proto \
+ php/tests/proto/test_reserved_enum_value_lower.proto \
+ php/tests/proto/test_reserved_enum_value_upper.proto \
+ php/tests/proto/test_reserved_message_lower.proto \
+ php/tests/proto/test_reserved_message_upper.proto \
php/tests/proto/test_service.proto \
php/tests/proto/test_service_namespace.proto \
php/tests/test.sh \
php/tests/test_base.php \
php/tests/test_util.php \
- php/tests/well_known_test.php \
php/tests/undefined_test.php \
- php/README.md \
- php/composer.json \
- php/generate_descriptor_protos.sh \
- php/phpunit.xml \
- composer.json
+ php/tests/well_known_test.php
python_EXTRA_DIST= \
python/MANIFEST.in \
@@ -862,6 +906,7 @@ ruby_EXTRA_DIST= \
ruby/src/main/java/google/ProtobufJavaService.java \
ruby/src/main/sentinel.proto \
ruby/tests/basic.rb \
+ ruby/tests/gc_test.rb \
ruby/tests/repeated_field_test.rb \
ruby/tests/stress.rb \
ruby/tests/generated_code.proto \
@@ -990,8 +1035,10 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
+ cmake/protobuf-lite.pc.cmake \
cmake/protobuf-module.cmake.in \
cmake/protobuf-options.cmake \
+ cmake/protobuf.pc.cmake \
cmake/protoc.cmake \
cmake/tests.cmake \
editors/README.txt \
diff --git a/Protobuf.podspec b/Protobuf.podspec
index 88bd5b7d..d559d18a 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
- s.version = '3.4.0'
+ s.version = '3.4.1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'
diff --git a/configure.ac b/configure.ac
index 04f7eb7a..0d3e5fb3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.4.0],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.4.1],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec
index d32fd943..5b38241a 100644
--- a/csharp/Google.Protobuf.Tools.nuspec
+++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
- <version>3.4.0</version>
+ <version>3.4.1</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index 4e63646b..75b38175 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
- <VersionPrefix>3.4.0</VersionPrefix>
+ <VersionPrefix>3.4.1</VersionPrefix>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
diff --git a/java/core/pom.xml b/java/core/pom.xml
index 4608fce6..b0925f74 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.4.0</version>
+ <version>3.4.1</version>
</parent>
<artifactId>protobuf-java</artifactId>
diff --git a/java/pom.xml b/java/pom.xml
index dd3ba3b8..bc8e89b5 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -11,7 +11,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.4.0</version>
+ <version>3.4.1</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>
diff --git a/java/util/pom.xml b/java/util/pom.xml
index 61abd146..35afb844 100644
--- a/java/util/pom.xml
+++ b/java/util/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.4.0</version>
+ <version>3.4.1</version>
</parent>
<artifactId>protobuf-java-util</artifactId>
diff --git a/js/package.json b/js/package.json
index c8b75385..5231c846 100644
--- a/js/package.json
+++ b/js/package.json
@@ -1,6 +1,6 @@
{
"name": "google-protobuf",
- "version": "3.4.0",
+ "version": "3.4.1",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 9ac24bb3..a825789f 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -279,6 +279,12 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
)
;;
+ 9.0* )
+ XCODEBUILD_TEST_BASE_IOS+=(
+ -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
+ )
+ ;;
* )
echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}"
exit 2
diff --git a/objectivec/GPBDescriptor.m b/objectivec/GPBDescriptor.m
index 0753a948..3c3844da 100644
--- a/objectivec/GPBDescriptor.m
+++ b/objectivec/GPBDescriptor.m
@@ -1027,10 +1027,6 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
return GPBExtensionIsRepeated(description_);
}
-- (BOOL)isMap {
- return (description_->options & GPBFieldMapKeyMask) != 0;
-}
-
- (BOOL)isPackable {
return GPBExtensionIsPacked(description_);
}
diff --git a/objectivec/GPBUnknownField.m b/objectivec/GPBUnknownField.m
index 30efe756..9d5c97f3 100644
--- a/objectivec/GPBUnknownField.m
+++ b/objectivec/GPBUnknownField.m
@@ -79,7 +79,7 @@
result->mutableFixed32List_ = [mutableFixed32List_ copyWithZone:zone];
result->mutableFixed64List_ = [mutableFixed64List_ copyWithZone:zone];
result->mutableLengthDelimitedList_ =
- [mutableLengthDelimitedList_ copyWithZone:zone];
+ [mutableLengthDelimitedList_ mutableCopyWithZone:zone];
result->mutableVarintList_ = [mutableVarintList_ copyWithZone:zone];
if (mutableGroupList_.count) {
result->mutableGroupList_ = [[NSMutableArray allocWithZone:zone]
@@ -97,6 +97,7 @@
if (self == object) return YES;
if (![object isKindOfClass:[GPBUnknownField class]]) return NO;
GPBUnknownField *field = (GPBUnknownField *)object;
+ if (number_ != field->number_) return NO;
BOOL equalVarint =
(mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) ||
[mutableVarintList_ isEqual:field->mutableVarintList_];
@@ -202,8 +203,9 @@
}
- (NSString *)description {
- NSMutableString *description = [NSMutableString
- stringWithFormat:@"<%@ %p>: Field: %d {\n", [self class], self, number_];
+ NSMutableString *description =
+ [NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n",
+ [self class], self, number_];
[mutableVarintList_
enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
#pragma unused(idx, stop)
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
index cd7fcc9e..266b05a1 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
@@ -562,7 +562,7 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0800;
+ LastUpgradeCheck = 0900;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
LastSwiftMigration = 0800;
@@ -794,6 +794,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -803,6 +805,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
@@ -860,6 +864,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -869,6 +875,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 2883109c..d3c29389 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0800"
+ LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -300,6 +301,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index b1243b79..e7fb8215 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0800"
+ LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -54,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
@@ -89,6 +90,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
index 2211cb37..1f1172b2 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
@@ -639,7 +639,7 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0800;
+ LastUpgradeCheck = 0900;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
LastSwiftMigration = 0800;
@@ -956,6 +956,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -965,6 +967,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
@@ -1023,6 +1027,8 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_ASSIGN_ENUM = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -1032,6 +1038,8 @@
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 1ba3a329..03acb083 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0800"
+ LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -309,6 +310,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index edbe6898..98bcd562 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0800"
+ LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -54,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
@@ -89,6 +90,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objectivec/Tests/GPBArrayTests.m b/objectivec/Tests/GPBArrayTests.m
index 31f75501..e414d90a 100644
--- a/objectivec/Tests/GPBArrayTests.m
+++ b/objectivec/Tests/GPBArrayTests.m
@@ -39,6 +39,7 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBEnumArray (TestingTweak)
+ (instancetype)arrayWithValue:(int32_t)value;
++ (instancetype)arrayWithCapacity:(NSUInteger)count;
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count;
@end
@@ -72,6 +73,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
rawValues:&value
count:1] autorelease];
}
++ (instancetype)arrayWithCapacity:(NSUInteger)count {
+ return [[[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
+ capacity:count] autorelease];
+}
- (instancetype)initWithValues:(const int32_t [])values
count:(NSUInteger)count {
return [self initWithValidationFunction:TestingEnum_IsValidValue
@@ -177,6 +182,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertNotEqual(idx, 0U);
//% ++idx2;
//% }];
+//% // Ensure description doesn't choke.
+//% XCTAssertTrue(array.description.length > 10);
//% [array release];
//%}
//%
@@ -201,6 +208,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% NAME$S count:GPBARRAYSIZE(kValues3)];
//% XCTAssertNotNil(array3);
//%
+//% // Identity
+//% XCTAssertTrue([array1 isEqual:array1]);
+//% // Wrong type doesn't blow up.
+//% XCTAssertFalse([array1 isEqual:@"bogus"]);
//% // 1/1Prime should be different objects, but equal.
//% XCTAssertNotEqual(array1, array1prime);
//% XCTAssertEqualObjects(array1, array1prime);
@@ -271,6 +282,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% [array add##HELPER##ValuesFromArray:array2];
//% XCTAssertEqual(array.count, 5U);
//%
+//% // Zero/nil inputs do nothing.
+//% [array addValues:kValues1 count:0];
+//% XCTAssertEqual(array.count, 5U);
+//% [array addValues:NULL count:5];
+//% XCTAssertEqual(array.count, 5U);
+//%
//% XCTAssertEqual([array valueAtIndex:0], VAL1);
//% XCTAssertEqual([array valueAtIndex:1], VAL2);
//% XCTAssertEqual([array valueAtIndex:2], VAL3);
@@ -391,9 +408,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//%- (void)testInternalResizing {
//% const TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 };
//% GPB##NAME##Array *array =
-//% [[GPB##NAME##Array alloc] initWithValues:kValues
-//% NAME$S count:GPBARRAYSIZE(kValues)];
+//% [GPB##NAME##Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
//% XCTAssertNotNil(array);
+//% [array addValues:kValues count:GPBARRAYSIZE(kValues)];
//%
//% // Add/remove to trigger the intneral buffer to grow/shrink.
//% for (int i = 0; i < 100; ++i) {
@@ -410,7 +427,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
//% XCTAssertEqual(array.count, 404U);
//% [array removeAll];
//% XCTAssertEqual(array.count, 0U);
-//% [array release];
//%}
//%
//%@end
@@ -510,6 +526,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -534,6 +552,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -604,6 +626,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 1);
XCTAssertEqual([array valueAtIndex:1], 2);
XCTAssertEqual([array valueAtIndex:2], 3);
@@ -724,9 +752,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 1, 2, 3, 4 };
GPBInt32Array *array =
- [[GPBInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -743,7 +771,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -843,6 +870,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -867,6 +896,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -937,6 +970,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 11U);
XCTAssertEqual([array valueAtIndex:1], 12U);
XCTAssertEqual([array valueAtIndex:2], 13U);
@@ -1057,9 +1096,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint32_t kValues[] = { 11U, 12U, 13U, 14U };
GPBUInt32Array *array =
- [[GPBUInt32Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt32Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1076,7 +1115,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1176,6 +1214,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1200,6 +1240,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1270,6 +1314,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 31LL);
XCTAssertEqual([array valueAtIndex:1], 32LL);
XCTAssertEqual([array valueAtIndex:2], 33LL);
@@ -1390,9 +1440,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int64_t kValues[] = { 31LL, 32LL, 33LL, 34LL };
GPBInt64Array *array =
- [[GPBInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1409,7 +1459,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1509,6 +1558,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1533,6 +1584,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1603,6 +1658,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 41ULL);
XCTAssertEqual([array valueAtIndex:1], 42ULL);
XCTAssertEqual([array valueAtIndex:2], 43ULL);
@@ -1723,9 +1784,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const uint64_t kValues[] = { 41ULL, 42ULL, 43ULL, 44ULL };
GPBUInt64Array *array =
- [[GPBUInt64Array alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBUInt64Array arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -1742,7 +1803,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -1842,6 +1902,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -1866,6 +1928,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -1936,6 +2002,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 51.f);
XCTAssertEqual([array valueAtIndex:1], 52.f);
XCTAssertEqual([array valueAtIndex:2], 53.f);
@@ -2056,9 +2128,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const float kValues[] = { 51.f, 52.f, 53.f, 54.f };
GPBFloatArray *array =
- [[GPBFloatArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBFloatArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2075,7 +2147,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2175,6 +2246,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2199,6 +2272,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2269,6 +2346,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 61.);
XCTAssertEqual([array valueAtIndex:1], 62.);
XCTAssertEqual([array valueAtIndex:2], 63.);
@@ -2389,9 +2472,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const double kValues[] = { 61., 62., 63., 64. };
GPBDoubleArray *array =
- [[GPBDoubleArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBDoubleArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2408,7 +2491,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2508,6 +2590,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2532,6 +2616,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2602,6 +2690,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], TRUE);
XCTAssertEqual([array valueAtIndex:1], TRUE);
XCTAssertEqual([array valueAtIndex:2], FALSE);
@@ -2722,9 +2816,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const BOOL kValues[] = { TRUE, TRUE, FALSE, FALSE };
GPBBoolArray *array =
- [[GPBBoolArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBBoolArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -2741,7 +2835,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
@@ -2841,6 +2934,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertNotEqual(idx, 0U);
++idx2;
}];
+ // Ensure description doesn't choke.
+ XCTAssertTrue(array.description.length > 10);
[array release];
}
@@ -2865,6 +2960,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
count:GPBARRAYSIZE(kValues3)];
XCTAssertNotNil(array3);
+ // Identity
+ XCTAssertTrue([array1 isEqual:array1]);
+ // Wrong type doesn't blow up.
+ XCTAssertFalse([array1 isEqual:@"bogus"]);
// 1/1Prime should be different objects, but equal.
XCTAssertNotEqual(array1, array1prime);
XCTAssertEqualObjects(array1, array1prime);
@@ -2935,6 +3034,12 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
[array addRawValuesFromArray:array2];
XCTAssertEqual(array.count, 5U);
+ // Zero/nil inputs do nothing.
+ [array addValues:kValues1 count:0];
+ XCTAssertEqual(array.count, 5U);
+ [array addValues:NULL count:5];
+ XCTAssertEqual(array.count, 5U);
+
XCTAssertEqual([array valueAtIndex:0], 71);
XCTAssertEqual([array valueAtIndex:1], 72);
XCTAssertEqual([array valueAtIndex:2], 73);
@@ -3055,9 +3160,9 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
- (void)testInternalResizing {
const int32_t kValues[] = { 71, 72, 73, 74 };
GPBEnumArray *array =
- [[GPBEnumArray alloc] initWithValues:kValues
- count:GPBARRAYSIZE(kValues)];
+ [GPBEnumArray arrayWithCapacity:GPBARRAYSIZE(kValues)];
XCTAssertNotNil(array);
+ [array addValues:kValues count:GPBARRAYSIZE(kValues)];
// Add/remove to trigger the intneral buffer to grow/shrink.
for (int i = 0; i < 100; ++i) {
@@ -3074,7 +3179,6 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
XCTAssertEqual(array.count, 404U);
[array removeAll];
XCTAssertEqual(array.count, 0U);
- [array release];
}
@end
diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m
index 1e1c3de8..199ea655 100644
--- a/objectivec/Tests/GPBDescriptorTests.m
+++ b/objectivec/Tests/GPBDescriptorTests.m
@@ -32,7 +32,7 @@
#import <objc/runtime.h>
-#import "GPBDescriptor.h"
+#import "GPBDescriptor_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestObjc.pbobjc.h"
#import "google/protobuf/Descriptor.pbobjc.h"
@@ -83,6 +83,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"TestAllTypes_NestedEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Foreign Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignEnum"];
@@ -93,6 +95,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ForeignEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Import Enum
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportEnum"];
@@ -103,6 +107,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
@"ImportEnum");
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
// Nested Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedMessage"];
@@ -111,6 +117,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Foreign Message
fieldDescriptorWithName =
@@ -120,6 +128,8 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
// Import Message
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportMessage"];
@@ -128,6 +138,12 @@
XCTAssertNotNil(fieldDescriptorWithNumber);
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
+ XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
+ XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
+
+ // Some failed lookups.
+ XCTAssertNil([descriptor fieldWithName:@"NOT THERE"]);
+ XCTAssertNil([descriptor fieldWithNumber:9876543]);
}
- (void)testEnumDescriptor {
@@ -159,6 +175,7 @@
XCTAssertNotNil(enumName);
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]);
XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
+ XCTAssertNil([descriptor textFormatNameForValue:99999]);
// Bad values
enumName = [descriptor enumNameForValue:0];
@@ -253,4 +270,102 @@
XCTAssertNil(bazString.containingOneof);
}
+- (void)testExtensiondDescriptor {
+ Class msgClass = [TestAllExtensions class];
+ Class packedMsgClass = [TestPackedExtensions class];
+
+ // Int
+
+ GPBExtensionDescriptor *descriptor = [UnittestRoot optionalInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqualObjects(descriptor.defaultValue, @0);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ descriptor = [UnittestRoot defaultInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqualObjects(descriptor.defaultValue, @41);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Enum
+
+ descriptor = [UnittestRoot optionalNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqual(descriptor.defaultValue, @1);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ descriptor = [UnittestRoot defaultNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertEqual(descriptor.defaultValue, @2);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ // Message
+
+ descriptor = [UnittestRoot optionalNestedMessageExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Repeated Int
+
+ descriptor = [UnittestRoot repeatedInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ descriptor = [UnittestRoot packedInt32Extension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
+ XCTAssertTrue(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Repeated Enum
+
+ descriptor = [UnittestRoot repeatedNestedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
+
+ descriptor = [UnittestRoot packedEnumExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
+ XCTAssertTrue(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"ForeignEnum");
+
+ // Repeated Message
+
+ descriptor = [UnittestRoot repeatedNestedMessageExtension];
+ XCTAssertNotNil(descriptor);
+ XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
+ XCTAssertFalse(descriptor.isPackable);
+ XCTAssertNil(descriptor.defaultValue);
+ XCTAssertNil(descriptor.enumDescriptor);
+
+ // Compare (used internally for serialization).
+
+ GPBExtensionDescriptor *ext1 = [UnittestRoot optionalInt32Extension];
+ XCTAssertEqual(ext1.fieldNumber, 1u);
+ GPBExtensionDescriptor *ext2 = [UnittestRoot optionalInt64Extension];
+ XCTAssertEqual(ext2.fieldNumber, 2u);
+
+ XCTAssertEqual([ext1 compareByFieldNumber:ext2], NSOrderedAscending);
+ XCTAssertEqual([ext2 compareByFieldNumber:ext1], NSOrderedDescending);
+ XCTAssertEqual([ext1 compareByFieldNumber:ext1], NSOrderedSame);
+}
+
@end
diff --git a/objectivec/Tests/GPBUnknownFieldSetTest.m b/objectivec/Tests/GPBUnknownFieldSetTest.m
index b2b5b21e..64cbd2d2 100644
--- a/objectivec/Tests/GPBUnknownFieldSetTest.m
+++ b/objectivec/Tests/GPBUnknownFieldSetTest.m
@@ -34,6 +34,10 @@
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "google/protobuf/Unittest.pbobjc.h"
+static NSData *DataFromCStr(const char *str) {
+ return [NSData dataWithBytes:str length:strlen(str)];
+}
+
@interface GPBUnknownFieldSet (GPBUnknownFieldSetTest)
- (void)getTags:(int32_t*)tags;
@end
@@ -60,6 +64,95 @@
unknownFields_ = emptyMessage_.unknownFields;
}
+- (void)testInvalidFieldNumber {
+ GPBUnknownFieldSet *set = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
+ XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
+}
+
+- (void)testEqualityAndHash {
+ // Empty
+
+ GPBUnknownFieldSet *set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertTrue([set1 isEqual:set1]);
+ XCTAssertFalse([set1 isEqual:@"foo"]);
+ GPBUnknownFieldSet *set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Varint
+
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field1 addVarint:1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ [field2 addVarint:1];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed32
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field1 addFixed32:2];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ [field2 addFixed32:2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Fixed64
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field1 addFixed64:3];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field2 addFixed64:3];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // LengthDelimited
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup1 addVarint:1];
+ [group1 addField:fieldGroup1];
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [fieldGroup2 addVarint:1];
+ [group2 addField:fieldGroup2];
+
+ field1 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field1 addGroup:group1];
+ [set1 addField:field1];
+ XCTAssertNotEqualObjects(set1, set2);
+ field2 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field2 addGroup:group2];
+ [set2 addField:field2];
+ XCTAssertEqualObjects(set1, set2);
+ XCTAssertEqual([set1 hash], [set2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(set1.description.length > 10);
+}
+
// Constructs a protocol buffer which contains fields with all the same
// numbers as allFieldsData except that each field is some other wire
// type.
@@ -112,6 +205,24 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:4];
[set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [set1 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [set1 addField:field];
+
+ GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup1 addVarint:100];
+ [group1 addField:fieldGroup1];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [set1 addField:field];
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
@@ -120,22 +231,63 @@
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
[field addVarint:3];
[set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:7];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:30];
+ [set2 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set2 addField:field];
+
+ GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup2 addVarint:99];
+ [group2 addField:fieldGroup2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group2];
+ [set2 addField:field];
GPBUnknownFieldSet* set3 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field addVarint:1];
[set3 addField:field];
- field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
- [field addVarint:4];
- [set3 addField:field];
-
- GPBUnknownFieldSet* set4 = [[[GPBUnknownFieldSet alloc] init] autorelease];
field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
[field addVarint:2];
- [set4 addField:field];
+ [set3 addField:field];
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
+ [field addVarint:4];
+ [set3 addField:field];
[field addVarint:3];
- [set4 addField:field];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
+ [field addFixed32:6];
+ [field addFixed32:7];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
+ [field addFixed64:20];
+ [field addFixed64:30];
+ [set3 addField:field];
+ field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
+ [field addLengthDelimited:DataFromCStr("data1")];
+ [field addLengthDelimited:DataFromCStr("data2")];
+ [set3 addField:field];
+
+ GPBUnknownFieldSet *group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3a1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
+ [fieldGroup3a1 addVarint:100];
+ [group3a addField:fieldGroup3a1];
+ GPBUnknownFieldSet *group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
+ [fieldGroup3b2 addVarint:99];
+ [group3b addField:fieldGroup3b2];
+
+ field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
+ [field addGroup:group1];
+ [field addGroup:group3b];
+ [set3 addField:field];
TestEmptyMessage* source1 = [TestEmptyMessage message];
[source1 setUnknownFields:set1];
@@ -143,8 +295,6 @@
[source2 setUnknownFields:set2];
TestEmptyMessage* source3 = [TestEmptyMessage message];
[source3 setUnknownFields:set3];
- TestEmptyMessage* source4 = [TestEmptyMessage message];
- [source4 setUnknownFields:set4];
TestEmptyMessage* destination1 = [TestEmptyMessage message];
[destination1 mergeFrom:source1];
@@ -152,9 +302,10 @@
TestEmptyMessage* destination2 = [TestEmptyMessage message];
[destination2 mergeFrom:source3];
- [destination2 mergeFrom:source4];
XCTAssertEqualObjects(destination1.data, destination2.data);
+ XCTAssertEqualObjects(destination1.data, source3.data);
+ XCTAssertEqualObjects(destination2.data, source3.data);
}
- (void)testClearMessage {
@@ -240,6 +391,107 @@
XCTAssertEqual(0x7FFFFFFFFFFFFFFFULL, [field2.varintList valueAtIndex:0]);
}
+#pragma mark - Field tests
+// Some tests directly on fields since the dictionary in FieldSet can gate
+// testing some of these.
+
+- (void)testFieldEqualityAndHash {
+ GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertTrue([field1 isEqual:field1]);
+ XCTAssertFalse([field1 isEqual:@"foo"]);
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ XCTAssertNotEqualObjects(field1, field2);
+
+ field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Varint
+
+ [field1 addVarint:10];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:10];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addVarint:11];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addVarint:11];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed32
+
+ [field1 addFixed32:20];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:20];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed32:21];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed32:21];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Fixed64
+
+ [field1 addFixed64:30];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:30];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addFixed64:31];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addFixed64:31];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // LengthDelimited
+
+ [field1 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("foo")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+ [field1 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertNotEqualObjects(field1, field2);
+ [field2 addLengthDelimited:DataFromCStr("bar")];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Group
+
+ GPBUnknownFieldSet *group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
+ [fieldGroup addVarint:100];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field1 addGroup:group];
+ XCTAssertNotEqualObjects(field1, field2);
+ group = [[[GPBUnknownFieldSet alloc] init] autorelease];
+ fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
+ [fieldGroup addVarint:101];
+ [group addField:fieldGroup];
+ [field2 addGroup:group];
+ XCTAssertEqualObjects(field1, field2);
+ XCTAssertEqual([field1 hash], [field2 hash]);
+
+ // Exercise description for completeness.
+ XCTAssertTrue(field1.description.length > 10);
+}
+
- (void)testMergingFields {
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field1 addVarint:1];
@@ -247,9 +499,8 @@
[field1 addFixed64:3];
[field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]];
[field1 addGroup:[[unknownFields_ copy] autorelease]];
- GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
+ GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
[field2 mergeFromField:field1];
- XCTAssertEqualObjects(field1, field2);
}
@end
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index 421b84e5..13f7cdd6 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -30,9 +30,6 @@
#include "protobuf.h"
-const char* const kReservedNames[] = {"Empty", "ECHO", "ARRAY"};
-const int kReservedNamesSize = 3;
-
// Forward declare.
static void descriptor_init_c_instance(Descriptor* intern TSRMLS_DC);
static void descriptor_free_c(Descriptor* object TSRMLS_DC);
@@ -747,12 +744,16 @@ static const char *classname_prefix(const char *classname,
return prefix_given;
}
- for (i = 0; i < kReservedNamesSize; i++) {
- if (strcmp(kReservedNames[i], classname) == 0) {
- is_reserved = true;
- break;
- }
+ char* lower = ALLOC_N(char, strlen(classname) + 1);
+ i = 0;
+ while(classname[i]) {
+ lower[i] = (char)tolower(classname[i]);
+ i++;
}
+ lower[i] = 0;
+
+ is_reserved = is_reserved_name(lower);
+ FREE(lower);
if (is_reserved) {
if (package_name != NULL && strcmp("google.protobuf", package_name) == 0) {
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index 93a5e9c4..7e2b3ae6 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -142,6 +142,23 @@ static const void* newhandlerdata(upb_handlers* h, uint32_t ofs) {
return hd_ofs;
}
+typedef size_t (*encodeunknown_handlerfunc)(void* _sink, const void* hd,
+ const char* ptr, size_t len,
+ const upb_bufhandle* handle);
+
+typedef struct {
+ encodeunknown_handlerfunc handler;
+} unknownfields_handlerdata_t;
+
+// Creates a handlerdata for unknown fields.
+static const void *newunknownfieldshandlerdata(upb_handlers* h) {
+ unknownfields_handlerdata_t* hd =
+ (unknownfields_handlerdata_t*)malloc(sizeof(unknownfields_handlerdata_t));
+ hd->handler = stringsink_string;
+ upb_handlers_addcleanup(h, hd, free);
+ return hd;
+}
+
typedef struct {
size_t ofs;
const upb_msgdef *md;
@@ -944,6 +961,24 @@ static void add_handlers_for_oneof_field(upb_handlers *h,
upb_handlerattr_uninit(&attr);
}
+static bool add_unknown_handler(void* closure, const void* hd, const char* buf,
+ size_t size) {
+ encodeunknown_handlerfunc handler =
+ ((unknownfields_handlerdata_t*)hd)->handler;
+
+ MessageHeader* msg = (MessageHeader*)closure;
+ stringsink* unknown = DEREF(message_data(msg), 0, stringsink*);
+ if (unknown == NULL) {
+ DEREF(message_data(msg), 0, stringsink*) = ALLOC(stringsink);
+ unknown = DEREF(message_data(msg), 0, stringsink*);
+ stringsink_init(unknown);
+ }
+
+ handler(unknown, NULL, buf, size, NULL);
+
+ return true;
+}
+
static void add_handlers_for_message(const void* closure,
upb_handlers* h) {
const upb_msgdef* msgdef = upb_handlers_msgdef(h);
@@ -967,6 +1002,10 @@ static void add_handlers_for_message(const void* closure,
desc->layout = create_layout(desc->msgdef);
}
+ upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
+ upb_handlerattr_sethandlerdata(&attr, newunknownfieldshandlerdata(h));
+ upb_handlers_setunknown(h, add_unknown_handler, &attr);
+
for (upb_msg_field_begin(&i, desc->msgdef);
!upb_msg_field_done(&i);
upb_msg_field_next(&i)) {
@@ -1278,6 +1317,11 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc,
}
}
+ stringsink* unknown = DEREF(message_data(msg), 0, stringsink*);
+ if (unknown != NULL) {
+ upb_sink_putunknown(sink, unknown->ptr, unknown->len);
+ }
+
upb_sink_endmsg(sink, &status);
}
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c
index 50a0430c..291f5c24 100644
--- a/php/ext/google/protobuf/message.c
+++ b/php/ext/google/protobuf/message.c
@@ -38,6 +38,7 @@
zend_class_entry* message_type;
zend_object_handlers* message_handlers;
static const char TYPE_URL_PREFIX[] = "type.googleapis.com/";
+static void hex_to_binary(const char* hex, char** binary, int* binary_len);
static zend_function_entry message_methods[] = {
PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC)
@@ -80,6 +81,10 @@ static HashTable* message_get_properties(zval* object TSRMLS_DC);
// Define object free method.
PHP_PROTO_OBJECT_FREE_START(MessageHeader, message)
+ if (*(void**)intern->data != NULL) {
+ stringsink_uninit(*(void**)intern->data);
+ FREE(*(void**)intern->data);
+ }
FREE(intern->data);
PHP_PROTO_OBJECT_FREE_END
@@ -158,16 +163,26 @@ static zval* message_get_property_internal(zval* object,
#if PHP_MAJOR_VERSION < 7
property_info =
zend_get_property_info(Z_OBJCE_P(object), member, true TSRMLS_CC);
- return layout_get(
- self->descriptor->layout, message_data(self), field,
- OBJ_PROP(Z_OBJ_P(object), property_info->offset) TSRMLS_CC);
#else
property_info =
zend_get_property_info(Z_OBJCE_P(object), Z_STR_P(member), true);
+#endif
return layout_get(
self->descriptor->layout, message_data(self), field,
OBJ_PROP(Z_OBJ_P(object), property_info->offset) TSRMLS_CC);
-#endif
+}
+
+static void message_get_oneof_property_internal(zval* object, zval* member,
+ zval* return_value TSRMLS_DC) {
+ MessageHeader* self = UNBOX(MessageHeader, object);
+ const upb_fielddef* field;
+ field = upb_msgdef_ntofz(self->descriptor->msgdef, Z_STRVAL_P(member));
+ if (field == NULL) {
+ return;
+ }
+
+ layout_get(self->descriptor->layout, message_data(self), field,
+ ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC);
}
#if PHP_MAJOR_VERSION < 7
@@ -311,11 +326,6 @@ PHP_METHOD(Message, readOneof) {
const upb_fielddef* field = upb_msgdef_itof(msg->descriptor->msgdef, index);
- int property_cache_index =
- msg->descriptor->layout->fields[upb_fielddef_index(field)].cache_index;
- zval* property_ptr = CACHED_PTR_TO_ZVAL_PTR(
- OBJ_PROP(Z_OBJ_P(getThis()), property_cache_index));
-
// Unlike singular fields, oneof fields share cached property. So we cannot
// let lay_get modify the cached property. Instead, we pass in the return
// value directly.
@@ -382,6 +392,474 @@ PHP_METHOD(Message, whichOneof) {
PHP_PROTO_RETVAL_ZVAL(getThis()); \
}
+#define PHP_PROTO_ONEOF_FIELD_ACCESSORS(UPPER_CLASS, LOWER_CLASS, UPPER_FIELD, \
+ LOWER_FIELD) \
+ PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \
+ zval member; \
+ PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \
+ PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \
+ message_get_oneof_property_internal(getThis(), &member, \
+ return_value TSRMLS_CC); \
+ PHP_PROTO_FAKE_SCOPE_END; \
+ } \
+ PHP_METHOD(UPPER_CLASS, set##UPPER_FIELD) { \
+ zval* value = NULL; \
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == \
+ FAILURE) { \
+ return; \
+ } \
+ zval member; \
+ PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \
+ message_set_property_internal(getThis(), &member, value TSRMLS_CC); \
+ PHP_PROTO_RETVAL_ZVAL(getThis()); \
+ }
+
+#define PHP_PROTO_ONEOF_ACCESSORS(UPPER_CLASS, LOWER_CLASS, UPPER_FIELD, \
+ LOWER_FIELD) \
+ PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \
+ MessageHeader* msg = UNBOX(MessageHeader, getThis()); \
+ PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \
+ const upb_oneofdef* oneof = upb_msgdef_ntoo( \
+ msg->descriptor->msgdef, LOWER_FIELD, strlen(LOWER_FIELD)); \
+ const char* oneof_case_name = layout_get_oneof_case( \
+ msg->descriptor->layout, message_data(msg), oneof TSRMLS_CC); \
+ PHP_PROTO_FAKE_SCOPE_END; \
+ PHP_PROTO_RETURN_STRING(oneof_case_name, 1); \
+ }
+
+// Forward declare file init functions
+static void init_file_any(TSRMLS_D);
+static void init_file_api(TSRMLS_D);
+static void init_file_duration(TSRMLS_D);
+static void init_file_field_mask(TSRMLS_D);
+static void init_file_empty(TSRMLS_D);
+static void init_file_source_context(TSRMLS_D);
+static void init_file_struct(TSRMLS_D);
+static void init_file_timestamp(TSRMLS_D);
+static void init_file_type(TSRMLS_D);
+static void init_file_wrappers(TSRMLS_D);
+
+// Define file init functions
+static void init_file_any(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f"
+ "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479"
+ "70655f75726c180120012809120d0a0576616c756518022001280c426f0a"
+ "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f"
+ "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566"
+ "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f"
+ "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_api(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_file_source_context(TSRMLS_C);
+ init_file_type(TSRMLS_C);
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0aee050a19676f6f676c652f70726f746f6275662f6170692e70726f746f"
+ "120f676f6f676c652e70726f746f6275661a24676f6f676c652f70726f74"
+ "6f6275662f736f757263655f636f6e746578742e70726f746f1a1a676f6f"
+ "676c652f70726f746f6275662f747970652e70726f746f2281020a034170"
+ "69120c0a046e616d6518012001280912280a076d6574686f647318022003"
+ "280b32172e676f6f676c652e70726f746f6275662e4d6574686f6412280a"
+ "076f7074696f6e7318032003280b32172e676f6f676c652e70726f746f62"
+ "75662e4f7074696f6e120f0a0776657273696f6e18042001280912360a0e"
+ "736f757263655f636f6e7465787418052001280b321e2e676f6f676c652e"
+ "70726f746f6275662e536f75726365436f6e7465787412260a066d697869"
+ "6e7318062003280b32162e676f6f676c652e70726f746f6275662e4d6978"
+ "696e12270a0673796e74617818072001280e32172e676f6f676c652e7072"
+ "6f746f6275662e53796e74617822d5010a064d6574686f64120c0a046e61"
+ "6d6518012001280912180a10726571756573745f747970655f75726c1802"
+ "2001280912190a11726571756573745f73747265616d696e671803200128"
+ "0812190a11726573706f6e73655f747970655f75726c180420012809121a"
+ "0a12726573706f6e73655f73747265616d696e6718052001280812280a07"
+ "6f7074696f6e7318062003280b32172e676f6f676c652e70726f746f6275"
+ "662e4f7074696f6e12270a0673796e74617818072001280e32172e676f6f"
+ "676c652e70726f746f6275662e53796e74617822230a054d6978696e120c"
+ "0a046e616d65180120012809120c0a04726f6f7418022001280942750a13"
+ "636f6d2e676f6f676c652e70726f746f627566420841706950726f746f50"
+ "015a2b676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f"
+ "70726f746f6275662f6170693b617069a20203475042aa021e476f6f676c"
+ "652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f"
+ "746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_duration(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e"
+ "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261"
+ "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73"
+ "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642"
+ "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67"
+ "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e"
+ "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765"
+ "6c6c4b6e6f776e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_field_mask(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173"
+ "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669"
+ "656c644d61736b120d0a0570617468731801200328094289010a13636f6d"
+ "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f"
+ "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f"
+ "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d"
+ "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765"
+ "6c6c4b6e6f776e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_empty(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f"
+ "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276"
+ "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072"
+ "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f"
+ "6275662f7074797065732f656d707479f80101a20203475042aa021e476f"
+ "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206"
+ "70726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_source_context(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f"
+ "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222"
+ "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801"
+ "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212"
+ "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67"
+ "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f"
+ "757263655f636f6e746578743b736f757263655f636f6e74657874a20203"
+ "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77"
+ "6e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_struct(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e7072"
+ "6f746f120f676f6f676c652e70726f746f6275662284010a065374727563"
+ "7412330a066669656c647318012003280b32232e676f6f676c652e70726f"
+ "746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669"
+ "656c6473456e747279120b0a036b657918012001280912250a0576616c75"
+ "6518022001280b32162e676f6f676c652e70726f746f6275662e56616c75"
+ "653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518"
+ "012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c5661"
+ "6c7565480012160a0c6e756d6265725f76616c7565180220012801480012"
+ "160a0c737472696e675f76616c7565180320012809480012140a0a626f6f"
+ "6c5f76616c75651804200128084800122f0a0c7374727563745f76616c75"
+ "6518052001280b32172e676f6f676c652e70726f746f6275662e53747275"
+ "6374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f"
+ "676c652e70726f746f6275662e4c69737456616c7565480042060a046b69"
+ "6e6422330a094c69737456616c756512260a0676616c7565731801200328"
+ "0b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e"
+ "756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a1363"
+ "6f6d2e676f6f676c652e70726f746f627566420b53747275637450726f74"
+ "6f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275"
+ "662f7074797065732f7374727563743b7374727563747062f80101a20203"
+ "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77"
+ "6e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_timestamp(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70"
+ "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d"
+ "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e"
+ "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275"
+ "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f"
+ "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573"
+ "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275"
+ "662e57656c6c4b6e6f776e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_type(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_file_any(TSRMLS_C);
+ init_file_source_context(TSRMLS_C);
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0aba0c0a1a676f6f676c652f70726f746f6275662f747970652e70726f74"
+ "6f120f676f6f676c652e70726f746f6275661a19676f6f676c652f70726f"
+ "746f6275662f616e792e70726f746f1a24676f6f676c652f70726f746f62"
+ "75662f736f757263655f636f6e746578742e70726f746f22d7010a045479"
+ "7065120c0a046e616d6518012001280912260a066669656c647318022003"
+ "280b32162e676f6f676c652e70726f746f6275662e4669656c64120e0a06"
+ "6f6e656f667318032003280912280a076f7074696f6e7318042003280b32"
+ "172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a0e736f"
+ "757263655f636f6e7465787418052001280b321e2e676f6f676c652e7072"
+ "6f746f6275662e536f75726365436f6e7465787412270a0673796e746178"
+ "18062001280e32172e676f6f676c652e70726f746f6275662e53796e7461"
+ "7822d5050a054669656c6412290a046b696e6418012001280e321b2e676f"
+ "6f676c652e70726f746f6275662e4669656c642e4b696e6412370a0b6361"
+ "7264696e616c69747918022001280e32222e676f6f676c652e70726f746f"
+ "6275662e4669656c642e43617264696e616c697479120e0a066e756d6265"
+ "72180320012805120c0a046e616d6518042001280912100a08747970655f"
+ "75726c18062001280912130a0b6f6e656f665f696e646578180720012805"
+ "120e0a067061636b656418082001280812280a076f7074696f6e73180920"
+ "03280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e1211"
+ "0a096a736f6e5f6e616d65180a2001280912150a0d64656661756c745f76"
+ "616c7565180b2001280922c8020a044b696e6412100a0c545950455f554e"
+ "4b4e4f574e1000120f0a0b545950455f444f55424c451001120e0a0a5459"
+ "50455f464c4f41541002120e0a0a545950455f494e5436341003120f0a0b"
+ "545950455f55494e5436341004120e0a0a545950455f494e543332100512"
+ "100a0c545950455f46495845443634100612100a0c545950455f46495845"
+ "4433321007120d0a09545950455f424f4f4c1008120f0a0b545950455f53"
+ "5452494e471009120e0a0a545950455f47524f5550100a12100a0c545950"
+ "455f4d455353414745100b120e0a0a545950455f4259544553100c120f0a"
+ "0b545950455f55494e543332100d120d0a09545950455f454e554d100e12"
+ "110a0d545950455f5346495845443332100f12110a0d545950455f534649"
+ "58454436341010120f0a0b545950455f53494e5433321011120f0a0b5459"
+ "50455f53494e543634101222740a0b43617264696e616c69747912170a13"
+ "43415244494e414c4954595f554e4b4e4f574e100012180a144341524449"
+ "4e414c4954595f4f5054494f4e414c100112180a1443415244494e414c49"
+ "54595f5245515549524544100212180a1443415244494e414c4954595f52"
+ "45504541544544100322ce010a04456e756d120c0a046e616d6518012001"
+ "2809122d0a09656e756d76616c756518022003280b321a2e676f6f676c65"
+ "2e70726f746f6275662e456e756d56616c756512280a076f7074696f6e73"
+ "18032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f"
+ "6e12360a0e736f757263655f636f6e7465787418042001280b321e2e676f"
+ "6f676c652e70726f746f6275662e536f75726365436f6e7465787412270a"
+ "0673796e74617818052001280e32172e676f6f676c652e70726f746f6275"
+ "662e53796e74617822530a09456e756d56616c7565120c0a046e616d6518"
+ "0120012809120e0a066e756d62657218022001280512280a076f7074696f"
+ "6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f7074"
+ "696f6e223b0a064f7074696f6e120c0a046e616d6518012001280912230a"
+ "0576616c756518022001280b32142e676f6f676c652e70726f746f627566"
+ "2e416e792a2e0a0653796e74617812110a0d53594e5441585f50524f544f"
+ "32100012110a0d53594e5441585f50524f544f331001427d0a13636f6d2e"
+ "676f6f676c652e70726f746f62756642095479706550726f746f50015a2f"
+ "676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f70726f"
+ "746f6275662f70747970653b7074797065f80101a20203475042aa021e47"
+ "6f6f676c652e50726f746f6275662e57656c6c4b6e6f776e547970657362"
+ "0670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+static void init_file_wrappers(TSRMLS_D) {
+ static bool is_initialized = false;
+ if (is_initialized) return;
+ init_generated_pool_once(TSRMLS_C);
+ const char* generated_file =
+ "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e"
+ "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562"
+ "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61"
+ "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634"
+ "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634"
+ "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256"
+ "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256"
+ "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c"
+ "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c"
+ "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75"
+ "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65"
+ "2e70726f746f627566420d577261707065727350726f746f50015a2a6769"
+ "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065"
+ "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50"
+ "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33";
+ char* binary;
+ int binary_len;
+ hex_to_binary(generated_file, &binary, &binary_len);
+ internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
+ FREE(binary);
+ is_initialized = true;
+}
+
+// -----------------------------------------------------------------------------
+// Define enum
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// Field_Cardinality
+// -----------------------------------------------------------------------------
+
+static zend_function_entry field_cardinality_methods[] = {
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* field_cardinality_type;
+
+// Init class entry.
+PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field_Cardinality",
+ Field_Cardinality, field_cardinality)
+ zend_declare_class_constant_long(field_cardinality_type,
+ "CARDINALITY_UNKNOWN", 19, 0 TSRMLS_CC);
+ zend_declare_class_constant_long(field_cardinality_type,
+ "CARDINALITY_OPTIONAL", 20, 1 TSRMLS_CC);
+ zend_declare_class_constant_long(field_cardinality_type,
+ "CARDINALITY_REQUIRED", 20, 2 TSRMLS_CC);
+ zend_declare_class_constant_long(field_cardinality_type,
+ "CARDINALITY_REPEATED", 20, 3 TSRMLS_CC);
+PHP_PROTO_INIT_ENUMCLASS_END
+
+// -----------------------------------------------------------------------------
+// Field_Kind
+// -----------------------------------------------------------------------------
+
+static zend_function_entry field_kind_methods[] = {
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* field_kind_type;
+
+// Init class entry.
+PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Field_Kind",
+ Field_Kind, field_kind)
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_UNKNOWN", 12, 0 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_DOUBLE", 11, 1 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_FLOAT", 10, 2 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_INT64", 10, 3 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_UINT64", 11, 4 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_INT32", 10, 5 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_FIXED64", 12, 6 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_FIXED32", 12, 7 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_BOOL", 9, 8 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_STRING", 11, 9 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_GROUP", 10, 10 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_MESSAGE", 12, 11 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_BYTES", 10, 12 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_UINT32", 11, 13 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_ENUM", 9, 14 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_SFIXED32", 13, 15 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_SFIXED64", 13, 16 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_SINT32", 11, 17 TSRMLS_CC);
+ zend_declare_class_constant_long(field_kind_type,
+ "TYPE_SINT64", 11, 18 TSRMLS_CC);
+PHP_PROTO_INIT_ENUMCLASS_END
+
+// -----------------------------------------------------------------------------
+// NullValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry null_value_methods[] = {
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* null_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\NullValue",
+ NullValue, null_value)
+ zend_declare_class_constant_long(null_value_type,
+ "NULL_VALUE", 10, 0 TSRMLS_CC);
+PHP_PROTO_INIT_ENUMCLASS_END
+
+// -----------------------------------------------------------------------------
+// Syntax
+// -----------------------------------------------------------------------------
+
+static zend_function_entry syntax_methods[] = {
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* syntax_type;
+
+// Init class entry.
+PHP_PROTO_INIT_ENUMCLASS_START("Google\\Protobuf\\Syntax",
+ Syntax, syntax)
+ zend_declare_class_constant_long(syntax_type,
+ "SYNTAX_PROTO2", 13, 0 TSRMLS_CC);
+ zend_declare_class_constant_long(syntax_type,
+ "SYNTAX_PROTO3", 13, 1 TSRMLS_CC);
+PHP_PROTO_INIT_ENUMCLASS_END
+
+
+
+// -----------------------------------------------------------------------------
+// Define message
+// -----------------------------------------------------------------------------
+
// -----------------------------------------------------------------------------
// Any
// -----------------------------------------------------------------------------
@@ -409,7 +887,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Any", Any, any)
"" ,ZEND_ACC_PRIVATE TSRMLS_CC);
PHP_PROTO_INIT_SUBMSGCLASS_END
-void hex_to_binary(const char* hex, char** binary, int* binary_len) {
+static void hex_to_binary(const char* hex, char** binary, int* binary_len) {
int i;
int hex_len = strlen(hex);
*binary_len = hex_len / 2;
@@ -431,25 +909,7 @@ void hex_to_binary(const char* hex, char** binary, int* binary_len) {
}
PHP_METHOD(Any, __construct) {
- PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(any_type);
- if (desc_php == NULL) {
- init_generated_pool_once(TSRMLS_C);
- const char* generated_file =
- "0acd010a19676f6f676c652f70726f746f6275662f616e792e70726f746f"
- "120f676f6f676c652e70726f746f62756622260a03416e7912100a087479"
- "70655f75726c180120012809120d0a0576616c756518022001280c426f0a"
- "13636f6d2e676f6f676c652e70726f746f6275664208416e7950726f746f"
- "50015a256769746875622e636f6d2f676f6c616e672f70726f746f627566"
- "2f7074797065732f616e79a20203475042aa021e476f6f676c652e50726f"
- "746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33";
- char* binary;
- int binary_len;
- hex_to_binary(generated_file, &binary, &binary_len);
-
- internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
- FREE(binary);
- }
-
+ init_file_any(TSRMLS_C);
MessageHeader* intern = UNBOX(MessageHeader, getThis());
custom_data_init(any_type, intern PHP_PROTO_TSRMLS_CC);
}
@@ -611,26 +1071,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Duration",
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(Duration, __construct) {
- PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(duration_type);
- if (desc_php == NULL) {
- init_generated_pool_once(TSRMLS_C);
- const char* generated_file =
- "0ae3010a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e"
- "70726f746f120f676f6f676c652e70726f746f627566222a0a0844757261"
- "74696f6e120f0a077365636f6e6473180120012803120d0a056e616e6f73"
- "180220012805427c0a13636f6d2e676f6f676c652e70726f746f62756642"
- "0d4475726174696f6e50726f746f50015a2a6769746875622e636f6d2f67"
- "6f6c616e672f70726f746f6275662f7074797065732f6475726174696f6e"
- "f80101a20203475042aa021e476f6f676c652e50726f746f6275662e5765"
- "6c6c4b6e6f776e5479706573620670726f746f33";
- char* binary;
- int binary_len;
- hex_to_binary(generated_file, &binary, &binary_len);
-
- internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
- FREE(binary);
- }
-
+ init_file_duration(TSRMLS_C);
MessageHeader* intern = UNBOX(MessageHeader, getThis());
custom_data_init(duration_type, intern PHP_PROTO_TSRMLS_CC);
}
@@ -666,26 +1107,7 @@ PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Timestamp",
PHP_PROTO_INIT_SUBMSGCLASS_END
PHP_METHOD(Timestamp, __construct) {
- PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(timestamp_type);
- if (desc_php == NULL) {
- init_generated_pool_once(TSRMLS_C);
- const char* generated_file =
- "0ae7010a1f676f6f676c652f70726f746f6275662f74696d657374616d70"
- "2e70726f746f120f676f6f676c652e70726f746f627566222b0a0954696d"
- "657374616d70120f0a077365636f6e6473180120012803120d0a056e616e"
- "6f73180220012805427e0a13636f6d2e676f6f676c652e70726f746f6275"
- "66420e54696d657374616d7050726f746f50015a2b6769746875622e636f"
- "6d2f676f6c616e672f70726f746f6275662f7074797065732f74696d6573"
- "74616d70f80101a20203475042aa021e476f6f676c652e50726f746f6275"
- "662e57656c6c4b6e6f776e5479706573620670726f746f33";
- char* binary;
- int binary_len;
- hex_to_binary(generated_file, &binary, &binary_len);
-
- internal_add_generated_file(binary, binary_len, generated_pool TSRMLS_CC);
- FREE(binary);
- }
-
+ init_file_timestamp(TSRMLS_C);
MessageHeader* intern = UNBOX(MessageHeader, getThis());
custom_data_init(timestamp_type, intern PHP_PROTO_TSRMLS_CC);
}
@@ -758,3 +1180,852 @@ PHP_METHOD(Timestamp, toDateTime) {
zval* datetime_ptr = &datetime;
PHP_PROTO_RETVAL_ZVAL(datetime_ptr);
}
+
+// -----------------------------------------------------------------------------
+// Api
+// -----------------------------------------------------------------------------
+
+static zend_function_entry api_methods[] = {
+ PHP_ME(Api, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getMethods, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setMethods, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getVersion, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setVersion, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getMixins, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setMixins, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, getSyntax, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Api, setSyntax, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* api_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Api",
+ Api, api)
+ zend_class_implements(api_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(api_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "methods", strlen("methods"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "version", strlen("version"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "source_context", strlen("source_context"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "mixins", strlen("mixins"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(api_type, "syntax", strlen("syntax"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Api, __construct) {
+ init_file_api(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(api_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Methods, "methods")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Options, "options")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Version, "version")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, SourceContext, "source_context")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Mixins, "mixins")
+PHP_PROTO_FIELD_ACCESSORS(Api, api, Syntax, "syntax")
+
+// -----------------------------------------------------------------------------
+// BoolValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry bool_value_methods[] = {
+ PHP_ME(BoolValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(BoolValue, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(BoolValue, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* bool_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BoolValue",
+ BoolValue, bool_value)
+ zend_class_implements(bool_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(bool_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(BoolValue, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(bool_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(BoolValue, bool_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// BytesValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry bytes_value_methods[] = {
+ PHP_ME(BytesValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(BytesValue, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(BytesValue, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* bytes_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\BytesValue",
+ BytesValue, bytes_value)
+ zend_class_implements(bytes_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(bytes_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(BytesValue, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(bytes_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(BytesValue, bytes_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// DoubleValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry double_value_methods[] = {
+ PHP_ME(DoubleValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DoubleValue, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DoubleValue, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* double_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\DoubleValue",
+ DoubleValue, double_value)
+ zend_class_implements(double_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(double_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(DoubleValue, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(double_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(DoubleValue, double_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// Enum
+// -----------------------------------------------------------------------------
+
+static zend_function_entry enum_methods[] = {
+ PHP_ME(Enum, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, getEnumvalue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, setEnumvalue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, setOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, getSyntax, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Enum, setSyntax, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* enum_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Enum",
+ Enum, enum)
+ zend_class_implements(enum_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(enum_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_type, "enumvalue", strlen("enumvalue"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_type, "source_context", strlen("source_context"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_type, "syntax", strlen("syntax"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Enum, __construct) {
+ init_file_type(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(enum_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Enumvalue, "enumvalue")
+PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Options, "options")
+PHP_PROTO_FIELD_ACCESSORS(Enum, enum, SourceContext, "source_context")
+PHP_PROTO_FIELD_ACCESSORS(Enum, enum, Syntax, "syntax")
+
+// -----------------------------------------------------------------------------
+// EnumValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry enum_value_methods[] = {
+ PHP_ME(EnumValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, getNumber, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, setNumber, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(EnumValue, setOptions, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* enum_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\EnumValue",
+ EnumValue, enum_value)
+ zend_class_implements(enum_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(enum_value_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_value_type, "number", strlen("number"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(enum_value_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(EnumValue, __construct) {
+ init_file_type(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(enum_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Number, "number")
+PHP_PROTO_FIELD_ACCESSORS(EnumValue, enum_value, Options, "options")
+
+// -----------------------------------------------------------------------------
+// FieldMask
+// -----------------------------------------------------------------------------
+
+static zend_function_entry field_mask_methods[] = {
+ PHP_ME(FieldMask, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(FieldMask, getPaths, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(FieldMask, setPaths, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* field_mask_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\FieldMask",
+ FieldMask, field_mask)
+ zend_class_implements(field_mask_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(field_mask_type, "paths", strlen("paths"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(FieldMask, __construct) {
+ init_file_field_mask(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(field_mask_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(FieldMask, field_mask, Paths, "paths")
+
+// -----------------------------------------------------------------------------
+// Field
+// -----------------------------------------------------------------------------
+
+static zend_function_entry field_methods[] = {
+ PHP_ME(Field, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getKind, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setKind, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getCardinality, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setCardinality, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getNumber, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setNumber, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getOneofIndex, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setOneofIndex, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getPacked, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setPacked, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getJsonName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setJsonName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, getDefaultValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Field, setDefaultValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* field_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Field",
+ Field, field)
+ zend_class_implements(field_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(field_type, "kind", strlen("kind"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "cardinality", strlen("cardinality"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "number", strlen("number"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "type_url", strlen("type_url"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "oneof_index", strlen("oneof_index"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "packed", strlen("packed"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "json_name", strlen("json_name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(field_type, "default_value", strlen("default_value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Field, __construct) {
+ init_file_type(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(field_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Kind, "kind")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Cardinality, "cardinality")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Number, "number")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, TypeUrl, "type_url")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, OneofIndex, "oneof_index")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Packed, "packed")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, Options, "options")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, JsonName, "json_name")
+PHP_PROTO_FIELD_ACCESSORS(Field, field, DefaultValue, "default_value")
+
+// -----------------------------------------------------------------------------
+// FloatValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry float_value_methods[] = {
+ PHP_ME(FloatValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(FloatValue, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(FloatValue, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* float_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\FloatValue",
+ FloatValue, float_value)
+ zend_class_implements(float_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(float_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(FloatValue, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(float_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(FloatValue, float_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// GPBEmpty
+// -----------------------------------------------------------------------------
+
+static zend_function_entry empty_methods[] = {
+ PHP_ME(GPBEmpty, __construct, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* empty_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\GPBEmpty",
+ GPBEmpty, empty)
+ zend_class_implements(empty_type TSRMLS_CC, 1, message_type);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(GPBEmpty, __construct) {
+ init_file_empty(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(empty_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+
+// -----------------------------------------------------------------------------
+// Int32Value
+// -----------------------------------------------------------------------------
+
+static zend_function_entry int32_value_methods[] = {
+ PHP_ME(Int32Value, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Int32Value, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Int32Value, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* int32_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int32Value",
+ Int32Value, int32_value)
+ zend_class_implements(int32_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(int32_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Int32Value, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(int32_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Int32Value, int32_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// Int64Value
+// -----------------------------------------------------------------------------
+
+static zend_function_entry int64_value_methods[] = {
+ PHP_ME(Int64Value, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Int64Value, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Int64Value, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* int64_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Int64Value",
+ Int64Value, int64_value)
+ zend_class_implements(int64_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(int64_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Int64Value, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(int64_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Int64Value, int64_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// ListValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry list_value_methods[] = {
+ PHP_ME(ListValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(ListValue, getValues, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(ListValue, setValues, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* list_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\ListValue",
+ ListValue, list_value)
+ zend_class_implements(list_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(list_value_type, "values", strlen("values"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(ListValue, __construct) {
+ init_file_struct(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(list_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(ListValue, list_value, Values, "values")
+
+// -----------------------------------------------------------------------------
+// Method
+// -----------------------------------------------------------------------------
+
+static zend_function_entry method_methods[] = {
+ PHP_ME(Method, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getRequestTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setRequestTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getRequestStreaming, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setRequestStreaming, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getResponseTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setResponseTypeUrl, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getResponseStreaming, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setResponseStreaming, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, getSyntax, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Method, setSyntax, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* method_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Method",
+ Method, method)
+ zend_class_implements(method_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(method_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "request_type_url", strlen("request_type_url"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "request_streaming", strlen("request_streaming"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "response_type_url", strlen("response_type_url"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "response_streaming", strlen("response_streaming"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(method_type, "syntax", strlen("syntax"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Method, __construct) {
+ init_file_api(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(method_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Method, method, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, RequestTypeUrl, "request_type_url")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, RequestStreaming, "request_streaming")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, ResponseTypeUrl, "response_type_url")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, ResponseStreaming, "response_streaming")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, Options, "options")
+PHP_PROTO_FIELD_ACCESSORS(Method, method, Syntax, "syntax")
+
+// -----------------------------------------------------------------------------
+// Mixin
+// -----------------------------------------------------------------------------
+
+static zend_function_entry mixin_methods[] = {
+ PHP_ME(Mixin, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Mixin, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Mixin, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Mixin, getRoot, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Mixin, setRoot, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* mixin_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Mixin",
+ Mixin, mixin)
+ zend_class_implements(mixin_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(mixin_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(mixin_type, "root", strlen("root"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Mixin, __construct) {
+ init_file_api(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(mixin_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Mixin, mixin, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Mixin, mixin, Root, "root")
+
+// -----------------------------------------------------------------------------
+// Option
+// -----------------------------------------------------------------------------
+
+static zend_function_entry option_methods[] = {
+ PHP_ME(Option, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Option, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Option, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Option, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Option, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* option_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Option",
+ Option, option)
+ zend_class_implements(option_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(option_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(option_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Option, __construct) {
+ init_file_type(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(option_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Option, option, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Option, option, Value, "value")
+
+// -----------------------------------------------------------------------------
+// SourceContext
+// -----------------------------------------------------------------------------
+
+static zend_function_entry source_context_methods[] = {
+ PHP_ME(SourceContext, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(SourceContext, getFileName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(SourceContext, setFileName, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* source_context_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\SourceContext",
+ SourceContext, source_context)
+ zend_class_implements(source_context_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(source_context_type, "file_name", strlen("file_name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(SourceContext, __construct) {
+ init_file_source_context(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(source_context_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(SourceContext, source_context, FileName, "file_name")
+
+// -----------------------------------------------------------------------------
+// StringValue
+// -----------------------------------------------------------------------------
+
+static zend_function_entry string_value_methods[] = {
+ PHP_ME(StringValue, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(StringValue, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(StringValue, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* string_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\StringValue",
+ StringValue, string_value)
+ zend_class_implements(string_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(string_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(StringValue, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(string_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(StringValue, string_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// Struct
+// -----------------------------------------------------------------------------
+
+static zend_function_entry struct_methods[] = {
+ PHP_ME(Struct, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Struct, getFields, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Struct, setFields, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* struct_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Struct",
+ Struct, struct)
+ zend_class_implements(struct_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(struct_type, "fields", strlen("fields"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Struct, __construct) {
+ init_file_struct(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(struct_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Struct, struct, Fields, "fields")
+
+// -----------------------------------------------------------------------------
+// Type
+// -----------------------------------------------------------------------------
+
+static zend_function_entry type_methods[] = {
+ PHP_ME(Type, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setName, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getFields, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setFields, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getOneofs, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setOneofs, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setOptions, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setSourceContext, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, getSyntax, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Type, setSyntax, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* type_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Type",
+ Type, type)
+ zend_class_implements(type_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(type_type, "name", strlen("name"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(type_type, "fields", strlen("fields"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(type_type, "oneofs", strlen("oneofs"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(type_type, "options", strlen("options"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(type_type, "source_context", strlen("source_context"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_declare_property_null(type_type, "syntax", strlen("syntax"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Type, __construct) {
+ init_file_type(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(type_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(Type, type, Name, "name")
+PHP_PROTO_FIELD_ACCESSORS(Type, type, Fields, "fields")
+PHP_PROTO_FIELD_ACCESSORS(Type, type, Oneofs, "oneofs")
+PHP_PROTO_FIELD_ACCESSORS(Type, type, Options, "options")
+PHP_PROTO_FIELD_ACCESSORS(Type, type, SourceContext, "source_context")
+PHP_PROTO_FIELD_ACCESSORS(Type, type, Syntax, "syntax")
+
+// -----------------------------------------------------------------------------
+// UInt32Value
+// -----------------------------------------------------------------------------
+
+static zend_function_entry u_int32_value_methods[] = {
+ PHP_ME(UInt32Value, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(UInt32Value, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(UInt32Value, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* u_int32_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt32Value",
+ UInt32Value, u_int32_value)
+ zend_class_implements(u_int32_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(u_int32_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(UInt32Value, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(u_int32_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(UInt32Value, u_int32_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// UInt64Value
+// -----------------------------------------------------------------------------
+
+static zend_function_entry u_int64_value_methods[] = {
+ PHP_ME(UInt64Value, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(UInt64Value, getValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(UInt64Value, setValue, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* u_int64_value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\UInt64Value",
+ UInt64Value, u_int64_value)
+ zend_class_implements(u_int64_value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(u_int64_value_type, "value", strlen("value"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(UInt64Value, __construct) {
+ init_file_wrappers(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(u_int64_value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_FIELD_ACCESSORS(UInt64Value, u_int64_value, Value, "value")
+
+// -----------------------------------------------------------------------------
+// Value
+// -----------------------------------------------------------------------------
+
+static zend_function_entry value_methods[] = {
+ PHP_ME(Value, __construct, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getNullValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setNullValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getNumberValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setNumberValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getStringValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setStringValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getBoolValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setBoolValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getStructValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setStructValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getListValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, setListValue, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Value, getKind, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+
+zend_class_entry* value_type;
+
+// Init class entry.
+PHP_PROTO_INIT_SUBMSGCLASS_START("Google\\Protobuf\\Value",
+ Value, value)
+ zend_class_implements(value_type TSRMLS_CC, 1, message_type);
+ zend_declare_property_null(value_type, "kind", strlen("kind"),
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+PHP_PROTO_INIT_SUBMSGCLASS_END
+
+PHP_METHOD(Value, __construct) {
+ init_file_struct(TSRMLS_C);
+ MessageHeader* intern = UNBOX(MessageHeader, getThis());
+ custom_data_init(value_type, intern PHP_PROTO_TSRMLS_CC);
+}
+
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, NullValue, "null_value")
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, NumberValue, "number_value")
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, StringValue, "string_value")
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, BoolValue, "bool_value")
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, StructValue, "struct_value")
+PHP_PROTO_ONEOF_FIELD_ACCESSORS(Value, value, ListValue, "list_value")
+PHP_PROTO_ONEOF_ACCESSORS(Value, value, Kind, "kind")
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml
index 2d318517..4a473801 100644
--- a/php/ext/google/protobuf/package.xml
+++ b/php/ext/google/protobuf/package.xml
@@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
- <date>2017-01-13</date>
- <time>16:06:07</time>
+ <date>2017-09-14</date>
+ <time>11:02:07</time>
<version>
- <release>3.4.0</release>
- <api>3.4.0</api>
+ <release>3.4.1</release>
+ <api>3.4.1</api>
</version>
<stability>
<release>stable</release>
@@ -152,5 +152,21 @@ GA release.
GA release.
</notes>
</release>
+ <release>
+ <version>
+ <release>3.4.1</release>
+ <api>3.4.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2017-09-14</date>
+ <time>11:02:07</time>
+ <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
+ <notes>
+GA release.
+ </notes>
+ </release>
</changelog>
</package>
diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c
index 42bc31cf..b67089e0 100644
--- a/php/ext/google/protobuf/protobuf.c
+++ b/php/ext/google/protobuf/protobuf.c
@@ -49,6 +49,7 @@ static HashTable* ce_to_php_obj_map;
// Global map from message/enum's proto fully-qualified name to corresponding
// wrapper Descriptor/EnumDescriptor instances.
static HashTable* proto_to_php_obj_map;
+static HashTable* reserved_names;
// -----------------------------------------------------------------------------
// Global maps.
@@ -144,6 +145,36 @@ PHP_PROTO_HASHTABLE_VALUE get_proto_obj(const char* proto) {
}
// -----------------------------------------------------------------------------
+// Reserved Name.
+// -----------------------------------------------------------------------------
+
+// Although we already have kReservedNames, we still add them to hash table to
+// speed up look up.
+const char *const kReservedNames[] = {
+ "abstract", "and", "array", "as", "break",
+ "callable", "case", "catch", "class", "clone",
+ "const", "continue", "declare", "default", "die",
+ "do", "echo", "else", "elseif", "empty",
+ "enddeclare", "endfor", "endforeach", "endif", "endswitch",
+ "endwhile", "eval", "exit", "extends", "final",
+ "for", "foreach", "function", "global", "goto",
+ "if", "implements", "include", "include_once", "instanceof",
+ "insteadof", "interface", "isset", "list", "namespace",
+ "new", "or", "print", "private", "protected",
+ "public", "require", "require_once", "return", "static",
+ "switch", "throw", "trait", "try", "unset",
+ "use", "var", "while", "xor", "int",
+ "float", "bool", "string", "true", "false",
+ "null", "void", "iterable"};
+const int kReservedNamesSize = 73;
+
+bool is_reserved_name(const char* name) {
+ void** value;
+ return (php_proto_zend_hash_find(reserved_names, name, strlen(name),
+ (void**)&value) == SUCCESS);
+}
+
+// -----------------------------------------------------------------------------
// Utilities.
// -----------------------------------------------------------------------------
@@ -190,6 +221,8 @@ static void php_proto_hashtable_descriptor_release(zval* value) {
#endif
static PHP_RINIT_FUNCTION(protobuf) {
+ int i = 0;
+
ALLOC_HASHTABLE(upb_def_to_php_obj_map);
zend_hash_init(upb_def_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0);
@@ -199,6 +232,13 @@ static PHP_RINIT_FUNCTION(protobuf) {
ALLOC_HASHTABLE(proto_to_php_obj_map);
zend_hash_init(proto_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0);
+ ALLOC_HASHTABLE(reserved_names);
+ zend_hash_init(reserved_names, 16, NULL, NULL, 0);
+ for (i = 0; i < kReservedNamesSize; i++) {
+ php_proto_zend_hash_update(reserved_names, kReservedNames[i],
+ strlen(kReservedNames[i]));
+ }
+
generated_pool = NULL;
generated_pool_php = NULL;
internal_generated_pool_php = NULL;
@@ -216,6 +256,9 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
zend_hash_destroy(proto_to_php_obj_map);
FREE_HASHTABLE(proto_to_php_obj_map);
+ zend_hash_destroy(reserved_names);
+ FREE_HASHTABLE(reserved_names);
+
#if PHP_MAJOR_VERSION < 7
if (generated_pool_php != NULL) {
zval_dtor(generated_pool_php);
@@ -256,9 +299,37 @@ static PHP_MINIT_FUNCTION(protobuf) {
repeated_field_init(TSRMLS_C);
repeated_field_iter_init(TSRMLS_C);
util_init(TSRMLS_C);
+
any_init(TSRMLS_C);
+ api_init(TSRMLS_C);
+ bool_value_init(TSRMLS_C);
+ bytes_value_init(TSRMLS_C);
+ double_value_init(TSRMLS_C);
duration_init(TSRMLS_C);
+ enum_init(TSRMLS_C);
+ enum_value_init(TSRMLS_C);
+ field_cardinality_init(TSRMLS_C);
+ field_init(TSRMLS_C);
+ field_kind_init(TSRMLS_C);
+ field_mask_init(TSRMLS_C);
+ float_value_init(TSRMLS_C);
+ empty_init(TSRMLS_C);
+ int32_value_init(TSRMLS_C);
+ int64_value_init(TSRMLS_C);
+ list_value_init(TSRMLS_C);
+ method_init(TSRMLS_C);
+ mixin_init(TSRMLS_C);
+ null_value_init(TSRMLS_C);
+ option_init(TSRMLS_C);
+ source_context_init(TSRMLS_C);
+ string_value_init(TSRMLS_C);
+ struct_init(TSRMLS_C);
+ syntax_init(TSRMLS_C);
timestamp_init(TSRMLS_C);
+ type_init(TSRMLS_C);
+ u_int32_value_init(TSRMLS_C);
+ u_int64_value_init(TSRMLS_C);
+ value_init(TSRMLS_C);
return 0;
}
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index d4ab2ce8..cb098747 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
-#define PHP_PROTOBUF_VERSION "3.4.0"
+#define PHP_PROTOBUF_VERSION "3.4.1"
#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8
@@ -80,6 +80,9 @@
#define php_proto_zend_hash_update_zval(ht, key, key_len, value) \
zend_hash_update(ht, key, key_len, value, sizeof(void*), NULL)
+#define php_proto_zend_hash_update(ht, key, key_len) \
+ zend_hash_update(ht, key, key_len, 0, 0, NULL)
+
#define php_proto_zend_hash_index_update_mem(ht, h, pData, nDataSize, pDest) \
zend_hash_index_update(ht, h, pData, nDataSize, pDest)
@@ -90,6 +93,9 @@
#define php_proto_zend_hash_index_find_zval(ht, h, pDest) \
zend_hash_index_find(ht, h, pDest)
+#define php_proto_zend_hash_find(ht, key, key_len, pDest) \
+ zend_hash_find(ht, key, key_len, pDest)
+
#define php_proto_zend_hash_index_find_mem(ht, h, pDest) \
zend_hash_index_find(ht, h, pDest)
@@ -127,6 +133,16 @@
#define PHP_PROTO_INIT_SUBMSGCLASS_END \
}
+#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
+ void LOWWERNAME##_init(TSRMLS_D) { \
+ zend_class_entry class_type; \
+ const char* class_name = CLASSNAME; \
+ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
+ LOWWERNAME##_methods); \
+ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC);
+#define PHP_PROTO_INIT_ENUMCLASS_END \
+ }
+
#define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
@@ -260,6 +276,15 @@ static inline int php_proto_zend_hash_index_update_zval(HashTable* ht, ulong h,
return result != NULL ? SUCCESS : FAILURE;
}
+static inline int php_proto_zend_hash_update(HashTable* ht, const char* key,
+ size_t key_len) {
+ void* result = NULL;
+ zval temp;
+ ZVAL_LONG(&temp, 0);
+ result = zend_hash_str_update(ht, key, key_len, &temp);
+ return result != NULL ? SUCCESS : FAILURE;
+}
+
static inline int php_proto_zend_hash_index_update_mem(HashTable* ht, ulong h,
void* pData, uint nDataSize,
void** pDest) {
@@ -293,6 +318,13 @@ static inline int php_proto_zend_hash_index_find_zval(const HashTable* ht,
return result != NULL ? SUCCESS : FAILURE;
}
+static inline int php_proto_zend_hash_find(const HashTable* ht, const char* key,
+ size_t key_len, void** pDest) {
+ void* result = NULL;
+ result = zend_hash_str_find(ht, key, key_len);
+ return result != NULL ? SUCCESS : FAILURE;
+}
+
static inline int php_proto_zend_hash_index_find_mem(const HashTable* ht,
ulong h, void** pDest) {
void* result = NULL;
@@ -365,6 +397,16 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht,
#define PHP_PROTO_INIT_SUBMSGCLASS_END \
}
+#define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
+ void LOWWERNAME##_init(TSRMLS_D) { \
+ zend_class_entry class_type; \
+ const char* class_name = CLASSNAME; \
+ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \
+ LOWWERNAME##_methods); \
+ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC);
+#define PHP_PROTO_INIT_ENUMCLASS_END \
+ }
+
#define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \
void LOWWERNAME##_init(TSRMLS_D) { \
zend_class_entry class_type; \
@@ -517,40 +559,108 @@ static inline int php_proto_zend_lookup_class(
// ----------------------------------------------------------------------------
struct Any;
-struct DescriptorPool;
+struct Api;
+struct BoolValue;
+struct BytesValue;
struct Descriptor;
+struct DescriptorPool;
+struct DoubleValue;
struct Duration;
+struct Enum;
struct EnumDescriptor;
+struct EnumValue;
struct EnumValueDescriptor;
+struct Field;
struct FieldDescriptor;
+struct FieldMask;
+struct Field_Cardinality;
+struct Field_Kind;
+struct FloatValue;
+struct GPBEmpty;
+struct Int32Value;
+struct Int64Value;
struct InternalDescriptorPool;
+struct ListValue;
+struct Map;
+struct MapIter;
struct MessageField;
struct MessageHeader;
struct MessageLayout;
+struct Method;
+struct Mixin;
+struct NullValue;
+struct Oneof;
+struct Option;
struct RepeatedField;
struct RepeatedFieldIter;
-struct Map;
-struct MapIter;
-struct Oneof;
+struct SourceContext;
+struct StringValue;
+struct Struct;
+struct Syntax;
struct Timestamp;
+struct Type;
+struct UInt32Value;
+struct UInt64Value;
+struct Value;
typedef struct Any Any;
-typedef struct DescriptorPool DescriptorPool;
+typedef struct Api Api;
+typedef struct BoolValue BoolValue;
+typedef struct BytesValue BytesValue;
+typedef struct Descriptor Descriptor;
typedef struct Descriptor Descriptor;
+typedef struct DescriptorPool DescriptorPool;
+typedef struct DescriptorPool DescriptorPool;
+typedef struct DoubleValue DoubleValue;
typedef struct Duration Duration;
+typedef struct Enum Enum;
typedef struct EnumDescriptor EnumDescriptor;
+typedef struct EnumDescriptor EnumDescriptor;
+typedef struct EnumValue EnumValue;
+typedef struct EnumValueDescriptor EnumValueDescriptor;
typedef struct EnumValueDescriptor EnumValueDescriptor;
+typedef struct Field Field;
typedef struct FieldDescriptor FieldDescriptor;
+typedef struct FieldDescriptor FieldDescriptor;
+typedef struct FieldMask FieldMask;
+typedef struct Field_Cardinality Field_Cardinality;
+typedef struct Field_Kind Field_Kind;
+typedef struct FloatValue FloatValue;
+typedef struct GPBEmpty GPBEmpty;
+typedef struct Int32Value Int32Value;
+typedef struct Int64Value Int64Value;
+typedef struct InternalDescriptorPool InternalDescriptorPool;
typedef struct InternalDescriptorPool InternalDescriptorPool;
+typedef struct ListValue ListValue;
+typedef struct Map Map;
+typedef struct Map Map;
+typedef struct MapIter MapIter;
+typedef struct MapIter MapIter;
typedef struct MessageField MessageField;
+typedef struct MessageField MessageField;
+typedef struct MessageHeader MessageHeader;
typedef struct MessageHeader MessageHeader;
typedef struct MessageLayout MessageLayout;
+typedef struct MessageLayout MessageLayout;
+typedef struct Method Method;
+typedef struct Mixin Mixin;
+typedef struct NullValue NullValue;
+typedef struct Oneof Oneof;
+typedef struct Oneof Oneof;
+typedef struct Option Option;
+typedef struct RepeatedField RepeatedField;
typedef struct RepeatedField RepeatedField;
typedef struct RepeatedFieldIter RepeatedFieldIter;
-typedef struct Map Map;
-typedef struct MapIter MapIter;
-typedef struct Oneof Oneof;
+typedef struct RepeatedFieldIter RepeatedFieldIter;
+typedef struct SourceContext SourceContext;
+typedef struct StringValue StringValue;
+typedef struct Struct Struct;
+typedef struct Syntax Syntax;
typedef struct Timestamp Timestamp;
+typedef struct Type Type;
+typedef struct UInt32Value UInt32Value;
+typedef struct UInt64Value UInt64Value;
+typedef struct Value Value;
// -----------------------------------------------------------------------------
// Globals.
@@ -561,21 +671,48 @@ ZEND_END_MODULE_GLOBALS(protobuf)
// Init module and PHP classes.
void any_init(TSRMLS_D);
+void api_init(TSRMLS_D);
+void bool_value_init(TSRMLS_D);
+void bytes_value_init(TSRMLS_D);
void descriptor_init(TSRMLS_D);
+void descriptor_pool_init(TSRMLS_D);
+void double_value_init(TSRMLS_D);
void duration_init(TSRMLS_D);
+void empty_init(TSRMLS_D);
void enum_descriptor_init(TSRMLS_D);
-void descriptor_pool_init(TSRMLS_D);
-void internal_descriptor_pool_init(TSRMLS_D);
+void enum_init(TSRMLS_D);
+void enum_value_init(TSRMLS_D);
+void field_cardinality_init(TSRMLS_D);
void field_descriptor_init(TSRMLS_D);
+void field_init(TSRMLS_D);
+void field_kind_init(TSRMLS_D);
+void field_mask_init(TSRMLS_D);
+void float_value_init(TSRMLS_D);
void gpb_type_init(TSRMLS_D);
+void int32_value_init(TSRMLS_D);
+void int64_value_init(TSRMLS_D);
+void internal_descriptor_pool_init(TSRMLS_D);
+void list_value_init(TSRMLS_D);
void map_field_init(TSRMLS_D);
void map_field_iter_init(TSRMLS_D);
void message_init(TSRMLS_D);
+void method_init(TSRMLS_D);
+void mixin_init(TSRMLS_D);
+void null_value_init(TSRMLS_D);
void oneof_descriptor_init(TSRMLS_D);
+void option_init(TSRMLS_D);
void repeated_field_init(TSRMLS_D);
void repeated_field_iter_init(TSRMLS_D);
+void source_context_init(TSRMLS_D);
+void string_value_init(TSRMLS_D);
+void struct_init(TSRMLS_D);
+void syntax_init(TSRMLS_D);
void timestamp_init(TSRMLS_D);
+void type_init(TSRMLS_D);
+void uint32_value_init(TSRMLS_D);
+void uint64_value_init(TSRMLS_D);
void util_init(TSRMLS_D);
+void value_init(TSRMLS_D);
// Global map from upb {msg,enum}defs to wrapper Descriptor/EnumDescriptor
// instances.
@@ -837,6 +974,11 @@ bool protobuf_convert_to_double(zval* from, double* to);
bool protobuf_convert_to_bool(zval* from, int8_t* to);
bool protobuf_convert_to_string(zval* from);
+void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type,
+ zval* val, zval* return_value);
+void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type,
+ PHP_PROTO_LONG value_type, zval* val, zval* return_value);
+
PHP_METHOD(Util, checkInt32);
PHP_METHOD(Util, checkUint32);
PHP_METHOD(Util, checkInt64);
@@ -1051,9 +1193,205 @@ PHP_METHOD(Timestamp, setSeconds);
PHP_METHOD(Timestamp, getNanos);
PHP_METHOD(Timestamp, setNanos);
+PHP_METHOD(Api, __construct);
+PHP_METHOD(Api, getName);
+PHP_METHOD(Api, setName);
+PHP_METHOD(Api, getMethods);
+PHP_METHOD(Api, setMethods);
+PHP_METHOD(Api, getOptions);
+PHP_METHOD(Api, setOptions);
+PHP_METHOD(Api, getVersion);
+PHP_METHOD(Api, setVersion);
+PHP_METHOD(Api, getSourceContext);
+PHP_METHOD(Api, setSourceContext);
+PHP_METHOD(Api, getMixins);
+PHP_METHOD(Api, setMixins);
+PHP_METHOD(Api, getSyntax);
+PHP_METHOD(Api, setSyntax);
+
+PHP_METHOD(BoolValue, __construct);
+PHP_METHOD(BoolValue, getValue);
+PHP_METHOD(BoolValue, setValue);
+
+PHP_METHOD(BytesValue, __construct);
+PHP_METHOD(BytesValue, getValue);
+PHP_METHOD(BytesValue, setValue);
+
+PHP_METHOD(DoubleValue, __construct);
+PHP_METHOD(DoubleValue, getValue);
+PHP_METHOD(DoubleValue, setValue);
+
+PHP_METHOD(Enum, __construct);
+PHP_METHOD(Enum, getName);
+PHP_METHOD(Enum, setName);
+PHP_METHOD(Enum, getEnumvalue);
+PHP_METHOD(Enum, setEnumvalue);
+PHP_METHOD(Enum, getOptions);
+PHP_METHOD(Enum, setOptions);
+PHP_METHOD(Enum, getSourceContext);
+PHP_METHOD(Enum, setSourceContext);
+PHP_METHOD(Enum, getSyntax);
+PHP_METHOD(Enum, setSyntax);
+
+PHP_METHOD(EnumValue, __construct);
+PHP_METHOD(EnumValue, getName);
+PHP_METHOD(EnumValue, setName);
+PHP_METHOD(EnumValue, getNumber);
+PHP_METHOD(EnumValue, setNumber);
+PHP_METHOD(EnumValue, getOptions);
+PHP_METHOD(EnumValue, setOptions);
+
+PHP_METHOD(FieldMask, __construct);
+PHP_METHOD(FieldMask, getPaths);
+PHP_METHOD(FieldMask, setPaths);
+
+PHP_METHOD(Field, __construct);
+PHP_METHOD(Field, getKind);
+PHP_METHOD(Field, setKind);
+PHP_METHOD(Field, getCardinality);
+PHP_METHOD(Field, setCardinality);
+PHP_METHOD(Field, getNumber);
+PHP_METHOD(Field, setNumber);
+PHP_METHOD(Field, getName);
+PHP_METHOD(Field, setName);
+PHP_METHOD(Field, getTypeUrl);
+PHP_METHOD(Field, setTypeUrl);
+PHP_METHOD(Field, getOneofIndex);
+PHP_METHOD(Field, setOneofIndex);
+PHP_METHOD(Field, getPacked);
+PHP_METHOD(Field, setPacked);
+PHP_METHOD(Field, getOptions);
+PHP_METHOD(Field, setOptions);
+PHP_METHOD(Field, getJsonName);
+PHP_METHOD(Field, setJsonName);
+PHP_METHOD(Field, getDefaultValue);
+PHP_METHOD(Field, setDefaultValue);
+
+PHP_METHOD(FloatValue, __construct);
+PHP_METHOD(FloatValue, getValue);
+PHP_METHOD(FloatValue, setValue);
+
+PHP_METHOD(GPBEmpty, __construct);
+
+PHP_METHOD(Int32Value, __construct);
+PHP_METHOD(Int32Value, getValue);
+PHP_METHOD(Int32Value, setValue);
+
+PHP_METHOD(Int64Value, __construct);
+PHP_METHOD(Int64Value, getValue);
+PHP_METHOD(Int64Value, setValue);
+
+PHP_METHOD(ListValue, __construct);
+PHP_METHOD(ListValue, getValues);
+PHP_METHOD(ListValue, setValues);
+
+PHP_METHOD(Method, __construct);
+PHP_METHOD(Method, getName);
+PHP_METHOD(Method, setName);
+PHP_METHOD(Method, getRequestTypeUrl);
+PHP_METHOD(Method, setRequestTypeUrl);
+PHP_METHOD(Method, getRequestStreaming);
+PHP_METHOD(Method, setRequestStreaming);
+PHP_METHOD(Method, getResponseTypeUrl);
+PHP_METHOD(Method, setResponseTypeUrl);
+PHP_METHOD(Method, getResponseStreaming);
+PHP_METHOD(Method, setResponseStreaming);
+PHP_METHOD(Method, getOptions);
+PHP_METHOD(Method, setOptions);
+PHP_METHOD(Method, getSyntax);
+PHP_METHOD(Method, setSyntax);
+
+PHP_METHOD(Mixin, __construct);
+PHP_METHOD(Mixin, getName);
+PHP_METHOD(Mixin, setName);
+PHP_METHOD(Mixin, getRoot);
+PHP_METHOD(Mixin, setRoot);
+
+PHP_METHOD(Option, __construct);
+PHP_METHOD(Option, getName);
+PHP_METHOD(Option, setName);
+PHP_METHOD(Option, getValue);
+PHP_METHOD(Option, setValue);
+
+PHP_METHOD(SourceContext, __construct);
+PHP_METHOD(SourceContext, getFileName);
+PHP_METHOD(SourceContext, setFileName);
+
+PHP_METHOD(StringValue, __construct);
+PHP_METHOD(StringValue, getValue);
+PHP_METHOD(StringValue, setValue);
+
+PHP_METHOD(Struct, __construct);
+PHP_METHOD(Struct, getFields);
+PHP_METHOD(Struct, setFields);
+
+PHP_METHOD(Type, __construct);
+PHP_METHOD(Type, getName);
+PHP_METHOD(Type, setName);
+PHP_METHOD(Type, getFields);
+PHP_METHOD(Type, setFields);
+PHP_METHOD(Type, getOneofs);
+PHP_METHOD(Type, setOneofs);
+PHP_METHOD(Type, getOptions);
+PHP_METHOD(Type, setOptions);
+PHP_METHOD(Type, getSourceContext);
+PHP_METHOD(Type, setSourceContext);
+PHP_METHOD(Type, getSyntax);
+PHP_METHOD(Type, setSyntax);
+
+PHP_METHOD(UInt32Value, __construct);
+PHP_METHOD(UInt32Value, getValue);
+PHP_METHOD(UInt32Value, setValue);
+
+PHP_METHOD(UInt64Value, __construct);
+PHP_METHOD(UInt64Value, getValue);
+PHP_METHOD(UInt64Value, setValue);
+
+PHP_METHOD(Value, __construct);
+PHP_METHOD(Value, getNullValue);
+PHP_METHOD(Value, setNullValue);
+PHP_METHOD(Value, getNumberValue);
+PHP_METHOD(Value, setNumberValue);
+PHP_METHOD(Value, getStringValue);
+PHP_METHOD(Value, setStringValue);
+PHP_METHOD(Value, getBoolValue);
+PHP_METHOD(Value, setBoolValue);
+PHP_METHOD(Value, getStructValue);
+PHP_METHOD(Value, setStructValue);
+PHP_METHOD(Value, getListValue);
+PHP_METHOD(Value, setListValue);
+PHP_METHOD(Value, getKind);
+
extern zend_class_entry* any_type;
+extern zend_class_entry* api_type;
+extern zend_class_entry* bool_value_type;
+extern zend_class_entry* bytes_value_type;
+extern zend_class_entry* double_value_type;
extern zend_class_entry* duration_type;
+extern zend_class_entry* empty_type;
+extern zend_class_entry* enum_type;
+extern zend_class_entry* enum_value_type;
+extern zend_class_entry* field_cardinality_type;
+extern zend_class_entry* field_kind_type;
+extern zend_class_entry* field_mask_type;
+extern zend_class_entry* field_type;
+extern zend_class_entry* float_value_type;
+extern zend_class_entry* int32_value_type;
+extern zend_class_entry* int64_value_type;
+extern zend_class_entry* list_value_type;
+extern zend_class_entry* method_type;
+extern zend_class_entry* mixin_type;
+extern zend_class_entry* null_value_type;
+extern zend_class_entry* option_type;
+extern zend_class_entry* source_context_type;
+extern zend_class_entry* string_value_type;
+extern zend_class_entry* struct_type;
+extern zend_class_entry* syntax_type;
extern zend_class_entry* timestamp_type;
+extern zend_class_entry* type_type;
+extern zend_class_entry* uint32_value_type;
+extern zend_class_entry* uint64_value_type;
+extern zend_class_entry* value_type;
// -----------------------------------------------------------------------------
// Upb.
@@ -1097,4 +1435,8 @@ static inline zval* php_proto_message_read_property(
#endif
}
+// Reserved name
+bool is_reserved_name(const char* name);
+bool is_valid_constant_name(const char* name);
+
#endif // __GOOGLE_PROTOBUF_PHP_PROTOBUF_H__
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index cc34dcf6..e7910c85 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -583,9 +583,12 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) {
upb_msg_oneof_iter oit;
size_t off = 0;
int i = 0;
+
+ // Reserve space for unknown fields.
+ off += sizeof(void*);
+
TSRMLS_FETCH();
Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(msgdef));
-
layout->fields = ALLOC_N(MessageField, nfields);
for (upb_msg_field_begin(&it, msgdef); !upb_msg_field_done(&it);
@@ -744,6 +747,10 @@ void layout_init(MessageLayout* layout, void* storage,
zend_object* object PHP_PROTO_TSRMLS_DC) {
int i;
upb_msg_field_iter it;
+
+ // Init unknown fields
+ memset(storage, 0, sizeof(void*));
+
for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it);
upb_msg_field_next(&it), i++) {
const upb_fielddef* field = upb_msg_iter_field(&it);
@@ -856,12 +863,41 @@ void layout_set(MessageLayout* layout, MessageHeader* header,
zval* property_ptr = CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory);
if (EXPECTED(property_ptr != val)) {
+ zend_class_entry *subce = NULL;
+ zval converted_value;
+
+ if (upb_fielddef_ismap(field)) {
+ const upb_msgdef* mapmsg = upb_fielddef_msgsubdef(field);
+ const upb_fielddef* keyfield = upb_msgdef_ntof(mapmsg, "key", 3);
+ const upb_fielddef* valuefield = upb_msgdef_ntof(mapmsg, "value", 5);
+ if (upb_fielddef_descriptortype(valuefield) ==
+ UPB_DESCRIPTOR_TYPE_MESSAGE) {
+ const upb_msgdef* submsg = upb_fielddef_msgsubdef(valuefield);
+ Descriptor* subdesc =
+ UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg));
+ subce = subdesc->klass;
+ }
+ check_map_field(subce, upb_fielddef_descriptortype(keyfield),
+ upb_fielddef_descriptortype(valuefield), val,
+ &converted_value);
+ } else {
+ if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
+ const upb_msgdef* submsg = upb_fielddef_msgsubdef(field);
+ Descriptor* subdesc =
+ UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg));
+ subce = subdesc->klass;
+ }
+
+ check_repeated_field(subce, upb_fielddef_descriptortype(field), val,
+ &converted_value);
+ }
#if PHP_MAJOR_VERSION < 7
- REPLACE_ZVAL_VALUE((zval**)memory, val, 1);
+ REPLACE_ZVAL_VALUE((zval**)memory, &converted_value, 1);
#else
- php_proto_zval_ptr_dtor(property_ptr);
- ZVAL_ZVAL(property_ptr, val, 1, 0);
+ php_proto_zval_ptr_dtor(property_ptr);
+ ZVAL_ZVAL(property_ptr, &converted_value, 1, 0);
#endif
+ zval_dtor(&converted_value);
}
} else {
upb_fieldtype_t type = upb_fielddef_type(field);
diff --git a/php/ext/google/protobuf/type_check.c b/php/ext/google/protobuf/type_check.c
index fada8d6a..f588774c 100644
--- a/php/ext/google/protobuf/type_check.c
+++ b/php/ext/google/protobuf/type_check.c
@@ -428,21 +428,15 @@ PHP_METHOD(Util, checkMessage) {
RETURN_ZVAL(val, 1, 0);
}
-PHP_METHOD(Util, checkRepeatedField) {
- zval* val;
- PHP_PROTO_LONG type;
- const zend_class_entry* klass = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl|C", &val, &type,
- &klass) == FAILURE) {
- return;
- }
-
+void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type,
+ zval* val, zval* return_value) {
#if PHP_MAJOR_VERSION >= 7
if (Z_ISREF_P(val)) {
ZVAL_DEREF(val);
}
#endif
+ TSRMLS_FETCH();
if (Z_TYPE_P(val) == IS_ARRAY) {
HashTable* table = HASH_OF(val);
HashPosition pointer;
@@ -492,24 +486,28 @@ PHP_METHOD(Util, checkRepeatedField) {
zend_error(E_USER_ERROR, "Incorrect repeated field type.");
return;
}
-
}
-PHP_METHOD(Util, checkMapField) {
+PHP_METHOD(Util, checkRepeatedField) {
zval* val;
- PHP_PROTO_LONG key_type, value_type;
+ PHP_PROTO_LONG type;
const zend_class_entry* klass = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll|C", &val, &key_type,
- &value_type, &klass) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl|C", &val, &type,
+ &klass) == FAILURE) {
return;
}
+ RETURN_ZVAL(val, 1, 0);
+}
+void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type,
+ PHP_PROTO_LONG value_type, zval* val, zval* return_value) {
#if PHP_MAJOR_VERSION >= 7
if (Z_ISREF_P(val)) {
ZVAL_DEREF(val);
}
#endif
+ TSRMLS_FETCH();
if (Z_TYPE_P(val) == IS_ARRAY) {
HashTable* table = Z_ARRVAL_P(val);
HashPosition pointer;
@@ -565,3 +563,14 @@ PHP_METHOD(Util, checkMapField) {
return;
}
}
+
+PHP_METHOD(Util, checkMapField) {
+ zval* val;
+ PHP_PROTO_LONG key_type, value_type;
+ const zend_class_entry* klass = NULL;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll|C", &val, &key_type,
+ &value_type, &klass) == FAILURE) {
+ return;
+ }
+ RETURN_ZVAL(val, 1, 0);
+}
diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c
index d701dcba..c02a5ce4 100644
--- a/php/ext/google/protobuf/upb.c
+++ b/php/ext/google/protobuf/upb.c
@@ -2,6 +2,585 @@
#include "upb.h"
+/* Maps descriptor type -> upb field type. */
+static const uint8_t upb_desctype_to_fieldtype[] = {
+ UPB_WIRE_TYPE_END_GROUP, /* ENDGROUP */
+ UPB_TYPE_DOUBLE, /* DOUBLE */
+ UPB_TYPE_FLOAT, /* FLOAT */
+ UPB_TYPE_INT64, /* INT64 */
+ UPB_TYPE_UINT64, /* UINT64 */
+ UPB_TYPE_INT32, /* INT32 */
+ UPB_TYPE_UINT64, /* FIXED64 */
+ UPB_TYPE_UINT32, /* FIXED32 */
+ UPB_TYPE_BOOL, /* BOOL */
+ UPB_TYPE_STRING, /* STRING */
+ UPB_TYPE_MESSAGE, /* GROUP */
+ UPB_TYPE_MESSAGE, /* MESSAGE */
+ UPB_TYPE_BYTES, /* BYTES */
+ UPB_TYPE_UINT32, /* UINT32 */
+ UPB_TYPE_ENUM, /* ENUM */
+ UPB_TYPE_INT32, /* SFIXED32 */
+ UPB_TYPE_INT64, /* SFIXED64 */
+ UPB_TYPE_INT32, /* SINT32 */
+ UPB_TYPE_INT64, /* SINT64 */
+};
+
+/* Data pertaining to the parse. */
+typedef struct {
+ upb_env *env;
+ /* Current decoding pointer. Points to the beginning of a field until we
+ * have finished decoding the whole field. */
+ const char *ptr;
+} upb_decstate;
+
+/* Data pertaining to a single message frame. */
+typedef struct {
+ const char *limit;
+ int32_t group_number; /* 0 if we are not parsing a group. */
+
+ /* These members are unset for an unknown group frame. */
+ char *msg;
+ const upb_msglayout_msginit_v1 *m;
+} upb_decframe;
+
+#define CHK(x) if (!(x)) { return false; }
+
+static bool upb_skip_unknowngroup(upb_decstate *d, int field_number,
+ const char *limit);
+static bool upb_decode_message(upb_decstate *d, const char *limit,
+ int group_number, char *msg,
+ const upb_msglayout_msginit_v1 *l);
+
+static bool upb_decode_varint(const char **ptr, const char *limit,
+ uint64_t *val) {
+ uint8_t byte;
+ int bitpos = 0;
+ const char *p = *ptr;
+ *val = 0;
+
+ do {
+ CHK(bitpos < 70 && p < limit);
+ byte = *p;
+ *val |= (uint64_t)(byte & 0x7F) << bitpos;
+ p++;
+ bitpos += 7;
+ } while (byte & 0x80);
+
+ *ptr = p;
+ return true;
+}
+
+static bool upb_decode_varint32(const char **ptr, const char *limit,
+ uint32_t *val) {
+ uint64_t u64;
+ CHK(upb_decode_varint(ptr, limit, &u64) && u64 <= UINT32_MAX);
+ *val = u64;
+ return true;
+}
+
+static bool upb_decode_64bit(const char **ptr, const char *limit,
+ uint64_t *val) {
+ CHK(limit - *ptr >= 8);
+ memcpy(val, *ptr, 8);
+ *ptr += 8;
+ return true;
+}
+
+static bool upb_decode_32bit(const char **ptr, const char *limit,
+ uint32_t *val) {
+ CHK(limit - *ptr >= 4);
+ memcpy(val, *ptr, 4);
+ *ptr += 4;
+ return true;
+}
+
+static bool upb_decode_tag(const char **ptr, const char *limit,
+ int *field_number, int *wire_type) {
+ uint32_t tag = 0;
+ CHK(upb_decode_varint32(ptr, limit, &tag));
+ *field_number = tag >> 3;
+ *wire_type = tag & 7;
+ return true;
+}
+
+static int32_t upb_zzdecode_32(uint32_t n) {
+ return (n >> 1) ^ -(int32_t)(n & 1);
+}
+
+static int64_t upb_zzdecode_64(uint64_t n) {
+ return (n >> 1) ^ -(int64_t)(n & 1);
+}
+
+static bool upb_decode_string(const char **ptr, const char *limit,
+ upb_stringview *val) {
+ uint32_t len;
+
+ CHK(upb_decode_varint32(ptr, limit, &len) &&
+ len < INT32_MAX &&
+ limit - *ptr >= (int32_t)len);
+
+ *val = upb_stringview_make(*ptr, len);
+ *ptr += len;
+ return true;
+}
+
+static void upb_set32(void *msg, size_t ofs, uint32_t val) {
+ memcpy((char*)msg + ofs, &val, sizeof(val));
+}
+
+static bool upb_append_unknown(upb_decstate *d, upb_decframe *frame,
+ const char *start) {
+ UPB_UNUSED(d);
+ UPB_UNUSED(frame);
+ UPB_UNUSED(start);
+ return true;
+}
+
+static bool upb_skip_unknownfielddata(upb_decstate *d, upb_decframe *frame,
+ int field_number, int wire_type) {
+ switch (wire_type) {
+ case UPB_WIRE_TYPE_VARINT: {
+ uint64_t val;
+ return upb_decode_varint(&d->ptr, frame->limit, &val);
+ }
+ case UPB_WIRE_TYPE_32BIT: {
+ uint32_t val;
+ return upb_decode_32bit(&d->ptr, frame->limit, &val);
+ }
+ case UPB_WIRE_TYPE_64BIT: {
+ uint64_t val;
+ return upb_decode_64bit(&d->ptr, frame->limit, &val);
+ }
+ case UPB_WIRE_TYPE_DELIMITED: {
+ upb_stringview val;
+ return upb_decode_string(&d->ptr, frame->limit, &val);
+ }
+ case UPB_WIRE_TYPE_START_GROUP:
+ return upb_skip_unknowngroup(d, field_number, frame->limit);
+ case UPB_WIRE_TYPE_END_GROUP:
+ CHK(field_number == frame->group_number);
+ frame->limit = d->ptr;
+ return true;
+ }
+ return false;
+}
+
+static bool upb_array_grow(upb_array *arr, size_t elements) {
+ size_t needed = arr->len + elements;
+ size_t new_size = UPB_MAX(arr->size, 8);
+ size_t new_bytes;
+ size_t old_bytes;
+ void *new_data;
+
+ while (new_size < needed) {
+ new_size *= 2;
+ }
+
+ old_bytes = arr->len * arr->element_size;
+ new_bytes = new_size * arr->element_size;
+ new_data = upb_realloc(arr->alloc, arr->data, old_bytes, new_bytes);
+ CHK(new_data);
+
+ arr->data = new_data;
+ arr->size = new_size;
+ return true;
+}
+
+static void *upb_array_reserve(upb_array *arr, size_t elements) {
+ if (arr->size - arr->len < elements) {
+ CHK(upb_array_grow(arr, elements));
+ }
+ return (char*)arr->data + (arr->len * arr->element_size);
+}
+
+static void *upb_array_add(upb_array *arr, size_t elements) {
+ void *ret = upb_array_reserve(arr, elements);
+ arr->len += elements;
+ return ret;
+}
+
+static upb_array *upb_getarr(upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ UPB_ASSERT(field->label == UPB_LABEL_REPEATED);
+ return *(upb_array**)&frame->msg[field->offset];
+}
+
+static upb_array *upb_getorcreatearr(upb_decstate *d,
+ upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ upb_array *arr = upb_getarr(frame, field);
+
+ if (!arr) {
+ arr = upb_env_malloc(d->env, sizeof(*arr));
+ if (!arr) {
+ return NULL;
+ }
+ upb_array_init(arr, upb_desctype_to_fieldtype[field->type],
+ upb_arena_alloc(upb_env_arena(d->env)));
+ *(upb_array**)&frame->msg[field->offset] = arr;
+ }
+
+ return arr;
+}
+
+static void upb_sethasbit(upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ UPB_ASSERT(field->hasbit != UPB_NO_HASBIT);
+ frame->msg[field->hasbit / 8] |= (1 << (field->hasbit % 8));
+}
+
+static void upb_setoneofcase(upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ UPB_ASSERT(field->oneof_index != UPB_NOT_IN_ONEOF);
+ upb_set32(frame->msg, frame->m->oneofs[field->oneof_index].case_offset,
+ field->number);
+}
+
+static char *upb_decode_prepareslot(upb_decstate *d,
+ upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ char *field_mem = frame->msg + field->offset;
+ upb_array *arr;
+
+ if (field->label == UPB_LABEL_REPEATED) {
+ arr = upb_getorcreatearr(d, frame, field);
+ field_mem = upb_array_reserve(arr, 1);
+ }
+
+ return field_mem;
+}
+
+static void upb_decode_setpresent(upb_decframe *frame,
+ const upb_msglayout_fieldinit_v1 *field) {
+ if (field->label == UPB_LABEL_REPEATED) {
+ upb_array *arr = upb_getarr(frame, field);
+ UPB_ASSERT(arr->len < arr->size);
+ arr->len++;
+ } else if (field->oneof_index != UPB_NOT_IN_ONEOF) {
+ upb_setoneofcase(frame, field);
+ } else if (field->hasbit != UPB_NO_HASBIT) {
+ upb_sethasbit(frame, field);
+ }
+}
+
+static bool upb_decode_submsg(upb_decstate *d,
+ upb_decframe *frame,
+ const char *limit,
+ const upb_msglayout_fieldinit_v1 *field,
+ int group_number) {
+ char *submsg = *(void**)&frame->msg[field->offset];
+ const upb_msglayout_msginit_v1 *subm;
+
+ UPB_ASSERT(field->submsg_index != UPB_NO_SUBMSG);
+ subm = frame->m->submsgs[field->submsg_index];
+ UPB_ASSERT(subm);
+
+ if (!submsg) {
+ submsg = upb_env_malloc(d->env, upb_msg_sizeof((upb_msglayout *)subm));
+ CHK(submsg);
+ submsg = upb_msg_init(
+ submsg, (upb_msglayout*)subm, upb_arena_alloc(upb_env_arena(d->env)));
+ *(void**)&frame->msg[field->offset] = submsg;
+ }
+
+ upb_decode_message(d, limit, group_number, submsg, subm);
+
+ return true;
+}
+
+static bool upb_decode_varintfield(upb_decstate *d, upb_decframe *frame,
+ const char *field_start,
+ const upb_msglayout_fieldinit_v1 *field) {
+ uint64_t val;
+ void *field_mem;
+
+ field_mem = upb_decode_prepareslot(d, frame, field);
+ CHK(field_mem);
+ CHK(upb_decode_varint(&d->ptr, frame->limit, &val));
+
+ switch ((upb_descriptortype_t)field->type) {
+ case UPB_DESCRIPTOR_TYPE_INT64:
+ case UPB_DESCRIPTOR_TYPE_UINT64:
+ memcpy(field_mem, &val, sizeof(val));
+ break;
+ case UPB_DESCRIPTOR_TYPE_INT32:
+ case UPB_DESCRIPTOR_TYPE_UINT32:
+ case UPB_DESCRIPTOR_TYPE_ENUM: {
+ uint32_t val32 = val;
+ memcpy(field_mem, &val32, sizeof(val32));
+ break;
+ }
+ case UPB_DESCRIPTOR_TYPE_BOOL: {
+ bool valbool = val != 0;
+ memcpy(field_mem, &valbool, sizeof(valbool));
+ break;
+ }
+ case UPB_DESCRIPTOR_TYPE_SINT32: {
+ int32_t decoded = upb_zzdecode_32(val);
+ memcpy(field_mem, &decoded, sizeof(decoded));
+ break;
+ }
+ case UPB_DESCRIPTOR_TYPE_SINT64: {
+ int64_t decoded = upb_zzdecode_64(val);
+ memcpy(field_mem, &decoded, sizeof(decoded));
+ break;
+ }
+ default:
+ return upb_append_unknown(d, frame, field_start);
+ }
+
+ upb_decode_setpresent(frame, field);
+ return true;
+}
+
+static bool upb_decode_64bitfield(upb_decstate *d, upb_decframe *frame,
+ const char *field_start,
+ const upb_msglayout_fieldinit_v1 *field) {
+ void *field_mem;
+ uint64_t val;
+
+ field_mem = upb_decode_prepareslot(d, frame, field);
+ CHK(field_mem);
+ CHK(upb_decode_64bit(&d->ptr, frame->limit, &val));
+
+ switch ((upb_descriptortype_t)field->type) {
+ case UPB_DESCRIPTOR_TYPE_DOUBLE:
+ case UPB_DESCRIPTOR_TYPE_FIXED64:
+ case UPB_DESCRIPTOR_TYPE_SFIXED64:
+ memcpy(field_mem, &val, sizeof(val));
+ break;
+ default:
+ return upb_append_unknown(d, frame, field_start);
+ }
+
+ upb_decode_setpresent(frame, field);
+ return true;
+}
+
+static bool upb_decode_32bitfield(upb_decstate *d, upb_decframe *frame,
+ const char *field_start,
+ const upb_msglayout_fieldinit_v1 *field) {
+ void *field_mem;
+ uint32_t val;
+
+ field_mem = upb_decode_prepareslot(d, frame, field);
+ CHK(field_mem);
+ CHK(upb_decode_32bit(&d->ptr, frame->limit, &val));
+
+ switch ((upb_descriptortype_t)field->type) {
+ case UPB_DESCRIPTOR_TYPE_FLOAT:
+ case UPB_DESCRIPTOR_TYPE_FIXED32:
+ case UPB_DESCRIPTOR_TYPE_SFIXED32:
+ memcpy(field_mem, &val, sizeof(val));
+ break;
+ default:
+ return upb_append_unknown(d, frame, field_start);
+ }
+
+ upb_decode_setpresent(frame, field);
+ return true;
+}
+
+static bool upb_decode_fixedpacked(upb_array *arr, upb_stringview data,
+ int elem_size) {
+ int elements = data.size / elem_size;
+ void *field_mem;
+
+ CHK((size_t)(elements * elem_size) == data.size);
+ field_mem = upb_array_add(arr, elements);
+ CHK(field_mem);
+ memcpy(field_mem, data.data, data.size);
+ return true;
+}
+
+static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame,
+ const char *field_start,
+ const upb_msglayout_fieldinit_v1 *field,
+ upb_stringview val) {
+ upb_array *arr = upb_getorcreatearr(d, frame, field);
+
+#define VARINT_CASE(ctype, decode) { \
+ const char *ptr = val.data; \
+ const char *limit = ptr + val.size; \
+ while (ptr < limit) { \
+ uint64_t val; \
+ void *field_mem; \
+ ctype decoded; \
+ CHK(upb_decode_varint(&ptr, limit, &val)); \
+ decoded = (decode)(val); \
+ field_mem = upb_array_add(arr, 1); \
+ CHK(field_mem); \
+ memcpy(field_mem, &decoded, sizeof(ctype)); \
+ } \
+ return true; \
+}
+
+ switch ((upb_descriptortype_t)field->type) {
+ case UPB_DESCRIPTOR_TYPE_STRING:
+ case UPB_DESCRIPTOR_TYPE_BYTES: {
+ void *field_mem = upb_array_add(arr, 1);
+ CHK(field_mem);
+ memcpy(field_mem, &val, sizeof(val));
+ return true;
+ }
+ case UPB_DESCRIPTOR_TYPE_FLOAT:
+ case UPB_DESCRIPTOR_TYPE_FIXED32:
+ case UPB_DESCRIPTOR_TYPE_SFIXED32:
+ return upb_decode_fixedpacked(arr, val, sizeof(int32_t));
+ case UPB_DESCRIPTOR_TYPE_DOUBLE:
+ case UPB_DESCRIPTOR_TYPE_FIXED64:
+ case UPB_DESCRIPTOR_TYPE_SFIXED64:
+ return upb_decode_fixedpacked(arr, val, sizeof(int64_t));
+ case UPB_DESCRIPTOR_TYPE_INT32:
+ case UPB_DESCRIPTOR_TYPE_UINT32:
+ case UPB_DESCRIPTOR_TYPE_ENUM:
+ /* TODO: proto2 enum field that isn't in the enum. */
+ VARINT_CASE(uint32_t, uint32_t);
+ case UPB_DESCRIPTOR_TYPE_INT64:
+ case UPB_DESCRIPTOR_TYPE_UINT64:
+ VARINT_CASE(uint64_t, uint64_t);
+ case UPB_DESCRIPTOR_TYPE_BOOL:
+ VARINT_CASE(bool, bool);
+ case UPB_DESCRIPTOR_TYPE_SINT32:
+ VARINT_CASE(int32_t, upb_zzdecode_32);
+ case UPB_DESCRIPTOR_TYPE_SINT64:
+ VARINT_CASE(int64_t, upb_zzdecode_64);
+ case UPB_DESCRIPTOR_TYPE_MESSAGE:
+ CHK(val.size <= (size_t)(frame->limit - val.data));
+ return upb_decode_submsg(d, frame, val.data + val.size, field, 0);
+ case UPB_DESCRIPTOR_TYPE_GROUP:
+ return upb_append_unknown(d, frame, field_start);
+ }
+#undef VARINT_CASE
+ UPB_UNREACHABLE();
+}
+
+static bool upb_decode_delimitedfield(upb_decstate *d, upb_decframe *frame,
+ const char *field_start,
+ const upb_msglayout_fieldinit_v1 *field) {
+ upb_stringview val;
+
+ CHK(upb_decode_string(&d->ptr, frame->limit, &val));
+
+ if (field->label == UPB_LABEL_REPEATED) {
+ return upb_decode_toarray(d, frame, field_start, field, val);
+ } else {
+ switch ((upb_descriptortype_t)field->type) {
+ case UPB_DESCRIPTOR_TYPE_STRING:
+ case UPB_DESCRIPTOR_TYPE_BYTES: {
+ void *field_mem = upb_decode_prepareslot(d, frame, field);
+ CHK(field_mem);
+ memcpy(field_mem, &val, sizeof(val));
+ break;
+ }
+ case UPB_DESCRIPTOR_TYPE_MESSAGE:
+ CHK(val.size <= (size_t)(frame->limit - val.data));
+ CHK(upb_decode_submsg(d, frame, val.data + val.size, field, 0));
+ break;
+ default:
+ /* TODO(haberman): should we accept the last element of a packed? */
+ return upb_append_unknown(d, frame, field_start);
+ }
+ upb_decode_setpresent(frame, field);
+ return true;
+ }
+}
+
+static const upb_msglayout_fieldinit_v1 *upb_find_field(
+ const upb_msglayout_msginit_v1 *l, uint32_t field_number) {
+ /* Lots of optimization opportunities here. */
+ int i;
+ for (i = 0; i < l->field_count; i++) {
+ if (l->fields[i].number == field_number) {
+ return &l->fields[i];
+ }
+ }
+
+ return NULL; /* Unknown field. */
+}
+
+static bool upb_decode_field(upb_decstate *d, upb_decframe *frame) {
+ int field_number;
+ int wire_type;
+ const char *field_start = d->ptr;
+ const upb_msglayout_fieldinit_v1 *field;
+
+ CHK(upb_decode_tag(&d->ptr, frame->limit, &field_number, &wire_type));
+ field = upb_find_field(frame->m, field_number);
+
+ if (field) {
+ switch (wire_type) {
+ case UPB_WIRE_TYPE_VARINT:
+ return upb_decode_varintfield(d, frame, field_start, field);
+ case UPB_WIRE_TYPE_32BIT:
+ return upb_decode_32bitfield(d, frame, field_start, field);
+ case UPB_WIRE_TYPE_64BIT:
+ return upb_decode_64bitfield(d, frame, field_start, field);
+ case UPB_WIRE_TYPE_DELIMITED:
+ return upb_decode_delimitedfield(d, frame, field_start, field);
+ case UPB_WIRE_TYPE_START_GROUP:
+ CHK(field->type == UPB_DESCRIPTOR_TYPE_GROUP);
+ return upb_decode_submsg(d, frame, frame->limit, field, field_number);
+ case UPB_WIRE_TYPE_END_GROUP:
+ CHK(frame->group_number == field_number)
+ frame->limit = d->ptr;
+ return true;
+ default:
+ return false;
+ }
+ } else {
+ CHK(field_number != 0);
+ return upb_skip_unknownfielddata(d, frame, field_number, wire_type);
+ }
+}
+
+static bool upb_skip_unknowngroup(upb_decstate *d, int field_number,
+ const char *limit) {
+ upb_decframe frame;
+ frame.msg = NULL;
+ frame.m = NULL;
+ frame.group_number = field_number;
+ frame.limit = limit;
+
+ while (d->ptr < frame.limit) {
+ int wire_type;
+ int field_number;
+
+ CHK(upb_decode_tag(&d->ptr, frame.limit, &field_number, &wire_type));
+ CHK(upb_skip_unknownfielddata(d, &frame, field_number, wire_type));
+ }
+
+ return true;
+}
+
+static bool upb_decode_message(upb_decstate *d, const char *limit,
+ int group_number, char *msg,
+ const upb_msglayout_msginit_v1 *l) {
+ upb_decframe frame;
+ frame.group_number = group_number;
+ frame.limit = limit;
+ frame.msg = msg;
+ frame.m = l;
+
+ while (d->ptr < frame.limit) {
+ CHK(upb_decode_field(d, &frame));
+ }
+
+ return true;
+}
+
+bool upb_decode(upb_stringview buf, void *msg,
+ const upb_msglayout_msginit_v1 *l, upb_env *env) {
+ upb_decstate state;
+ state.ptr = buf.data;
+ state.env = env;
+
+ return upb_decode_message(&state, buf.data + buf.size, 0, msg, l);
+}
+
+#undef CHK
+
+
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -326,6 +905,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
v = upb_value_bool(true);
upb_inttable_insert(&t, UPB_STARTMSG_SELECTOR, v);
upb_inttable_insert(&t, UPB_ENDMSG_SELECTOR, v);
+ upb_inttable_insert(&t, UPB_UNKNOWN_SELECTOR, v);
for(upb_msg_field_begin(&j, m);
!upb_msg_field_done(&j);
upb_msg_field_next(&j)) {
@@ -2359,6 +2939,397 @@ bool upb_symtab_done(const upb_symtab_iter *iter) {
const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
}
+/* We encode backwards, to avoid pre-computing lengths (one-pass encode). */
+
+
+#define UPB_PB_VARINT_MAX_LEN 10
+#define CHK(x) do { if (!(x)) { return false; } } while(0)
+
+/* Maps descriptor type -> upb field type. */
+static const uint8_t upb_desctype_to_fieldtype2[] = {
+ UPB_WIRE_TYPE_END_GROUP, /* ENDGROUP */
+ UPB_TYPE_DOUBLE, /* DOUBLE */
+ UPB_TYPE_FLOAT, /* FLOAT */
+ UPB_TYPE_INT64, /* INT64 */
+ UPB_TYPE_UINT64, /* UINT64 */
+ UPB_TYPE_INT32, /* INT32 */
+ UPB_TYPE_UINT64, /* FIXED64 */
+ UPB_TYPE_UINT32, /* FIXED32 */
+ UPB_TYPE_BOOL, /* BOOL */
+ UPB_TYPE_STRING, /* STRING */
+ UPB_TYPE_MESSAGE, /* GROUP */
+ UPB_TYPE_MESSAGE, /* MESSAGE */
+ UPB_TYPE_BYTES, /* BYTES */
+ UPB_TYPE_UINT32, /* UINT32 */
+ UPB_TYPE_ENUM, /* ENUM */
+ UPB_TYPE_INT32, /* SFIXED32 */
+ UPB_TYPE_INT64, /* SFIXED64 */
+ UPB_TYPE_INT32, /* SINT32 */
+ UPB_TYPE_INT64, /* SINT64 */
+};
+
+static size_t upb_encode_varint(uint64_t val, char *buf) {
+ size_t i;
+ if (val < 128) { buf[0] = val; return 1; }
+ i = 0;
+ while (val) {
+ uint8_t byte = val & 0x7fU;
+ val >>= 7;
+ if (val) byte |= 0x80U;
+ buf[i++] = byte;
+ }
+ return i;
+}
+
+static uint32_t upb_zzencode_32(int32_t n) { return (n << 1) ^ (n >> 31); }
+static uint64_t upb_zzencode_64(int64_t n) { return (n << 1) ^ (n >> 63); }
+
+typedef struct {
+ upb_env *env;
+ char *buf, *ptr, *limit;
+} upb_encstate;
+
+static size_t upb_roundup_pow2(size_t bytes) {
+ size_t ret = 128;
+ while (ret < bytes) {
+ ret *= 2;
+ }
+ return ret;
+}
+
+static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) {
+ size_t old_size = e->limit - e->buf;
+ size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr));
+ char *new_buf = upb_env_realloc(e->env, e->buf, old_size, new_size);
+ CHK(new_buf);
+
+ /* We want previous data at the end, realloc() put it at the beginning. */
+ memmove(e->limit - old_size, e->buf, old_size);
+
+ e->ptr = new_buf + new_size - (e->limit - e->ptr);
+ e->limit = new_buf + new_size;
+ e->buf = new_buf;
+ return true;
+}
+
+/* Call to ensure that at least "bytes" bytes are available for writing at
+ * e->ptr. Returns false if the bytes could not be allocated. */
+static bool upb_encode_reserve(upb_encstate *e, size_t bytes) {
+ CHK(UPB_LIKELY((size_t)(e->ptr - e->buf) >= bytes) ||
+ upb_encode_growbuffer(e, bytes));
+
+ e->ptr -= bytes;
+ return true;
+}
+
+/* Writes the given bytes to the buffer, handling reserve/advance. */
+static bool upb_put_bytes(upb_encstate *e, const void *data, size_t len) {
+ CHK(upb_encode_reserve(e, len));
+ memcpy(e->ptr, data, len);
+ return true;
+}
+
+static bool upb_put_fixed64(upb_encstate *e, uint64_t val) {
+ /* TODO(haberman): byte-swap for big endian. */
+ return upb_put_bytes(e, &val, sizeof(uint64_t));
+}
+
+static bool upb_put_fixed32(upb_encstate *e, uint32_t val) {
+ /* TODO(haberman): byte-swap for big endian. */
+ return upb_put_bytes(e, &val, sizeof(uint32_t));
+}
+
+static bool upb_put_varint(upb_encstate *e, uint64_t val) {
+ size_t len;
+ char *start;
+ CHK(upb_encode_reserve(e, UPB_PB_VARINT_MAX_LEN));
+ len = upb_encode_varint(val, e->ptr);
+ start = e->ptr + UPB_PB_VARINT_MAX_LEN - len;
+ memmove(start, e->ptr, len);
+ e->ptr = start;
+ return true;
+}
+
+static bool upb_put_double(upb_encstate *e, double d) {
+ uint64_t u64;
+ UPB_ASSERT(sizeof(double) == sizeof(uint64_t));
+ memcpy(&u64, &d, sizeof(uint64_t));
+ return upb_put_fixed64(e, u64);
+}
+
+static bool upb_put_float(upb_encstate *e, float d) {
+ uint32_t u32;
+ UPB_ASSERT(sizeof(float) == sizeof(uint32_t));
+ memcpy(&u32, &d, sizeof(uint32_t));
+ return upb_put_fixed32(e, u32);
+}
+
+static uint32_t upb_readcase(const char *msg, const upb_msglayout_msginit_v1 *m,
+ int oneof_index) {
+ uint32_t ret;
+ memcpy(&ret, msg + m->oneofs[oneof_index].case_offset, sizeof(ret));
+ return ret;
+}
+
+static bool upb_readhasbit(const char *msg,
+ const upb_msglayout_fieldinit_v1 *f) {
+ UPB_ASSERT(f->hasbit != UPB_NO_HASBIT);
+ return msg[f->hasbit / 8] & (1 << (f->hasbit % 8));
+}
+
+static bool upb_put_tag(upb_encstate *e, int field_number, int wire_type) {
+ return upb_put_varint(e, (field_number << 3) | wire_type);
+}
+
+static bool upb_put_fixedarray(upb_encstate *e, const upb_array *arr,
+ size_t size) {
+ size_t bytes = arr->len * size;
+ return upb_put_bytes(e, arr->data, bytes) && upb_put_varint(e, bytes);
+}
+
+bool upb_encode_message(upb_encstate *e, const char *msg,
+ const upb_msglayout_msginit_v1 *m,
+ size_t *size);
+
+static bool upb_encode_array(upb_encstate *e, const char *field_mem,
+ const upb_msglayout_msginit_v1 *m,
+ const upb_msglayout_fieldinit_v1 *f) {
+ const upb_array *arr = *(const upb_array**)field_mem;
+
+ if (arr == NULL || arr->len == 0) {
+ return true;
+ }
+
+ UPB_ASSERT(arr->type == upb_desctype_to_fieldtype2[f->type]);
+
+#define VARINT_CASE(ctype, encode) { \
+ ctype *start = arr->data; \
+ ctype *ptr = start + arr->len; \
+ size_t pre_len = e->limit - e->ptr; \
+ do { \
+ ptr--; \
+ CHK(upb_put_varint(e, encode)); \
+ } while (ptr != start); \
+ CHK(upb_put_varint(e, e->limit - e->ptr - pre_len)); \
+} \
+break; \
+do { ; } while(0)
+
+ switch (f->type) {
+ case UPB_DESCRIPTOR_TYPE_DOUBLE:
+ CHK(upb_put_fixedarray(e, arr, sizeof(double)));
+ break;
+ case UPB_DESCRIPTOR_TYPE_FLOAT:
+ CHK(upb_put_fixedarray(e, arr, sizeof(float)));
+ break;
+ case UPB_DESCRIPTOR_TYPE_SFIXED64:
+ case UPB_DESCRIPTOR_TYPE_FIXED64:
+ CHK(upb_put_fixedarray(e, arr, sizeof(uint64_t)));
+ break;
+ case UPB_DESCRIPTOR_TYPE_FIXED32:
+ case UPB_DESCRIPTOR_TYPE_SFIXED32:
+ CHK(upb_put_fixedarray(e, arr, sizeof(uint32_t)));
+ break;
+ case UPB_DESCRIPTOR_TYPE_INT64:
+ case UPB_DESCRIPTOR_TYPE_UINT64:
+ VARINT_CASE(uint64_t, *ptr);
+ case UPB_DESCRIPTOR_TYPE_UINT32:
+ case UPB_DESCRIPTOR_TYPE_INT32:
+ case UPB_DESCRIPTOR_TYPE_ENUM:
+ VARINT_CASE(uint32_t, *ptr);
+ case UPB_DESCRIPTOR_TYPE_BOOL:
+ VARINT_CASE(bool, *ptr);
+ case UPB_DESCRIPTOR_TYPE_SINT32:
+ VARINT_CASE(int32_t, upb_zzencode_32(*ptr));
+ case UPB_DESCRIPTOR_TYPE_SINT64:
+ VARINT_CASE(int64_t, upb_zzencode_64(*ptr));
+ case UPB_DESCRIPTOR_TYPE_STRING:
+ case UPB_DESCRIPTOR_TYPE_BYTES: {
+ upb_stringview *start = arr->data;
+ upb_stringview *ptr = start + arr->len;
+ do {
+ ptr--;
+ CHK(upb_put_bytes(e, ptr->data, ptr->size) &&
+ upb_put_varint(e, ptr->size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED));
+ } while (ptr != start);
+ return true;
+ }
+ case UPB_DESCRIPTOR_TYPE_GROUP: {
+ void **start = arr->data;
+ void **ptr = start + arr->len;
+ const upb_msglayout_msginit_v1 *subm = m->submsgs[f->submsg_index];
+ do {
+ size_t size;
+ ptr--;
+ CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) &&
+ upb_encode_message(e, *ptr, subm, &size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP));
+ } while (ptr != start);
+ return true;
+ }
+ case UPB_DESCRIPTOR_TYPE_MESSAGE: {
+ void **start = arr->data;
+ void **ptr = start + arr->len;
+ const upb_msglayout_msginit_v1 *subm = m->submsgs[f->submsg_index];
+ do {
+ size_t size;
+ ptr--;
+ CHK(upb_encode_message(e, *ptr, subm, &size) &&
+ upb_put_varint(e, size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED));
+ } while (ptr != start);
+ return true;
+ }
+ }
+#undef VARINT_CASE
+
+ /* We encode all primitive arrays as packed, regardless of what was specified
+ * in the .proto file. Could special case 1-sized arrays. */
+ CHK(upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED));
+ return true;
+}
+
+static bool upb_encode_scalarfield(upb_encstate *e, const char *field_mem,
+ const upb_msglayout_msginit_v1 *m,
+ const upb_msglayout_fieldinit_v1 *f,
+ bool is_proto3) {
+ bool skip_zero_value = is_proto3 && f->oneof_index == UPB_NOT_IN_ONEOF;
+
+#define CASE(ctype, type, wire_type, encodeval) do { \
+ ctype val = *(ctype*)field_mem; \
+ if (skip_zero_value && val == 0) { \
+ return true; \
+ } \
+ return upb_put_ ## type(e, encodeval) && \
+ upb_put_tag(e, f->number, wire_type); \
+} while(0)
+
+ switch (f->type) {
+ case UPB_DESCRIPTOR_TYPE_DOUBLE:
+ CASE(double, double, UPB_WIRE_TYPE_64BIT, val);
+ case UPB_DESCRIPTOR_TYPE_FLOAT:
+ CASE(float, float, UPB_WIRE_TYPE_32BIT, val);
+ case UPB_DESCRIPTOR_TYPE_INT64:
+ case UPB_DESCRIPTOR_TYPE_UINT64:
+ CASE(uint64_t, varint, UPB_WIRE_TYPE_VARINT, val);
+ case UPB_DESCRIPTOR_TYPE_UINT32:
+ case UPB_DESCRIPTOR_TYPE_INT32:
+ case UPB_DESCRIPTOR_TYPE_ENUM:
+ CASE(uint32_t, varint, UPB_WIRE_TYPE_VARINT, val);
+ case UPB_DESCRIPTOR_TYPE_SFIXED64:
+ case UPB_DESCRIPTOR_TYPE_FIXED64:
+ CASE(uint64_t, fixed64, UPB_WIRE_TYPE_64BIT, val);
+ case UPB_DESCRIPTOR_TYPE_FIXED32:
+ case UPB_DESCRIPTOR_TYPE_SFIXED32:
+ CASE(uint32_t, fixed32, UPB_WIRE_TYPE_32BIT, val);
+ case UPB_DESCRIPTOR_TYPE_BOOL:
+ CASE(bool, varint, UPB_WIRE_TYPE_VARINT, val);
+ case UPB_DESCRIPTOR_TYPE_SINT32:
+ CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_32(val));
+ case UPB_DESCRIPTOR_TYPE_SINT64:
+ CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_64(val));
+ case UPB_DESCRIPTOR_TYPE_STRING:
+ case UPB_DESCRIPTOR_TYPE_BYTES: {
+ upb_stringview view = *(upb_stringview*)field_mem;
+ if (skip_zero_value && view.size == 0) {
+ return true;
+ }
+ return upb_put_bytes(e, view.data, view.size) &&
+ upb_put_varint(e, view.size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
+ }
+ case UPB_DESCRIPTOR_TYPE_GROUP: {
+ size_t size;
+ void *submsg = *(void**)field_mem;
+ const upb_msglayout_msginit_v1 *subm = m->submsgs[f->submsg_index];
+ if (skip_zero_value && submsg == NULL) {
+ return true;
+ }
+ return upb_put_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP) &&
+ upb_encode_message(e, submsg, subm, &size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP);
+ }
+ case UPB_DESCRIPTOR_TYPE_MESSAGE: {
+ size_t size;
+ void *submsg = *(void**)field_mem;
+ const upb_msglayout_msginit_v1 *subm = m->submsgs[f->submsg_index];
+ if (skip_zero_value && submsg == NULL) {
+ return true;
+ }
+ return upb_encode_message(e, submsg, subm, &size) &&
+ upb_put_varint(e, size) &&
+ upb_put_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
+ }
+ }
+#undef CASE
+ UPB_UNREACHABLE();
+}
+
+bool upb_encode_hasscalarfield(const char *msg,
+ const upb_msglayout_msginit_v1 *m,
+ const upb_msglayout_fieldinit_v1 *f) {
+ if (f->oneof_index != UPB_NOT_IN_ONEOF) {
+ return upb_readcase(msg, m, f->oneof_index) == f->number;
+ } else if (m->is_proto2) {
+ return upb_readhasbit(msg, f);
+ } else {
+ /* For proto3, we'll test for the field being empty later. */
+ return true;
+ }
+}
+
+bool upb_encode_message(upb_encstate* e, const char *msg,
+ const upb_msglayout_msginit_v1 *m,
+ size_t *size) {
+ int i;
+ char *buf_end = e->ptr;
+
+ if (msg == NULL) {
+ return true;
+ }
+
+ for (i = m->field_count - 1; i >= 0; i--) {
+ const upb_msglayout_fieldinit_v1 *f = &m->fields[i];
+
+ if (f->label == UPB_LABEL_REPEATED) {
+ CHK(upb_encode_array(e, msg + f->offset, m, f));
+ } else {
+ if (upb_encode_hasscalarfield(msg, m, f)) {
+ CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, !m->is_proto2));
+ }
+ }
+ }
+
+ *size = buf_end - e->ptr;
+ return true;
+}
+
+char *upb_encode(const void *msg, const upb_msglayout_msginit_v1 *m,
+ upb_env *env, size_t *size) {
+ upb_encstate e;
+ e.env = env;
+ e.buf = NULL;
+ e.limit = NULL;
+ e.ptr = NULL;
+
+ if (!upb_encode_message(&e, msg, m, size)) {
+ *size = 0;
+ return NULL;
+ }
+
+ *size = e.limit - e.ptr;
+
+ if (*size == 0) {
+ static char ch;
+ return &ch;
+ } else {
+ UPB_ASSERT(e.ptr);
+ return e.ptr;
+ }
+}
+
+#undef CHK
/*
** TODO(haberman): it's unclear whether a lot of the consistency checks should
** UPB_ASSERT() or return false.
@@ -2730,6 +3701,12 @@ SETTER(endseq, upb_endfield_handlerfunc*, UPB_HANDLER_ENDSEQ)
#undef SETTER
+bool upb_handlers_setunknown(upb_handlers *h, upb_unknown_handlerfunc *func,
+ upb_handlerattr *attr) {
+ return doset(h, UPB_UNKNOWN_SELECTOR, NULL, UPB_HANDLER_INT32,
+ (upb_func *)func, attr);
+}
+
bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
upb_handlerattr *attr) {
return doset(h, UPB_STARTMSG_SELECTOR, NULL, UPB_HANDLER_INT32,
@@ -3079,7 +4056,8 @@ bool upb_fieldtype_mapkeyok(upb_fieldtype_t type) {
void *upb_array_pack(const upb_array *arr, void *p, size_t *ofs, size_t size);
void *upb_map_pack(const upb_map *map, void *p, size_t *ofs, size_t size);
-#define CHARPTR_AT(msg, ofs) ((char*)msg + ofs)
+#define PTR_AT(msg, ofs, type) (type*)((char*)msg + ofs)
+#define VOIDPTR_AT(msg, ofs) PTR_AT(msg, ofs, void)
#define ENCODE_MAX_NESTING 64
#define CHECK_TRUE(x) if (!(x)) { return false; }
@@ -3121,12 +4099,20 @@ static size_t upb_msgval_sizeof(upb_fieldtype_t type) {
case UPB_TYPE_MESSAGE:
return sizeof(void*);
case UPB_TYPE_STRING:
- return sizeof(char*) + sizeof(size_t);
+ return sizeof(upb_stringview);
}
UPB_UNREACHABLE();
}
-static uint8_t upb_msg_fieldsize(const upb_fielddef *f) {
+static uint8_t upb_msg_fieldsize(const upb_msglayout_fieldinit_v1 *field) {
+ if (field->label == UPB_LABEL_REPEATED) {
+ return sizeof(void*);
+ } else {
+ return upb_msgval_sizeof(field->type);
+ }
+}
+
+static uint8_t upb_msg_fielddefsize(const upb_fielddef *f) {
if (upb_fielddef_isseq(f)) {
return sizeof(void*);
} else {
@@ -3170,7 +4156,6 @@ static upb_ctype_t upb_fieldtotabtype(upb_fieldtype_t type) {
}
static upb_msgval upb_msgval_fromdefault(const upb_fielddef *f) {
- /* TODO(haberman): improve/optimize this (maybe use upb_msgval in fielddef) */
switch (upb_fielddef_type(f)) {
case UPB_TYPE_FLOAT:
return upb_msgval_float(upb_fielddef_defaultfloat(f));
@@ -3182,7 +4167,7 @@ static upb_msgval upb_msgval_fromdefault(const upb_fielddef *f) {
case UPB_TYPE_BYTES: {
size_t len;
const char *ptr = upb_fielddef_defaultstr(f, &len);
- return upb_msgval_str(ptr, len);
+ return upb_msgval_makestr(ptr, len);
}
case UPB_TYPE_MESSAGE:
return upb_msgval_msg(NULL);
@@ -3205,63 +4190,44 @@ static upb_msgval upb_msgval_fromdefault(const upb_fielddef *f) {
/** upb_msglayout *************************************************************/
struct upb_msglayout {
- upb_msgfactory *factory;
- const upb_msgdef *msgdef;
- size_t size;
- size_t extdict_offset;
- void *default_msg;
- uint32_t *field_offsets;
- uint32_t *case_offsets;
- uint32_t *hasbits;
- bool has_extdict;
- uint8_t align;
+ struct upb_msglayout_msginit_v1 data;
};
-static void upb_msg_checkfield(const upb_msglayout *l, const upb_fielddef *f) {
- UPB_ASSERT(l->msgdef == upb_fielddef_containingtype(f));
-}
-
static void upb_msglayout_free(upb_msglayout *l) {
- upb_gfree(l->default_msg);
+ upb_gfree(l->data.default_msg);
upb_gfree(l);
}
-const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l) {
- return l->msgdef;
-}
-
static size_t upb_msglayout_place(upb_msglayout *l, size_t size) {
size_t ret;
- l->size = align_up(l->size, size);
- l->align = align_up(l->align, size);
- ret = l->size;
- l->size += size;
+ l->data.size = align_up(l->data.size, size);
+ ret = l->data.size;
+ l->data.size += size;
return ret;
}
static uint32_t upb_msglayout_offset(const upb_msglayout *l,
const upb_fielddef *f) {
- return l->field_offsets[upb_fielddef_index(f)];
+ return l->data.fields[upb_fielddef_index(f)].offset;
}
static uint32_t upb_msglayout_hasbit(const upb_msglayout *l,
const upb_fielddef *f) {
- return l->hasbits[upb_fielddef_index(f)];
+ return l->data.fields[upb_fielddef_index(f)].hasbit;
}
-static bool upb_msglayout_initdefault(upb_msglayout *l) {
- const upb_msgdef *m = l->msgdef;
+static bool upb_msglayout_initdefault(upb_msglayout *l, const upb_msgdef *m) {
upb_msg_field_iter it;
- if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2 && l->size) {
+ if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2 && l->data.size) {
/* Allocate default message and set default values in it. */
- l->default_msg = upb_gmalloc(l->size);
- if (!l->default_msg) {
+ l->data.default_msg = upb_gmalloc(l->data.size);
+ if (!l->data.default_msg) {
return false;
}
- memset(l->default_msg, 0, l->size);
+ memset(l->data.default_msg, 0, l->data.size);
for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
upb_msg_field_next(&it)) {
@@ -3271,10 +4237,14 @@ static bool upb_msglayout_initdefault(upb_msglayout *l) {
continue;
}
+ /* TODO(haberman): handle strings. */
if (!upb_fielddef_isstring(f) &&
!upb_fielddef_issubmsg(f) &&
!upb_fielddef_isseq(f)) {
- upb_msg_set(l->default_msg, f, upb_msgval_fromdefault(f), l);
+ upb_msg_set(l->data.default_msg,
+ upb_fielddef_index(f),
+ upb_msgval_fromdefault(f),
+ l);
}
}
}
@@ -3287,22 +4257,46 @@ static upb_msglayout *upb_msglayout_new(const upb_msgdef *m) {
upb_msg_oneof_iter oit;
upb_msglayout *l;
size_t hasbit;
- size_t array_size = upb_msgdef_numfields(m) + upb_msgdef_numoneofs(m);
+ size_t submsg_count = 0;
+ const upb_msglayout_msginit_v1 **submsgs;
+ upb_msglayout_fieldinit_v1 *fields;
+ upb_msglayout_oneofinit_v1 *oneofs;
- if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2) {
- array_size += upb_msgdef_numfields(m); /* hasbits. */
+ for (upb_msg_field_begin(&it, m);
+ !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+ if (upb_fielddef_issubmsg(f)) {
+ submsg_count++;
+ }
}
- l = upb_gmalloc(sizeof(*l) + (sizeof(uint32_t) * array_size));
+ l = upb_gmalloc(sizeof(*l));
if (!l) return NULL;
memset(l, 0, sizeof(*l));
- l->msgdef = m;
- l->align = 1;
- l->field_offsets = (uint32_t*)CHARPTR_AT(l, sizeof(*l));
- l->case_offsets = l->field_offsets + upb_msgdef_numfields(m);
- l->hasbits = l->case_offsets + upb_msgdef_numoneofs(m);
+ fields = upb_gmalloc(upb_msgdef_numfields(m) * sizeof(*fields));
+ submsgs = upb_gmalloc(submsg_count * sizeof(*submsgs));
+ oneofs = upb_gmalloc(upb_msgdef_numoneofs(m) * sizeof(*oneofs));
+
+ if ((!fields && upb_msgdef_numfields(m)) ||
+ (!submsgs && submsg_count) ||
+ (!oneofs && upb_msgdef_numoneofs(m))) {
+ /* OOM. */
+ upb_gfree(l);
+ upb_gfree(fields);
+ upb_gfree(submsgs);
+ upb_gfree(oneofs);
+ return NULL;
+ }
+
+ l->data.field_count = upb_msgdef_numfields(m);
+ l->data.oneof_count = upb_msgdef_numoneofs(m);
+ l->data.fields = fields;
+ l->data.submsgs = submsgs;
+ l->data.oneofs = oneofs;
+ l->data.is_proto2 = (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2);
/* Allocate data offsets in three stages:
*
@@ -3313,74 +4307,75 @@ static upb_msglayout *upb_msglayout_new(const upb_msgdef *m) {
* OPT: There is a lot of room for optimization here to minimize the size.
*/
- /* Allocate hasbits. Start at sizeof(void*) for upb_alloc*. */
- for (upb_msg_field_begin(&it, m), hasbit = sizeof(void*) * 8;
+ /* Allocate hasbits and set basic field attributes. */
+ for (upb_msg_field_begin(&it, m), hasbit = 0;
!upb_msg_field_done(&it);
upb_msg_field_next(&it)) {
const upb_fielddef* f = upb_msg_iter_field(&it);
+ upb_msglayout_fieldinit_v1 *field = &fields[upb_fielddef_index(f)];
+
+ field->number = upb_fielddef_number(f);
+ field->type = upb_fielddef_type(f);
+ field->label = upb_fielddef_label(f);
+
+ if (upb_fielddef_containingoneof(f)) {
+ field->oneof_index = upb_oneofdef_index(upb_fielddef_containingoneof(f));
+ } else {
+ field->oneof_index = UPB_NOT_IN_ONEOF;
+ }
if (upb_fielddef_haspresence(f) && !upb_fielddef_containingoneof(f)) {
- l->hasbits[upb_fielddef_index(f)] = hasbit++;
+ field->hasbit = hasbit++;
}
}
/* Account for space used by hasbits. */
- l->size = div_round_up(hasbit, 8);
+ l->data.size = div_round_up(hasbit, 8);
/* Allocate non-oneof fields. */
for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
upb_msg_field_next(&it)) {
const upb_fielddef* f = upb_msg_iter_field(&it);
- size_t field_size = upb_msg_fieldsize(f);
+ size_t field_size = upb_msg_fielddefsize(f);
size_t index = upb_fielddef_index(f);
-
if (upb_fielddef_containingoneof(f)) {
/* Oneofs are handled separately below. */
continue;
}
- l->field_offsets[index] = upb_msglayout_place(l, field_size);
+ fields[index].offset = upb_msglayout_place(l, field_size);
}
/* Allocate oneof fields. Each oneof field consists of a uint32 for the case
* and space for the actual data. */
for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit);
upb_msg_oneof_next(&oit)) {
- const upb_oneofdef* oneof = upb_msg_iter_oneof(&oit);
+ const upb_oneofdef* o = upb_msg_iter_oneof(&oit);
upb_oneof_iter fit;
+
size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */
+ upb_msglayout_oneofinit_v1 *oneof = &oneofs[upb_oneofdef_index(o)];
size_t field_size = 0;
- size_t case_offset;
- size_t val_offset;
/* Calculate field size: the max of all field sizes. */
- for (upb_oneof_begin(&fit, oneof);
+ for (upb_oneof_begin(&fit, o);
!upb_oneof_done(&fit);
upb_oneof_next(&fit)) {
const upb_fielddef* f = upb_oneof_iter_field(&fit);
- field_size = UPB_MAX(field_size, upb_msg_fieldsize(f));
+ field_size = UPB_MAX(field_size, upb_msg_fielddefsize(f));
}
/* Align and allocate case offset. */
- case_offset = upb_msglayout_place(l, case_size);
- val_offset = upb_msglayout_place(l, field_size);
-
- l->case_offsets[upb_oneofdef_index(oneof)] = case_offset;
-
- /* Assign all fields in the oneof this same offset. */
- for (upb_oneof_begin(&fit, oneof); !upb_oneof_done(&fit);
- upb_oneof_next(&fit)) {
- const upb_fielddef* f = upb_oneof_iter_field(&fit);
- l->field_offsets[upb_fielddef_index(f)] = val_offset;
- }
+ oneof->case_offset = upb_msglayout_place(l, case_size);
+ oneof->data_offset = upb_msglayout_place(l, field_size);
}
/* Size of the entire structure should be a multiple of its greatest
- * alignment. */
- l->size = align_up(l->size, l->align);
+ * alignment. TODO: track overall alignment for real? */
+ l->data.size = align_up(l->data.size, 8);
- if (upb_msglayout_initdefault(l)) {
+ if (upb_msglayout_initdefault(l, m)) {
return l;
} else {
upb_msglayout_free(l);
@@ -3388,10 +4383,6 @@ static upb_msglayout *upb_msglayout_new(const upb_msgdef *m) {
}
}
-upb_msgfactory *upb_msglayout_factory(const upb_msglayout *layout) {
- return layout->factory;
-}
-
/** upb_msgfactory ************************************************************/
@@ -3448,7 +4439,6 @@ const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
upb_msglayout *l = upb_msglayout_new(m);
upb_inttable_insertptr(&mutable_f->layouts, m, upb_value_ptr(l));
UPB_ASSERT(l);
- l->factory = f;
return l;
}
}
@@ -3457,16 +4447,15 @@ const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
void *upb_msg_startstr(void *msg, const void *hd, size_t size_hint) {
uint32_t ofs = (uintptr_t)hd;
- /* We pass NULL here because we know we can get away with it. */
- upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_alloc *alloc = upb_msg_alloc(msg);
upb_msgval val;
UPB_UNUSED(size_hint);
val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
- upb_free(alloc, (void*)val.str.ptr);
- val.str.ptr = NULL;
- val.str.len = 0;
+ upb_free(alloc, (void*)val.str.data);
+ val.str.data = NULL;
+ val.str.size = 0;
upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
return msg;
@@ -3475,23 +4464,22 @@ void *upb_msg_startstr(void *msg, const void *hd, size_t size_hint) {
size_t upb_msg_str(void *msg, const void *hd, const char *ptr, size_t size,
const upb_bufhandle *handle) {
uint32_t ofs = (uintptr_t)hd;
- /* We pass NULL here because we know we can get away with it. */
- upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_alloc *alloc = upb_msg_alloc(msg);
upb_msgval val;
size_t newsize;
UPB_UNUSED(handle);
val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
- newsize = val.str.len + size;
- val.str.ptr = upb_realloc(alloc, (void*)val.str.ptr, val.str.len, newsize);
+ newsize = val.str.size + size;
+ val.str.data = upb_realloc(alloc, (void*)val.str.data, val.str.size, newsize);
- if (!val.str.ptr) {
+ if (!val.str.data) {
return false;
}
- memcpy((char*)val.str.ptr + val.str.len, ptr, size);
- val.str.len = newsize;
+ memcpy((char*)val.str.data + val.str.size, ptr, size);
+ val.str.size = newsize;
upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
return size;
}
@@ -3556,13 +4544,14 @@ static upb_selector_t getsel2(const upb_fielddef *f, upb_handlertype_t type) {
static bool upb_visitor_hasfield(const upb_msg *msg, const upb_fielddef *f,
const upb_msglayout *layout) {
+ int field_index = upb_fielddef_index(f);
if (upb_fielddef_isseq(f)) {
- return upb_msgval_getarr(upb_msg_get(msg, f, layout)) != NULL;
+ return upb_msgval_getarr(upb_msg_get(msg, field_index, layout)) != NULL;
} else if (upb_msgdef_syntax(upb_fielddef_containingtype(f)) ==
UPB_SYNTAX_PROTO2) {
- return upb_msg_has(msg, f, layout);
+ return upb_msg_has(msg, field_index, layout);
} else {
- upb_msgval val = upb_msg_get(msg, f, layout);
+ upb_msgval val = upb_msg_get(msg, field_index, layout);
switch (upb_fielddef_type(f)) {
case UPB_TYPE_FLOAT:
return upb_msgval_getfloat(val) != 0;
@@ -3581,7 +4570,7 @@ static bool upb_visitor_hasfield(const upb_msg *msg, const upb_fielddef *f,
return upb_msgval_getuint64(val) != 0;
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES:
- return upb_msgval_getstr(val) && upb_msgval_getstrlen(val) > 0;
+ return upb_msgval_getstr(val).size > 0;
case UPB_TYPE_MESSAGE:
return upb_msgval_getmsg(val) != NULL;
}
@@ -3592,7 +4581,7 @@ static bool upb_visitor_hasfield(const upb_msg *msg, const upb_fielddef *f,
static bool upb_visitor_visitmsg2(const upb_msg *msg,
const upb_msglayout *layout, upb_sink *sink,
int depth) {
- const upb_msgdef *md = upb_msglayout_msgdef(layout);
+ const upb_msgdef *md = upb_handlers_msgdef(sink->handlers);
upb_msg_field_iter i;
upb_status status;
@@ -3614,7 +4603,7 @@ static bool upb_visitor_visitmsg2(const upb_msg *msg,
continue;
}
- val = upb_msg_get(msg, f, layout);
+ val = upb_msg_get(msg, upb_fielddef_index(f), layout);
if (upb_fielddef_isseq(f)) {
const upb_array *arr = upb_msgval_getarr(val);
@@ -3683,194 +4672,160 @@ bool upb_visitor_visitmsg(upb_visitor *visitor, const upb_msg *msg) {
/* If we always read/write as a consistent type to each address, this shouldn't
* violate aliasing.
*/
-#define DEREF(msg, ofs, type) *(type*)CHARPTR_AT(msg, ofs)
-
-static upb_inttable *upb_msg_trygetextdict(const upb_msg *msg,
- const upb_msglayout *l) {
- return l->has_extdict ? DEREF(msg, l->extdict_offset, upb_inttable*) : NULL;
-}
+#define DEREF(msg, ofs, type) *PTR_AT(msg, ofs, type)
-static upb_inttable *upb_msg_getextdict(upb_msg *msg,
- const upb_msglayout *l,
- upb_alloc *a) {
- upb_inttable *ext_dict;
- UPB_ASSERT(l->has_extdict);
+/* Internal members of a upb_msg. We can change this without breaking binary
+ * compatibility. We put these before the user's data. The user's upb_msg*
+ * points after the upb_msg_internal. */
- ext_dict = upb_msg_trygetextdict(msg, l);
+/* Used when a message is not extendable. */
+typedef struct {
+ /* TODO(haberman): add unknown fields. */
+ upb_alloc *alloc;
+} upb_msg_internal;
- if (!ext_dict) {
- ext_dict = upb_malloc(a, sizeof(upb_inttable));
+/* Used when a message is extendable. */
+typedef struct {
+ upb_inttable *extdict;
+ upb_msg_internal base;
+} upb_msg_internal_withext;
- if (!ext_dict) {
- return NULL;
- }
+static int upb_msg_internalsize(const upb_msglayout *l) {
+ return sizeof(upb_msg_internal) - l->data.extendable * sizeof(void*);
+}
- /* Use an 8-byte type to ensure all bytes are copied. */
- if (!upb_inttable_init2(ext_dict, UPB_CTYPE_INT64, a)) {
- upb_free(a, ext_dict);
- return NULL;
- }
+static upb_msg_internal *upb_msg_getinternal(upb_msg *msg) {
+ return VOIDPTR_AT(msg, -sizeof(upb_msg_internal));
+}
- DEREF(msg, l->extdict_offset, upb_inttable*) = ext_dict;
- }
+static const upb_msg_internal *upb_msg_getinternal_const(const upb_msg *msg) {
+ return VOIDPTR_AT(msg, -sizeof(upb_msg_internal));
+}
- return ext_dict;
+static upb_msg_internal_withext *upb_msg_getinternalwithext(
+ upb_msg *msg, const upb_msglayout *l) {
+ UPB_ASSERT(l->data.extendable);
+ return VOIDPTR_AT(msg, -sizeof(upb_msg_internal_withext));
}
-static uint32_t upb_msg_getoneofint(const upb_msg *msg,
- const upb_oneofdef *o,
- const upb_msglayout *l) {
- size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
- return DEREF(msg, oneof_ofs, uint8_t);
+static const upb_msglayout_fieldinit_v1 *upb_msg_checkfield(
+ int field_index, const upb_msglayout *l) {
+ UPB_ASSERT(field_index >= 0 && field_index < l->data.field_count);
+ return &l->data.fields[field_index];
}
-static void upb_msg_setoneofcase(const upb_msg *msg,
- const upb_oneofdef *o,
- const upb_msglayout *l,
- uint32_t val) {
- size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
- DEREF(msg, oneof_ofs, uint8_t) = val;
+static bool upb_msg_inoneof(const upb_msglayout_fieldinit_v1 *field) {
+ return field->oneof_index != UPB_NOT_IN_ONEOF;
}
+static uint32_t *upb_msg_oneofcase(const upb_msg *msg, int field_index,
+ const upb_msglayout *l) {
+ const upb_msglayout_fieldinit_v1 *field = upb_msg_checkfield(field_index, l);
+ UPB_ASSERT(upb_msg_inoneof(field));
+ return PTR_AT(msg, l->data.oneofs[field->oneof_index].case_offset, uint32_t);
+}
-static bool upb_msg_oneofis(const upb_msg *msg, const upb_msglayout *l,
- const upb_oneofdef *o, const upb_fielddef *f) {
- return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+size_t upb_msg_sizeof(const upb_msglayout *l) {
+ return l->data.size + upb_msg_internalsize(l);
}
-size_t upb_msg_sizeof(const upb_msglayout *l) { return l->size; }
+upb_msg *upb_msg_init(void *mem, const upb_msglayout *l, upb_alloc *a) {
+ upb_msg *msg = VOIDPTR_AT(mem, upb_msg_internalsize(l));
-void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a) {
- if (l->default_msg) {
- memcpy(msg, l->default_msg, l->size);
+ /* Initialize normal members. */
+ if (l->data.default_msg) {
+ memcpy(msg, l->data.default_msg, l->data.size);
} else {
- memset(msg, 0, l->size);
+ memset(msg, 0, l->data.size);
}
- /* Set arena pointer. */
- memcpy(msg, &a, sizeof(a));
-}
+ /* Initialize internal members. */
+ upb_msg_getinternal(msg)->alloc = a;
-void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l) {
- upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
- if (ext_dict) {
- upb_inttable_uninit2(ext_dict, upb_msg_alloc(msg, l));
+ if (l->data.extendable) {
+ upb_msg_getinternalwithext(msg, l)->extdict = NULL;
}
-}
-upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a) {
- upb_msg *msg = upb_malloc(a, upb_msg_sizeof(l));
+ return msg;
+}
- if (msg) {
- upb_msg_init(msg, l, a);
+void *upb_msg_uninit(upb_msg *msg, const upb_msglayout *l) {
+ if (l->data.extendable) {
+ upb_inttable *ext_dict = upb_msg_getinternalwithext(msg, l)->extdict;
+ if (ext_dict) {
+ upb_inttable_uninit2(ext_dict, upb_msg_alloc(msg));
+ upb_free(upb_msg_alloc(msg), ext_dict);
+ }
}
- return msg;
+ return VOIDPTR_AT(msg, -upb_msg_internalsize(l));
+}
+
+upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a) {
+ void *mem = upb_malloc(a, upb_msg_sizeof(l));
+ return mem ? upb_msg_init(mem, l, a) : NULL;
}
void upb_msg_free(upb_msg *msg, const upb_msglayout *l) {
- upb_msg_uninit(msg, l);
- upb_free(upb_msg_alloc(msg, l), msg);
+ upb_free(upb_msg_alloc(msg), upb_msg_uninit(msg, l));
}
-upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l) {
- upb_alloc *alloc;
- UPB_UNUSED(l);
- memcpy(&alloc, msg, sizeof(alloc));
- return alloc;
+upb_alloc *upb_msg_alloc(const upb_msg *msg) {
+ return upb_msg_getinternal_const(msg)->alloc;
}
bool upb_msg_has(const upb_msg *msg,
- const upb_fielddef *f,
+ int field_index,
const upb_msglayout *l) {
- const upb_oneofdef *o;
- upb_msg_checkfield(l, f);
- UPB_ASSERT(upb_fielddef_haspresence(f));
+ const upb_msglayout_fieldinit_v1 *field = upb_msg_checkfield(field_index, l);
- if (upb_fielddef_isextension(f)) {
- /* Extensions are set when they are present in the extension dict. */
- upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
- upb_value v;
- return ext_dict != NULL &&
- upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &v);
- } else if ((o = upb_fielddef_containingoneof(f)) != NULL) {
+ UPB_ASSERT(l->data.is_proto2);
+
+ if (upb_msg_inoneof(field)) {
/* Oneofs are set when the oneof number is set to this field. */
- return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+ return *upb_msg_oneofcase(msg, field_index, l) == field->number;
} else {
/* Other fields are set when their hasbit is set. */
- uint32_t hasbit = l->hasbits[upb_fielddef_index(f)];
+ uint32_t hasbit = l->data.fields[field_index].hasbit;
return DEREF(msg, hasbit / 8, char) | (1 << (hasbit % 8));
}
}
-upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f,
+upb_msgval upb_msg_get(const upb_msg *msg, int field_index,
const upb_msglayout *l) {
- upb_msg_checkfield(l, f);
+ const upb_msglayout_fieldinit_v1 *field = upb_msg_checkfield(field_index, l);
+ int size = upb_msg_fieldsize(field);
- if (upb_fielddef_isextension(f)) {
- upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
- upb_value val;
- if (upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &val)) {
- return upb_msgval_fromval(val);
+ if (upb_msg_inoneof(field)) {
+ if (*upb_msg_oneofcase(msg, field_index, l) == field->number) {
+ size_t ofs = l->data.oneofs[field->oneof_index].data_offset;
+ return upb_msgval_read(msg, ofs, size);
} else {
- return upb_msgval_fromdefault(f);
+ /* Return default. */
+ return upb_msgval_read(l->data.default_msg, field->offset, size);
}
} else {
- size_t ofs = l->field_offsets[upb_fielddef_index(f)];
- const upb_oneofdef *o = upb_fielddef_containingoneof(f);
- upb_msgval ret;
-
- if (o && !upb_msg_oneofis(msg, l, o, f)) {
- /* Oneof defaults can't come from the message because the memory is reused
- * by all types in the oneof. */
- return upb_msgval_fromdefault(f);
- }
-
- ret = upb_msgval_read(msg, ofs, upb_msg_fieldsize(f));
- return ret;
+ return upb_msgval_read(msg, field->offset, size);
}
}
-bool upb_msg_set(upb_msg *msg,
- const upb_fielddef *f,
- upb_msgval val,
+void upb_msg_set(upb_msg *msg, int field_index, upb_msgval val,
const upb_msglayout *l) {
- upb_alloc *a = upb_msg_alloc(msg, l);
- upb_msg_checkfield(l, f);
-
- if (upb_fielddef_isextension(f)) {
- /* TODO(haberman): introduce table API that can do this in one call. */
- upb_inttable *ext = upb_msg_getextdict(msg, l, a);
- upb_value val2 = upb_toval(val);
- if (!upb_inttable_replace(ext, upb_fielddef_number(f), val2) &&
- !upb_inttable_insert2(ext, upb_fielddef_number(f), val2, a)) {
- return false;
- }
- } else {
- size_t ofs = l->field_offsets[upb_fielddef_index(f)];
- const upb_oneofdef *o = upb_fielddef_containingoneof(f);
-
- if (o) {
- upb_msg_setoneofcase(msg, o, l, upb_fielddef_number(f));
- }
+ const upb_msglayout_fieldinit_v1 *field = upb_msg_checkfield(field_index, l);
+ int size = upb_msg_fieldsize(field);
- upb_msgval_write(msg, ofs, val, upb_msg_fieldsize(f));
+ if (upb_msg_inoneof(field)) {
+ size_t ofs = l->data.oneofs[field->oneof_index].data_offset;
+ *upb_msg_oneofcase(msg, field_index, l) = field->number;
+ upb_msgval_write(msg, ofs, val, size);
+ } else {
+ upb_msgval_write(msg, field->offset, val, size);
}
- return true;
}
/** upb_array *****************************************************************/
-struct upb_array {
- upb_fieldtype_t type;
- uint8_t element_size;
- void *data; /* Each element is element_size. */
- size_t len; /* Measured in elements. */
- size_t size; /* Measured in elements. */
- upb_alloc *alloc;
-};
-
#define DEREF_ARR(arr, i, type) ((type*)arr->data)[i]
size_t upb_array_sizeof(upb_fieldtype_t type) {
@@ -3965,8 +4920,8 @@ static void upb_map_tokey(upb_fieldtype_t type, upb_msgval *key,
switch (type) {
case UPB_TYPE_STRING:
/* Point to string data of the input key. */
- *out_key = key->str.ptr;
- *out_len = key->str.len;
+ *out_key = key->str.data;
+ *out_len = key->str.size;
return;
case UPB_TYPE_BOOL:
case UPB_TYPE_INT32:
@@ -3991,7 +4946,7 @@ static upb_msgval upb_map_fromkey(upb_fieldtype_t type, const char *key,
size_t len) {
switch (type) {
case UPB_TYPE_STRING:
- return upb_msgval_str(key, len);
+ return upb_msgval_makestr(key, len);
case UPB_TYPE_BOOL:
case UPB_TYPE_INT32:
case UPB_TYPE_UINT32:
@@ -6451,138 +7406,138 @@ static upb_inttable reftables[268];
#endif
static const upb_msgdef msgs[22] = {
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", 40, 8, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[0], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[0]), false, UPB_SYNTAX_PROTO2, &reftables[0], &reftables[1]),
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", 4, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[11], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[16]), false, UPB_SYNTAX_PROTO2, &reftables[2], &reftables[3]),
- UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ReservedRange", 4, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[14], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[20]), false, UPB_SYNTAX_PROTO2, &reftables[4], &reftables[5]),
- UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[17], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[24]), false, UPB_SYNTAX_PROTO2, &reftables[6], &reftables[7]),
- UPB_MSGDEF_INIT("google.protobuf.EnumOptions", 8, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[0], &arrays[21], 4, 2), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[28]), false, UPB_SYNTAX_PROTO2, &reftables[8], &reftables[9]),
- UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", 8, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[25], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[32]), false, UPB_SYNTAX_PROTO2, &reftables[10], &reftables[11]),
- UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", 7, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[2], &arrays[29], 2, 1), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[36]), false, UPB_SYNTAX_PROTO2, &reftables[12], &reftables[13]),
- UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", 23, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[31], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[40]), false, UPB_SYNTAX_PROTO2, &reftables[14], &reftables[15]),
- UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 12, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]),
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 42, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]),
- UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]),
- UPB_MSGDEF_INIT("google.protobuf.FileOptions", 37, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 42, 17), UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]),
- UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[110], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]),
- UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[118], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]),
- UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[125], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]),
- UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[126], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]),
- UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[128], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]),
- UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[132], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]),
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[133], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]),
- UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[135], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]),
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[142], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]),
- UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[151], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]),
+ UPB_MSGDEF_INIT("google.protobuf.DescriptorProto", 41, 8, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[0], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[0]), false, UPB_SYNTAX_PROTO2, &reftables[0], &reftables[1]),
+ UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ExtensionRange", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[11], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[16]), false, UPB_SYNTAX_PROTO2, &reftables[2], &reftables[3]),
+ UPB_MSGDEF_INIT("google.protobuf.DescriptorProto.ReservedRange", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[14], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[20]), false, UPB_SYNTAX_PROTO2, &reftables[4], &reftables[5]),
+ UPB_MSGDEF_INIT("google.protobuf.EnumDescriptorProto", 12, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[17], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[24]), false, UPB_SYNTAX_PROTO2, &reftables[6], &reftables[7]),
+ UPB_MSGDEF_INIT("google.protobuf.EnumOptions", 9, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[0], &arrays[21], 4, 2), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[28]), false, UPB_SYNTAX_PROTO2, &reftables[8], &reftables[9]),
+ UPB_MSGDEF_INIT("google.protobuf.EnumValueDescriptorProto", 9, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[25], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[32]), false, UPB_SYNTAX_PROTO2, &reftables[10], &reftables[11]),
+ UPB_MSGDEF_INIT("google.protobuf.EnumValueOptions", 8, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[2], &arrays[29], 2, 1), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[36]), false, UPB_SYNTAX_PROTO2, &reftables[12], &reftables[13]),
+ UPB_MSGDEF_INIT("google.protobuf.FieldDescriptorProto", 24, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[31], 11, 10), UPB_STRTABLE_INIT(10, 15, UPB_CTYPE_PTR, 4, &strentries[40]), false, UPB_SYNTAX_PROTO2, &reftables[14], &reftables[15]),
+ UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 13, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]),
+ UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 43, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]),
+ UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 7, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]),
+ UPB_MSGDEF_INIT("google.protobuf.FileOptions", 38, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 42, 17), UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]),
+ UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 11, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[110], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]),
+ UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 16, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[118], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]),
+ UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 8, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[125], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]),
+ UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[126], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]),
+ UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 12, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[128], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]),
+ UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 8, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[132], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]),
+ UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 7, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[133], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]),
+ UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 20, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[135], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]),
+ UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 19, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[142], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]),
+ UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 7, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[151], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]),
};
static const upb_fielddef fields[107] = {
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 15, 6, {0},&reftables[44], &reftables[45]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 6, 1, {0},&reftables[46], &reftables[47]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 23, 12, {0},&reftables[48], &reftables[49]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_generic_services", 16, &msgs[11], NULL, 17, 6, {0},&reftables[50], &reftables[51]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "client_streaming", 5, &msgs[13], NULL, 13, 4, {0},&reftables[52], &reftables[53]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "csharp_namespace", 37, &msgs[11], NULL, 27, 14, {0},&reftables[54], &reftables[55]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 6, 1, {0},&reftables[56], &reftables[57]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 16, 7, {0},&reftables[58], &reftables[59]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 30, 8, {0},&reftables[60], &reftables[61]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[62], &reftables[63]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[64], &reftables[65]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[66], &reftables[67]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 21, 10, {0},&reftables[68], &reftables[69]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[70], &reftables[71]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[72], &reftables[73]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[74], &reftables[75]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 11, 4, {0},&reftables[76], &reftables[77]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 3, 1, {0},&reftables[78], &reftables[79]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 3, 1, {0},&reftables[80], &reftables[81]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[82], &reftables[83]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[84], &reftables[85]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 7, 2, {0},&reftables[86], &reftables[87]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 24, 4, {0},&reftables[88], &reftables[89]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 19, 3, {0},&reftables[90], &reftables[91]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension_range", 5, &msgs[0], (const upb_def*)(&msgs[1]), 21, 3, {0},&reftables[92], &reftables[93]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "field", 2, &msgs[0], (const upb_def*)(&msgs[7]), 12, 0, {0},&reftables[94], &reftables[95]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "file", 1, &msgs[10], (const upb_def*)(&msgs[9]), 5, 0, {0},&reftables[96], &reftables[97]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "go_package", 11, &msgs[11], NULL, 14, 5, {0},&reftables[98], &reftables[99]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "identifier_value", 3, &msgs[20], NULL, 6, 1, {0},&reftables[100], &reftables[101]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "input_type", 2, &msgs[13], NULL, 7, 2, {0},&reftables[102], &reftables[103]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, false, false, false, "is_extension", 2, &msgs[21], NULL, 5, 1, {0},&reftables[104], &reftables[105]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generate_equals_and_hash", 20, &msgs[11], NULL, 20, 9, {0},&reftables[106], &reftables[107]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generic_services", 17, &msgs[11], NULL, 18, 7, {0},&reftables[108], &reftables[109]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_multiple_files", 10, &msgs[11], NULL, 13, 4, {0},&reftables[110], &reftables[111]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_outer_classname", 8, &msgs[11], NULL, 9, 2, {0},&reftables[112], &reftables[113]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_package", 1, &msgs[11], NULL, 6, 1, {0},&reftables[114], &reftables[115]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_string_check_utf8", 27, &msgs[11], NULL, 22, 11, {0},&reftables[116], &reftables[117]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "javanano_use_deprecated_package", 38, &msgs[11], NULL, 30, 15, {0},&reftables[118], &reftables[119]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "json_name", 10, &msgs[7], NULL, 20, 9, {0},&reftables[120], &reftables[121]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "jstype", 6, &msgs[8], (const upb_def*)(&enums[3]), 10, 5, {0},&reftables[122], &reftables[123]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "label", 4, &msgs[7], (const upb_def*)(&enums[0]), 11, 4, {0},&reftables[124], &reftables[125]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "lazy", 5, &msgs[8], NULL, 9, 4, {0},&reftables[126], &reftables[127]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "leading_comments", 3, &msgs[19], NULL, 8, 2, {0},&reftables[128], &reftables[129]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "leading_detached_comments", 6, &msgs[19], NULL, 16, 4, {0},&reftables[130], &reftables[131]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "location", 1, &msgs[18], (const upb_def*)(&msgs[19]), 5, 0, {0},&reftables[132], &reftables[133]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "map_entry", 7, &msgs[12], NULL, 9, 4, {0},&reftables[134], &reftables[135]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 6, 1, {0},&reftables[136], &reftables[137]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[138], &reftables[139]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 6, 0, {0},&reftables[140], &reftables[141]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[142], &reftables[143]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[144], &reftables[145]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[146], &reftables[147]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[148], &reftables[149]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[150], &reftables[151]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[152], &reftables[153]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[154], &reftables[155]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[156], &reftables[157]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[158], &reftables[159]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 2, 0, {0},&reftables[160], &reftables[161]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 10, 3, {0},&reftables[162], &reftables[163]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 15, 1, {0},&reftables[164], &reftables[165]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 7, 2, {0},&reftables[166], &reftables[167]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[168], &reftables[169]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[170], &reftables[171]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 24, 13, {0},&reftables[172], &reftables[173]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 28, 6, {0},&reftables[174], &reftables[175]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 19, 8, {0},&reftables[176], &reftables[177]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 12, 3, {0},&reftables[178], &reftables[179]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[180], &reftables[181]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[182], &reftables[183]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[184], &reftables[185]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[186], &reftables[187]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[188], &reftables[189]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[190], &reftables[191]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[192], &reftables[193]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 10, 3, {0},&reftables[194], &reftables[195]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 25, 7, {0},&reftables[196], &reftables[197]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 7, 2, {0},&reftables[198], &reftables[199]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 4, 0, {0},&reftables[200], &reftables[201]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_class_prefix", 40, &msgs[11], NULL, 31, 16, {0},&reftables[202], &reftables[203]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_namespace", 41, &msgs[11], NULL, 34, 17, {0},&reftables[204], &reftables[205]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[206], &reftables[207]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[208], &reftables[209]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[210], &reftables[211]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[212], &reftables[213]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[214], &reftables[215]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[216], &reftables[217]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[218], &reftables[219]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[220], &reftables[221]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[222], &reftables[223]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[224], &reftables[225]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[226], &reftables[227]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[228], &reftables[229]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[230], &reftables[231]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[232], &reftables[233]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[234], &reftables[235]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[236], &reftables[237]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[248], &reftables[249]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[250], &reftables[251]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[252], &reftables[253]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[254], &reftables[255]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[256], &reftables[257]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 16, 6, {0},&reftables[44], &reftables[45]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 7, 1, {0},&reftables[46], &reftables[47]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 24, 12, {0},&reftables[48], &reftables[49]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_generic_services", 16, &msgs[11], NULL, 18, 6, {0},&reftables[50], &reftables[51]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "client_streaming", 5, &msgs[13], NULL, 14, 4, {0},&reftables[52], &reftables[53]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "csharp_namespace", 37, &msgs[11], NULL, 28, 14, {0},&reftables[54], &reftables[55]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 7, 1, {0},&reftables[56], &reftables[57]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 17, 7, {0},&reftables[58], &reftables[59]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 31, 8, {0},&reftables[60], &reftables[61]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 9, 3, {0},&reftables[62], &reftables[63]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 7, 1, {0},&reftables[64], &reftables[65]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 9, 3, {0},&reftables[66], &reftables[67]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 22, 10, {0},&reftables[68], &reftables[69]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 7, 1, {0},&reftables[70], &reftables[71]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 8, 2, {0},&reftables[72], &reftables[73]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 7, 1, {0},&reftables[74], &reftables[75]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 12, 4, {0},&reftables[76], &reftables[77]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 4, 1, {0},&reftables[78], &reftables[79]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 4, 1, {0},&reftables[80], &reftables[81]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 14, 1, {0},&reftables[82], &reftables[83]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 19, 2, {0},&reftables[84], &reftables[85]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 8, 2, {0},&reftables[86], &reftables[87]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 25, 4, {0},&reftables[88], &reftables[89]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 20, 3, {0},&reftables[90], &reftables[91]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension_range", 5, &msgs[0], (const upb_def*)(&msgs[1]), 22, 3, {0},&reftables[92], &reftables[93]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "field", 2, &msgs[0], (const upb_def*)(&msgs[7]), 13, 0, {0},&reftables[94], &reftables[95]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "file", 1, &msgs[10], (const upb_def*)(&msgs[9]), 6, 0, {0},&reftables[96], &reftables[97]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "go_package", 11, &msgs[11], NULL, 15, 5, {0},&reftables[98], &reftables[99]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "identifier_value", 3, &msgs[20], NULL, 7, 1, {0},&reftables[100], &reftables[101]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "input_type", 2, &msgs[13], NULL, 8, 2, {0},&reftables[102], &reftables[103]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_BOOL, 0, false, false, false, false, "is_extension", 2, &msgs[21], NULL, 6, 1, {0},&reftables[104], &reftables[105]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generate_equals_and_hash", 20, &msgs[11], NULL, 21, 9, {0},&reftables[106], &reftables[107]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_generic_services", 17, &msgs[11], NULL, 19, 7, {0},&reftables[108], &reftables[109]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_multiple_files", 10, &msgs[11], NULL, 14, 4, {0},&reftables[110], &reftables[111]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_outer_classname", 8, &msgs[11], NULL, 10, 2, {0},&reftables[112], &reftables[113]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "java_package", 1, &msgs[11], NULL, 7, 1, {0},&reftables[114], &reftables[115]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "java_string_check_utf8", 27, &msgs[11], NULL, 23, 11, {0},&reftables[116], &reftables[117]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "javanano_use_deprecated_package", 38, &msgs[11], NULL, 31, 15, {0},&reftables[118], &reftables[119]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "json_name", 10, &msgs[7], NULL, 21, 9, {0},&reftables[120], &reftables[121]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "jstype", 6, &msgs[8], (const upb_def*)(&enums[3]), 11, 5, {0},&reftables[122], &reftables[123]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "label", 4, &msgs[7], (const upb_def*)(&enums[0]), 12, 4, {0},&reftables[124], &reftables[125]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "lazy", 5, &msgs[8], NULL, 10, 4, {0},&reftables[126], &reftables[127]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "leading_comments", 3, &msgs[19], NULL, 9, 2, {0},&reftables[128], &reftables[129]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "leading_detached_comments", 6, &msgs[19], NULL, 17, 4, {0},&reftables[130], &reftables[131]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "location", 1, &msgs[18], (const upb_def*)(&msgs[19]), 6, 0, {0},&reftables[132], &reftables[133]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "map_entry", 7, &msgs[12], NULL, 10, 4, {0},&reftables[134], &reftables[135]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 7, 1, {0},&reftables[136], &reftables[137]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 11, 0, {0},&reftables[138], &reftables[139]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 7, 0, {0},&reftables[140], &reftables[141]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 6, 0, {0},&reftables[142], &reftables[143]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 5, 1, {0},&reftables[144], &reftables[145]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 23, 6, {0},&reftables[146], &reftables[147]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 9, 2, {0},&reftables[148], &reftables[149]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 9, 2, {0},&reftables[150], &reftables[151]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 3, 0, {0},&reftables[152], &reftables[153]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 5, 1, {0},&reftables[154], &reftables[155]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 5, 1, {0},&reftables[156], &reftables[157]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 33, 8, {0},&reftables[158], &reftables[159]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 3, 0, {0},&reftables[160], &reftables[161]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 11, 3, {0},&reftables[162], &reftables[163]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 16, 1, {0},&reftables[164], &reftables[165]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 8, 2, {0},&reftables[166], &reftables[167]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 11, 3, {0},&reftables[168], &reftables[169]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 8, 2, {0},&reftables[170], &reftables[171]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 25, 13, {0},&reftables[172], &reftables[173]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 29, 6, {0},&reftables[174], &reftables[175]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 20, 8, {0},&reftables[176], &reftables[177]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 13, 3, {0},&reftables[178], &reftables[179]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 26, 5, {0},&reftables[180], &reftables[181]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 21, 4, {0},&reftables[182], &reftables[183]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 4, 0, {0},&reftables[184], &reftables[185]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 4, 0, {0},&reftables[186], &reftables[187]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 8, 1, {0},&reftables[188], &reftables[189]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 8, 1, {0},&reftables[190], &reftables[191]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 4, 0, {0},&reftables[192], &reftables[193]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 11, 3, {0},&reftables[194], &reftables[195]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 26, 7, {0},&reftables[196], &reftables[197]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 8, 2, {0},&reftables[198], &reftables[199]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 5, 0, {0},&reftables[200], &reftables[201]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_class_prefix", 40, &msgs[11], NULL, 32, 16, {0},&reftables[202], &reftables[203]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_namespace", 41, &msgs[11], NULL, 35, 17, {0},&reftables[204], &reftables[205]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 10, 2, {0},&reftables[206], &reftables[207]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 36, 9, {0},&reftables[208], &reftables[209]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 20, 8, {0},&reftables[210], &reftables[211]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 38, 9, {0},&reftables[212], &reftables[213]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 32, 7, {0},&reftables[214], &reftables[215]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 15, 5, {0},&reftables[216], &reftables[217]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 17, 2, {0},&reftables[218], &reftables[219]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 22, 5, {0},&reftables[220], &reftables[221]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 8, 1, {0},&reftables[222], &reftables[223]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 3, 0, {0},&reftables[224], &reftables[225]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 3, 0, {0},&reftables[226], &reftables[227]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 13, 5, {0},&reftables[228], &reftables[229]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 40, 11, {0},&reftables[230], &reftables[231]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 12, 3, {0},&reftables[232], &reftables[233]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 13, 5, {0},&reftables[234], &reftables[235]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 14, 6, {0},&reftables[236], &reftables[237]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[238], &reftables[239]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[240], &reftables[241]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[242], &reftables[243]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[244], &reftables[245]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[246], &reftables[247]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[248], &reftables[249]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 6, 0, {0},&reftables[250], &reftables[251]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 7, 0, {0},&reftables[252], &reftables[253]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 12, 6, {0},&reftables[254], &reftables[255]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 39, 10, {0},&reftables[256], &reftables[257]),
};
static const upb_enumdef enums[5] = {
@@ -7401,6 +8356,7 @@ typedef struct {
struct upb_descreader {
upb_sink sink;
upb_inttable files;
+ upb_strtable files_by_name;
upb_filedef *file; /* The last file in files. */
upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING];
int stack_len;
@@ -7567,6 +8523,7 @@ static size_t file_onname(void *closure, const void *hd, const char *buf,
UPB_UNUSED(handle);
name = upb_gstrndup(buf, n);
+ upb_strtable_insert(&r->files_by_name, name, upb_value_ptr(r->file));
/* XXX: see comment at the top of the file. */
ok = upb_filedef_setname(r->file, name, NULL);
upb_gfree(name);
@@ -7680,6 +8637,18 @@ static void *file_startext(void *closure, const void *hd) {
return r;
}
+static size_t file_ondep(void *closure, const void *hd, const char *buf,
+ size_t n, const upb_bufhandle *handle) {
+ upb_descreader *r = closure;
+ upb_value val;
+ if (upb_strtable_lookup2(&r->files_by_name, buf, n, &val)) {
+ upb_filedef_adddep(r->file, upb_value_getptr(val));
+ }
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
+ return n;
+}
+
/** Handlers for google.protobuf.EnumValueDescriptorProto. *********************/
static bool enumval_startmsg(void *closure, const void *hd) {
@@ -8124,6 +9093,8 @@ static void reghandlers(const void *closure, upb_handlers *h) {
&file_startenum, NULL);
upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, extension),
&file_startext, NULL);
+ upb_handlers_setstring(h, F(FileDescriptorProto, dependency),
+ &file_ondep, NULL);
} else if (upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)) {
upb_handlers_setstartmsg(h, &enumval_startmsg, NULL);
upb_handlers_setendmsg(h, &enumval_endmsg, NULL);
@@ -8183,6 +9154,7 @@ void descreader_cleanup(void *_r) {
upb_gfree(r->name);
upb_inttable_uninit(&r->files);
+ upb_strtable_uninit(&r->files_by_name);
upb_inttable_uninit(&r->oneofs);
upb_gfree(r->default_string);
while (r->stack_len > 0) {
@@ -8201,6 +9173,7 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) {
}
upb_inttable_init(&r->files, UPB_CTYPE_PTR);
+ upb_strtable_init(&r->files_by_name, UPB_CTYPE_PTR);
upb_inttable_init(&r->oneofs, UPB_CTYPE_PTR);
upb_sink_reset(upb_descreader_input(r), h, r);
r->stack_len = 0;
@@ -8500,7 +9473,7 @@ static void put32(compiler *c, uint32_t v) {
*c->pc++ = v;
}
-static void putop(compiler *c, opcode op, ...) {
+static void putop(compiler *c, int op, ...) {
va_list ap;
va_start(ap, op);
@@ -9783,7 +10756,6 @@ have_tag:
return upb_pbdecoder_suspend(d);
}
- /* TODO: deliver to unknown field callback. */
switch (wire_type) {
case UPB_WIRE_TYPE_32BIT:
CHECK_RETURN(skip(d, 4));
@@ -9821,6 +10793,8 @@ have_tag:
}
if (d->top->groupnum >= 0) {
+ /* TODO: More code needed for handling unknown groups. */
+ upb_sink_putunknown(&d->top->sink, d->checkpoint, d->ptr - d->checkpoint);
return DECODE_OK;
}
@@ -10676,6 +11650,12 @@ static void *encode_startdelimfield(void *c, const void *hd) {
return ok ? c : UPB_BREAK;
}
+static bool encode_unknown(void *c, const void *hd, const char *buf,
+ size_t len) {
+ UPB_UNUSED(hd);
+ return encode_bytes(c, buf, len) && commit(c);
+}
+
static bool encode_enddelimfield(void *c, const void *hd) {
UPB_UNUSED(hd);
return end_delim(c);
@@ -10738,6 +11718,7 @@ static void newhandlers_callback(const void *closure, upb_handlers *h) {
upb_handlers_setstartmsg(h, startmsg, NULL);
upb_handlers_setendmsg(h, endmsg, NULL);
+ upb_handlers_setunknown(h, encode_unknown, NULL);
m = upb_handlers_msgdef(h);
for(upb_msg_field_begin(&i, m);
@@ -11350,8 +12331,9 @@ done:
** - handling of keys/escape-sequences/etc that span input buffers.
*/
-#include <assert.h>
#include <errno.h>
+#include <float.h>
+#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -11936,103 +12918,160 @@ static void start_number(upb_json_parser *p, const char *ptr) {
capture_begin(p, ptr);
}
-static bool parse_number(upb_json_parser *p);
+static bool parse_number(upb_json_parser *p, bool is_quoted);
static bool end_number(upb_json_parser *p, const char *ptr) {
if (!capture_end(p, ptr)) {
return false;
}
- return parse_number(p);
+ return parse_number(p, false);
}
-static bool parse_number(upb_json_parser *p) {
- size_t len;
- const char *buf;
- const char *myend;
+/* |buf| is NULL-terminated. |buf| itself will never include quotes;
+ * |is_quoted| tells us whether this text originally appeared inside quotes. */
+static bool parse_number_from_buffer(upb_json_parser *p, const char *buf,
+ bool is_quoted) {
+ size_t len = strlen(buf);
+ const char *bufend = buf + len;
char *end;
+ upb_fieldtype_t type = upb_fielddef_type(p->top->f);
+ double val;
+ double dummy;
+ double inf = 1.0 / 0.0; /* C89 does not have an INFINITY macro. */
- /* strtol() and friends unfortunately do not support specifying the length of
- * the input string, so we need to force a copy into a NULL-terminated buffer. */
- if (!multipart_text(p, "\0", 1, false)) {
+ errno = 0;
+
+ if (len == 0 || buf[0] == ' ') {
return false;
}
- buf = accumulate_getptr(p, &len);
- myend = buf + len - 1; /* One for NULL. */
-
- /* XXX: We are using strtol to parse integers, but this is wrong as even
- * integers can be represented as 1e6 (for example), which strtol can't
- * handle correctly.
- *
- * XXX: Also, we can't handle large integers properly because strto[u]ll
- * isn't in C89.
- *
- * XXX: Also, we don't properly check floats for overflow, since strtof
- * isn't in C89. */
- switch (upb_fielddef_type(p->top->f)) {
+ /* For integer types, first try parsing with integer-specific routines.
+ * If these succeed, they will be more accurate for int64/uint64 than
+ * strtod().
+ */
+ switch (type) {
case UPB_TYPE_ENUM:
case UPB_TYPE_INT32: {
- long val = strtol(p->accumulated, &end, 0);
- if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || end != myend)
- goto err;
- else
+ long val = strtol(buf, &end, 0);
+ if (errno == ERANGE || end != bufend) {
+ break;
+ } else if (val > INT32_MAX || val < INT32_MIN) {
+ return false;
+ } else {
upb_sink_putint32(&p->top->sink, parser_getsel(p), val);
- break;
- }
- case UPB_TYPE_INT64: {
- long long val = strtol(p->accumulated, &end, 0);
- if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || end != myend)
- goto err;
- else
- upb_sink_putint64(&p->top->sink, parser_getsel(p), val);
- break;
+ return true;
+ }
}
case UPB_TYPE_UINT32: {
- unsigned long val = strtoul(p->accumulated, &end, 0);
- if (val > UINT32_MAX || errno == ERANGE || end != myend)
- goto err;
- else
+ unsigned long val = strtoul(buf, &end, 0);
+ if (end != bufend) {
+ break;
+ } else if (val > UINT32_MAX || errno == ERANGE) {
+ return false;
+ } else {
upb_sink_putuint32(&p->top->sink, parser_getsel(p), val);
- break;
+ return true;
+ }
+ }
+ /* XXX: We can't handle [u]int64 properly on 32-bit machines because
+ * strto[u]ll isn't in C89. */
+ case UPB_TYPE_INT64: {
+ long val = strtol(buf, &end, 0);
+ if (errno == ERANGE || end != bufend) {
+ break;
+ } else {
+ upb_sink_putint64(&p->top->sink, parser_getsel(p), val);
+ return true;
+ }
}
case UPB_TYPE_UINT64: {
- unsigned long long val = strtoul(p->accumulated, &end, 0);
- if (val > UINT64_MAX || errno == ERANGE || end != myend)
- goto err;
- else
+ unsigned long val = strtoul(p->accumulated, &end, 0);
+ if (end != bufend) {
+ break;
+ } else if (errno == ERANGE) {
+ return false;
+ } else {
upb_sink_putuint64(&p->top->sink, parser_getsel(p), val);
- break;
+ return true;
+ }
}
- case UPB_TYPE_DOUBLE: {
- double val = strtod(p->accumulated, &end);
- if (errno == ERANGE || end != myend)
- goto err;
- else
- upb_sink_putdouble(&p->top->sink, parser_getsel(p), val);
+ default:
break;
+ }
+
+ if (type != UPB_TYPE_DOUBLE && type != UPB_TYPE_FLOAT && is_quoted) {
+ /* Quoted numbers for integer types are not allowed to be in double form. */
+ return false;
+ }
+
+ if (len == strlen("Infinity") && strcmp(buf, "Infinity") == 0) {
+ /* C89 does not have an INFINITY macro. */
+ val = inf;
+ } else if (len == strlen("-Infinity") && strcmp(buf, "-Infinity") == 0) {
+ val = -inf;
+ } else {
+ val = strtod(buf, &end);
+ if (errno == ERANGE || end != bufend) {
+ return false;
}
- case UPB_TYPE_FLOAT: {
- float val = strtod(p->accumulated, &end);
- if (errno == ERANGE || end != myend)
- goto err;
- else
- upb_sink_putfloat(&p->top->sink, parser_getsel(p), val);
- break;
+ }
+
+ switch (type) {
+#define CASE(capitaltype, smalltype, ctype, min, max) \
+ case UPB_TYPE_ ## capitaltype: { \
+ if (modf(val, &dummy) != 0 || val > max || val < min) { \
+ return false; \
+ } else { \
+ upb_sink_put ## smalltype(&p->top->sink, parser_getsel(p), \
+ (ctype)val); \
+ return true; \
+ } \
+ break; \
}
+ case UPB_TYPE_ENUM:
+ CASE(INT32, int32, int32_t, INT32_MIN, INT32_MAX);
+ CASE(INT64, int64, int64_t, INT64_MIN, INT64_MAX);
+ CASE(UINT32, uint32, uint32_t, 0, UINT32_MAX);
+ CASE(UINT64, uint64, uint64_t, 0, UINT64_MAX);
+#undef CASE
+
+ case UPB_TYPE_DOUBLE:
+ upb_sink_putdouble(&p->top->sink, parser_getsel(p), val);
+ return true;
+ case UPB_TYPE_FLOAT:
+ if ((val > FLT_MAX || val < -FLT_MAX) && val != inf && val != -inf) {
+ return false;
+ } else {
+ upb_sink_putfloat(&p->top->sink, parser_getsel(p), val);
+ return true;
+ }
default:
- UPB_ASSERT(false);
+ return false;
}
+}
- multipart_end(p);
+static bool parse_number(upb_json_parser *p, bool is_quoted) {
+ size_t len;
+ const char *buf;
- return true;
+ /* strtol() and friends unfortunately do not support specifying the length of
+ * the input string, so we need to force a copy into a NULL-terminated buffer. */
+ if (!multipart_text(p, "\0", 1, false)) {
+ return false;
+ }
-err:
- upb_status_seterrf(&p->status, "error parsing number: %s", buf);
- upb_env_reporterror(p->env, &p->status);
- multipart_end(p);
- return false;
+ buf = accumulate_getptr(p, &len);
+
+ if (parse_number_from_buffer(p, buf, is_quoted)) {
+ multipart_end(p);
+ return true;
+ } else {
+ upb_status_seterrf(&p->status, "error parsing number: %s", buf);
+ upb_env_reporterror(p->env, &p->status);
+ multipart_end(p);
+ return false;
+ }
}
static bool parser_putbool(upb_json_parser *p, bool val) {
@@ -12085,17 +13124,16 @@ static bool start_stringval(upb_json_parser *p) {
multipart_startaccum(p);
return true;
}
- } else if (upb_fielddef_type(p->top->f) == UPB_TYPE_ENUM) {
- /* No need to push a frame -- symbolic enum names in quotes remain in the
- * current parser frame.
- *
- * Enum string values must accumulate so we can look up the value in a table
- * once it is complete. */
+ } else if (upb_fielddef_type(p->top->f) != UPB_TYPE_BOOL &&
+ upb_fielddef_type(p->top->f) != UPB_TYPE_MESSAGE) {
+ /* No need to push a frame -- numeric values in quotes remain in the
+ * current parser frame. These values must accmulate so we can convert
+ * them all at once at the end. */
multipart_startaccum(p);
return true;
} else {
upb_status_seterrf(&p->status,
- "String specified for non-string/non-enum field: %s",
+ "String specified for bool or submessage field: %s",
upb_fielddef_name(p->top->f));
upb_env_reporterror(p->env, &p->status);
return false;
@@ -12142,6 +13180,15 @@ static bool end_stringval(upb_json_parser *p) {
break;
}
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_UINT64:
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_FLOAT:
+ ok = parse_number(p, true);
+ break;
+
default:
UPB_ASSERT(false);
upb_status_seterrmsg(&p->status, "Internal error in JSON decoder");
@@ -12185,7 +13232,7 @@ static bool parse_mapentry_key(upb_json_parser *p) {
case UPB_TYPE_UINT32:
case UPB_TYPE_UINT64:
/* Invoke end_number. The accum buffer has the number's text already. */
- if (!parse_number(p)) {
+ if (!parse_number(p, true)) {
return false;
}
break;
@@ -12476,11 +13523,11 @@ static void end_object(upb_json_parser *p) {
* final state once, when the closing '"' is seen. */
-#line 1244 "upb/json/parser.rl"
+#line 1310 "upb/json/parser.rl"
-#line 1156 "upb/json/parser.c"
+#line 1222 "upb/json/parser.c"
static const char _json_actions[] = {
0, 1, 0, 1, 2, 1, 3, 1,
5, 1, 6, 1, 7, 1, 8, 1,
@@ -12629,7 +13676,7 @@ static const int json_en_value_machine = 27;
static const int json_en_main = 1;
-#line 1247 "upb/json/parser.rl"
+#line 1313 "upb/json/parser.rl"
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
const upb_bufhandle *handle) {
@@ -12651,7 +13698,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
capture_resume(parser, buf);
-#line 1327 "upb/json/parser.c"
+#line 1393 "upb/json/parser.c"
{
int _klen;
unsigned int _trans;
@@ -12726,118 +13773,118 @@ _match:
switch ( *_acts++ )
{
case 0:
-#line 1159 "upb/json/parser.rl"
+#line 1225 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 1:
-#line 1160 "upb/json/parser.rl"
+#line 1226 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 10; goto _again;} }
break;
case 2:
-#line 1164 "upb/json/parser.rl"
+#line 1230 "upb/json/parser.rl"
{ start_text(parser, p); }
break;
case 3:
-#line 1165 "upb/json/parser.rl"
+#line 1231 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_text(parser, p)); }
break;
case 4:
-#line 1171 "upb/json/parser.rl"
+#line 1237 "upb/json/parser.rl"
{ start_hex(parser); }
break;
case 5:
-#line 1172 "upb/json/parser.rl"
+#line 1238 "upb/json/parser.rl"
{ hexdigit(parser, p); }
break;
case 6:
-#line 1173 "upb/json/parser.rl"
+#line 1239 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_hex(parser)); }
break;
case 7:
-#line 1179 "upb/json/parser.rl"
+#line 1245 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(escape(parser, p)); }
break;
case 8:
-#line 1185 "upb/json/parser.rl"
+#line 1251 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 9:
-#line 1188 "upb/json/parser.rl"
+#line 1254 "upb/json/parser.rl"
{ {stack[top++] = cs; cs = 19; goto _again;} }
break;
case 10:
-#line 1190 "upb/json/parser.rl"
+#line 1256 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 27; goto _again;} }
break;
case 11:
-#line 1195 "upb/json/parser.rl"
+#line 1261 "upb/json/parser.rl"
{ start_member(parser); }
break;
case 12:
-#line 1196 "upb/json/parser.rl"
+#line 1262 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_membername(parser)); }
break;
case 13:
-#line 1199 "upb/json/parser.rl"
+#line 1265 "upb/json/parser.rl"
{ end_member(parser); }
break;
case 14:
-#line 1205 "upb/json/parser.rl"
+#line 1271 "upb/json/parser.rl"
{ start_object(parser); }
break;
case 15:
-#line 1208 "upb/json/parser.rl"
+#line 1274 "upb/json/parser.rl"
{ end_object(parser); }
break;
case 16:
-#line 1214 "upb/json/parser.rl"
+#line 1280 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_array(parser)); }
break;
case 17:
-#line 1218 "upb/json/parser.rl"
+#line 1284 "upb/json/parser.rl"
{ end_array(parser); }
break;
case 18:
-#line 1223 "upb/json/parser.rl"
+#line 1289 "upb/json/parser.rl"
{ start_number(parser, p); }
break;
case 19:
-#line 1224 "upb/json/parser.rl"
+#line 1290 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_number(parser, p)); }
break;
case 20:
-#line 1226 "upb/json/parser.rl"
+#line 1292 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_stringval(parser)); }
break;
case 21:
-#line 1227 "upb/json/parser.rl"
+#line 1293 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_stringval(parser)); }
break;
case 22:
-#line 1229 "upb/json/parser.rl"
+#line 1295 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(parser_putbool(parser, true)); }
break;
case 23:
-#line 1231 "upb/json/parser.rl"
+#line 1297 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(parser_putbool(parser, false)); }
break;
case 24:
-#line 1233 "upb/json/parser.rl"
+#line 1299 "upb/json/parser.rl"
{ /* null value */ }
break;
case 25:
-#line 1235 "upb/json/parser.rl"
+#line 1301 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_subobject(parser)); }
break;
case 26:
-#line 1236 "upb/json/parser.rl"
+#line 1302 "upb/json/parser.rl"
{ end_subobject(parser); }
break;
case 27:
-#line 1241 "upb/json/parser.rl"
+#line 1307 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
-#line 1513 "upb/json/parser.c"
+#line 1579 "upb/json/parser.c"
}
}
@@ -12850,7 +13897,7 @@ _again:
_out: {}
}
-#line 1268 "upb/json/parser.rl"
+#line 1334 "upb/json/parser.rl"
if (p != pe) {
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
@@ -12891,13 +13938,13 @@ static void json_parser_reset(upb_json_parser *p) {
/* Emit Ragel initialization of the parser. */
-#line 1567 "upb/json/parser.c"
+#line 1633 "upb/json/parser.c"
{
cs = json_start;
top = 0;
}
-#line 1308 "upb/json/parser.rl"
+#line 1374 "upb/json/parser.rl"
p->current_state = cs;
p->parser_top = top;
accumulate_clear(p);
@@ -13194,10 +14241,23 @@ static void putstring(upb_json_printer *p, const char *buf, unsigned int len) {
* Right now we use %.8g and %.17g for float/double, respectively, to match
* proto2::util::JsonFormat's defaults. May want to change this later. */
+const char neginf[] = "\"-Infinity\"";
+const char inf[] = "\"Infinity\"";
+
static size_t fmt_double(double val, char* buf, size_t length) {
- size_t n = _upb_snprintf(buf, length, "%.17g", val);
- CHKLENGTH(n > 0 && n < length);
- return n;
+ if (val == (1.0 / 0.0)) {
+ CHKLENGTH(length >= strlen(inf));
+ strcpy(buf, inf);
+ return strlen(inf);
+ } else if (val == (-1.0 / 0.0)) {
+ CHKLENGTH(length >= strlen(neginf));
+ strcpy(buf, neginf);
+ return strlen(neginf);
+ } else {
+ size_t n = _upb_snprintf(buf, length, "%.17g", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+ }
}
static size_t fmt_float(float val, char* buf, size_t length) {
diff --git a/php/ext/google/protobuf/upb.h b/php/ext/google/protobuf/upb.h
index 4b51275d..10371e8b 100644
--- a/php/ext/google/protobuf/upb.h
+++ b/php/ext/google/protobuf/upb.h
@@ -1,66 +1,13 @@
// Amalgamated source file
/*
-** Defs are upb's internal representation of the constructs that can appear
-** in a .proto file:
-**
-** - upb::MessageDef (upb_msgdef): describes a "message" construct.
-** - upb::FieldDef (upb_fielddef): describes a message field.
-** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
-** - upb::EnumDef (upb_enumdef): describes an enum.
-** - upb::OneofDef (upb_oneofdef): describes a oneof.
-** - upb::Def (upb_def): base class of all the others.
-**
-** TODO: definitions of services.
-**
-** Like upb_refcounted objects, defs are mutable only until frozen, and are
-** only thread-safe once frozen.
-**
-** This is a mixed C/C++ interface that offers a full API to both languages.
-** See the top-level README for more information.
-*/
-
-#ifndef UPB_DEF_H_
-#define UPB_DEF_H_
-
-/*
-** upb::RefCounted (upb_refcounted)
-**
-** A refcounting scheme that supports circular refs. It accomplishes this by
-** partitioning the set of objects into groups such that no cycle spans groups;
-** we can then reference-count the group as a whole and ignore refs within the
-** group. When objects are mutable, these groups are computed very
-** conservatively; we group any objects that have ever had a link between them.
-** When objects are frozen, we compute strongly-connected components which
-** allows us to be precise and only group objects that are actually cyclic.
+** This file contains shared definitions that are widely used across upb.
**
** This is a mixed C/C++ interface that offers a full API to both languages.
** See the top-level README for more information.
*/
-#ifndef UPB_REFCOUNTED_H_
-#define UPB_REFCOUNTED_H_
-
-/*
-** upb_table
-**
-** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
-** This file defines very fast int->upb_value (inttable) and string->upb_value
-** (strtable) hash tables.
-**
-** The table uses chained scatter with Brent's variation (inspired by the Lua
-** implementation of hash tables). The hash function for strings is Austin
-** Appleby's "MurmurHash."
-**
-** The inttable uses uintptr_t as its key, which guarantees it can be used to
-** store pointers or integers of at least 32 bits (upb isn't really useful on
-** systems where sizeof(void*) < 4).
-**
-** The table must be homogenous (all values of the same type). In debug
-** mode, we check this on insert and lookup.
-*/
-
-#ifndef UPB_TABLE_H_
-#define UPB_TABLE_H_
+#ifndef UPB_H_
+#define UPB_H_
// php.h intentionally defined NDEBUG. We have to define this macro in order to
// be used together with php.h
@@ -68,18 +15,6 @@
#define NDEBUG
#endif
-#include <stdint.h>
-#include <string.h>
-/*
-** This file contains shared definitions that are widely used across upb.
-**
-** This is a mixed C/C++ interface that offers a full API to both languages.
-** See the top-level README for more information.
-*/
-
-#ifndef UPB_H_
-#define UPB_H_
-
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -106,6 +41,9 @@ template <int N> class InlinedEnvironment;
#define UPB_INLINE static
#endif
+/* Hints to the compiler about likely/unlikely branches. */
+#define UPB_LIKELY(x) __builtin_expect((x),1)
+
/* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
* doesn't provide these preprocessor symbols. */
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
@@ -367,6 +305,16 @@ class PointerBase2 : public PointerBase<T, Base> {
#endif
+/* A list of types as they are encoded on-the-wire. */
+typedef enum {
+ UPB_WIRE_TYPE_VARINT = 0,
+ UPB_WIRE_TYPE_64BIT = 1,
+ UPB_WIRE_TYPE_DELIMITED = 2,
+ UPB_WIRE_TYPE_START_GROUP = 3,
+ UPB_WIRE_TYPE_END_GROUP = 4,
+ UPB_WIRE_TYPE_32BIT = 5
+} upb_wiretype_t;
+
/* upb::ErrorSpace ************************************************************/
@@ -695,7 +643,7 @@ void upb_env_uninit(upb_env *e);
void upb_env_initonly(upb_env *e);
-upb_arena *upb_env_arena(upb_env *e);
+UPB_INLINE upb_arena *upb_env_arena(upb_env *e) { return (upb_arena*)e; }
bool upb_env_ok(const upb_env *e);
void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud);
@@ -795,6 +743,106 @@ template <int N> class upb::InlinedEnvironment : public upb::Environment {
#endif /* UPB_H_ */
+/*
+** upb_decode: parsing into a upb_msg using a upb_msglayout.
+*/
+
+#ifndef UPB_DECODE_H_
+#define UPB_DECODE_H_
+
+/*
+** upb::Message is a representation for protobuf messages.
+**
+** However it differs from other common representations like
+** google::protobuf::Message in one key way: it does not prescribe any
+** ownership between messages and submessages, and it relies on the
+** client to delete each message/submessage/array/map at the appropriate
+** time.
+**
+** A client can access a upb::Message without knowing anything about
+** ownership semantics, but to create or mutate a message a user needs
+** to implement the memory management themselves.
+**
+** Currently all messages, arrays, and maps store a upb_alloc* internally.
+** Mutating operations use this when they require dynamically-allocated
+** memory. We could potentially eliminate this size overhead later by
+** letting the user flip a bit on the factory that prevents this from
+** being stored. The user would then need to use separate functions where
+** the upb_alloc* is passed explicitly. However for handlers to populate
+** such structures, they would need a place to store this upb_alloc* during
+** parsing; upb_handlers don't currently have a good way to accommodate this.
+**
+** TODO: UTF-8 checking?
+**/
+
+#ifndef UPB_MSG_H_
+#define UPB_MSG_H_
+
+/*
+** Defs are upb's internal representation of the constructs that can appear
+** in a .proto file:
+**
+** - upb::MessageDef (upb_msgdef): describes a "message" construct.
+** - upb::FieldDef (upb_fielddef): describes a message field.
+** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
+** - upb::EnumDef (upb_enumdef): describes an enum.
+** - upb::OneofDef (upb_oneofdef): describes a oneof.
+** - upb::Def (upb_def): base class of all the others.
+**
+** TODO: definitions of services.
+**
+** Like upb_refcounted objects, defs are mutable only until frozen, and are
+** only thread-safe once frozen.
+**
+** This is a mixed C/C++ interface that offers a full API to both languages.
+** See the top-level README for more information.
+*/
+
+#ifndef UPB_DEF_H_
+#define UPB_DEF_H_
+
+/*
+** upb::RefCounted (upb_refcounted)
+**
+** A refcounting scheme that supports circular refs. It accomplishes this by
+** partitioning the set of objects into groups such that no cycle spans groups;
+** we can then reference-count the group as a whole and ignore refs within the
+** group. When objects are mutable, these groups are computed very
+** conservatively; we group any objects that have ever had a link between them.
+** When objects are frozen, we compute strongly-connected components which
+** allows us to be precise and only group objects that are actually cyclic.
+**
+** This is a mixed C/C++ interface that offers a full API to both languages.
+** See the top-level README for more information.
+*/
+
+#ifndef UPB_REFCOUNTED_H_
+#define UPB_REFCOUNTED_H_
+
+/*
+** upb_table
+**
+** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
+** This file defines very fast int->upb_value (inttable) and string->upb_value
+** (strtable) hash tables.
+**
+** The table uses chained scatter with Brent's variation (inspired by the Lua
+** implementation of hash tables). The hash function for strings is Austin
+** Appleby's "MurmurHash."
+**
+** The inttable uses uintptr_t as its key, which guarantees it can be used to
+** store pointers or integers of at least 32 bits (upb isn't really useful on
+** systems where sizeof(void*) < 4).
+**
+** The table must be homogenous (all values of the same type). In debug
+** mode, we check this on insert and lookup.
+*/
+
+#ifndef UPB_TABLE_H_
+#define UPB_TABLE_H_
+
+#include <stdint.h>
+#include <string.h>
#ifdef __cplusplus
extern "C" {
@@ -3857,196 +3905,6 @@ inline bool FileDef::AddDependency(const FileDef* file) {
#endif /* UPB_DEF_H_ */
/*
-** This file contains definitions of structs that should be considered private
-** and NOT stable across versions of upb.
-**
-** The only reason they are declared here and not in .c files is to allow upb
-** and the application (if desired) to embed statically-initialized instances
-** of structures like defs.
-**
-** If you include this file, all guarantees of ABI compatibility go out the
-** window! Any code that includes this file needs to recompile against the
-** exact same version of upb that they are linking against.
-**
-** You also need to recompile if you change the value of the UPB_DEBUG_REFS
-** flag.
-*/
-
-
-#ifndef UPB_STATICINIT_H_
-#define UPB_STATICINIT_H_
-
-#ifdef __cplusplus
-/* Because of how we do our typedefs, this header can't be included from C++. */
-#error This file cannot be included from C++
-#endif
-
-/* upb_refcounted *************************************************************/
-
-
-/* upb_def ********************************************************************/
-
-struct upb_def {
- upb_refcounted base;
-
- const char *fullname;
- const upb_filedef* file;
- char type; /* A upb_deftype_t (char to save space) */
-
- /* Used as a flag during the def's mutable stage. Must be false unless
- * it is currently being used by a function on the stack. This allows
- * us to easily determine which defs were passed into the function's
- * current invocation. */
- bool came_from_user;
-};
-
-#define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
- { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
-
-
-/* upb_fielddef ***************************************************************/
-
-struct upb_fielddef {
- upb_def base;
-
- union {
- int64_t sint;
- uint64_t uint;
- double dbl;
- float flt;
- void *bytes;
- } defaultval;
- union {
- const upb_msgdef *def; /* If !msg_is_symbolic. */
- char *name; /* If msg_is_symbolic. */
- } msg;
- union {
- const upb_def *def; /* If !subdef_is_symbolic. */
- char *name; /* If subdef_is_symbolic. */
- } sub; /* The msgdef or enumdef for this field, if upb_hassubdef(f). */
- bool subdef_is_symbolic;
- bool msg_is_symbolic;
- const upb_oneofdef *oneof;
- bool default_is_string;
- bool type_is_set_; /* False until type is explicitly set. */
- bool is_extension_;
- bool lazy_;
- bool packed_;
- upb_intfmt_t intfmt;
- bool tagdelim;
- upb_fieldtype_t type_;
- upb_label_t label_;
- uint32_t number_;
- uint32_t selector_base; /* Used to index into a upb::Handlers table. */
- uint32_t index_;
-};
-
-extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
-
-#define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
- packed, name, num, msgdef, subdef, selector_base, \
- index, defaultval, refs, ref2s) \
- { \
- UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
- defaultval, {msgdef}, {subdef}, NULL, false, false, \
- type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
- lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
- }
-
-
-/* upb_msgdef *****************************************************************/
-
-struct upb_msgdef {
- upb_def base;
-
- size_t selector_count;
- uint32_t submsg_field_count;
-
- /* Tables for looking up fields by number and name. */
- upb_inttable itof; /* int to field */
- upb_strtable ntof; /* name to field/oneof */
-
- /* Is this a map-entry message? */
- bool map_entry;
-
- /* Whether this message has proto2 or proto3 semantics. */
- upb_syntax_t syntax;
-
- /* TODO(haberman): proper extension ranges (there can be multiple). */
-};
-
-extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
-
-/* TODO: also support static initialization of the oneofs table. This will be
- * needed if we compile in descriptors that contain oneofs. */
-#define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
- map_entry, syntax, refs, ref2s) \
- { \
- UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
- selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
- }
-
-
-/* upb_enumdef ****************************************************************/
-
-struct upb_enumdef {
- upb_def base;
-
- upb_strtable ntoi;
- upb_inttable iton;
- int32_t defaultval;
-};
-
-extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
-
-#define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
- iton, defaultval }
-
-
-/* upb_oneofdef ***************************************************************/
-
-struct upb_oneofdef {
- upb_refcounted base;
-
- uint32_t index; /* Index within oneofs. */
- const char *name;
- upb_strtable ntof;
- upb_inttable itof;
- const upb_msgdef *parent;
-};
-
-extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
-
-#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
- { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
-
-
-/* upb_symtab *****************************************************************/
-
-struct upb_symtab {
- upb_refcounted base;
-
- upb_strtable symtab;
-};
-
-struct upb_filedef {
- upb_refcounted base;
-
- const char *name;
- const char *package;
- const char *phpprefix;
- const char *phpnamespace;
- upb_syntax_t syntax;
-
- upb_inttable defs;
- upb_inttable deps;
-};
-
-extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
-
-#endif /* UPB_STATICINIT_H_ */
-/*
** upb::Handlers (upb_handlers)
**
** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the
@@ -4150,7 +4008,8 @@ UPB_END_EXTERN_C
/* Static selectors for upb::Handlers. */
#define UPB_STARTMSG_SELECTOR 0
#define UPB_ENDMSG_SELECTOR 1
-#define UPB_STATIC_SELECTOR_COUNT 2
+#define UPB_UNKNOWN_SELECTOR 2
+#define UPB_STATIC_SELECTOR_COUNT 3
/* Static selectors for upb::BytesHandler. */
#define UPB_STARTSTR_SELECTOR 0
@@ -4679,6 +4538,8 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
/* Handler function typedefs. */
+typedef bool upb_unknown_handlerfunc(void *c, const void *hd, const char *buf,
+ size_t n);
typedef bool upb_startmsg_handlerfunc(void *c, const void*);
typedef bool upb_endmsg_handlerfunc(void *c, const void *, upb_status *status);
typedef void* upb_startfield_handlerfunc(void *c, const void *hd);
@@ -4732,6 +4593,8 @@ const upb_status *upb_handlers_status(upb_handlers *h);
void upb_handlers_clearerr(upb_handlers *h);
const upb_msgdef *upb_handlers_msgdef(const upb_handlers *h);
bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *hfree);
+bool upb_handlers_setunknown(upb_handlers *h, upb_unknown_handlerfunc *func,
+ upb_handlerattr *attr);
bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
upb_handlerattr *attr);
@@ -6301,6 +6164,18 @@ UPB_INLINE size_t upb_sink_putstring(upb_sink *s, upb_selector_t sel,
return handler(s->closure, hd, buf, n, handle);
}
+UPB_INLINE bool upb_sink_putunknown(upb_sink *s, const char *buf, size_t n) {
+ typedef upb_unknown_handlerfunc func;
+ func *handler;
+ const void *hd;
+ if (!s->handlers) return true;
+ handler = (func *)upb_handlers_gethandler(s->handlers, UPB_UNKNOWN_SELECTOR);
+
+ if (!handler) return n;
+ hd = upb_handlers_gethandlerdata(s->handlers, UPB_UNKNOWN_SELECTOR);
+ return handler(s->closure, hd, buf, n);
+}
+
UPB_INLINE bool upb_sink_startmsg(upb_sink *s) {
typedef upb_startmsg_handlerfunc func;
func *startmsg;
@@ -6505,34 +6380,6 @@ inline bool BufferSource::PutBuffer(const char *buf, size_t len,
#endif
#endif
-/*
-** upb::Message is a representation for protobuf messages.
-**
-** However it differs from other common representations like
-** google::protobuf::Message in one key way: it does not prescribe any
-** ownership between messages and submessages, and it relies on the
-** client to delete each message/submessage/array/map at the appropriate
-** time.
-**
-** A client can access a upb::Message without knowing anything about
-** ownership semantics, but to create or mutate a message a user needs
-** to implement the memory management themselves.
-**
-** Currently all messages, arrays, and maps store a upb_alloc* internally.
-** Mutating operations use this when they require dynamically-allocated
-** memory. We could potentially eliminate this size overhead later by
-** letting the user flip a bit on the factory that prevents this from
-** being stored. The user would then need to use separate functions where
-** the upb_alloc* is passed explicitly. However for handlers to populate
-** such structures, they would need a place to store this upb_alloc* during
-** parsing; upb_handlers don't currently have a good way to accommodate this.
-**
-** TODO: UTF-8 checking?
-**/
-
-#ifndef UPB_MSG_H_
-#define UPB_MSG_H_
-
#ifdef __cplusplus
@@ -6569,21 +6416,6 @@ typedef void upb_msg;
* instances of this from a upb_msgfactory, and the factory always owns the
* msglayout. */
-/* Gets the factory for this layout */
-upb_msgfactory *upb_msglayout_factory(const upb_msglayout *l);
-
-/* Get the msglayout for a submessage. This requires that this field is a
- * submessage, ie. upb_fielddef_issubmsg(upb_msglayout_msgdef(l)) == true.
- *
- * Since map entry messages don't have layouts, if upb_fielddef_ismap(f) == true
- * then this function will return the layout for the map's value. It requires
- * that the value type of the map field is a submessage. */
-const upb_msglayout *upb_msglayout_sublayout(const upb_msglayout *l,
- const upb_fielddef *f);
-
-/* Returns the msgdef for this msglayout. */
-const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l);
-
/** upb_visitor ***************************************************************/
@@ -6629,6 +6461,23 @@ const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
const upb_handlers *h);
+/** upb_stringview ************************************************************/
+
+typedef struct {
+ const char *data;
+ size_t size;
+} upb_stringview;
+
+UPB_INLINE upb_stringview upb_stringview_make(const char *data, size_t size) {
+ upb_stringview ret;
+ ret.data = data;
+ ret.size = size;
+ return ret;
+}
+
+#define UPB_STRINGVIEW_INIT(ptr, len) {ptr, len}
+
+
/** upb_msgval ****************************************************************/
/* A union representing all possible protobuf values. Used for generic get/set
@@ -6646,10 +6495,7 @@ typedef union {
const upb_msg* msg;
const upb_array* arr;
const void* ptr;
- struct {
- const char *ptr;
- size_t len;
- } str;
+ upb_stringview str;
} upb_msgval;
#define ACCESSORS(name, membername, ctype) \
@@ -6676,22 +6522,12 @@ ACCESSORS(map, map, const upb_map*)
ACCESSORS(msg, msg, const upb_msg*)
ACCESSORS(ptr, ptr, const void*)
ACCESSORS(arr, arr, const upb_array*)
+ACCESSORS(str, str, upb_stringview)
#undef ACCESSORS
-UPB_INLINE upb_msgval upb_msgval_str(const char *ptr, size_t len) {
- upb_msgval ret;
- ret.str.ptr = ptr;
- ret.str.len = len;
- return ret;
-}
-
-UPB_INLINE const char* upb_msgval_getstr(upb_msgval val) {
- return val.str.ptr;
-}
-
-UPB_INLINE size_t upb_msgval_getstrlen(upb_msgval val) {
- return val.str.len;
+UPB_INLINE upb_msgval upb_msgval_makestr(const char *data, size_t size) {
+ return upb_msgval_str(upb_stringview_make(data, size));
}
@@ -6716,19 +6552,29 @@ size_t upb_msg_sizeof(const upb_msglayout *l);
* upb_msg_uninit() must be called to release internally-allocated memory
* unless the allocator is an arena that does not require freeing.
*
+ * Please note that upb_msg_init() may return a value that is different than
+ * |msg|, so you must assign the return value and not cast your memory block
+ * to upb_msg* directly!
+ *
* Please note that upb_msg_uninit() does *not* free any submessages, maps,
* or arrays referred to by this message's fields. You must free them manually
- * yourself. */
-void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a);
-void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
+ * yourself.
+ *
+ * upb_msg_uninit returns the original memory block, which may be useful if
+ * you dynamically allocated it (though upb_msg_new() would normally be more
+ * appropriate in this case). */
+upb_msg *upb_msg_init(void *msg, const upb_msglayout *l, upb_alloc *a);
+void *upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
/* Like upb_msg_init() / upb_msg_uninit(), except the message's memory is
* allocated / freed from the given upb_alloc. */
upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a);
void upb_msg_free(upb_msg *msg, const upb_msglayout *l);
-/* Returns the upb_alloc for the given message. */
-upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l);
+/* Returns the upb_alloc for the given message.
+ * TODO(haberman): get rid of this? Not sure we want to be storing this
+ * for every message. */
+upb_alloc *upb_msg_alloc(const upb_msg *msg);
/* Packs the tree of messages rooted at "msg" into a single hunk of memory,
* allocated from the given allocator. */
@@ -6748,25 +6594,14 @@ void *upb_msg_pack(const upb_msg *msg, const upb_msglayout *l,
* arenas).
*/
upb_msgval upb_msg_get(const upb_msg *msg,
- const upb_fielddef *f,
+ int field_index,
const upb_msglayout *l);
/* May only be called for fields where upb_fielddef_haspresence(f) == true. */
bool upb_msg_has(const upb_msg *msg,
- const upb_fielddef *f,
+ int field_index,
const upb_msglayout *l);
-/* Returns NULL if no field in the oneof is set. */
-const upb_fielddef *upb_msg_getoneofcase(const upb_msg *msg,
- const upb_oneofdef *o,
- const upb_msglayout *l);
-
-/* Returns true if any field in the oneof is set. */
-bool upb_msg_hasoneof(const upb_msg *msg,
- const upb_oneofdef *o,
- const upb_msglayout *l);
-
-
/* Mutable message API. May only be called by the owner of the message who
* knows its ownership scheme and how to keep it consistent. */
@@ -6774,8 +6609,8 @@ bool upb_msg_hasoneof(const upb_msg *msg,
* management: if you overwrite a pointer to a msg/array/map/string without
* cleaning it up (or using an arena) it will leak.
*/
-bool upb_msg_set(upb_msg *msg,
- const upb_fielddef *f,
+void upb_msg_set(upb_msg *msg,
+ int field_index,
upb_msgval val,
const upb_msglayout *l);
@@ -6786,12 +6621,7 @@ bool upb_msg_set(upb_msg *msg,
* arrays/maps/strings/msgs that this field may have pointed to.
*/
bool upb_msg_clearfield(upb_msg *msg,
- const upb_fielddef *f,
- const upb_msglayout *l);
-
-/* Clears all fields in the oneof such that none of them are set. */
-bool upb_msg_clearoneof(upb_msg *msg,
- const upb_oneofdef *o,
+ int field_index,
const upb_msglayout *l);
/* TODO(haberman): copyfrom()/mergefrom()? */
@@ -6904,9 +6734,288 @@ bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
size_t *offset,
int32_t *hasbit);
+
+/** Interfaces for generated code *********************************************/
+
+#define UPB_NOT_IN_ONEOF UINT16_MAX
+#define UPB_NO_HASBIT UINT16_MAX
+#define UPB_NO_SUBMSG UINT16_MAX
+
+typedef struct {
+ uint32_t number;
+ uint32_t offset; /* If in a oneof, offset of default in default_msg below. */
+ uint16_t hasbit; /* UPB_NO_HASBIT if no hasbit. */
+ uint16_t oneof_index; /* UPB_NOT_IN_ONEOF if not in a oneof. */
+ uint16_t submsg_index; /* UPB_NO_SUBMSG if no submsg. */
+ uint8_t type;
+ uint8_t label;
+} upb_msglayout_fieldinit_v1;
+
+typedef struct {
+ uint32_t data_offset;
+ uint32_t case_offset;
+} upb_msglayout_oneofinit_v1;
+
+typedef struct upb_msglayout_msginit_v1 {
+ const struct upb_msglayout_msginit_v1 *const* submsgs;
+ const upb_msglayout_fieldinit_v1 *fields;
+ const upb_msglayout_oneofinit_v1 *oneofs;
+ void *default_msg;
+ /* Must be aligned to sizeof(void*). Doesn't include internal members like
+ * unknown fields, extension dict, pointer to msglayout, etc. */
+ uint32_t size;
+ uint16_t field_count;
+ uint16_t oneof_count;
+ bool extendable;
+ bool is_proto2;
+} upb_msglayout_msginit_v1;
+
+#define UPB_ALIGN_UP_TO(val, align) ((val + (align - 1)) & -align)
+#define UPB_ALIGNED_SIZEOF(type) UPB_ALIGN_UP_TO(sizeof(type), sizeof(void*))
+
+/* Initialize/uninitialize a msglayout from a msginit. If upb uses v1
+ * internally, this will not allocate any memory. Should only be used by
+ * generated code. */
+upb_msglayout *upb_msglayout_frominit_v1(
+ const upb_msglayout_msginit_v1 *init, upb_alloc *a);
+void upb_msglayout_uninit_v1(upb_msglayout *layout, upb_alloc *a);
+
UPB_END_EXTERN_C
#endif /* UPB_MSG_H_ */
+
+UPB_BEGIN_EXTERN_C
+
+bool upb_decode(upb_stringview buf, void *msg,
+ const upb_msglayout_msginit_v1 *l, upb_env *env);
+
+UPB_END_EXTERN_C
+
+#endif /* UPB_DECODE_H_ */
+/*
+** structs.int.h: structures definitions that are internal to upb.
+*/
+
+#ifndef UPB_STRUCTS_H_
+#define UPB_STRUCTS_H_
+
+struct upb_array {
+ upb_fieldtype_t type;
+ uint8_t element_size;
+ void *data; /* Each element is element_size. */
+ size_t len; /* Measured in elements. */
+ size_t size; /* Measured in elements. */
+ upb_alloc *alloc;
+};
+
+#endif /* UPB_STRUCTS_H_ */
+
+/*
+** This file contains definitions of structs that should be considered private
+** and NOT stable across versions of upb.
+**
+** The only reason they are declared here and not in .c files is to allow upb
+** and the application (if desired) to embed statically-initialized instances
+** of structures like defs.
+**
+** If you include this file, all guarantees of ABI compatibility go out the
+** window! Any code that includes this file needs to recompile against the
+** exact same version of upb that they are linking against.
+**
+** You also need to recompile if you change the value of the UPB_DEBUG_REFS
+** flag.
+*/
+
+
+#ifndef UPB_STATICINIT_H_
+#define UPB_STATICINIT_H_
+
+#ifdef __cplusplus
+/* Because of how we do our typedefs, this header can't be included from C++. */
+#error This file cannot be included from C++
+#endif
+
+/* upb_refcounted *************************************************************/
+
+
+/* upb_def ********************************************************************/
+
+struct upb_def {
+ upb_refcounted base;
+
+ const char *fullname;
+ const upb_filedef* file;
+ char type; /* A upb_deftype_t (char to save space) */
+
+ /* Used as a flag during the def's mutable stage. Must be false unless
+ * it is currently being used by a function on the stack. This allows
+ * us to easily determine which defs were passed into the function's
+ * current invocation. */
+ bool came_from_user;
+};
+
+#define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
+ { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
+
+
+/* upb_fielddef ***************************************************************/
+
+struct upb_fielddef {
+ upb_def base;
+
+ union {
+ int64_t sint;
+ uint64_t uint;
+ double dbl;
+ float flt;
+ void *bytes;
+ } defaultval;
+ union {
+ const upb_msgdef *def; /* If !msg_is_symbolic. */
+ char *name; /* If msg_is_symbolic. */
+ } msg;
+ union {
+ const upb_def *def; /* If !subdef_is_symbolic. */
+ char *name; /* If subdef_is_symbolic. */
+ } sub; /* The msgdef or enumdef for this field, if upb_hassubdef(f). */
+ bool subdef_is_symbolic;
+ bool msg_is_symbolic;
+ const upb_oneofdef *oneof;
+ bool default_is_string;
+ bool type_is_set_; /* False until type is explicitly set. */
+ bool is_extension_;
+ bool lazy_;
+ bool packed_;
+ upb_intfmt_t intfmt;
+ bool tagdelim;
+ upb_fieldtype_t type_;
+ upb_label_t label_;
+ uint32_t number_;
+ uint32_t selector_base; /* Used to index into a upb::Handlers table. */
+ uint32_t index_;
+};
+
+extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
+
+#define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
+ packed, name, num, msgdef, subdef, selector_base, \
+ index, defaultval, refs, ref2s) \
+ { \
+ UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
+ defaultval, {msgdef}, {subdef}, NULL, false, false, \
+ type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
+ lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
+ }
+
+
+/* upb_msgdef *****************************************************************/
+
+struct upb_msgdef {
+ upb_def base;
+
+ size_t selector_count;
+ uint32_t submsg_field_count;
+
+ /* Tables for looking up fields by number and name. */
+ upb_inttable itof; /* int to field */
+ upb_strtable ntof; /* name to field/oneof */
+
+ /* Is this a map-entry message? */
+ bool map_entry;
+
+ /* Whether this message has proto2 or proto3 semantics. */
+ upb_syntax_t syntax;
+
+ /* TODO(haberman): proper extension ranges (there can be multiple). */
+};
+
+extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
+
+/* TODO: also support static initialization of the oneofs table. This will be
+ * needed if we compile in descriptors that contain oneofs. */
+#define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
+ map_entry, syntax, refs, ref2s) \
+ { \
+ UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
+ selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
+ }
+
+
+/* upb_enumdef ****************************************************************/
+
+struct upb_enumdef {
+ upb_def base;
+
+ upb_strtable ntoi;
+ upb_inttable iton;
+ int32_t defaultval;
+};
+
+extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
+
+#define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
+ { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
+ iton, defaultval }
+
+
+/* upb_oneofdef ***************************************************************/
+
+struct upb_oneofdef {
+ upb_refcounted base;
+
+ uint32_t index; /* Index within oneofs. */
+ const char *name;
+ upb_strtable ntof;
+ upb_inttable itof;
+ const upb_msgdef *parent;
+};
+
+extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
+
+#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
+ { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
+
+
+/* upb_symtab *****************************************************************/
+
+struct upb_symtab {
+ upb_refcounted base;
+
+ upb_strtable symtab;
+};
+
+struct upb_filedef {
+ upb_refcounted base;
+
+ const char *name;
+ const char *package;
+ const char *phpprefix;
+ const char *phpnamespace;
+ upb_syntax_t syntax;
+
+ upb_inttable defs;
+ upb_inttable deps;
+};
+
+extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
+
+#endif /* UPB_STATICINIT_H_ */
+/*
+** upb_encode: parsing into a upb_msg using a upb_msglayout.
+*/
+
+#ifndef UPB_ENCODE_H_
+#define UPB_ENCODE_H_
+
+
+UPB_BEGIN_EXTERN_C
+
+char *upb_encode(const void *msg, const upb_msglayout_msginit_v1 *l,
+ upb_env *env, size_t *size);
+
+UPB_END_EXTERN_C
+
+#endif /* UPB_ENCODE_H_ */
/*
** upb::descriptor::Reader (upb_descreader)
**
@@ -8296,21 +8405,9 @@ UPB_INLINE void upb_pbdecoder_unpackdispatch(uint64_t dispatch, uint64_t *ofs,
extern "C" {
#endif
-/* A list of types as they are encoded on-the-wire. */
-typedef enum {
- UPB_WIRE_TYPE_VARINT = 0,
- UPB_WIRE_TYPE_64BIT = 1,
- UPB_WIRE_TYPE_DELIMITED = 2,
- UPB_WIRE_TYPE_START_GROUP = 3,
- UPB_WIRE_TYPE_END_GROUP = 4,
- UPB_WIRE_TYPE_32BIT = 5
-} upb_wiretype_t;
-
#define UPB_MAX_WIRE_TYPE 5
-/* The maximum number of bytes that it takes to encode a 64-bit varint.
- * Note that with a better encoding this could be 9 (TODO: write up a
- * wiki document about this). */
+/* The maximum number of bytes that it takes to encode a 64-bit varint. */
#define UPB_PB_VARINT_MAX_LEN 10
/* Array of the "native" (ie. non-packed-repeated) wire type for the given a
diff --git a/php/src/GPBMetadata/Google/Protobuf/Api.php b/php/src/GPBMetadata/Google/Protobuf/Api.php
new file mode 100644
index 00000000..b18e0d33
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/Api.php
@@ -0,0 +1,49 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/api.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class Api
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ \GPBMetadata\Google\Protobuf\SourceContext::initOnce();
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0ac8050a19676f6f676c652f70726f746f6275662f6170692e70726f746f" .
+ "120f676f6f676c652e70726f746f6275661a1a676f6f676c652f70726f74" .
+ "6f6275662f747970652e70726f746f2281020a03417069120c0a046e616d" .
+ "6518012001280912280a076d6574686f647318022003280b32172e676f6f" .
+ "676c652e70726f746f6275662e4d6574686f6412280a076f7074696f6e73" .
+ "18032003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" .
+ "6e120f0a0776657273696f6e18042001280912360a0e736f757263655f63" .
+ "6f6e7465787418052001280b321e2e676f6f676c652e70726f746f627566" .
+ "2e536f75726365436f6e7465787412260a066d6978696e7318062003280b" .
+ "32162e676f6f676c652e70726f746f6275662e4d6978696e12270a067379" .
+ "6e74617818072001280e32172e676f6f676c652e70726f746f6275662e53" .
+ "796e74617822d5010a064d6574686f64120c0a046e616d65180120012809" .
+ "12180a10726571756573745f747970655f75726c18022001280912190a11" .
+ "726571756573745f73747265616d696e6718032001280812190a11726573" .
+ "706f6e73655f747970655f75726c180420012809121a0a12726573706f6e" .
+ "73655f73747265616d696e6718052001280812280a076f7074696f6e7318" .
+ "062003280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e" .
+ "12270a0673796e74617818072001280e32172e676f6f676c652e70726f74" .
+ "6f6275662e53796e74617822230a054d6978696e120c0a046e616d651801" .
+ "20012809120c0a04726f6f7418022001280942750a13636f6d2e676f6f67" .
+ "6c652e70726f746f627566420841706950726f746f50015a2b676f6f676c" .
+ "652e676f6c616e672e6f72672f67656e70726f746f2f70726f746f627566" .
+ "2f6170693b617069a20203475042aa021e476f6f676c652e50726f746f62" .
+ "75662e57656c6c4b6e6f776e5479706573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/FieldMask.php b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php
new file mode 100644
index 00000000..5812be1e
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/FieldMask.php
@@ -0,0 +1,31 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/field_mask.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class FieldMask
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0ae3010a20676f6f676c652f70726f746f6275662f6669656c645f6d6173" .
+ "6b2e70726f746f120f676f6f676c652e70726f746f627566221a0a094669" .
+ "656c644d61736b120d0a0570617468731801200328094289010a13636f6d" .
+ "2e676f6f676c652e70726f746f627566420e4669656c644d61736b50726f" .
+ "746f50015a39676f6f676c652e676f6c616e672e6f72672f67656e70726f" .
+ "746f2f70726f746f6275662f6669656c645f6d61736b3b6669656c645f6d" .
+ "61736ba20203475042aa021e476f6f676c652e50726f746f6275662e5765" .
+ "6c6c4b6e6f776e5479706573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php
new file mode 100644
index 00000000..88f42a11
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/GPBEmpty.php
@@ -0,0 +1,30 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/empty.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class GPBEmpty
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" .
+ "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" .
+ "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" .
+ "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" .
+ "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" .
+ "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" .
+ "70726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/SourceContext.php b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php
new file mode 100644
index 00000000..495c6de4
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/SourceContext.php
@@ -0,0 +1,32 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/source_context.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class SourceContext
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0afb010a24676f6f676c652f70726f746f6275662f736f757263655f636f" .
+ "6e746578742e70726f746f120f676f6f676c652e70726f746f6275662222" .
+ "0a0d536f75726365436f6e7465787412110a0966696c655f6e616d651801" .
+ "200128094295010a13636f6d2e676f6f676c652e70726f746f6275664212" .
+ "536f75726365436f6e7465787450726f746f50015a41676f6f676c652e67" .
+ "6f6c616e672e6f72672f67656e70726f746f2f70726f746f6275662f736f" .
+ "757263655f636f6e746578743b736f757263655f636f6e74657874a20203" .
+ "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" .
+ "6e5479706573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/Struct.php b/php/src/GPBMetadata/Google/Protobuf/Struct.php
new file mode 100644
index 00000000..96b42af4
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/Struct.php
@@ -0,0 +1,45 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/struct.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class Struct
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0a81050a1c676f6f676c652f70726f746f6275662f7374727563742e7072" .
+ "6f746f120f676f6f676c652e70726f746f6275662284010a065374727563" .
+ "7412330a066669656c647318012003280b32232e676f6f676c652e70726f" .
+ "746f6275662e5374727563742e4669656c6473456e7472791a450a0b4669" .
+ "656c6473456e747279120b0a036b657918012001280912250a0576616c75" .
+ "6518022001280b32162e676f6f676c652e70726f746f6275662e56616c75" .
+ "653a02380122ea010a0556616c756512300a0a6e756c6c5f76616c756518" .
+ "012001280e321a2e676f6f676c652e70726f746f6275662e4e756c6c5661" .
+ "6c7565480012160a0c6e756d6265725f76616c7565180220012801480012" .
+ "160a0c737472696e675f76616c7565180320012809480012140a0a626f6f" .
+ "6c5f76616c75651804200128084800122f0a0c7374727563745f76616c75" .
+ "6518052001280b32172e676f6f676c652e70726f746f6275662e53747275" .
+ "6374480012300a0a6c6973745f76616c756518062001280b321a2e676f6f" .
+ "676c652e70726f746f6275662e4c69737456616c7565480042060a046b69" .
+ "6e6422330a094c69737456616c756512260a0676616c7565731801200328" .
+ "0b32162e676f6f676c652e70726f746f6275662e56616c75652a1b0a094e" .
+ "756c6c56616c7565120e0a0a4e554c4c5f56414c554510004281010a1363" .
+ "6f6d2e676f6f676c652e70726f746f627566420b53747275637450726f74" .
+ "6f50015a316769746875622e636f6d2f676f6c616e672f70726f746f6275" .
+ "662f7074797065732f7374727563743b7374727563747062f80101a20203" .
+ "475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f77" .
+ "6e5479706573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/Type.php b/php/src/GPBMetadata/Google/Protobuf/Type.php
new file mode 100644
index 00000000..8fbe8cbf
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/Type.php
@@ -0,0 +1,78 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class Type
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ \GPBMetadata\Google\Protobuf\Any::initOnce();
+ \GPBMetadata\Google\Protobuf\SourceContext::initOnce();
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0a9f0c0a1a676f6f676c652f70726f746f6275662f747970652e70726f74" .
+ "6f120f676f6f676c652e70726f746f6275661a24676f6f676c652f70726f" .
+ "746f6275662f736f757263655f636f6e746578742e70726f746f22d7010a" .
+ "0454797065120c0a046e616d6518012001280912260a066669656c647318" .
+ "022003280b32162e676f6f676c652e70726f746f6275662e4669656c6412" .
+ "0e0a066f6e656f667318032003280912280a076f7074696f6e7318042003" .
+ "280b32172e676f6f676c652e70726f746f6275662e4f7074696f6e12360a" .
+ "0e736f757263655f636f6e7465787418052001280b321e2e676f6f676c65" .
+ "2e70726f746f6275662e536f75726365436f6e7465787412270a0673796e" .
+ "74617818062001280e32172e676f6f676c652e70726f746f6275662e5379" .
+ "6e74617822d5050a054669656c6412290a046b696e6418012001280e321b" .
+ "2e676f6f676c652e70726f746f6275662e4669656c642e4b696e6412370a" .
+ "0b63617264696e616c69747918022001280e32222e676f6f676c652e7072" .
+ "6f746f6275662e4669656c642e43617264696e616c697479120e0a066e75" .
+ "6d626572180320012805120c0a046e616d6518042001280912100a087479" .
+ "70655f75726c18062001280912130a0b6f6e656f665f696e646578180720" .
+ "012805120e0a067061636b656418082001280812280a076f7074696f6e73" .
+ "18092003280b32172e676f6f676c652e70726f746f6275662e4f7074696f" .
+ "6e12110a096a736f6e5f6e616d65180a2001280912150a0d64656661756c" .
+ "745f76616c7565180b2001280922c8020a044b696e6412100a0c54595045" .
+ "5f554e4b4e4f574e1000120f0a0b545950455f444f55424c451001120e0a" .
+ "0a545950455f464c4f41541002120e0a0a545950455f494e543634100312" .
+ "0f0a0b545950455f55494e5436341004120e0a0a545950455f494e543332" .
+ "100512100a0c545950455f46495845443634100612100a0c545950455f46" .
+ "4958454433321007120d0a09545950455f424f4f4c1008120f0a0b545950" .
+ "455f535452494e471009120e0a0a545950455f47524f5550100a12100a0c" .
+ "545950455f4d455353414745100b120e0a0a545950455f4259544553100c" .
+ "120f0a0b545950455f55494e543332100d120d0a09545950455f454e554d" .
+ "100e12110a0d545950455f5346495845443332100f12110a0d545950455f" .
+ "53464958454436341010120f0a0b545950455f53494e5433321011120f0a" .
+ "0b545950455f53494e543634101222740a0b43617264696e616c69747912" .
+ "170a1343415244494e414c4954595f554e4b4e4f574e100012180a144341" .
+ "5244494e414c4954595f4f5054494f4e414c100112180a1443415244494e" .
+ "414c4954595f5245515549524544100212180a1443415244494e414c4954" .
+ "595f5245504541544544100322ce010a04456e756d120c0a046e616d6518" .
+ "0120012809122d0a09656e756d76616c756518022003280b321a2e676f6f" .
+ "676c652e70726f746f6275662e456e756d56616c756512280a076f707469" .
+ "6f6e7318032003280b32172e676f6f676c652e70726f746f6275662e4f70" .
+ "74696f6e12360a0e736f757263655f636f6e7465787418042001280b321e" .
+ "2e676f6f676c652e70726f746f6275662e536f75726365436f6e74657874" .
+ "12270a0673796e74617818052001280e32172e676f6f676c652e70726f74" .
+ "6f6275662e53796e74617822530a09456e756d56616c7565120c0a046e61" .
+ "6d65180120012809120e0a066e756d62657218022001280512280a076f70" .
+ "74696f6e7318032003280b32172e676f6f676c652e70726f746f6275662e" .
+ "4f7074696f6e223b0a064f7074696f6e120c0a046e616d65180120012809" .
+ "12230a0576616c756518022001280b32142e676f6f676c652e70726f746f" .
+ "6275662e416e792a2e0a0653796e74617812110a0d53594e5441585f5052" .
+ "4f544f32100012110a0d53594e5441585f50524f544f331001427d0a1363" .
+ "6f6d2e676f6f676c652e70726f746f62756642095479706550726f746f50" .
+ "015a2f676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" .
+ "70726f746f6275662f70747970653b7074797065f80101a20203475042aa" .
+ "021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e547970" .
+ "6573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/GPBMetadata/Google/Protobuf/Wrappers.php b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php
new file mode 100644
index 00000000..dd72ff48
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/Wrappers.php
@@ -0,0 +1,38 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace GPBMetadata\Google\Protobuf;
+
+class Wrappers
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->internalAddGeneratedFile(hex2bin(
+ "0abf030a1e676f6f676c652f70726f746f6275662f77726170706572732e" .
+ "70726f746f120f676f6f676c652e70726f746f627566221c0a0b446f7562" .
+ "6c6556616c7565120d0a0576616c7565180120012801221b0a0a466c6f61" .
+ "7456616c7565120d0a0576616c7565180120012802221b0a0a496e743634" .
+ "56616c7565120d0a0576616c7565180120012803221c0a0b55496e743634" .
+ "56616c7565120d0a0576616c7565180120012804221b0a0a496e74333256" .
+ "616c7565120d0a0576616c7565180120012805221c0a0b55496e74333256" .
+ "616c7565120d0a0576616c756518012001280d221a0a09426f6f6c56616c" .
+ "7565120d0a0576616c7565180120012808221c0a0b537472696e6756616c" .
+ "7565120d0a0576616c7565180120012809221b0a0a427974657356616c75" .
+ "65120d0a0576616c756518012001280c427c0a13636f6d2e676f6f676c65" .
+ "2e70726f746f627566420d577261707065727350726f746f50015a2a6769" .
+ "746875622e636f6d2f676f6c616e672f70726f746f6275662f7074797065" .
+ "732f7772617070657273f80101a20203475042aa021e476f6f676c652e50" .
+ "726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33"
+ ));
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php
new file mode 100644
index 00000000..d0dda3cd
--- /dev/null
+++ b/php/src/Google/Protobuf/Api.php
@@ -0,0 +1,310 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/api.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Api is a light-weight descriptor for an API Interface.
+ * Interfaces are also described as "protocol buffer services" in some contexts,
+ * such as by the "service" keyword in a .proto file, but they are different
+ * from API Services, which represent a concrete implementation of an interface
+ * as opposed to simply a description of methods and bindings. They are also
+ * sometimes simply referred to as "APIs" in other contexts, such as the name of
+ * this message itself. See https://cloud.google.com/apis/design/glossary for
+ * detailed terminology.
+ *
+ * Generated from protobuf message <code>google.protobuf.Api</code>
+ */
+class Api extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The fully qualified name of this interface, including package name
+ * followed by the interface's simple name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * The methods of this interface, in unspecified order.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Method methods = 2;</code>
+ */
+ private $methods;
+ /**
+ * Any metadata attached to the interface.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ */
+ private $options;
+ /**
+ * A version string for this interface. If specified, must have the form
+ * `major-version.minor-version`, as in `1.10`. If the minor version is
+ * omitted, it defaults to zero. If the entire version field is empty, the
+ * major version is derived from the package name, as outlined below. If the
+ * field is not empty, the version in the package name will be verified to be
+ * consistent with what is provided here.
+ * The versioning schema uses [semantic
+ * versioning](http://semver.org) where the major version number
+ * indicates a breaking change and the minor version an additive,
+ * non-breaking change. Both version numbers are signals to users
+ * what to expect from different versions, and should be carefully
+ * chosen based on the product plan.
+ * The major version is also reflected in the package name of the
+ * interface, which must end in `v<major-version>`, as in
+ * `google.feature.v1`. For major versions 0 and 1, the suffix can
+ * be omitted. Zero major versions must only be used for
+ * experimental, non-GA interfaces.
+ *
+ * Generated from protobuf field <code>string version = 4;</code>
+ */
+ private $version = '';
+ /**
+ * Source context for the protocol buffer service represented by this
+ * message.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ */
+ private $source_context = null;
+ /**
+ * Included interfaces. See [Mixin][].
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Mixin mixins = 6;</code>
+ */
+ private $mixins;
+ /**
+ * The source syntax of the service.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ */
+ private $syntax = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Api::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The fully qualified name of this interface, including package name
+ * followed by the interface's simple name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The fully qualified name of this interface, including package name
+ * followed by the interface's simple name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * The methods of this interface, in unspecified order.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Method methods = 2;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getMethods()
+ {
+ return $this->methods;
+ }
+
+ /**
+ * The methods of this interface, in unspecified order.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Method methods = 2;</code>
+ * @param \Google\Protobuf\Method[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setMethods($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Method::class);
+ $this->methods = $arr;
+
+ return $this;
+ }
+
+ /**
+ * Any metadata attached to the interface.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Any metadata attached to the interface.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+ /**
+ * A version string for this interface. If specified, must have the form
+ * `major-version.minor-version`, as in `1.10`. If the minor version is
+ * omitted, it defaults to zero. If the entire version field is empty, the
+ * major version is derived from the package name, as outlined below. If the
+ * field is not empty, the version in the package name will be verified to be
+ * consistent with what is provided here.
+ * The versioning schema uses [semantic
+ * versioning](http://semver.org) where the major version number
+ * indicates a breaking change and the minor version an additive,
+ * non-breaking change. Both version numbers are signals to users
+ * what to expect from different versions, and should be carefully
+ * chosen based on the product plan.
+ * The major version is also reflected in the package name of the
+ * interface, which must end in `v<major-version>`, as in
+ * `google.feature.v1`. For major versions 0 and 1, the suffix can
+ * be omitted. Zero major versions must only be used for
+ * experimental, non-GA interfaces.
+ *
+ * Generated from protobuf field <code>string version = 4;</code>
+ * @return string
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * A version string for this interface. If specified, must have the form
+ * `major-version.minor-version`, as in `1.10`. If the minor version is
+ * omitted, it defaults to zero. If the entire version field is empty, the
+ * major version is derived from the package name, as outlined below. If the
+ * field is not empty, the version in the package name will be verified to be
+ * consistent with what is provided here.
+ * The versioning schema uses [semantic
+ * versioning](http://semver.org) where the major version number
+ * indicates a breaking change and the minor version an additive,
+ * non-breaking change. Both version numbers are signals to users
+ * what to expect from different versions, and should be carefully
+ * chosen based on the product plan.
+ * The major version is also reflected in the package name of the
+ * interface, which must end in `v<major-version>`, as in
+ * `google.feature.v1`. For major versions 0 and 1, the suffix can
+ * be omitted. Zero major versions must only be used for
+ * experimental, non-GA interfaces.
+ *
+ * Generated from protobuf field <code>string version = 4;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setVersion($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->version = $var;
+
+ return $this;
+ }
+
+ /**
+ * Source context for the protocol buffer service represented by this
+ * message.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ * @return \Google\Protobuf\SourceContext
+ */
+ public function getSourceContext()
+ {
+ return $this->source_context;
+ }
+
+ /**
+ * Source context for the protocol buffer service represented by this
+ * message.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ * @param \Google\Protobuf\SourceContext $var
+ * @return $this
+ */
+ public function setSourceContext($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class);
+ $this->source_context = $var;
+
+ return $this;
+ }
+
+ /**
+ * Included interfaces. See [Mixin][].
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Mixin mixins = 6;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getMixins()
+ {
+ return $this->mixins;
+ }
+
+ /**
+ * Included interfaces. See [Mixin][].
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Mixin mixins = 6;</code>
+ * @param \Google\Protobuf\Mixin[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setMixins($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Mixin::class);
+ $this->mixins = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The source syntax of the service.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ * @return int
+ */
+ public function getSyntax()
+ {
+ return $this->syntax;
+ }
+
+ /**
+ * The source syntax of the service.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setSyntax($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class);
+ $this->syntax = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/BoolValue.php b/php/src/Google/Protobuf/BoolValue.php
new file mode 100644
index 00000000..c28bf941
--- /dev/null
+++ b/php/src/Google/Protobuf/BoolValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `bool`.
+ * The JSON representation for `BoolValue` is JSON `true` and `false`.
+ *
+ * Generated from protobuf message <code>google.protobuf.BoolValue</code>
+ */
+class BoolValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The bool value.
+ *
+ * Generated from protobuf field <code>bool value = 1;</code>
+ */
+ private $value = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The bool value.
+ *
+ * Generated from protobuf field <code>bool value = 1;</code>
+ * @return bool
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The bool value.
+ *
+ * Generated from protobuf field <code>bool value = 1;</code>
+ * @param bool $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/BytesValue.php b/php/src/Google/Protobuf/BytesValue.php
new file mode 100644
index 00000000..d6a6b2e6
--- /dev/null
+++ b/php/src/Google/Protobuf/BytesValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `bytes`.
+ * The JSON representation for `BytesValue` is JSON string.
+ *
+ * Generated from protobuf message <code>google.protobuf.BytesValue</code>
+ */
+class BytesValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The bytes value.
+ *
+ * Generated from protobuf field <code>bytes value = 1;</code>
+ */
+ private $value = '';
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The bytes value.
+ *
+ * Generated from protobuf field <code>bytes value = 1;</code>
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The bytes value.
+ *
+ * Generated from protobuf field <code>bytes value = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/DoubleValue.php b/php/src/Google/Protobuf/DoubleValue.php
new file mode 100644
index 00000000..6718ce3c
--- /dev/null
+++ b/php/src/Google/Protobuf/DoubleValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `double`.
+ * The JSON representation for `DoubleValue` is JSON number.
+ *
+ * Generated from protobuf message <code>google.protobuf.DoubleValue</code>
+ */
+class DoubleValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The double value.
+ *
+ * Generated from protobuf field <code>double value = 1;</code>
+ */
+ private $value = 0.0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The double value.
+ *
+ * Generated from protobuf field <code>double value = 1;</code>
+ * @return float
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The double value.
+ *
+ * Generated from protobuf field <code>double value = 1;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php
new file mode 100644
index 00000000..c63efc74
--- /dev/null
+++ b/php/src/Google/Protobuf/Enum.php
@@ -0,0 +1,185 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Enum type definition.
+ *
+ * Generated from protobuf message <code>google.protobuf.Enum</code>
+ */
+class Enum extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Enum type name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * Enum value definitions.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.EnumValue enumvalue = 2;</code>
+ */
+ private $enumvalue;
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ */
+ private $options;
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 4;</code>
+ */
+ private $source_context = null;
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 5;</code>
+ */
+ private $syntax = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Enum type name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Enum type name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * Enum value definitions.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.EnumValue enumvalue = 2;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getEnumvalue()
+ {
+ return $this->enumvalue;
+ }
+
+ /**
+ * Enum value definitions.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.EnumValue enumvalue = 2;</code>
+ * @param \Google\Protobuf\EnumValue[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setEnumvalue($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\EnumValue::class);
+ $this->enumvalue = $arr;
+
+ return $this;
+ }
+
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 4;</code>
+ * @return \Google\Protobuf\SourceContext
+ */
+ public function getSourceContext()
+ {
+ return $this->source_context;
+ }
+
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 4;</code>
+ * @param \Google\Protobuf\SourceContext $var
+ * @return $this
+ */
+ public function setSourceContext($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class);
+ $this->source_context = $var;
+
+ return $this;
+ }
+
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 5;</code>
+ * @return int
+ */
+ public function getSyntax()
+ {
+ return $this->syntax;
+ }
+
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 5;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setSyntax($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class);
+ $this->syntax = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/EnumValue.php b/php/src/Google/Protobuf/EnumValue.php
new file mode 100644
index 00000000..e102c29f
--- /dev/null
+++ b/php/src/Google/Protobuf/EnumValue.php
@@ -0,0 +1,121 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Enum value definition.
+ *
+ * Generated from protobuf message <code>google.protobuf.EnumValue</code>
+ */
+class EnumValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Enum value name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * Enum value number.
+ *
+ * Generated from protobuf field <code>int32 number = 2;</code>
+ */
+ private $number = 0;
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ */
+ private $options;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Enum value name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Enum value name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * Enum value number.
+ *
+ * Generated from protobuf field <code>int32 number = 2;</code>
+ * @return int
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * Enum value number.
+ *
+ * Generated from protobuf field <code>int32 number = 2;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setNumber($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->number = $var;
+
+ return $this;
+ }
+
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 3;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Field.php b/php/src/Google/Protobuf/Field.php
new file mode 100644
index 00000000..0b560d89
--- /dev/null
+++ b/php/src/Google/Protobuf/Field.php
@@ -0,0 +1,351 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * A single field of a message type.
+ *
+ * Generated from protobuf message <code>google.protobuf.Field</code>
+ */
+class Field extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The field type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Kind kind = 1;</code>
+ */
+ private $kind = 0;
+ /**
+ * The field cardinality.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Cardinality cardinality = 2;</code>
+ */
+ private $cardinality = 0;
+ /**
+ * The field number.
+ *
+ * Generated from protobuf field <code>int32 number = 3;</code>
+ */
+ private $number = 0;
+ /**
+ * The field name.
+ *
+ * Generated from protobuf field <code>string name = 4;</code>
+ */
+ private $name = '';
+ /**
+ * The field type URL, without the scheme, for message or enumeration
+ * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ *
+ * Generated from protobuf field <code>string type_url = 6;</code>
+ */
+ private $type_url = '';
+ /**
+ * The index of the field type in `Type.oneofs`, for message or enumeration
+ * types. The first type has index 1; zero means the type is not in the list.
+ *
+ * Generated from protobuf field <code>int32 oneof_index = 7;</code>
+ */
+ private $oneof_index = 0;
+ /**
+ * Whether to use alternative packed wire representation.
+ *
+ * Generated from protobuf field <code>bool packed = 8;</code>
+ */
+ private $packed = false;
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 9;</code>
+ */
+ private $options;
+ /**
+ * The field JSON name.
+ *
+ * Generated from protobuf field <code>string json_name = 10;</code>
+ */
+ private $json_name = '';
+ /**
+ * The string value of the default value of this field. Proto2 syntax only.
+ *
+ * Generated from protobuf field <code>string default_value = 11;</code>
+ */
+ private $default_value = '';
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The field type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Kind kind = 1;</code>
+ * @return int
+ */
+ public function getKind()
+ {
+ return $this->kind;
+ }
+
+ /**
+ * The field type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Kind kind = 1;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setKind($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Field_Kind::class);
+ $this->kind = $var;
+
+ return $this;
+ }
+
+ /**
+ * The field cardinality.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Cardinality cardinality = 2;</code>
+ * @return int
+ */
+ public function getCardinality()
+ {
+ return $this->cardinality;
+ }
+
+ /**
+ * The field cardinality.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Field.Cardinality cardinality = 2;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setCardinality($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Field_Cardinality::class);
+ $this->cardinality = $var;
+
+ return $this;
+ }
+
+ /**
+ * The field number.
+ *
+ * Generated from protobuf field <code>int32 number = 3;</code>
+ * @return int
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * The field number.
+ *
+ * Generated from protobuf field <code>int32 number = 3;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setNumber($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->number = $var;
+
+ return $this;
+ }
+
+ /**
+ * The field name.
+ *
+ * Generated from protobuf field <code>string name = 4;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The field name.
+ *
+ * Generated from protobuf field <code>string name = 4;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * The field type URL, without the scheme, for message or enumeration
+ * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ *
+ * Generated from protobuf field <code>string type_url = 6;</code>
+ * @return string
+ */
+ public function getTypeUrl()
+ {
+ return $this->type_url;
+ }
+
+ /**
+ * The field type URL, without the scheme, for message or enumeration
+ * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ *
+ * Generated from protobuf field <code>string type_url = 6;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setTypeUrl($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->type_url = $var;
+
+ return $this;
+ }
+
+ /**
+ * The index of the field type in `Type.oneofs`, for message or enumeration
+ * types. The first type has index 1; zero means the type is not in the list.
+ *
+ * Generated from protobuf field <code>int32 oneof_index = 7;</code>
+ * @return int
+ */
+ public function getOneofIndex()
+ {
+ return $this->oneof_index;
+ }
+
+ /**
+ * The index of the field type in `Type.oneofs`, for message or enumeration
+ * types. The first type has index 1; zero means the type is not in the list.
+ *
+ * Generated from protobuf field <code>int32 oneof_index = 7;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setOneofIndex($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->oneof_index = $var;
+
+ return $this;
+ }
+
+ /**
+ * Whether to use alternative packed wire representation.
+ *
+ * Generated from protobuf field <code>bool packed = 8;</code>
+ * @return bool
+ */
+ public function getPacked()
+ {
+ return $this->packed;
+ }
+
+ /**
+ * Whether to use alternative packed wire representation.
+ *
+ * Generated from protobuf field <code>bool packed = 8;</code>
+ * @param bool $var
+ * @return $this
+ */
+ public function setPacked($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->packed = $var;
+
+ return $this;
+ }
+
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 9;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 9;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The field JSON name.
+ *
+ * Generated from protobuf field <code>string json_name = 10;</code>
+ * @return string
+ */
+ public function getJsonName()
+ {
+ return $this->json_name;
+ }
+
+ /**
+ * The field JSON name.
+ *
+ * Generated from protobuf field <code>string json_name = 10;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setJsonName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->json_name = $var;
+
+ return $this;
+ }
+
+ /**
+ * The string value of the default value of this field. Proto2 syntax only.
+ *
+ * Generated from protobuf field <code>string default_value = 11;</code>
+ * @return string
+ */
+ public function getDefaultValue()
+ {
+ return $this->default_value;
+ }
+
+ /**
+ * The string value of the default value of this field. Proto2 syntax only.
+ *
+ * Generated from protobuf field <code>string default_value = 11;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setDefaultValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->default_value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/FieldMask.php b/php/src/Google/Protobuf/FieldMask.php
new file mode 100644
index 00000000..e18586af
--- /dev/null
+++ b/php/src/Google/Protobuf/FieldMask.php
@@ -0,0 +1,209 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/field_mask.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * `FieldMask` represents a set of symbolic field paths, for example:
+ * paths: "f.a"
+ * paths: "f.b.d"
+ * Here `f` represents a field in some root message, `a` and `b`
+ * fields in the message found in `f`, and `d` a field found in the
+ * message in `f.b`.
+ * Field masks are used to specify a subset of fields that should be
+ * returned by a get operation or modified by an update operation.
+ * Field masks also have a custom JSON encoding (see below).
+ * # Field Masks in Projections
+ * When used in the context of a projection, a response message or
+ * sub-message is filtered by the API to only contain those fields as
+ * specified in the mask. For example, if the mask in the previous
+ * example is applied to a response message as follows:
+ * f {
+ * a : 22
+ * b {
+ * d : 1
+ * x : 2
+ * }
+ * y : 13
+ * }
+ * z: 8
+ * The result will not contain specific values for fields x,y and z
+ * (their value will be set to the default, and omitted in proto text
+ * output):
+ * f {
+ * a : 22
+ * b {
+ * d : 1
+ * }
+ * }
+ * A repeated field is not allowed except at the last position of a
+ * paths string.
+ * If a FieldMask object is not present in a get operation, the
+ * operation applies to all fields (as if a FieldMask of all fields
+ * had been specified).
+ * Note that a field mask does not necessarily apply to the
+ * top-level response message. In case of a REST get operation, the
+ * field mask applies directly to the response, but in case of a REST
+ * list operation, the mask instead applies to each individual message
+ * in the returned resource list. In case of a REST custom method,
+ * other definitions may be used. Where the mask applies will be
+ * clearly documented together with its declaration in the API. In
+ * any case, the effect on the returned resource/resources is required
+ * behavior for APIs.
+ * # Field Masks in Update Operations
+ * A field mask in update operations specifies which fields of the
+ * targeted resource are going to be updated. The API is required
+ * to only change the values of the fields as specified in the mask
+ * and leave the others untouched. If a resource is passed in to
+ * describe the updated values, the API ignores the values of all
+ * fields not covered by the mask.
+ * If a repeated field is specified for an update operation, the existing
+ * repeated values in the target resource will be overwritten by the new values.
+ * Note that a repeated field is only allowed in the last position of a `paths`
+ * string.
+ * If a sub-message is specified in the last position of the field mask for an
+ * update operation, then the existing sub-message in the target resource is
+ * overwritten. Given the target message:
+ * f {
+ * b {
+ * d : 1
+ * x : 2
+ * }
+ * c : 1
+ * }
+ * And an update message:
+ * f {
+ * b {
+ * d : 10
+ * }
+ * }
+ * then if the field mask is:
+ * paths: "f.b"
+ * then the result will be:
+ * f {
+ * b {
+ * d : 10
+ * }
+ * c : 1
+ * }
+ * However, if the update mask was:
+ * paths: "f.b.d"
+ * then the result would be:
+ * f {
+ * b {
+ * d : 10
+ * x : 2
+ * }
+ * c : 1
+ * }
+ * In order to reset a field's value to the default, the field must
+ * be in the mask and set to the default value in the provided resource.
+ * Hence, in order to reset all fields of a resource, provide a default
+ * instance of the resource and set all fields in the mask, or do
+ * not provide a mask as described below.
+ * If a field mask is not present on update, the operation applies to
+ * all fields (as if a field mask of all fields has been specified).
+ * Note that in the presence of schema evolution, this may mean that
+ * fields the client does not know and has therefore not filled into
+ * the request will be reset to their default. If this is unwanted
+ * behavior, a specific service may require a client to always specify
+ * a field mask, producing an error if not.
+ * As with get operations, the location of the resource which
+ * describes the updated values in the request message depends on the
+ * operation kind. In any case, the effect of the field mask is
+ * required to be honored by the API.
+ * ## Considerations for HTTP REST
+ * The HTTP kind of an update operation which uses a field mask must
+ * be set to PATCH instead of PUT in order to satisfy HTTP semantics
+ * (PUT must only be used for full updates).
+ * # JSON Encoding of Field Masks
+ * In JSON, a field mask is encoded as a single string where paths are
+ * separated by a comma. Fields name in each path are converted
+ * to/from lower-camel naming conventions.
+ * As an example, consider the following message declarations:
+ * message Profile {
+ * User user = 1;
+ * Photo photo = 2;
+ * }
+ * message User {
+ * string display_name = 1;
+ * string address = 2;
+ * }
+ * In proto a field mask for `Profile` may look as such:
+ * mask {
+ * paths: "user.display_name"
+ * paths: "photo"
+ * }
+ * In JSON, the same mask is represented as below:
+ * {
+ * mask: "user.displayName,photo"
+ * }
+ * # Field Masks and Oneof Fields
+ * Field masks treat fields in oneofs just as regular fields. Consider the
+ * following message:
+ * message SampleMessage {
+ * oneof test_oneof {
+ * string name = 4;
+ * SubMessage sub_message = 9;
+ * }
+ * }
+ * The field mask can be:
+ * mask {
+ * paths: "name"
+ * }
+ * Or:
+ * mask {
+ * paths: "sub_message"
+ * }
+ * Note that oneof type names ("test_oneof" in this case) cannot be used in
+ * paths.
+ *
+ * Generated from protobuf message <code>google.protobuf.FieldMask</code>
+ */
+class FieldMask extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The set of field mask paths.
+ *
+ * Generated from protobuf field <code>repeated string paths = 1;</code>
+ */
+ private $paths;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\FieldMask::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The set of field mask paths.
+ *
+ * Generated from protobuf field <code>repeated string paths = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getPaths()
+ {
+ return $this->paths;
+ }
+
+ /**
+ * The set of field mask paths.
+ *
+ * Generated from protobuf field <code>repeated string paths = 1;</code>
+ * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setPaths($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->paths = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Field_Cardinality.php b/php/src/Google/Protobuf/Field_Cardinality.php
new file mode 100644
index 00000000..422587ca
--- /dev/null
+++ b/php/src/Google/Protobuf/Field_Cardinality.php
@@ -0,0 +1,39 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+/**
+ * Whether a field is optional, required, or repeated.
+ *
+ * Protobuf enum <code>Google\Protobuf\Field\Cardinality</code>
+ */
+class Field_Cardinality
+{
+ /**
+ * For fields with unknown cardinality.
+ *
+ * Generated from protobuf enum <code>CARDINALITY_UNKNOWN = 0;</code>
+ */
+ const CARDINALITY_UNKNOWN = 0;
+ /**
+ * For optional fields.
+ *
+ * Generated from protobuf enum <code>CARDINALITY_OPTIONAL = 1;</code>
+ */
+ const CARDINALITY_OPTIONAL = 1;
+ /**
+ * For required fields. Proto2 syntax only.
+ *
+ * Generated from protobuf enum <code>CARDINALITY_REQUIRED = 2;</code>
+ */
+ const CARDINALITY_REQUIRED = 2;
+ /**
+ * For repeated fields.
+ *
+ * Generated from protobuf enum <code>CARDINALITY_REPEATED = 3;</code>
+ */
+ const CARDINALITY_REPEATED = 3;
+}
+
diff --git a/php/src/Google/Protobuf/Field_Kind.php b/php/src/Google/Protobuf/Field_Kind.php
new file mode 100644
index 00000000..d0774970
--- /dev/null
+++ b/php/src/Google/Protobuf/Field_Kind.php
@@ -0,0 +1,129 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+/**
+ * Basic field types.
+ *
+ * Protobuf enum <code>Google\Protobuf\Field\Kind</code>
+ */
+class Field_Kind
+{
+ /**
+ * Field type unknown.
+ *
+ * Generated from protobuf enum <code>TYPE_UNKNOWN = 0;</code>
+ */
+ const TYPE_UNKNOWN = 0;
+ /**
+ * Field type double.
+ *
+ * Generated from protobuf enum <code>TYPE_DOUBLE = 1;</code>
+ */
+ const TYPE_DOUBLE = 1;
+ /**
+ * Field type float.
+ *
+ * Generated from protobuf enum <code>TYPE_FLOAT = 2;</code>
+ */
+ const TYPE_FLOAT = 2;
+ /**
+ * Field type int64.
+ *
+ * Generated from protobuf enum <code>TYPE_INT64 = 3;</code>
+ */
+ const TYPE_INT64 = 3;
+ /**
+ * Field type uint64.
+ *
+ * Generated from protobuf enum <code>TYPE_UINT64 = 4;</code>
+ */
+ const TYPE_UINT64 = 4;
+ /**
+ * Field type int32.
+ *
+ * Generated from protobuf enum <code>TYPE_INT32 = 5;</code>
+ */
+ const TYPE_INT32 = 5;
+ /**
+ * Field type fixed64.
+ *
+ * Generated from protobuf enum <code>TYPE_FIXED64 = 6;</code>
+ */
+ const TYPE_FIXED64 = 6;
+ /**
+ * Field type fixed32.
+ *
+ * Generated from protobuf enum <code>TYPE_FIXED32 = 7;</code>
+ */
+ const TYPE_FIXED32 = 7;
+ /**
+ * Field type bool.
+ *
+ * Generated from protobuf enum <code>TYPE_BOOL = 8;</code>
+ */
+ const TYPE_BOOL = 8;
+ /**
+ * Field type string.
+ *
+ * Generated from protobuf enum <code>TYPE_STRING = 9;</code>
+ */
+ const TYPE_STRING = 9;
+ /**
+ * Field type group. Proto2 syntax only, and deprecated.
+ *
+ * Generated from protobuf enum <code>TYPE_GROUP = 10;</code>
+ */
+ const TYPE_GROUP = 10;
+ /**
+ * Field type message.
+ *
+ * Generated from protobuf enum <code>TYPE_MESSAGE = 11;</code>
+ */
+ const TYPE_MESSAGE = 11;
+ /**
+ * Field type bytes.
+ *
+ * Generated from protobuf enum <code>TYPE_BYTES = 12;</code>
+ */
+ const TYPE_BYTES = 12;
+ /**
+ * Field type uint32.
+ *
+ * Generated from protobuf enum <code>TYPE_UINT32 = 13;</code>
+ */
+ const TYPE_UINT32 = 13;
+ /**
+ * Field type enum.
+ *
+ * Generated from protobuf enum <code>TYPE_ENUM = 14;</code>
+ */
+ const TYPE_ENUM = 14;
+ /**
+ * Field type sfixed32.
+ *
+ * Generated from protobuf enum <code>TYPE_SFIXED32 = 15;</code>
+ */
+ const TYPE_SFIXED32 = 15;
+ /**
+ * Field type sfixed64.
+ *
+ * Generated from protobuf enum <code>TYPE_SFIXED64 = 16;</code>
+ */
+ const TYPE_SFIXED64 = 16;
+ /**
+ * Field type sint32.
+ *
+ * Generated from protobuf enum <code>TYPE_SINT32 = 17;</code>
+ */
+ const TYPE_SINT32 = 17;
+ /**
+ * Field type sint64.
+ *
+ * Generated from protobuf enum <code>TYPE_SINT64 = 18;</code>
+ */
+ const TYPE_SINT64 = 18;
+}
+
diff --git a/php/src/Google/Protobuf/FloatValue.php b/php/src/Google/Protobuf/FloatValue.php
new file mode 100644
index 00000000..68787ef9
--- /dev/null
+++ b/php/src/Google/Protobuf/FloatValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `float`.
+ * The JSON representation for `FloatValue` is JSON number.
+ *
+ * Generated from protobuf message <code>google.protobuf.FloatValue</code>
+ */
+class FloatValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The float value.
+ *
+ * Generated from protobuf field <code>float value = 1;</code>
+ */
+ private $value = 0.0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The float value.
+ *
+ * Generated from protobuf field <code>float value = 1;</code>
+ * @return float
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The float value.
+ *
+ * Generated from protobuf field <code>float value = 1;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkFloat($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/GPBEmpty.php b/php/src/Google/Protobuf/GPBEmpty.php
new file mode 100644
index 00000000..24a93f96
--- /dev/null
+++ b/php/src/Google/Protobuf/GPBEmpty.php
@@ -0,0 +1,31 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/empty.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * A generic empty message that you can re-use to avoid defining duplicated
+ * empty messages in your APIs. A typical example is to use it as the request
+ * or the response type of an API method. For instance:
+ * service Foo {
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ * }
+ * The JSON representation for `Empty` is empty JSON object `{}`.
+ *
+ * Generated from protobuf message <code>google.protobuf.Empty</code>
+ */
+class GPBEmpty extends \Google\Protobuf\Internal\Message
+{
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\GPBEmpty::initOnce();
+ parent::__construct();
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Int32Value.php b/php/src/Google/Protobuf/Int32Value.php
new file mode 100644
index 00000000..d48aff1b
--- /dev/null
+++ b/php/src/Google/Protobuf/Int32Value.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `int32`.
+ * The JSON representation for `Int32Value` is JSON number.
+ *
+ * Generated from protobuf message <code>google.protobuf.Int32Value</code>
+ */
+class Int32Value extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The int32 value.
+ *
+ * Generated from protobuf field <code>int32 value = 1;</code>
+ */
+ private $value = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The int32 value.
+ *
+ * Generated from protobuf field <code>int32 value = 1;</code>
+ * @return int
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The int32 value.
+ *
+ * Generated from protobuf field <code>int32 value = 1;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Int64Value.php b/php/src/Google/Protobuf/Int64Value.php
new file mode 100644
index 00000000..a6fb9c5d
--- /dev/null
+++ b/php/src/Google/Protobuf/Int64Value.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `int64`.
+ * The JSON representation for `Int64Value` is JSON string.
+ *
+ * Generated from protobuf message <code>google.protobuf.Int64Value</code>
+ */
+class Int64Value extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The int64 value.
+ *
+ * Generated from protobuf field <code>int64 value = 1;</code>
+ */
+ private $value = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The int64 value.
+ *
+ * Generated from protobuf field <code>int64 value = 1;</code>
+ * @return int|string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The int64 value.
+ *
+ * Generated from protobuf field <code>int64 value = 1;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/CodedInputStream.php b/php/src/Google/Protobuf/Internal/CodedInputStream.php
index 6131d5d1..b612da5b 100644
--- a/php/src/Google/Protobuf/Internal/CodedInputStream.php
+++ b/php/src/Google/Protobuf/Internal/CodedInputStream.php
@@ -78,13 +78,18 @@ class CodedInputStream
return $this->buffer_end - $this->current;
}
- private function current()
+ public function current()
{
return $this->total_bytes_read -
($this->buffer_end - $this->current +
$this->buffer_size_after_limit);
}
+ public function substr($start, $end)
+ {
+ return substr($this->buffer, $start, $end - $start);
+ }
+
private function recomputeBufferLimits()
{
$this->buffer_end += $this->buffer_size_after_limit;
diff --git a/php/src/Google/Protobuf/Internal/CodedOutputStream.php b/php/src/Google/Protobuf/Internal/CodedOutputStream.php
index 4525d8dd..f75e9c66 100644
--- a/php/src/Google/Protobuf/Internal/CodedOutputStream.php
+++ b/php/src/Google/Protobuf/Internal/CodedOutputStream.php
@@ -101,7 +101,7 @@ class CodedOutputStream
return true;
}
- private static function writeVarintToArray($value, &$buffer, $trim = false)
+ public static function writeVarintToArray($value, &$buffer, $trim = false)
{
$current = 0;
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php
new file mode 100644
index 00000000..6b2449fa
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php
@@ -0,0 +1,109 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Range of reserved numeric values. Reserved values may not be used by
+ * entries in the same enum. Reserved ranges may not overlap.
+ * Note that this is distinct from DescriptorProto.ReservedRange in that it
+ * is inclusive such that it can appropriately represent the entire int32
+ * domain.
+ *
+ * Generated from protobuf message <code>google.protobuf.EnumDescriptorProto.EnumReservedRange</code>
+ */
+class EnumDescriptorProto_EnumReservedRange extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 start = 1;</code>
+ */
+ private $start = 0;
+ private $has_start = false;
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 end = 2;</code>
+ */
+ private $end = 0;
+ private $has_end = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 start = 1;</code>
+ * @return int
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 start = 1;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setStart($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->start = $var;
+ $this->has_start = true;
+
+ return $this;
+ }
+
+ public function hasStart()
+ {
+ return $this->has_start;
+ }
+
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 end = 2;</code>
+ * @return int
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+
+ /**
+ * Inclusive.
+ *
+ * Generated from protobuf field <code>optional int32 end = 2;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setEnd($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->end = $var;
+ $this->has_end = true;
+
+ return $this;
+ }
+
+ public function hasEnd()
+ {
+ return $this->has_end;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
new file mode 100644
index 00000000..ee9e38bb
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
@@ -0,0 +1,64 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>google.protobuf.ExtensionRangeOptions</code>
+ */
+class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The parser stores options it doesn't recognize here. See above.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The parser stores options it doesn't recognize here. See above.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * The parser stores options it doesn't recognize here. See above.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setUninterpretedOption($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $arr;
+ $this->has_uninterpreted_option = true;
+
+ return $this;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index a27220a0..7fa4a673 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -255,14 +255,29 @@ class GPBUtil
return $prefix;
}
- $reserved_words = array("Empty", "ECHO", "ARRAY");
- foreach ($reserved_words as $reserved_word) {
- if ($classname === $reserved_word) {
- if ($file_proto->getPackage() === "google.protobuf") {
- return "GPB";
- } else {
- return "PB";
- }
+ $reserved_words = array(
+ "abstract"=>0, "and"=>0, "array"=>0, "as"=>0, "break"=>0,
+ "callable"=>0, "case"=>0, "catch"=>0, "class"=>0, "clone"=>0,
+ "const"=>0, "continue"=>0, "declare"=>0, "default"=>0, "die"=>0,
+ "do"=>0, "echo"=>0, "else"=>0, "elseif"=>0, "empty"=>0,
+ "enddeclare"=>0, "endfor"=>0, "endforeach"=>0, "endif"=>0,
+ "endswitch"=>0, "endwhile"=>0, "eval"=>0, "exit"=>0, "extends"=>0,
+ "final"=>0, "for"=>0, "foreach"=>0, "function"=>0, "global"=>0,
+ "goto"=>0, "if"=>0, "implements"=>0, "include"=>0,
+ "include_once"=>0, "instanceof"=>0, "insteadof"=>0, "interface"=>0,
+ "isset"=>0, "list"=>0, "namespace"=>0, "new"=>0, "or"=>0,
+ "print"=>0, "private"=>0, "protected"=>0, "public"=>0, "require"=>0,
+ "require_once"=>0, "return"=>0, "static"=>0, "switch"=>0,
+ "throw"=>0, "trait"=>0, "try"=>0, "unset"=>0, "use"=>0, "var"=>0,
+ "while"=>0, "xor"=>0, "int"=>0, "float"=>0, "bool"=>0, "string"=>0,
+ "true"=>0, "false"=>0, "null"=>0, "void"=>0, "iterable"=>0
+ );
+
+ if (array_key_exists(strtolower($classname), $reserved_words)) {
+ if ($file_proto->getPackage() === "google.protobuf") {
+ return "GPB";
+ } else {
+ return "PB";
}
}
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index c0a3218b..b3c4e6f1 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -57,6 +57,7 @@ class Message
* @ignore
*/
private $desc;
+ private $unknown = "";
/**
* @ignore
@@ -226,13 +227,14 @@ class Message
/**
* @ignore
*/
- private static function skipField($input, $tag)
+ private function skipField($input, $tag)
{
$number = GPBWire::getTagFieldNumber($tag);
if ($number === 0) {
throw new GPBDecodeException("Illegal field number zero.");
}
+ $start = $input->current();
switch (GPBWire::getTagWireType($tag)) {
case GPBWireType::VARINT:
$uint64 = 0;
@@ -240,21 +242,21 @@ class Message
throw new GPBDecodeException(
"Unexpected EOF inside varint.");
}
- return;
+ break;
case GPBWireType::FIXED64:
$uint64 = 0;
if (!$input->readLittleEndian64($uint64)) {
throw new GPBDecodeException(
"Unexpected EOF inside fixed64.");
}
- return;
+ break;
case GPBWireType::FIXED32:
$uint32 = 0;
if (!$input->readLittleEndian32($uint32)) {
throw new GPBDecodeException(
"Unexpected EOF inside fixed32.");
}
- return;
+ break;
case GPBWireType::LENGTH_DELIMITED:
$length = 0;
if (!$input->readVarint32($length)) {
@@ -266,13 +268,18 @@ class Message
throw new GPBDecodeException(
"Unexpected EOF inside length delimited data.");
}
- return;
+ break;
case GPBWireType::START_GROUP:
case GPBWireType::END_GROUP:
throw new GPBDecodeException("Unexpected wire type.");
default:
throw new GPBDecodeException("Unexpected wire type.");
}
+ $end = $input->current();
+
+ $bytes = str_repeat(chr(0), CodedOutputStream::MAX_VARINT64_BYTES);
+ $size = CodedOutputStream::writeVarintToArray($tag, $bytes, true);
+ $this->unknown .= substr($bytes, 0, $size) . $input->substr($start, $end);
}
/**
@@ -423,7 +430,7 @@ class Message
}
if ($value_format === GPBWire::UNKNOWN) {
- self::skipField($input, $tag);
+ $this->skipField($input, $tag);
return;
} elseif ($value_format === GPBWire::NORMAL_FORMAT) {
self::parseFieldFromStreamNoTag($input, $field, $value);
@@ -461,6 +468,7 @@ class Message
*/
public function clear()
{
+ $this->unknown = "";
foreach ($this->desc->getField() as $field) {
$setter = $field->getSetter();
if ($field->isMap()) {
@@ -1043,6 +1051,7 @@ class Message
return false;
}
}
+ $output->writeRaw($this->unknown, strlen($this->unknown));
return true;
}
@@ -1428,6 +1437,7 @@ class Message
foreach ($fields as $field) {
$size += $this->fieldByteSize($field);
}
+ $size += strlen($this->unknown);
return $size;
}
diff --git a/php/src/Google/Protobuf/ListValue.php b/php/src/Google/Protobuf/ListValue.php
new file mode 100644
index 00000000..12552ef4
--- /dev/null
+++ b/php/src/Google/Protobuf/ListValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/struct.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * `ListValue` is a wrapper around a repeated field of values.
+ * The JSON representation for `ListValue` is JSON array.
+ *
+ * Generated from protobuf message <code>google.protobuf.ListValue</code>
+ */
+class ListValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Repeated field of dynamically typed values.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Value values = 1;</code>
+ */
+ private $values;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Struct::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Repeated field of dynamically typed values.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Value values = 1;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getValues()
+ {
+ return $this->values;
+ }
+
+ /**
+ * Repeated field of dynamically typed values.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Value values = 1;</code>
+ * @param \Google\Protobuf\Value[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setValues($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class);
+ $this->values = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Method.php b/php/src/Google/Protobuf/Method.php
new file mode 100644
index 00000000..f55cb764
--- /dev/null
+++ b/php/src/Google/Protobuf/Method.php
@@ -0,0 +1,249 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/api.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Method represents a method of an API interface.
+ *
+ * Generated from protobuf message <code>google.protobuf.Method</code>
+ */
+class Method extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The simple name of this method.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * A URL of the input message type.
+ *
+ * Generated from protobuf field <code>string request_type_url = 2;</code>
+ */
+ private $request_type_url = '';
+ /**
+ * If true, the request is streamed.
+ *
+ * Generated from protobuf field <code>bool request_streaming = 3;</code>
+ */
+ private $request_streaming = false;
+ /**
+ * The URL of the output message type.
+ *
+ * Generated from protobuf field <code>string response_type_url = 4;</code>
+ */
+ private $response_type_url = '';
+ /**
+ * If true, the response is streamed.
+ *
+ * Generated from protobuf field <code>bool response_streaming = 5;</code>
+ */
+ private $response_streaming = false;
+ /**
+ * Any metadata attached to the method.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 6;</code>
+ */
+ private $options;
+ /**
+ * The source syntax of this method.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ */
+ private $syntax = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Api::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The simple name of this method.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The simple name of this method.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * A URL of the input message type.
+ *
+ * Generated from protobuf field <code>string request_type_url = 2;</code>
+ * @return string
+ */
+ public function getRequestTypeUrl()
+ {
+ return $this->request_type_url;
+ }
+
+ /**
+ * A URL of the input message type.
+ *
+ * Generated from protobuf field <code>string request_type_url = 2;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setRequestTypeUrl($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->request_type_url = $var;
+
+ return $this;
+ }
+
+ /**
+ * If true, the request is streamed.
+ *
+ * Generated from protobuf field <code>bool request_streaming = 3;</code>
+ * @return bool
+ */
+ public function getRequestStreaming()
+ {
+ return $this->request_streaming;
+ }
+
+ /**
+ * If true, the request is streamed.
+ *
+ * Generated from protobuf field <code>bool request_streaming = 3;</code>
+ * @param bool $var
+ * @return $this
+ */
+ public function setRequestStreaming($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->request_streaming = $var;
+
+ return $this;
+ }
+
+ /**
+ * The URL of the output message type.
+ *
+ * Generated from protobuf field <code>string response_type_url = 4;</code>
+ * @return string
+ */
+ public function getResponseTypeUrl()
+ {
+ return $this->response_type_url;
+ }
+
+ /**
+ * The URL of the output message type.
+ *
+ * Generated from protobuf field <code>string response_type_url = 4;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setResponseTypeUrl($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->response_type_url = $var;
+
+ return $this;
+ }
+
+ /**
+ * If true, the response is streamed.
+ *
+ * Generated from protobuf field <code>bool response_streaming = 5;</code>
+ * @return bool
+ */
+ public function getResponseStreaming()
+ {
+ return $this->response_streaming;
+ }
+
+ /**
+ * If true, the response is streamed.
+ *
+ * Generated from protobuf field <code>bool response_streaming = 5;</code>
+ * @param bool $var
+ * @return $this
+ */
+ public function setResponseStreaming($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->response_streaming = $var;
+
+ return $this;
+ }
+
+ /**
+ * Any metadata attached to the method.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 6;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Any metadata attached to the method.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 6;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The source syntax of this method.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ * @return int
+ */
+ public function getSyntax()
+ {
+ return $this->syntax;
+ }
+
+ /**
+ * The source syntax of this method.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 7;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setSyntax($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class);
+ $this->syntax = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Mixin.php b/php/src/Google/Protobuf/Mixin.php
new file mode 100644
index 00000000..eb5117e0
--- /dev/null
+++ b/php/src/Google/Protobuf/Mixin.php
@@ -0,0 +1,153 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/api.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Declares an API Interface to be included in this interface. The including
+ * interface must redeclare all the methods from the included interface, but
+ * documentation and options are inherited as follows:
+ * - If after comment and whitespace stripping, the documentation
+ * string of the redeclared method is empty, it will be inherited
+ * from the original method.
+ * - Each annotation belonging to the service config (http,
+ * visibility) which is not set in the redeclared method will be
+ * inherited.
+ * - If an http annotation is inherited, the path pattern will be
+ * modified as follows. Any version prefix will be replaced by the
+ * version of the including interface plus the [root][] path if
+ * specified.
+ * Example of a simple mixin:
+ * package google.acl.v1;
+ * service AccessControl {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v1/{resource=**}:getAcl";
+ * }
+ * }
+ * package google.storage.v2;
+ * service Storage {
+ * rpc GetAcl(GetAclRequest) returns (Acl);
+ * // Get a data record.
+ * rpc GetData(GetDataRequest) returns (Data) {
+ * option (google.api.http).get = "/v2/{resource=**}";
+ * }
+ * }
+ * Example of a mixin configuration:
+ * apis:
+ * - name: google.storage.v2.Storage
+ * mixins:
+ * - name: google.acl.v1.AccessControl
+ * The mixin construct implies that all methods in `AccessControl` are
+ * also declared with same name and request/response types in
+ * `Storage`. A documentation generator or annotation processor will
+ * see the effective `Storage.GetAcl` method after inherting
+ * documentation and annotations as follows:
+ * service Storage {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v2/{resource=**}:getAcl";
+ * }
+ * ...
+ * }
+ * Note how the version in the path pattern changed from `v1` to `v2`.
+ * If the `root` field in the mixin is specified, it should be a
+ * relative path under which inherited HTTP paths are placed. Example:
+ * apis:
+ * - name: google.storage.v2.Storage
+ * mixins:
+ * - name: google.acl.v1.AccessControl
+ * root: acls
+ * This implies the following inherited HTTP annotation:
+ * service Storage {
+ * // Get the underlying ACL object.
+ * rpc GetAcl(GetAclRequest) returns (Acl) {
+ * option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
+ * }
+ * ...
+ * }
+ *
+ * Generated from protobuf message <code>google.protobuf.Mixin</code>
+ */
+class Mixin extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The fully qualified name of the interface which is included.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * If non-empty specifies a path under which inherited HTTP paths
+ * are rooted.
+ *
+ * Generated from protobuf field <code>string root = 2;</code>
+ */
+ private $root = '';
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Api::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The fully qualified name of the interface which is included.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The fully qualified name of the interface which is included.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * If non-empty specifies a path under which inherited HTTP paths
+ * are rooted.
+ *
+ * Generated from protobuf field <code>string root = 2;</code>
+ * @return string
+ */
+ public function getRoot()
+ {
+ return $this->root;
+ }
+
+ /**
+ * If non-empty specifies a path under which inherited HTTP paths
+ * are rooted.
+ *
+ * Generated from protobuf field <code>string root = 2;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setRoot($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->root = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/NullValue.php b/php/src/Google/Protobuf/NullValue.php
new file mode 100644
index 00000000..d4022ccc
--- /dev/null
+++ b/php/src/Google/Protobuf/NullValue.php
@@ -0,0 +1,23 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/struct.proto
+
+namespace Google\Protobuf;
+
+/**
+ * `NullValue` is a singleton enumeration to represent the null value for the
+ * `Value` type union.
+ * The JSON representation for `NullValue` is JSON `null`.
+ *
+ * Protobuf enum <code>Google\Protobuf\NullValue</code>
+ */
+class NullValue
+{
+ /**
+ * Null value.
+ *
+ * Generated from protobuf enum <code>NULL_VALUE = 0;</code>
+ */
+ const NULL_VALUE = 0;
+}
+
diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php
new file mode 100644
index 00000000..f8038681
--- /dev/null
+++ b/php/src/Google/Protobuf/Option.php
@@ -0,0 +1,108 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * A protocol buffer option, which can be attached to a message, field,
+ * enumeration, etc.
+ *
+ * Generated from protobuf message <code>google.protobuf.Option</code>
+ */
+class Option extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Any value = 2;</code>
+ */
+ private $value = null;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Any value = 2;</code>
+ * @return \Google\Protobuf\Any
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Any value = 2;</code>
+ * @param \Google\Protobuf\Any $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Any::class);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/SourceContext.php b/php/src/Google/Protobuf/SourceContext.php
new file mode 100644
index 00000000..07d90c68
--- /dev/null
+++ b/php/src/Google/Protobuf/SourceContext.php
@@ -0,0 +1,61 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/source_context.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * `SourceContext` represents information about the source of a
+ * protobuf element, like the file in which it is defined.
+ *
+ * Generated from protobuf message <code>google.protobuf.SourceContext</code>
+ */
+class SourceContext extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The path-qualified name of the .proto file that contained the associated
+ * protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ *
+ * Generated from protobuf field <code>string file_name = 1;</code>
+ */
+ private $file_name = '';
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\SourceContext::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The path-qualified name of the .proto file that contained the associated
+ * protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ *
+ * Generated from protobuf field <code>string file_name = 1;</code>
+ * @return string
+ */
+ public function getFileName()
+ {
+ return $this->file_name;
+ }
+
+ /**
+ * The path-qualified name of the .proto file that contained the associated
+ * protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ *
+ * Generated from protobuf field <code>string file_name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setFileName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->file_name = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/StringValue.php b/php/src/Google/Protobuf/StringValue.php
new file mode 100644
index 00000000..f6bcc48a
--- /dev/null
+++ b/php/src/Google/Protobuf/StringValue.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `string`.
+ * The JSON representation for `StringValue` is JSON string.
+ *
+ * Generated from protobuf message <code>google.protobuf.StringValue</code>
+ */
+class StringValue extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The string value.
+ *
+ * Generated from protobuf field <code>string value = 1;</code>
+ */
+ private $value = '';
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The string value.
+ *
+ * Generated from protobuf field <code>string value = 1;</code>
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The string value.
+ *
+ * Generated from protobuf field <code>string value = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Struct.php b/php/src/Google/Protobuf/Struct.php
new file mode 100644
index 00000000..721e991c
--- /dev/null
+++ b/php/src/Google/Protobuf/Struct.php
@@ -0,0 +1,63 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/struct.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * `Struct` represents a structured data value, consisting of fields
+ * which map to dynamically typed values. In some languages, `Struct`
+ * might be supported by a native representation. For example, in
+ * scripting languages like JS a struct is represented as an
+ * object. The details of that representation are described together
+ * with the proto support for the language.
+ * The JSON representation for `Struct` is JSON object.
+ *
+ * Generated from protobuf message <code>google.protobuf.Struct</code>
+ */
+class Struct extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Unordered map of dynamically typed values.
+ *
+ * Generated from protobuf field <code>map<string, .google.protobuf.Value> fields = 1;</code>
+ */
+ private $fields;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Struct::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Unordered map of dynamically typed values.
+ *
+ * Generated from protobuf field <code>map<string, .google.protobuf.Value> fields = 1;</code>
+ * @return \Google\Protobuf\Internal\MapField
+ */
+ public function getFields()
+ {
+ return $this->fields;
+ }
+
+ /**
+ * Unordered map of dynamically typed values.
+ *
+ * Generated from protobuf field <code>map<string, .google.protobuf.Value> fields = 1;</code>
+ * @param array|\Google\Protobuf\Internal\MapField $var
+ * @return $this
+ */
+ public function setFields($var)
+ {
+ $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Value::class);
+ $this->fields = $arr;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Syntax.php b/php/src/Google/Protobuf/Syntax.php
new file mode 100644
index 00000000..bb7b7896
--- /dev/null
+++ b/php/src/Google/Protobuf/Syntax.php
@@ -0,0 +1,27 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+/**
+ * The syntax in which a protocol buffer element is defined.
+ *
+ * Protobuf enum <code>Google\Protobuf\Syntax</code>
+ */
+class Syntax
+{
+ /**
+ * Syntax `proto2`.
+ *
+ * Generated from protobuf enum <code>SYNTAX_PROTO2 = 0;</code>
+ */
+ const SYNTAX_PROTO2 = 0;
+ /**
+ * Syntax `proto3`.
+ *
+ * Generated from protobuf enum <code>SYNTAX_PROTO3 = 1;</code>
+ */
+ const SYNTAX_PROTO3 = 1;
+}
+
diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php
new file mode 100644
index 00000000..7dbe2cab
--- /dev/null
+++ b/php/src/Google/Protobuf/Type.php
@@ -0,0 +1,217 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/type.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * A protocol buffer message type.
+ *
+ * Generated from protobuf message <code>google.protobuf.Type</code>
+ */
+class Type extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The fully qualified message name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ */
+ private $name = '';
+ /**
+ * The list of fields.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Field fields = 2;</code>
+ */
+ private $fields;
+ /**
+ * The list of types appearing in `oneof` definitions in this type.
+ *
+ * Generated from protobuf field <code>repeated string oneofs = 3;</code>
+ */
+ private $oneofs;
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 4;</code>
+ */
+ private $options;
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ */
+ private $source_context = null;
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 6;</code>
+ */
+ private $syntax = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Type::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The fully qualified message name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * The fully qualified message name.
+ *
+ * Generated from protobuf field <code>string name = 1;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+
+ return $this;
+ }
+
+ /**
+ * The list of fields.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Field fields = 2;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getFields()
+ {
+ return $this->fields;
+ }
+
+ /**
+ * The list of fields.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Field fields = 2;</code>
+ * @param \Google\Protobuf\Field[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setFields($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Field::class);
+ $this->fields = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The list of types appearing in `oneof` definitions in this type.
+ *
+ * Generated from protobuf field <code>repeated string oneofs = 3;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOneofs()
+ {
+ return $this->oneofs;
+ }
+
+ /**
+ * The list of types appearing in `oneof` definitions in this type.
+ *
+ * Generated from protobuf field <code>repeated string oneofs = 3;</code>
+ * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOneofs($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->oneofs = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 4;</code>
+ * @return \Google\Protobuf\Internal\RepeatedField
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * The protocol buffer options.
+ *
+ * Generated from protobuf field <code>repeated .google.protobuf.Option options = 4;</code>
+ * @param \Google\Protobuf\Option[]|\Google\Protobuf\Internal\RepeatedField $var
+ * @return $this
+ */
+ public function setOptions($var)
+ {
+ $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Option::class);
+ $this->options = $arr;
+
+ return $this;
+ }
+
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ * @return \Google\Protobuf\SourceContext
+ */
+ public function getSourceContext()
+ {
+ return $this->source_context;
+ }
+
+ /**
+ * The source context.
+ *
+ * Generated from protobuf field <code>.google.protobuf.SourceContext source_context = 5;</code>
+ * @param \Google\Protobuf\SourceContext $var
+ * @return $this
+ */
+ public function setSourceContext($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\SourceContext::class);
+ $this->source_context = $var;
+
+ return $this;
+ }
+
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 6;</code>
+ * @return int
+ */
+ public function getSyntax()
+ {
+ return $this->syntax;
+ }
+
+ /**
+ * The source syntax.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Syntax syntax = 6;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setSyntax($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class);
+ $this->syntax = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/UInt32Value.php b/php/src/Google/Protobuf/UInt32Value.php
new file mode 100644
index 00000000..61a3ddf1
--- /dev/null
+++ b/php/src/Google/Protobuf/UInt32Value.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `uint32`.
+ * The JSON representation for `UInt32Value` is JSON number.
+ *
+ * Generated from protobuf message <code>google.protobuf.UInt32Value</code>
+ */
+class UInt32Value extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The uint32 value.
+ *
+ * Generated from protobuf field <code>uint32 value = 1;</code>
+ */
+ private $value = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The uint32 value.
+ *
+ * Generated from protobuf field <code>uint32 value = 1;</code>
+ * @return int
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The uint32 value.
+ *
+ * Generated from protobuf field <code>uint32 value = 1;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/UInt64Value.php b/php/src/Google/Protobuf/UInt64Value.php
new file mode 100644
index 00000000..69f7eb8e
--- /dev/null
+++ b/php/src/Google/Protobuf/UInt64Value.php
@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/wrappers.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Wrapper message for `uint64`.
+ * The JSON representation for `UInt64Value` is JSON string.
+ *
+ * Generated from protobuf message <code>google.protobuf.UInt64Value</code>
+ */
+class UInt64Value extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The uint64 value.
+ *
+ * Generated from protobuf field <code>uint64 value = 1;</code>
+ */
+ private $value = 0;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Wrappers::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * The uint64 value.
+ *
+ * Generated from protobuf field <code>uint64 value = 1;</code>
+ * @return int|string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The uint64 value.
+ *
+ * Generated from protobuf field <code>uint64 value = 1;</code>
+ * @param int|string $var
+ * @return $this
+ */
+ public function setValue($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->value = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Value.php b/php/src/Google/Protobuf/Value.php
new file mode 100644
index 00000000..052a3779
--- /dev/null
+++ b/php/src/Google/Protobuf/Value.php
@@ -0,0 +1,194 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/struct.proto
+
+namespace Google\Protobuf;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * `Value` represents a dynamically typed value which can be either
+ * null, a number, a string, a boolean, a recursive struct value, or a
+ * list of values. A producer of value is expected to set one of that
+ * variants, absence of any variant indicates an error.
+ * The JSON representation for `Value` is JSON value.
+ *
+ * Generated from protobuf message <code>google.protobuf.Value</code>
+ */
+class Value extends \Google\Protobuf\Internal\Message
+{
+ protected $kind;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Struct::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * Represents a null value.
+ *
+ * Generated from protobuf field <code>.google.protobuf.NullValue null_value = 1;</code>
+ * @return int
+ */
+ public function getNullValue()
+ {
+ return $this->readOneof(1);
+ }
+
+ /**
+ * Represents a null value.
+ *
+ * Generated from protobuf field <code>.google.protobuf.NullValue null_value = 1;</code>
+ * @param int $var
+ * @return $this
+ */
+ public function setNullValue($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\NullValue::class);
+ $this->writeOneof(1, $var);
+
+ return $this;
+ }
+
+ /**
+ * Represents a double value.
+ *
+ * Generated from protobuf field <code>double number_value = 2;</code>
+ * @return float
+ */
+ public function getNumberValue()
+ {
+ return $this->readOneof(2);
+ }
+
+ /**
+ * Represents a double value.
+ *
+ * Generated from protobuf field <code>double number_value = 2;</code>
+ * @param float $var
+ * @return $this
+ */
+ public function setNumberValue($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->writeOneof(2, $var);
+
+ return $this;
+ }
+
+ /**
+ * Represents a string value.
+ *
+ * Generated from protobuf field <code>string string_value = 3;</code>
+ * @return string
+ */
+ public function getStringValue()
+ {
+ return $this->readOneof(3);
+ }
+
+ /**
+ * Represents a string value.
+ *
+ * Generated from protobuf field <code>string string_value = 3;</code>
+ * @param string $var
+ * @return $this
+ */
+ public function setStringValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(3, $var);
+
+ return $this;
+ }
+
+ /**
+ * Represents a boolean value.
+ *
+ * Generated from protobuf field <code>bool bool_value = 4;</code>
+ * @return bool
+ */
+ public function getBoolValue()
+ {
+ return $this->readOneof(4);
+ }
+
+ /**
+ * Represents a boolean value.
+ *
+ * Generated from protobuf field <code>bool bool_value = 4;</code>
+ * @param bool $var
+ * @return $this
+ */
+ public function setBoolValue($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->writeOneof(4, $var);
+
+ return $this;
+ }
+
+ /**
+ * Represents a structured value.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Struct struct_value = 5;</code>
+ * @return \Google\Protobuf\Struct
+ */
+ public function getStructValue()
+ {
+ return $this->readOneof(5);
+ }
+
+ /**
+ * Represents a structured value.
+ *
+ * Generated from protobuf field <code>.google.protobuf.Struct struct_value = 5;</code>
+ * @param \Google\Protobuf\Struct $var
+ * @return $this
+ */
+ public function setStructValue($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class);
+ $this->writeOneof(5, $var);
+
+ return $this;
+ }
+
+ /**
+ * Represents a repeated `Value`.
+ *
+ * Generated from protobuf field <code>.google.protobuf.ListValue list_value = 6;</code>
+ * @return \Google\Protobuf\ListValue
+ */
+ public function getListValue()
+ {
+ return $this->readOneof(6);
+ }
+
+ /**
+ * Represents a repeated `Value`.
+ *
+ * Generated from protobuf field <code>.google.protobuf.ListValue list_value = 6;</code>
+ * @param \Google\Protobuf\ListValue $var
+ * @return $this
+ */
+ public function setListValue($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\ListValue::class);
+ $this->writeOneof(6, $var);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getKind()
+ {
+ return $this->whichOneof("kind");
+ }
+
+}
+
diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh
index 6f1e4900..7caa46e7 100755
--- a/php/tests/compatibility_test.sh
+++ b/php/tests/compatibility_test.sh
@@ -20,7 +20,6 @@ function generate_proto() {
$PROTOC1 --php_out=generated proto/test_include.proto
$PROTOC2 --php_out=generated proto/test.proto proto/test_no_namespace.proto proto/test_prefix.proto
pushd ../../src
- $PROTOC2 --php_out=../php/tests/generated google/protobuf/empty.proto
$PROTOC2 --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto
popd
}
diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php
index b43dffb4..4dca922b 100644
--- a/php/tests/encode_decode_test.php
+++ b/php/tests/encode_decode_test.php
@@ -441,6 +441,33 @@ class EncodeDecodeTest extends TestBase
$m->mergeFromString(hex2bin('D205'));
}
+ public function testUnknown()
+ {
+ $m = new TestMessage();
+ $from = hex2bin('F80601');
+ $m->mergeFromString($from);
+ $to = $m->serializeToString();
+ $this->assertSame(bin2hex($from), bin2hex($to));
+
+ $m = new TestMessage();
+ $from = hex2bin('F9060000000000000000');
+ $m->mergeFromString($from);
+ $to = $m->serializeToString();
+ $this->assertSame(bin2hex($from), bin2hex($to));
+
+ $m = new TestMessage();
+ $from = hex2bin('FA0600');
+ $m->mergeFromString($from);
+ $to = $m->serializeToString();
+ $this->assertSame(bin2hex($from), bin2hex($to));
+
+ $m = new TestMessage();
+ $from = hex2bin('FD0600000000');
+ $m->mergeFromString($from);
+ $to = $m->serializeToString();
+ $this->assertSame(bin2hex($from), bin2hex($to));
+ }
+
public function testJsonEncode()
{
$from = new TestMessage();
diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh
index 0809bef3..484e2edf 100755
--- a/php/tests/gdb_test.sh
+++ b/php/tests/gdb_test.sh
@@ -3,7 +3,7 @@
# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which
# phpunit` --bootstrap autoload.php tmp_test.php
#
-gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php well_known_test.php
+gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php
#
# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
#
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index 98918bce..53d18ee7 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -691,6 +691,450 @@ class GeneratedClassTest extends TestBase
$m = new \Foo\PBEmpty();
$m = new \PrefixEmpty();
$m = new \Foo\PBARRAY();
+
+ $m = new \Lower\PBabstract();
+ $m = new \Lower\PBand();
+ $m = new \Lower\PBarray();
+ $m = new \Lower\PBas();
+ $m = new \Lower\PBbreak();
+ $m = new \Lower\PBcallable();
+ $m = new \Lower\PBcase();
+ $m = new \Lower\PBcatch();
+ $m = new \Lower\PBclass();
+ $m = new \Lower\PBclone();
+ $m = new \Lower\PBconst();
+ $m = new \Lower\PBcontinue();
+ $m = new \Lower\PBdeclare();
+ $m = new \Lower\PBdefault();
+ $m = new \Lower\PBdie();
+ $m = new \Lower\PBdo();
+ $m = new \Lower\PBecho();
+ $m = new \Lower\PBelse();
+ $m = new \Lower\PBelseif();
+ $m = new \Lower\PBempty();
+ $m = new \Lower\PBenddeclare();
+ $m = new \Lower\PBendfor();
+ $m = new \Lower\PBendforeach();
+ $m = new \Lower\PBendif();
+ $m = new \Lower\PBendswitch();
+ $m = new \Lower\PBendwhile();
+ $m = new \Lower\PBeval();
+ $m = new \Lower\PBexit();
+ $m = new \Lower\PBextends();
+ $m = new \Lower\PBfinal();
+ $m = new \Lower\PBfor();
+ $m = new \Lower\PBforeach();
+ $m = new \Lower\PBfunction();
+ $m = new \Lower\PBglobal();
+ $m = new \Lower\PBgoto();
+ $m = new \Lower\PBif();
+ $m = new \Lower\PBimplements();
+ $m = new \Lower\PBinclude();
+ $m = new \Lower\PBinclude_once();
+ $m = new \Lower\PBinstanceof();
+ $m = new \Lower\PBinsteadof();
+ $m = new \Lower\PBinterface();
+ $m = new \Lower\PBisset();
+ $m = new \Lower\PBlist();
+ $m = new \Lower\PBnamespace();
+ $m = new \Lower\PBnew();
+ $m = new \Lower\PBor();
+ $m = new \Lower\PBprint();
+ $m = new \Lower\PBprivate();
+ $m = new \Lower\PBprotected();
+ $m = new \Lower\PBpublic();
+ $m = new \Lower\PBrequire();
+ $m = new \Lower\PBrequire_once();
+ $m = new \Lower\PBreturn();
+ $m = new \Lower\PBstatic();
+ $m = new \Lower\PBswitch();
+ $m = new \Lower\PBthrow();
+ $m = new \Lower\PBtrait();
+ $m = new \Lower\PBtry();
+ $m = new \Lower\PBunset();
+ $m = new \Lower\PBuse();
+ $m = new \Lower\PBvar();
+ $m = new \Lower\PBwhile();
+ $m = new \Lower\PBxor();
+ $m = new \Lower\PBint();
+ $m = new \Lower\PBfloat();
+ $m = new \Lower\PBbool();
+ $m = new \Lower\PBstring();
+ $m = new \Lower\PBtrue();
+ $m = new \Lower\PBfalse();
+ $m = new \Lower\PBnull();
+ $m = new \Lower\PBvoid();
+ $m = new \Lower\PBiterable();
+
+ $m = new \Upper\PBABSTRACT();
+ $m = new \Upper\PBAND();
+ $m = new \Upper\PBARRAY();
+ $m = new \Upper\PBAS();
+ $m = new \Upper\PBBREAK();
+ $m = new \Upper\PBCALLABLE();
+ $m = new \Upper\PBCASE();
+ $m = new \Upper\PBCATCH();
+ $m = new \Upper\PBCLASS();
+ $m = new \Upper\PBCLONE();
+ $m = new \Upper\PBCONST();
+ $m = new \Upper\PBCONTINUE();
+ $m = new \Upper\PBDECLARE();
+ $m = new \Upper\PBDEFAULT();
+ $m = new \Upper\PBDIE();
+ $m = new \Upper\PBDO();
+ $m = new \Upper\PBECHO();
+ $m = new \Upper\PBELSE();
+ $m = new \Upper\PBELSEIF();
+ $m = new \Upper\PBEMPTY();
+ $m = new \Upper\PBENDDECLARE();
+ $m = new \Upper\PBENDFOR();
+ $m = new \Upper\PBENDFOREACH();
+ $m = new \Upper\PBENDIF();
+ $m = new \Upper\PBENDSWITCH();
+ $m = new \Upper\PBENDWHILE();
+ $m = new \Upper\PBEVAL();
+ $m = new \Upper\PBEXIT();
+ $m = new \Upper\PBEXTENDS();
+ $m = new \Upper\PBFINAL();
+ $m = new \Upper\PBFOR();
+ $m = new \Upper\PBFOREACH();
+ $m = new \Upper\PBFUNCTION();
+ $m = new \Upper\PBGLOBAL();
+ $m = new \Upper\PBGOTO();
+ $m = new \Upper\PBIF();
+ $m = new \Upper\PBIMPLEMENTS();
+ $m = new \Upper\PBINCLUDE();
+ $m = new \Upper\PBINCLUDE_ONCE();
+ $m = new \Upper\PBINSTANCEOF();
+ $m = new \Upper\PBINSTEADOF();
+ $m = new \Upper\PBINTERFACE();
+ $m = new \Upper\PBISSET();
+ $m = new \Upper\PBLIST();
+ $m = new \Upper\PBNAMESPACE();
+ $m = new \Upper\PBNEW();
+ $m = new \Upper\PBOR();
+ $m = new \Upper\PBPRINT();
+ $m = new \Upper\PBPRIVATE();
+ $m = new \Upper\PBPROTECTED();
+ $m = new \Upper\PBPUBLIC();
+ $m = new \Upper\PBREQUIRE();
+ $m = new \Upper\PBREQUIRE_ONCE();
+ $m = new \Upper\PBRETURN();
+ $m = new \Upper\PBSTATIC();
+ $m = new \Upper\PBSWITCH();
+ $m = new \Upper\PBTHROW();
+ $m = new \Upper\PBTRAIT();
+ $m = new \Upper\PBTRY();
+ $m = new \Upper\PBUNSET();
+ $m = new \Upper\PBUSE();
+ $m = new \Upper\PBVAR();
+ $m = new \Upper\PBWHILE();
+ $m = new \Upper\PBXOR();
+ $m = new \Upper\PBINT();
+ $m = new \Upper\PBFLOAT();
+ $m = new \Upper\PBBOOL();
+ $m = new \Upper\PBSTRING();
+ $m = new \Upper\PBTRUE();
+ $m = new \Upper\PBFALSE();
+ $m = new \Upper\PBNULL();
+ $m = new \Upper\PBVOID();
+ $m = new \Upper\PBITERABLE();
+
+ $m = new \Lower_enum\PBabstract();
+ $m = new \Lower_enum\PBand();
+ $m = new \Lower_enum\PBarray();
+ $m = new \Lower_enum\PBas();
+ $m = new \Lower_enum\PBbreak();
+ $m = new \Lower_enum\PBcallable();
+ $m = new \Lower_enum\PBcase();
+ $m = new \Lower_enum\PBcatch();
+ $m = new \Lower_enum\PBclass();
+ $m = new \Lower_enum\PBclone();
+ $m = new \Lower_enum\PBconst();
+ $m = new \Lower_enum\PBcontinue();
+ $m = new \Lower_enum\PBdeclare();
+ $m = new \Lower_enum\PBdefault();
+ $m = new \Lower_enum\PBdie();
+ $m = new \Lower_enum\PBdo();
+ $m = new \Lower_enum\PBecho();
+ $m = new \Lower_enum\PBelse();
+ $m = new \Lower_enum\PBelseif();
+ $m = new \Lower_enum\PBempty();
+ $m = new \Lower_enum\PBenddeclare();
+ $m = new \Lower_enum\PBendfor();
+ $m = new \Lower_enum\PBendforeach();
+ $m = new \Lower_enum\PBendif();
+ $m = new \Lower_enum\PBendswitch();
+ $m = new \Lower_enum\PBendwhile();
+ $m = new \Lower_enum\PBeval();
+ $m = new \Lower_enum\PBexit();
+ $m = new \Lower_enum\PBextends();
+ $m = new \Lower_enum\PBfinal();
+ $m = new \Lower_enum\PBfor();
+ $m = new \Lower_enum\PBforeach();
+ $m = new \Lower_enum\PBfunction();
+ $m = new \Lower_enum\PBglobal();
+ $m = new \Lower_enum\PBgoto();
+ $m = new \Lower_enum\PBif();
+ $m = new \Lower_enum\PBimplements();
+ $m = new \Lower_enum\PBinclude();
+ $m = new \Lower_enum\PBinclude_once();
+ $m = new \Lower_enum\PBinstanceof();
+ $m = new \Lower_enum\PBinsteadof();
+ $m = new \Lower_enum\PBinterface();
+ $m = new \Lower_enum\PBisset();
+ $m = new \Lower_enum\PBlist();
+ $m = new \Lower_enum\PBnamespace();
+ $m = new \Lower_enum\PBnew();
+ $m = new \Lower_enum\PBor();
+ $m = new \Lower_enum\PBprint();
+ $m = new \Lower_enum\PBprivate();
+ $m = new \Lower_enum\PBprotected();
+ $m = new \Lower_enum\PBpublic();
+ $m = new \Lower_enum\PBrequire();
+ $m = new \Lower_enum\PBrequire_once();
+ $m = new \Lower_enum\PBreturn();
+ $m = new \Lower_enum\PBstatic();
+ $m = new \Lower_enum\PBswitch();
+ $m = new \Lower_enum\PBthrow();
+ $m = new \Lower_enum\PBtrait();
+ $m = new \Lower_enum\PBtry();
+ $m = new \Lower_enum\PBunset();
+ $m = new \Lower_enum\PBuse();
+ $m = new \Lower_enum\PBvar();
+ $m = new \Lower_enum\PBwhile();
+ $m = new \Lower_enum\PBxor();
+ $m = new \Lower_enum\PBint();
+ $m = new \Lower_enum\PBfloat();
+ $m = new \Lower_enum\PBbool();
+ $m = new \Lower_enum\PBstring();
+ $m = new \Lower_enum\PBtrue();
+ $m = new \Lower_enum\PBfalse();
+ $m = new \Lower_enum\PBnull();
+ $m = new \Lower_enum\PBvoid();
+ $m = new \Lower_enum\PBiterable();
+
+ $m = new \Upper_enum\PBABSTRACT();
+ $m = new \Upper_enum\PBAND();
+ $m = new \Upper_enum\PBARRAY();
+ $m = new \Upper_enum\PBAS();
+ $m = new \Upper_enum\PBBREAK();
+ $m = new \Upper_enum\PBCALLABLE();
+ $m = new \Upper_enum\PBCASE();
+ $m = new \Upper_enum\PBCATCH();
+ $m = new \Upper_enum\PBCLASS();
+ $m = new \Upper_enum\PBCLONE();
+ $m = new \Upper_enum\PBCONST();
+ $m = new \Upper_enum\PBCONTINUE();
+ $m = new \Upper_enum\PBDECLARE();
+ $m = new \Upper_enum\PBDEFAULT();
+ $m = new \Upper_enum\PBDIE();
+ $m = new \Upper_enum\PBDO();
+ $m = new \Upper_enum\PBECHO();
+ $m = new \Upper_enum\PBELSE();
+ $m = new \Upper_enum\PBELSEIF();
+ $m = new \Upper_enum\PBEMPTY();
+ $m = new \Upper_enum\PBENDDECLARE();
+ $m = new \Upper_enum\PBENDFOR();
+ $m = new \Upper_enum\PBENDFOREACH();
+ $m = new \Upper_enum\PBENDIF();
+ $m = new \Upper_enum\PBENDSWITCH();
+ $m = new \Upper_enum\PBENDWHILE();
+ $m = new \Upper_enum\PBEVAL();
+ $m = new \Upper_enum\PBEXIT();
+ $m = new \Upper_enum\PBEXTENDS();
+ $m = new \Upper_enum\PBFINAL();
+ $m = new \Upper_enum\PBFOR();
+ $m = new \Upper_enum\PBFOREACH();
+ $m = new \Upper_enum\PBFUNCTION();
+ $m = new \Upper_enum\PBGLOBAL();
+ $m = new \Upper_enum\PBGOTO();
+ $m = new \Upper_enum\PBIF();
+ $m = new \Upper_enum\PBIMPLEMENTS();
+ $m = new \Upper_enum\PBINCLUDE();
+ $m = new \Upper_enum\PBINCLUDE_ONCE();
+ $m = new \Upper_enum\PBINSTANCEOF();
+ $m = new \Upper_enum\PBINSTEADOF();
+ $m = new \Upper_enum\PBINTERFACE();
+ $m = new \Upper_enum\PBISSET();
+ $m = new \Upper_enum\PBLIST();
+ $m = new \Upper_enum\PBNAMESPACE();
+ $m = new \Upper_enum\PBNEW();
+ $m = new \Upper_enum\PBOR();
+ $m = new \Upper_enum\PBPRINT();
+ $m = new \Upper_enum\PBPRIVATE();
+ $m = new \Upper_enum\PBPROTECTED();
+ $m = new \Upper_enum\PBPUBLIC();
+ $m = new \Upper_enum\PBREQUIRE();
+ $m = new \Upper_enum\PBREQUIRE_ONCE();
+ $m = new \Upper_enum\PBRETURN();
+ $m = new \Upper_enum\PBSTATIC();
+ $m = new \Upper_enum\PBSWITCH();
+ $m = new \Upper_enum\PBTHROW();
+ $m = new \Upper_enum\PBTRAIT();
+ $m = new \Upper_enum\PBTRY();
+ $m = new \Upper_enum\PBUNSET();
+ $m = new \Upper_enum\PBUSE();
+ $m = new \Upper_enum\PBVAR();
+ $m = new \Upper_enum\PBWHILE();
+ $m = new \Upper_enum\PBXOR();
+ $m = new \Upper_enum\PBINT();
+ $m = new \Upper_enum\PBFLOAT();
+ $m = new \Upper_enum\PBBOOL();
+ $m = new \Upper_enum\PBSTRING();
+ $m = new \Upper_enum\PBTRUE();
+ $m = new \Upper_enum\PBFALSE();
+ $m = new \Upper_enum\PBNULL();
+ $m = new \Upper_enum\PBVOID();
+ $m = new \Upper_enum\PBITERABLE();
+
+ $m = \Lower_enum_value\NotAllowed::PBabstract;
+ $m = \Lower_enum_value\NotAllowed::PBand;
+ $m = \Lower_enum_value\NotAllowed::PBarray;
+ $m = \Lower_enum_value\NotAllowed::PBas;
+ $m = \Lower_enum_value\NotAllowed::PBbreak;
+ $m = \Lower_enum_value\NotAllowed::PBcallable;
+ $m = \Lower_enum_value\NotAllowed::PBcase;
+ $m = \Lower_enum_value\NotAllowed::PBcatch;
+ $m = \Lower_enum_value\NotAllowed::PBclass;
+ $m = \Lower_enum_value\NotAllowed::PBclone;
+ $m = \Lower_enum_value\NotAllowed::PBconst;
+ $m = \Lower_enum_value\NotAllowed::PBcontinue;
+ $m = \Lower_enum_value\NotAllowed::PBdeclare;
+ $m = \Lower_enum_value\NotAllowed::PBdefault;
+ $m = \Lower_enum_value\NotAllowed::PBdie;
+ $m = \Lower_enum_value\NotAllowed::PBdo;
+ $m = \Lower_enum_value\NotAllowed::PBecho;
+ $m = \Lower_enum_value\NotAllowed::PBelse;
+ $m = \Lower_enum_value\NotAllowed::PBelseif;
+ $m = \Lower_enum_value\NotAllowed::PBempty;
+ $m = \Lower_enum_value\NotAllowed::PBenddeclare;
+ $m = \Lower_enum_value\NotAllowed::PBendfor;
+ $m = \Lower_enum_value\NotAllowed::PBendforeach;
+ $m = \Lower_enum_value\NotAllowed::PBendif;
+ $m = \Lower_enum_value\NotAllowed::PBendswitch;
+ $m = \Lower_enum_value\NotAllowed::PBendwhile;
+ $m = \Lower_enum_value\NotAllowed::PBeval;
+ $m = \Lower_enum_value\NotAllowed::PBexit;
+ $m = \Lower_enum_value\NotAllowed::PBextends;
+ $m = \Lower_enum_value\NotAllowed::PBfinal;
+ $m = \Lower_enum_value\NotAllowed::PBfor;
+ $m = \Lower_enum_value\NotAllowed::PBforeach;
+ $m = \Lower_enum_value\NotAllowed::PBfunction;
+ $m = \Lower_enum_value\NotAllowed::PBglobal;
+ $m = \Lower_enum_value\NotAllowed::PBgoto;
+ $m = \Lower_enum_value\NotAllowed::PBif;
+ $m = \Lower_enum_value\NotAllowed::PBimplements;
+ $m = \Lower_enum_value\NotAllowed::PBinclude;
+ $m = \Lower_enum_value\NotAllowed::PBinclude_once;
+ $m = \Lower_enum_value\NotAllowed::PBinstanceof;
+ $m = \Lower_enum_value\NotAllowed::PBinsteadof;
+ $m = \Lower_enum_value\NotAllowed::PBinterface;
+ $m = \Lower_enum_value\NotAllowed::PBisset;
+ $m = \Lower_enum_value\NotAllowed::PBlist;
+ $m = \Lower_enum_value\NotAllowed::PBnamespace;
+ $m = \Lower_enum_value\NotAllowed::PBnew;
+ $m = \Lower_enum_value\NotAllowed::PBor;
+ $m = \Lower_enum_value\NotAllowed::PBprint;
+ $m = \Lower_enum_value\NotAllowed::PBprivate;
+ $m = \Lower_enum_value\NotAllowed::PBprotected;
+ $m = \Lower_enum_value\NotAllowed::PBpublic;
+ $m = \Lower_enum_value\NotAllowed::PBrequire;
+ $m = \Lower_enum_value\NotAllowed::PBrequire_once;
+ $m = \Lower_enum_value\NotAllowed::PBreturn;
+ $m = \Lower_enum_value\NotAllowed::PBstatic;
+ $m = \Lower_enum_value\NotAllowed::PBswitch;
+ $m = \Lower_enum_value\NotAllowed::PBthrow;
+ $m = \Lower_enum_value\NotAllowed::PBtrait;
+ $m = \Lower_enum_value\NotAllowed::PBtry;
+ $m = \Lower_enum_value\NotAllowed::PBunset;
+ $m = \Lower_enum_value\NotAllowed::PBuse;
+ $m = \Lower_enum_value\NotAllowed::PBvar;
+ $m = \Lower_enum_value\NotAllowed::PBwhile;
+ $m = \Lower_enum_value\NotAllowed::PBxor;
+ $m = \Lower_enum_value\NotAllowed::int;
+ $m = \Lower_enum_value\NotAllowed::float;
+ $m = \Lower_enum_value\NotAllowed::bool;
+ $m = \Lower_enum_value\NotAllowed::string;
+ $m = \Lower_enum_value\NotAllowed::true;
+ $m = \Lower_enum_value\NotAllowed::false;
+ $m = \Lower_enum_value\NotAllowed::null;
+ $m = \Lower_enum_value\NotAllowed::void;
+ $m = \Lower_enum_value\NotAllowed::iterable;
+
+ $m = \Upper_enum_value\NotAllowed::PBABSTRACT;
+ $m = \Upper_enum_value\NotAllowed::PBAND;
+ $m = \Upper_enum_value\NotAllowed::PBARRAY;
+ $m = \Upper_enum_value\NotAllowed::PBAS;
+ $m = \Upper_enum_value\NotAllowed::PBBREAK;
+ $m = \Upper_enum_value\NotAllowed::PBCALLABLE;
+ $m = \Upper_enum_value\NotAllowed::PBCASE;
+ $m = \Upper_enum_value\NotAllowed::PBCATCH;
+ $m = \Upper_enum_value\NotAllowed::PBCLASS;
+ $m = \Upper_enum_value\NotAllowed::PBCLONE;
+ $m = \Upper_enum_value\NotAllowed::PBCONST;
+ $m = \Upper_enum_value\NotAllowed::PBCONTINUE;
+ $m = \Upper_enum_value\NotAllowed::PBDECLARE;
+ $m = \Upper_enum_value\NotAllowed::PBDEFAULT;
+ $m = \Upper_enum_value\NotAllowed::PBDIE;
+ $m = \Upper_enum_value\NotAllowed::PBDO;
+ $m = \Upper_enum_value\NotAllowed::PBECHO;
+ $m = \Upper_enum_value\NotAllowed::PBELSE;
+ $m = \Upper_enum_value\NotAllowed::PBELSEIF;
+ $m = \Upper_enum_value\NotAllowed::PBEMPTY;
+ $m = \Upper_enum_value\NotAllowed::PBENDDECLARE;
+ $m = \Upper_enum_value\NotAllowed::PBENDFOR;
+ $m = \Upper_enum_value\NotAllowed::PBENDFOREACH;
+ $m = \Upper_enum_value\NotAllowed::PBENDIF;
+ $m = \Upper_enum_value\NotAllowed::PBENDSWITCH;
+ $m = \Upper_enum_value\NotAllowed::PBENDWHILE;
+ $m = \Upper_enum_value\NotAllowed::PBEVAL;
+ $m = \Upper_enum_value\NotAllowed::PBEXIT;
+ $m = \Upper_enum_value\NotAllowed::PBEXTENDS;
+ $m = \Upper_enum_value\NotAllowed::PBFINAL;
+ $m = \Upper_enum_value\NotAllowed::PBFOR;
+ $m = \Upper_enum_value\NotAllowed::PBFOREACH;
+ $m = \Upper_enum_value\NotAllowed::PBFUNCTION;
+ $m = \Upper_enum_value\NotAllowed::PBGLOBAL;
+ $m = \Upper_enum_value\NotAllowed::PBGOTO;
+ $m = \Upper_enum_value\NotAllowed::PBIF;
+ $m = \Upper_enum_value\NotAllowed::PBIMPLEMENTS;
+ $m = \Upper_enum_value\NotAllowed::PBINCLUDE;
+ $m = \Upper_enum_value\NotAllowed::PBINCLUDE_ONCE;
+ $m = \Upper_enum_value\NotAllowed::PBINSTANCEOF;
+ $m = \Upper_enum_value\NotAllowed::PBINSTEADOF;
+ $m = \Upper_enum_value\NotAllowed::PBINTERFACE;
+ $m = \Upper_enum_value\NotAllowed::PBISSET;
+ $m = \Upper_enum_value\NotAllowed::PBLIST;
+ $m = \Upper_enum_value\NotAllowed::PBNAMESPACE;
+ $m = \Upper_enum_value\NotAllowed::PBNEW;
+ $m = \Upper_enum_value\NotAllowed::PBOR;
+ $m = \Upper_enum_value\NotAllowed::PBPRINT;
+ $m = \Upper_enum_value\NotAllowed::PBPRIVATE;
+ $m = \Upper_enum_value\NotAllowed::PBPROTECTED;
+ $m = \Upper_enum_value\NotAllowed::PBPUBLIC;
+ $m = \Upper_enum_value\NotAllowed::PBREQUIRE;
+ $m = \Upper_enum_value\NotAllowed::PBREQUIRE_ONCE;
+ $m = \Upper_enum_value\NotAllowed::PBRETURN;
+ $m = \Upper_enum_value\NotAllowed::PBSTATIC;
+ $m = \Upper_enum_value\NotAllowed::PBSWITCH;
+ $m = \Upper_enum_value\NotAllowed::PBTHROW;
+ $m = \Upper_enum_value\NotAllowed::PBTRAIT;
+ $m = \Upper_enum_value\NotAllowed::PBTRY;
+ $m = \Upper_enum_value\NotAllowed::PBUNSET;
+ $m = \Upper_enum_value\NotAllowed::PBUSE;
+ $m = \Upper_enum_value\NotAllowed::PBVAR;
+ $m = \Upper_enum_value\NotAllowed::PBWHILE;
+ $m = \Upper_enum_value\NotAllowed::PBXOR;
+ $m = \Upper_enum_value\NotAllowed::INT;
+ $m = \Upper_enum_value\NotAllowed::FLOAT;
+ $m = \Upper_enum_value\NotAllowed::BOOL;
+ $m = \Upper_enum_value\NotAllowed::STRING;
+ $m = \Upper_enum_value\NotAllowed::TRUE;
+ $m = \Upper_enum_value\NotAllowed::FALSE;
+ $m = \Upper_enum_value\NotAllowed::NULL;
+ $m = \Upper_enum_value\NotAllowed::VOID;
+ $m = \Upper_enum_value\NotAllowed::ITERABLE;
}
#########################################################
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 7c3a1801..b76c8bff 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -101,6 +101,10 @@ $n = new TestMessage();
$n->mergeFromString($data);
assert(1 === $n->getOneofMessage()->getA());
+$m = new TestMessage();
+$m->mergeFromString(hex2bin('F80601'));
+assert('F80601', bin2hex($m->serializeToString()));
+
# $from = new TestMessage();
# $to = new TestMessage();
# TestUtil::setTestMessage($from);
diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto
index 56cba446..d0109d83 100644
--- a/php/tests/proto/test.proto
+++ b/php/tests/proto/test.proto
@@ -115,6 +115,8 @@ message TestMessage {
message Empty {
int32 a = 1;
}
+
+ reserved 111;
}
enum TestEnum {
diff --git a/php/tests/proto/test_reserved_enum_lower.proto b/php/tests/proto/test_reserved_enum_lower.proto
new file mode 100644
index 00000000..d2daeaff
--- /dev/null
+++ b/php/tests/proto/test_reserved_enum_lower.proto
@@ -0,0 +1,77 @@
+syntax = "proto3";
+
+package lower_enum;
+
+enum abstract { ZERO1 = 0; }
+enum and { ZERO2 = 0; }
+enum array { ZERO3 = 0; }
+enum as { ZERO4 = 0; }
+enum break { ZERO5 = 0; }
+enum callable { ZERO6 = 0; }
+enum case { ZERO7 = 0; }
+enum catch { ZERO8 = 0; }
+enum class { ZERO9 = 0; }
+enum clone { ZERO10 = 0; }
+enum const { ZERO11 = 0; }
+enum continue { ZERO12 = 0; }
+enum declare { ZERO13 = 0; }
+enum default { ZERO14 = 0; }
+enum die { ZERO15 = 0; }
+enum do { ZERO16 = 0; }
+enum echo { ZERO17 = 0; }
+enum else { ZERO18 = 0; }
+enum elseif { ZERO19 = 0; }
+enum empty { ZERO20 = 0; }
+enum enddeclare { ZERO21 = 0; }
+enum endfor { ZERO22 = 0; }
+enum endforeach { ZERO23 = 0; }
+enum endif { ZERO24 = 0; }
+enum endswitch { ZERO25 = 0; }
+enum endwhile { ZERO26 = 0; }
+enum eval { ZERO27 = 0; }
+enum exit { ZERO28 = 0; }
+enum extends { ZERO29 = 0; }
+enum final { ZERO30 = 0; }
+enum for { ZERO31 = 0; }
+enum foreach { ZERO32 = 0; }
+enum function { ZERO33 = 0; }
+enum global { ZERO34 = 0; }
+enum goto { ZERO35 = 0; }
+enum if { ZERO36 = 0; }
+enum implements { ZERO37 = 0; }
+enum include { ZERO38 = 0; }
+enum include_once { ZERO39 = 0; }
+enum instanceof { ZERO40 = 0; }
+enum insteadof { ZERO41 = 0; }
+enum interface { ZERO42 = 0; }
+enum isset { ZERO43 = 0; }
+enum list { ZERO44 = 0; }
+enum namespace { ZERO45 = 0; }
+enum new { ZERO46 = 0; }
+enum or { ZERO47 = 0; }
+enum print { ZERO48 = 0; }
+enum private { ZERO49 = 0; }
+enum protected { ZERO50 = 0; }
+enum public { ZERO51 = 0; }
+enum require { ZERO52 = 0; }
+enum require_once { ZERO53 = 0; }
+enum return { ZERO54 = 0; }
+enum static { ZERO55 = 0; }
+enum switch { ZERO56 = 0; }
+enum throw { ZERO57 = 0; }
+enum trait { ZERO58 = 0; }
+enum try { ZERO59 = 0; }
+enum unset { ZERO60 = 0; }
+enum use { ZERO61 = 0; }
+enum var { ZERO62 = 0; }
+enum while { ZERO63 = 0; }
+enum xor { ZERO64 = 0; }
+enum int { ZERO65 = 0; }
+enum float { ZERO66 = 0; }
+enum bool { ZERO67 = 0; }
+enum string { ZERO68 = 0; }
+enum true { ZERO69 = 0; }
+enum false { ZERO70 = 0; }
+enum null { ZERO71 = 0; }
+enum void { ZERO72 = 0; }
+enum iterable { ZERO73 = 0; }
diff --git a/php/tests/proto/test_reserved_enum_upper.proto b/php/tests/proto/test_reserved_enum_upper.proto
new file mode 100644
index 00000000..a396fea3
--- /dev/null
+++ b/php/tests/proto/test_reserved_enum_upper.proto
@@ -0,0 +1,77 @@
+syntax = "proto3";
+
+package upper_enum;
+
+enum ABSTRACT { ZERO1 = 0; }
+enum AND { ZERO2 = 0; }
+enum ARRAY { ZERO3 = 0; }
+enum AS { ZERO4 = 0; }
+enum BREAK { ZERO5 = 0; }
+enum CALLABLE { ZERO6 = 0; }
+enum CASE { ZERO7 = 0; }
+enum CATCH { ZERO8 = 0; }
+enum CLASS { ZERO9 = 0; }
+enum CLONE { ZERO10 = 0; }
+enum CONST { ZERO11 = 0; }
+enum CONTINUE { ZERO12 = 0; }
+enum DECLARE { ZERO13 = 0; }
+enum DEFAULT { ZERO14 = 0; }
+enum DIE { ZERO15 = 0; }
+enum DO { ZERO16 = 0; }
+enum ECHO { ZERO17 = 0; }
+enum ELSE { ZERO18 = 0; }
+enum ELSEIF { ZERO19 = 0; }
+enum EMPTY { ZERO20 = 0; }
+enum ENDDECLARE { ZERO21 = 0; }
+enum ENDFOR { ZERO22 = 0; }
+enum ENDFOREACH { ZERO23 = 0; }
+enum ENDIF { ZERO24 = 0; }
+enum ENDSWITCH { ZERO25 = 0; }
+enum ENDWHILE { ZERO26 = 0; }
+enum EVAL { ZERO27 = 0; }
+enum EXIT { ZERO28 = 0; }
+enum EXTENDS { ZERO29 = 0; }
+enum FINAL { ZERO30 = 0; }
+enum FOR { ZERO31 = 0; }
+enum FOREACH { ZERO32 = 0; }
+enum FUNCTION { ZERO33 = 0; }
+enum GLOBAL { ZERO34 = 0; }
+enum GOTO { ZERO35 = 0; }
+enum IF { ZERO36 = 0; }
+enum IMPLEMENTS { ZERO37 = 0; }
+enum INCLUDE { ZERO38 = 0; }
+enum INCLUDE_ONCE { ZERO39 = 0; }
+enum INSTANCEOF { ZERO40 = 0; }
+enum INSTEADOF { ZERO41 = 0; }
+enum INTERFACE { ZERO42 = 0; }
+enum ISSET { ZERO43 = 0; }
+enum LIST { ZERO44 = 0; }
+enum NAMESPACE { ZERO45 = 0; }
+enum NEW { ZERO46 = 0; }
+enum OR { ZERO47 = 0; }
+enum PRINT { ZERO48 = 0; }
+enum PRIVATE { ZERO49 = 0; }
+enum PROTECTED { ZERO50 = 0; }
+enum PUBLIC { ZERO51 = 0; }
+enum REQUIRE { ZERO52 = 0; }
+enum REQUIRE_ONCE { ZERO53 = 0; }
+enum RETURN { ZERO54 = 0; }
+enum STATIC { ZERO55 = 0; }
+enum SWITCH { ZERO56 = 0; }
+enum THROW { ZERO57 = 0; }
+enum TRAIT { ZERO58 = 0; }
+enum TRY { ZERO59 = 0; }
+enum UNSET { ZERO60 = 0; }
+enum USE { ZERO61 = 0; }
+enum VAR { ZERO62 = 0; }
+enum WHILE { ZERO63 = 0; }
+enum XOR { ZERO64 = 0; }
+enum INT { ZERO65 = 0; }
+enum FLOAT { ZERO66 = 0; }
+enum BOOL { ZERO67 = 0; }
+enum STRING { ZERO68 = 0; }
+enum TRUE { ZERO69 = 0; }
+enum FALSE { ZERO70 = 0; }
+enum NULL { ZERO71 = 0; }
+enum VOID { ZERO72 = 0; }
+enum ITERABLE { ZERO73 = 0; }
diff --git a/php/tests/proto/test_reserved_enum_value_lower.proto b/php/tests/proto/test_reserved_enum_value_lower.proto
new file mode 100644
index 00000000..96da319e
--- /dev/null
+++ b/php/tests/proto/test_reserved_enum_value_lower.proto
@@ -0,0 +1,79 @@
+syntax = "proto3";
+
+package lower_enum_value;
+
+enum NotAllowed {
+ abstract = 0;
+ and = 1;
+ array = 2;
+ as = 3;
+ break = 4;
+ callable = 5;
+ case = 6;
+ catch = 7;
+ class = 8;
+ clone = 9;
+ const = 10;
+ continue = 11;
+ declare = 12;
+ default = 13;
+ die = 14;
+ do = 15;
+ echo = 16;
+ else = 17;
+ elseif = 18;
+ empty = 19;
+ enddeclare = 20;
+ endfor = 21;
+ endforeach = 22;
+ endif = 23;
+ endswitch = 24;
+ endwhile = 25;
+ eval = 26;
+ exit = 27;
+ extends = 28;
+ final = 29;
+ for = 30;
+ foreach = 31;
+ function = 32;
+ global = 33;
+ goto = 34;
+ if = 35;
+ implements = 36;
+ include = 37;
+ include_once = 38;
+ instanceof = 39;
+ insteadof = 40;
+ interface = 41;
+ isset = 42;
+ list = 43;
+ namespace = 44;
+ new = 45;
+ or = 46;
+ print = 47;
+ private = 48;
+ protected = 49;
+ public = 50;
+ require = 51;
+ require_once = 52;
+ return = 53;
+ static = 54;
+ switch = 55;
+ throw = 56;
+ trait = 57;
+ try = 58;
+ unset = 59;
+ use = 60;
+ var = 61;
+ while = 62;
+ xor = 63;
+ int = 64;
+ float = 65;
+ bool = 66;
+ string = 67;
+ true = 68;
+ false = 69;
+ null = 70;
+ void = 71;
+ iterable = 72;
+}
diff --git a/php/tests/proto/test_reserved_enum_value_upper.proto b/php/tests/proto/test_reserved_enum_value_upper.proto
new file mode 100644
index 00000000..b026a858
--- /dev/null
+++ b/php/tests/proto/test_reserved_enum_value_upper.proto
@@ -0,0 +1,79 @@
+syntax = "proto3";
+
+package upper_enum_value;
+
+enum NotAllowed {
+ ABSTRACT = 0;
+ AND = 1;
+ ARRAY = 2;
+ AS = 3;
+ BREAK = 4;
+ CALLABLE = 5;
+ CASE = 6;
+ CATCH = 7;
+ CLASS = 8;
+ CLONE = 9;
+ CONST = 10;
+ CONTINUE = 11;
+ DECLARE = 12;
+ DEFAULT = 13;
+ DIE = 14;
+ DO = 15;
+ ECHO = 16;
+ ELSE = 17;
+ ELSEIF = 18;
+ EMPTY = 19;
+ ENDDECLARE = 20;
+ ENDFOR = 21;
+ ENDFOREACH = 22;
+ ENDIF = 23;
+ ENDSWITCH = 24;
+ ENDWHILE = 25;
+ EVAL = 26;
+ EXIT = 27;
+ EXTENDS = 28;
+ FINAL = 29;
+ FOR = 30;
+ FOREACH = 31;
+ FUNCTION = 32;
+ GLOBAL = 33;
+ GOTO = 34;
+ IF = 35;
+ IMPLEMENTS = 36;
+ INCLUDE = 37;
+ INCLUDE_ONCE = 38;
+ INSTANCEOF = 39;
+ INSTEADOF = 40;
+ INTERFACE = 41;
+ ISSET = 42;
+ LIST = 43;
+ NAMESPACE = 44;
+ NEW = 45;
+ OR = 46;
+ PRINT = 47;
+ PRIVATE = 48;
+ PROTECTED = 49;
+ PUBLIC = 50;
+ REQUIRE = 51;
+ REQUIRE_ONCE = 52;
+ RETURN = 53;
+ STATIC = 54;
+ SWITCH = 55;
+ THROW = 56;
+ TRAIT = 57;
+ TRY = 58;
+ UNSET = 59;
+ USE = 60;
+ VAR = 61;
+ WHILE = 62;
+ XOR = 63;
+ INT = 64;
+ FLOAT = 65;
+ BOOL = 66;
+ STRING = 67;
+ TRUE = 68;
+ FALSE = 69;
+ NULL = 70;
+ VOID = 71;
+ ITERABLE = 72;
+}
diff --git a/php/tests/proto/test_reserved_message_lower.proto b/php/tests/proto/test_reserved_message_lower.proto
new file mode 100644
index 00000000..ed120808
--- /dev/null
+++ b/php/tests/proto/test_reserved_message_lower.proto
@@ -0,0 +1,77 @@
+syntax = "proto3";
+
+package lower;
+
+message abstract {}
+message and {}
+message array {}
+message as {}
+message break {}
+message callable {}
+message case {}
+message catch {}
+message class {}
+message clone {}
+message const {}
+message continue {}
+message declare {}
+message default {}
+message die {}
+message do {}
+message echo {}
+message else {}
+message elseif {}
+message empty {}
+message enddeclare {}
+message endfor {}
+message endforeach {}
+message endif {}
+message endswitch {}
+message endwhile {}
+message eval {}
+message exit {}
+message extends {}
+message final {}
+message for {}
+message foreach {}
+message function {}
+message global {}
+message goto {}
+message if {}
+message implements {}
+message include {}
+message include_once {}
+message instanceof {}
+message insteadof {}
+message interface {}
+message isset {}
+message list {}
+message namespace {}
+message new {}
+message or {}
+message print {}
+message private {}
+message protected {}
+message public {}
+message require {}
+message require_once {}
+message return {}
+message static {}
+message switch {}
+message throw {}
+message trait {}
+message try {}
+message unset {}
+message use {}
+message var {}
+message while {}
+message xor {}
+message int {}
+message float {}
+message bool {}
+message string {}
+message true {}
+message false {}
+message null {}
+message void {}
+message iterable {}
diff --git a/php/tests/proto/test_reserved_message_upper.proto b/php/tests/proto/test_reserved_message_upper.proto
new file mode 100644
index 00000000..2917fd11
--- /dev/null
+++ b/php/tests/proto/test_reserved_message_upper.proto
@@ -0,0 +1,77 @@
+syntax = "proto3";
+
+package upper;
+
+message ABSTRACT {}
+message AND {}
+message ARRAY {}
+message AS {}
+message BREAK {}
+message CALLABLE {}
+message CASE {}
+message CATCH {}
+message CLASS {}
+message CLONE {}
+message CONST {}
+message CONTINUE {}
+message DECLARE {}
+message DEFAULT {}
+message DIE {}
+message DO {}
+message ECHO {}
+message ELSE {}
+message ELSEIF {}
+message EMPTY {}
+message ENDDECLARE {}
+message ENDFOR {}
+message ENDFOREACH {}
+message ENDIF {}
+message ENDSWITCH {}
+message ENDWHILE {}
+message EVAL {}
+message EXIT {}
+message EXTENDS {}
+message FINAL {}
+message FOR {}
+message FOREACH {}
+message FUNCTION {}
+message GLOBAL {}
+message GOTO {}
+message IF {}
+message IMPLEMENTS {}
+message INCLUDE {}
+message INCLUDE_ONCE {}
+message INSTANCEOF {}
+message INSTEADOF {}
+message INTERFACE {}
+message ISSET {}
+message LIST {}
+message NAMESPACE {}
+message NEW {}
+message OR {}
+message PRINT {}
+message PRIVATE {}
+message PROTECTED {}
+message PUBLIC {}
+message REQUIRE {}
+message REQUIRE_ONCE {}
+message RETURN {}
+message STATIC {}
+message SWITCH {}
+message THROW {}
+message TRAIT {}
+message TRY {}
+message UNSET {}
+message USE {}
+message VAR {}
+message WHILE {}
+message XOR {}
+message INT {}
+message FLOAT {}
+message BOOL {}
+message STRING {}
+message TRUE {}
+message FALSE {}
+message NULL {}
+message VOID {}
+message ITERABLE {}
diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php
index 690ce5f5..a7760685 100644
--- a/php/tests/well_known_test.php
+++ b/php/tests/well_known_test.php
@@ -3,18 +3,43 @@
require_once('test_base.php');
require_once('test_util.php');
-use Google\Protobuf\GPBEmpty;
+use Foo\TestMessage;
use Google\Protobuf\Any;
+use Google\Protobuf\Api;
+use Google\Protobuf\BoolValue;
+use Google\Protobuf\BytesValue;
+use Google\Protobuf\DoubleValue;
use Google\Protobuf\Duration;
+use Google\Protobuf\Enum;
+use Google\Protobuf\EnumValue;
+use Google\Protobuf\Field;
+use Google\Protobuf\FieldMask;
+use Google\Protobuf\Field_Cardinality;
+use Google\Protobuf\Field_Kind;
+use Google\Protobuf\FloatValue;
+use Google\Protobuf\GPBEmpty;
+use Google\Protobuf\Int32Value;
+use Google\Protobuf\Int64Value;
+use Google\Protobuf\ListValue;
+use Google\Protobuf\Method;
+use Google\Protobuf\Mixin;
+use Google\Protobuf\NullValue;
+use Google\Protobuf\Option;
+use Google\Protobuf\SourceContext;
+use Google\Protobuf\StringValue;
+use Google\Protobuf\Struct;
+use Google\Protobuf\Syntax;
use Google\Protobuf\Timestamp;
-
-use Foo\TestMessage;
+use Google\Protobuf\Type;
+use Google\Protobuf\UInt32Value;
+use Google\Protobuf\UInt64Value;
+use Google\Protobuf\Value;
class NotMessage {}
class WellKnownTest extends TestBase {
- public function testNone()
+ public function testEmpty()
{
$msg = new GPBEmpty();
}
@@ -89,6 +114,191 @@ class WellKnownTest extends TestBase {
$any->unpack();
}
+ public function testApi()
+ {
+ $m = new Api();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setMethods([new Method()]);
+ $this->assertSame(1, count($m->getMethods()));
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+
+ $m->setVersion("a");
+ $this->assertSame("a", $m->getVersion());
+
+ $m->setSourceContext(new SourceContext());
+ $this->assertFalse(is_null($m->getSourceContext()));
+
+ $m->setMixins([new Mixin()]);
+ $this->assertSame(1, count($m->getMixins()));
+
+ $m->setSyntax(Syntax::SYNTAX_PROTO2);
+ $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax());
+
+ $m = new Method();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setRequestTypeUrl("a");
+ $this->assertSame("a", $m->getRequestTypeUrl());
+
+ $m->setRequestStreaming(true);
+ $this->assertSame(true, $m->getRequestStreaming());
+
+ $m->setResponseTypeUrl("a");
+ $this->assertSame("a", $m->getResponseTypeUrl());
+
+ $m->setResponseStreaming(true);
+ $this->assertSame(true, $m->getResponseStreaming());
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+
+ $m = new Mixin();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setRoot("a");
+ $this->assertSame("a", $m->getRoot());
+ }
+
+ public function testEnum()
+ {
+ $m = new Enum();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setEnumvalue([new EnumValue()]);
+ $this->assertSame(1, count($m->getEnumvalue()));
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+
+ $m->setSourceContext(new SourceContext());
+ $this->assertFalse(is_null($m->getSourceContext()));
+
+ $m->setSyntax(Syntax::SYNTAX_PROTO2);
+ $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax());
+ }
+
+ public function testEnumValue()
+ {
+ $m = new EnumValue();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setNumber(1);
+ $this->assertSame(1, $m->getNumber());
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+ }
+
+ public function testField()
+ {
+ $m = new Field();
+
+ $m->setKind(Field_Kind::TYPE_DOUBLE);
+ $this->assertSame(Field_Kind::TYPE_DOUBLE, $m->getKind());
+
+ $m->setCardinality(Field_Cardinality::CARDINALITY_OPTIONAL);
+ $this->assertSame(Field_Cardinality::CARDINALITY_OPTIONAL, $m->getCardinality());
+
+ $m->setNumber(1);
+ $this->assertSame(1, $m->getNumber());
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setTypeUrl("a");
+ $this->assertSame("a", $m->getTypeUrl());
+
+ $m->setOneofIndex(1);
+ $this->assertSame(1, $m->getOneofIndex());
+
+ $m->setPacked(true);
+ $this->assertSame(true, $m->getPacked());
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+
+ $m->setJsonName("a");
+ $this->assertSame("a", $m->getJsonName());
+
+ $m->setDefaultValue("a");
+ $this->assertSame("a", $m->getDefaultValue());
+ }
+
+ public function testFieldMask()
+ {
+ $m = new FieldMask();
+ $m->setPaths(["a"]);
+ $this->assertSame(1, count($m->getPaths()));
+ }
+
+ public function testOption()
+ {
+ $m = new Option();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setValue(new Any());
+ $this->assertFalse(is_null($m->getValue()));
+ }
+
+ public function testSourceContext()
+ {
+ $m = new SourceContext();
+ $m->setFileName("a");
+ $this->assertSame("a", $m->getFileName());
+ }
+
+ public function testStruct()
+ {
+ $m = new ListValue();
+ $m->setValues([new Value()]);
+ $this->assertSame(1, count($m->getValues()));
+
+ $m = new Value();
+
+ $m->setNullValue(NullValue::NULL_VALUE);
+ $this->assertSame(NullValue::NULL_VALUE, $m->getNullValue());
+ $this->assertSame("null_value", $m->getKind());
+
+ $m->setNumberValue(1.0);
+ $this->assertSame(1.0, $m->getNumberValue());
+ $this->assertSame("number_value", $m->getKind());
+
+ $m->setStringValue("a");
+ $this->assertSame("a", $m->getStringValue());
+ $this->assertSame("string_value", $m->getKind());
+
+ $m->setBoolValue(true);
+ $this->assertSame(true, $m->getBoolValue());
+ $this->assertSame("bool_value", $m->getKind());
+
+ $m->setStructValue(new Struct());
+ $this->assertFalse(is_null($m->getStructValue()));
+ $this->assertSame("struct_value", $m->getKind());
+
+ $m->setListValue(new ListValue());
+ $this->assertFalse(is_null($m->getListValue()));
+ $this->assertSame("list_value", $m->getKind());
+
+ $m = new Struct();
+ $m->setFields(array("a"=>new Value()));
+ $this->assertSame(1, count($m->getFields()));
+ }
+
public function testTimestamp()
{
$timestamp = new Timestamp();
@@ -109,6 +319,29 @@ class WellKnownTest extends TestBase {
$this->assertSame($from->format('U'), $to->format('U'));
}
+ public function testType()
+ {
+ $m = new Type();
+
+ $m->setName("a");
+ $this->assertSame("a", $m->getName());
+
+ $m->setFields([new Field()]);
+ $this->assertSame(1, count($m->getFields()));
+
+ $m->setOneofs(["a"]);
+ $this->assertSame(1, count($m->getOneofs()));
+
+ $m->setOptions([new Option()]);
+ $this->assertSame(1, count($m->getOptions()));
+
+ $m->setSourceContext(new SourceContext());
+ $this->assertFalse(is_null($m->getSourceContext()));
+
+ $m->setSyntax(Syntax::SYNTAX_PROTO2);
+ $this->assertSame(Syntax::SYNTAX_PROTO2, $m->getSyntax());
+ }
+
public function testDuration()
{
$duration = new Duration();
@@ -118,4 +351,43 @@ class WellKnownTest extends TestBase {
$this->assertEquals(1, $duration->getSeconds());
$this->assertSame(2, $duration->getNanos());
}
+
+ public function testWrappers()
+ {
+ $m = new DoubleValue();
+ $m->setValue(1.0);
+ $this->assertSame(1.0, $m->getValue());
+
+ $m = new FloatValue();
+ $m->setValue(1.0);
+ $this->assertSame(1.0, $m->getValue());
+
+ $m = new Int64Value();
+ $m->setValue(1);
+ $this->assertEquals(1, $m->getValue());
+
+ $m = new UInt64Value();
+ $m->setValue(1);
+ $this->assertEquals(1, $m->getValue());
+
+ $m = new Int32Value();
+ $m->setValue(1);
+ $this->assertSame(1, $m->getValue());
+
+ $m = new UInt32Value();
+ $m->setValue(1);
+ $this->assertSame(1, $m->getValue());
+
+ $m = new BoolValue();
+ $m->setValue(true);
+ $this->assertSame(true, $m->getValue());
+
+ $m = new StringValue();
+ $m->setValue("a");
+ $this->assertSame("a", $m->getValue());
+
+ $m = new BytesValue();
+ $m->setValue("a");
+ $this->assertSame("a", $m->getValue());
+ }
}
diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml
index d68709ea..c6f5a77f 100644
--- a/protoc-artifacts/pom.xml
+++ b/protoc-artifacts/pom.xml
@@ -10,7 +10,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
- <version>3.4.0</version>
+ <version>3.4.1</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index d26da0df..9f1a4f19 100755
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -30,7 +30,7 @@
# Copyright 2007 Google Inc. All Rights Reserved.
-__version__ = '3.4.0'
+__version__ = '3.4.1'
if __name__ != '__main__':
try:
diff --git a/python/google/protobuf/internal/decoder.py b/python/google/protobuf/internal/decoder.py
index ff3e6d30..52b64915 100755
--- a/python/google/protobuf/internal/decoder.py
+++ b/python/google/protobuf/internal/decoder.py
@@ -181,7 +181,7 @@ def ReadTag(buffer, pos):
while six.indexbytes(buffer, pos) & 0x80:
pos += 1
pos += 1
- return (buffer[start:pos], pos)
+ return (six.binary_type(buffer[start:pos]), pos)
# --------------------------------------------------------------------
diff --git a/python/google/protobuf/internal/encoder.py b/python/google/protobuf/internal/encoder.py
index 8c6a1189..40c62d67 100755
--- a/python/google/protobuf/internal/encoder.py
+++ b/python/google/protobuf/internal/encoder.py
@@ -418,7 +418,7 @@ def _VarintBytes(value):
def TagBytes(field_number, wire_type):
"""Encode the given tag and return the bytes. Only called at startup."""
- return _VarintBytes(wire_format.PackTag(field_number, wire_type))
+ return six.binary_type( _VarintBytes(wire_format.PackTag(field_number, wire_type)) )
# --------------------------------------------------------------------
# As with sizers (see above), we have a number of common encoder
diff --git a/ruby/Rakefile b/ruby/Rakefile
index a329a777..e30a75a3 100644
--- a/ruby/Rakefile
+++ b/ruby/Rakefile
@@ -99,7 +99,13 @@ Gem::PackageTask.new(spec) do |pkg|
end
Rake::TestTask.new(:test => :build) do |t|
- t.test_files = FileList["tests/*.rb"]
+ t.test_files = FileList["tests/*.rb"].exclude("tests/gc_test.rb")
+end
+
+# gc_test needs to be split out to ensure the generated file hasn't been
+# imported by other tests.
+Rake::TestTask.new(:gc_test => :build) do |t|
+ t.test_files = FileList["tests/gc_test.rb"]
end
task :build => [:clean, :compile, :genproto]
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index 845c0225..34d9663a 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -228,7 +228,6 @@ DEFINE_CLASS(Descriptor, "Google::Protobuf::Descriptor");
void Descriptor_mark(void* _self) {
Descriptor* self = _self;
rb_gc_mark(self->klass);
- rb_gc_mark(self->typeclass_references);
}
void Descriptor_free(void* _self) {
@@ -283,7 +282,6 @@ VALUE Descriptor_alloc(VALUE klass) {
self->pb_serialize_handlers = NULL;
self->json_serialize_handlers = NULL;
self->json_serialize_handlers_preserve = NULL;
- self->typeclass_references = rb_ary_new();
return ret;
}
@@ -1635,7 +1633,7 @@ VALUE Builder_alloc(VALUE klass) {
Builder* self = ALLOC(Builder);
VALUE ret = TypedData_Wrap_Struct(
klass, &_Builder_type, self);
- self->pending_list = rb_ary_new();
+ self->pending_list = Qnil;
self->defs = NULL;
return ret;
}
@@ -1645,6 +1643,7 @@ void Builder_register(VALUE module) {
rb_define_alloc_func(klass, Builder_alloc);
rb_define_method(klass, "add_message", Builder_add_message, 1);
rb_define_method(klass, "add_enum", Builder_add_enum, 1);
+ rb_define_method(klass, "initialize", Builder_initialize, 0);
rb_define_method(klass, "finalize_to_pool", Builder_finalize_to_pool, 1);
cBuilder = klass;
rb_gc_register_address(&cBuilder);
@@ -1652,6 +1651,18 @@ void Builder_register(VALUE module) {
/*
* call-seq:
+ * Builder.new(d) => builder
+ *
+ * Create a new message builder.
+ */
+VALUE Builder_initialize(VALUE _self) {
+ DEFINE_SELF(Builder, self, _self);
+ self->pending_list = rb_ary_new();
+ return Qnil;
+}
+
+/*
+ * call-seq:
* Builder.add_message(name, &block)
*
* Creates a new, empty descriptor with the given name, and invokes the block in
diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c
index 7cde4aec..c7750c44 100644
--- a/ruby/ext/google/protobuf_c/protobuf.c
+++ b/ruby/ext/google/protobuf_c/protobuf.c
@@ -110,6 +110,6 @@ void Init_protobuf_c() {
kRubyStringASCIIEncoding = rb_usascii_encoding();
kRubyString8bitEncoding = rb_ascii8bit_encoding();
- upb_def_to_ruby_obj_map = rb_hash_new();
rb_gc_register_address(&upb_def_to_ruby_obj_map);
+ upb_def_to_ruby_obj_map = rb_hash_new();
}
diff --git a/ruby/ext/google/protobuf_c/protobuf.h b/ruby/ext/google/protobuf_c/protobuf.h
index f4b110fe..21c7f001 100644
--- a/ruby/ext/google/protobuf_c/protobuf.h
+++ b/ruby/ext/google/protobuf_c/protobuf.h
@@ -116,10 +116,6 @@ struct Descriptor {
const upb_handlers* pb_serialize_handlers;
const upb_handlers* json_serialize_handlers;
const upb_handlers* json_serialize_handlers_preserve;
- // Handlers hold type class references for sub-message fields directly in some
- // cases. We need to keep these rooted because they might otherwise be
- // collected.
- VALUE typeclass_references;
};
struct FieldDescriptor {
@@ -280,6 +276,7 @@ void Builder_free(void* _self);
VALUE Builder_alloc(VALUE klass);
void Builder_register(VALUE module);
Builder* ruby_to_Builder(VALUE value);
+VALUE Builder_initialize(VALUE _self);
VALUE Builder_add_message(VALUE _self, VALUE name);
VALUE Builder_add_enum(VALUE _self, VALUE name);
VALUE Builder_finalize_to_pool(VALUE _self, VALUE pool_rb);
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec
index bd1e39f1..96606f06 100644
--- a/ruby/google-protobuf.gemspec
+++ b/ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
- s.version = "3.4.0.2"
+ s.version = "3.4.1.1"
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"
s.description = "Protocol Buffers are Google's data interchange format."
diff --git a/ruby/tests/gc_test.rb b/ruby/tests/gc_test.rb
new file mode 100644
index 00000000..f3470cca
--- /dev/null
+++ b/ruby/tests/gc_test.rb
@@ -0,0 +1,58 @@
+#!/usr/bin/ruby
+#
+# generated_code.rb is in the same directory as this test.
+$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
+
+old_gc = GC.stress
+GC.stress = 0x01 | 0x04
+require 'generated_code_pb'
+GC.stress = old_gc
+
+require 'test/unit'
+
+class GCTest < Test::Unit::TestCase
+ def get_msg
+ A::B::C::TestMessage.new(
+ :optional_int32 => 1,
+ :optional_int64 => 1,
+ :optional_uint32 => 1,
+ :optional_uint64 => 1,
+ :optional_bool => true,
+ :optional_double => 1.0,
+ :optional_float => 1.0,
+ :optional_string => "a",
+ :optional_bytes => "b",
+ :optional_enum => A::B::C::TestEnum::A,
+ :optional_msg => A::B::C::TestMessage.new(),
+ :repeated_int32 => [1],
+ :repeated_int64 => [1],
+ :repeated_uint32 => [1],
+ :repeated_uint64 => [1],
+ :repeated_bool => [true],
+ :repeated_double => [1.0],
+ :repeated_float => [1.0],
+ :repeated_string => ["a"],
+ :repeated_bytes => ["b"],
+ :repeated_enum => [A::B::C::TestEnum::A],
+ :repeated_msg => [A::B::C::TestMessage.new()],
+ :map_int32_string => {1 => "a"},
+ :map_int64_string => {1 => "a"},
+ :map_uint32_string => {1 => "a"},
+ :map_uint64_string => {1 => "a"},
+ :map_bool_string => {true => "a"},
+ :map_string_string => {"a" => "a"},
+ :map_string_msg => {"a" => A::B::C::TestMessage.new()},
+ :map_string_int32 => {"a" => 1},
+ :map_string_bool => {"a" => true},
+ )
+ end
+ def test_generated_msg
+ old_gc = GC.stress
+ GC.stress = 0x01 | 0x04
+ from = get_msg
+ data = A::B::C::TestMessage.encode(from)
+ to = A::B::C::TestMessage.decode(data)
+ GC.stress = old_gc
+ puts "passed"
+ end
+end
diff --git a/ruby/travis-test.sh b/ruby/travis-test.sh
index 52ea81b6..cbe7cd98 100755
--- a/ruby/travis-test.sh
+++ b/ruby/travis-test.sh
@@ -20,6 +20,7 @@ test_version() {
git clean -f && \
gem install bundler && bundle && \
rake test &&
+ rake gc_test &&
cd ../conformance && make test_ruby &&
cd ../ruby/compatibility_tests/v3.0.0 && ./test.sh"
fi
diff --git a/src/Makefile.am b/src/Makefile.am
index 2bc65664..b035fbd2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -564,8 +564,8 @@ protoc_inputs = \
google/protobuf/unittest_preserve_unknown_enum.proto \
google/protobuf/unittest.proto \
google/protobuf/unittest_proto3_arena.proto \
- google/protobuf/unittest_proto3_arena_lite.proto \
- google/protobuf/unittest_proto3_lite.proto \
+ google/protobuf/unittest_proto3_arena_lite.proto \
+ google/protobuf/unittest_proto3_lite.proto \
google/protobuf/unittest_well_known_types.proto \
google/protobuf/util/internal/testdata/anys.proto \
google/protobuf/util/internal/testdata/books.proto \
@@ -586,6 +586,12 @@ EXTRA_DIST = \
$(protoc_inputs) \
$(js_well_known_types_sources) \
solaris/libstdc++.la \
+ google/protobuf/unittest_proto3.proto \
+ google/protobuf/unittest_import_public_proto3.proto \
+ google/protobuf/unittest_import_proto3.proto \
+ google/protobuf/test_messages_proto3.proto \
+ google/protobuf/test_messages_proto2.proto \
+ google/protobuf/map_unittest_proto3.proto \
google/protobuf/io/gzip_stream.h \
google/protobuf/io/gzip_stream_unittest.sh \
google/protobuf/testdata/golden_message \
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index 60e6fce9..e4364ac2 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -49,8 +49,28 @@ const std::string kDescriptorMetadataFile =
"GPBMetadata/Google/Protobuf/Internal/Descriptor.php";
const std::string kDescriptorDirName = "Google/Protobuf/Internal";
const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal";
-const char* const kReservedNames[] = {"ARRAY", "Empty", "ECHO"};
-const int kReservedNamesSize = 3;
+const char* const kReservedNames[] = {
+ "abstract", "and", "array", "as", "break",
+ "callable", "case", "catch", "class", "clone",
+ "const", "continue", "declare", "default", "die",
+ "do", "echo", "else", "elseif", "empty",
+ "enddeclare", "endfor", "endforeach", "endif", "endswitch",
+ "endwhile", "eval", "exit", "extends", "final",
+ "for", "foreach", "function", "global", "goto",
+ "if", "implements", "include", "include_once", "instanceof",
+ "insteadof", "interface", "isset", "list", "namespace",
+ "new", "or", "print", "private", "protected",
+ "public", "require", "require_once", "return", "static",
+ "switch", "throw", "trait", "try", "unset",
+ "use", "var", "while", "xor", "int",
+ "float", "bool", "string", "true", "false",
+ "null", "void", "iterable"};
+const char* const kValidConstantNames[] = {
+ "int", "float", "bool", "string", "true",
+ "false", "null", "void", "iterable",
+};
+const int kReservedNamesSize = 73;
+const int kValidConstantNamesSize = 9;
const int kFieldSetter = 1;
const int kFieldGetter = 2;
const int kFieldProperty = 3;
@@ -125,8 +145,11 @@ std::string ClassNamePrefix(const string& classname,
bool is_reserved = false;
+ string lower = classname;
+ transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+
for (int i = 0; i < kReservedNamesSize; i++) {
- if (classname == kReservedNames[i]) {
+ if (lower == kReservedNames[i]) {
is_reserved = true;
break;
}
@@ -143,6 +166,33 @@ std::string ClassNamePrefix(const string& classname,
return "";
}
+std::string ConstantNamePrefix(const string& classname) {
+ bool is_reserved = false;
+
+ string lower = classname;
+ transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+
+ for (int i = 0; i < kReservedNamesSize; i++) {
+ if (lower == kReservedNames[i]) {
+ is_reserved = true;
+ break;
+ }
+ }
+
+ for (int i = 0; i < kValidConstantNamesSize; i++) {
+ if (lower == kValidConstantNames[i]) {
+ is_reserved = false;
+ break;
+ }
+ }
+
+ if (is_reserved) {
+ return "PB";
+ }
+
+ return "";
+}
+
template <typename DescriptorType>
std::string NamespacedName(const string& classname,
const DescriptorType* desc, bool is_descriptor) {
@@ -678,7 +728,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
const EnumValueDescriptor* value = en->value(i);
printer->Print(
"->value(\"^name^\", ^number^)\n",
- "name", ClassNamePrefix(value->name(), en) + value->name(),
+ "name", ConstantNamePrefix(value->name()) + value->name(),
"number", IntToString(value->number()));
}
printer->Print("->finalizeToPool();\n\n");
@@ -981,7 +1031,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
const EnumValueDescriptor* value = en->value(i);
GenerateEnumValueDocComment(&printer, value);
printer.Print("const ^name^ = ^number^;\n",
- "name", ClassNamePrefix(value->name(), en) + value->name(),
+ "name", ConstantNamePrefix(value->name()) + value->name(),
"number", IntToString(value->number()));
}
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index 58829560..3f54b848 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -4309,8 +4309,10 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
result->dependencies_once_ = tables_->AllocateOnceDynamic();
result->dependencies_names_ =
tables_->AllocateArray<const string*>(proto.dependency_size());
- memset(result->dependencies_names_, 0,
- sizeof(*result->dependencies_names_) * proto.dependency_size());
+ if (proto.dependency_size() > 0) {
+ memset(result->dependencies_names_, 0,
+ sizeof(*result->dependencies_names_) * proto.dependency_size());
+ }
} else {
result->dependencies_once_ = NULL;
result->dependencies_names_ = NULL;
diff --git a/src/google/protobuf/generated_message_table_driven.h b/src/google/protobuf/generated_message_table_driven.h
index 5b477051..6f3fe666 100644
--- a/src/google/protobuf/generated_message_table_driven.h
+++ b/src/google/protobuf/generated_message_table_driven.h
@@ -44,7 +44,8 @@
// We require C++11 and Clang to use constexpr for variables, as GCC 4.8
// requires constexpr to be consistent between declarations of variables
// unnecessarily (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541).
-#ifdef __clang__
+// VS 2017 Update 3 also supports this usage of constexpr.
+#if defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1911)
#define PROTOBUF_CONSTEXPR_VAR constexpr
#else // !__clang__
#define PROTOBUF_CONSTEXPR_VAR
diff --git a/src/google/protobuf/stubs/io_win32.cc b/src/google/protobuf/stubs/io_win32.cc
index 51656a78..7e1cf785 100644
--- a/src/google/protobuf/stubs/io_win32.cc
+++ b/src/google/protobuf/stubs/io_win32.cc
@@ -195,12 +195,12 @@ string normalize(string path) {
// Join all segments.
bool first = true;
std::ostringstream result;
- for (const auto& s : segments) {
+ for (int i = 0; i < segments.size(); ++i) {
if (!first) {
result << '\\';
}
first = false;
- result << s;
+ result << segments[i];
}
// Preserve trailing separator if the input contained it.
if (!path.empty() && is_separator(path[path.size() - 1])) {
diff --git a/src/google/protobuf/stubs/io_win32_unittest.cc b/src/google/protobuf/stubs/io_win32_unittest.cc
index 90bd9c96..3ef6c75d 100644
--- a/src/google/protobuf/stubs/io_win32_unittest.cc
+++ b/src/google/protobuf/stubs/io_win32_unittest.cc
@@ -34,7 +34,7 @@
//
// This file is only used on Windows, it's empty on other platforms.
-#if defined(_WIN32)
+#if defined(_MSC_VER)
#define WIN32_LEAN_AND_MEAN
#include <errno.h>
@@ -47,6 +47,7 @@
#include <windows.h>
#include <google/protobuf/stubs/io_win32.h>
+#include <google/protobuf/stubs/scoped_ptr.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
@@ -61,13 +62,12 @@ namespace win32 {
namespace {
using std::string;
-using std::unique_ptr;
using std::wstring;
class IoWin32Test : public ::testing::Test {
public:
- void SetUp() override;
- void TearDown() override;
+ void SetUp();
+ void TearDown();
protected:
bool CreateAllUnder(wstring path);
@@ -83,21 +83,31 @@ class IoWin32Test : public ::testing::Test {
EXPECT_FALSE(wtest_tmpdir.empty()); \
}
+namespace {
+void StripTrailingSlashes(string* str) {
+ int i = str->size() - 1;
+ for (; i >= 0 && ((*str)[i] == '/' || (*str)[i] == '\\'); --i) {}
+ str->resize(i+1);
+}
+} // namespace
+
void IoWin32Test::SetUp() {
test_tmpdir = string(TestTempDir());
wtest_tmpdir.clear();
if (test_tmpdir.empty()) {
const char* test_tmpdir_env = getenv("TEST_TMPDIR");
- if (test_tmpdir_env != nullptr && *test_tmpdir_env) {
+ if (test_tmpdir_env != NULL && *test_tmpdir_env) {
test_tmpdir = string(test_tmpdir_env);
}
// Only Bazel defines TEST_TMPDIR, CMake does not, so look for other
// suitable environment variables.
if (test_tmpdir.empty()) {
- for (const char* name : {"TEMP", "TMP"}) {
+ static const char* names[] = {"TEMP", "TMP"};
+ for (int i = 0; i < sizeof(names)/sizeof(names[0]); ++i) {
+ const char* name = names[i];
test_tmpdir_env = getenv(name);
- if (test_tmpdir_env != nullptr && *test_tmpdir_env) {
+ if (test_tmpdir_env != NULL && *test_tmpdir_env) {
test_tmpdir = string(test_tmpdir_env);
break;
}
@@ -128,9 +138,7 @@ void IoWin32Test::SetUp() {
}
}
- while (test_tmpdir.back() == '/' || test_tmpdir.back() == '\\') {
- test_tmpdir.pop_back();
- }
+ StripTrailingSlashes(&test_tmpdir);
test_tmpdir += "\\io_win32_unittest.tmp";
// CreateDirectoryA's limit is 248 chars, see MSDN.
@@ -185,7 +193,7 @@ bool IoWin32Test::DeleteAllUnder(wstring path) {
path = wstring(L"\\\\?\\") + path;
}
// Append "\" if necessary.
- if (path.back() != '\\') {
+ if (path[path.size() - 1] != '\\') {
path.push_back('\\');
}
@@ -326,7 +334,7 @@ TEST_F(IoWin32Test, ChdirTest) {
TEST_F(IoWin32Test, AsWindowsPathTest) {
DWORD size = GetCurrentDirectoryW(0, NULL);
- unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]);
+ scoped_array<wchar_t> cwd_str(new wchar_t[size]);
EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0);
wstring cwd = wstring(L"\\\\?\\") + cwd_str.get();
@@ -363,5 +371,5 @@ TEST_F(IoWin32Test, AsWindowsPathTest) {
} // namespace protobuf
} // namespace google
-#endif // defined(_WIN32)
+#endif // defined(_MSC_VER)
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 2ea97785..eed2a768 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -1244,10 +1244,12 @@ class TextFormat::Printer::TextGenerator
while (size > buffer_size_) {
// Data exceeds space in the buffer. Copy what we can and request a
// new buffer.
- memcpy(buffer_, data, buffer_size_);
- data += buffer_size_;
- size -= buffer_size_;
- void* void_buffer;
+ if (buffer_size_ > 0) {
+ memcpy(buffer_, data, buffer_size_);
+ data += buffer_size_;
+ size -= buffer_size_;
+ }
+ void* void_buffer = NULL;
failed_ = !output_->Next(&void_buffer, &buffer_size_);
if (failed_) return;
buffer_ = reinterpret_cast<char*>(void_buffer);
diff --git a/src/google/protobuf/util/internal/json_escaping.h b/src/google/protobuf/util/internal/json_escaping.h
index e3e329fc..9b8b2afd 100644
--- a/src/google/protobuf/util/internal/json_escaping.h
+++ b/src/google/protobuf/util/internal/json_escaping.h
@@ -86,6 +86,6 @@ class JsonEscaping {
} // namespace converter
} // namespace util
} // namespace protobuf
+} // namespace google
#endif // NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_
-} // namespace google
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index c85f1899..ce3569ce 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -61,9 +61,11 @@ void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
buffer_size_ -= len;
return;
}
- memcpy(buffer_, bytes, buffer_size_);
- bytes += buffer_size_;
- len -= buffer_size_;
+ if (buffer_size_ > 0) {
+ memcpy(buffer_, bytes, buffer_size_);
+ bytes += buffer_size_;
+ len -= buffer_size_;
+ }
if (!stream_->Next(&buffer_, &buffer_size_)) {
// There isn't a way for ByteSink to report errors.
buffer_size_ = 0;
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index f4f4380a..dee3ddba 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -179,7 +179,7 @@ namespace internal {
class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
public:
explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)
- : stream_(stream), buffer_size_(0) {}
+ : stream_(stream), buffer_(NULL), buffer_size_(0) {}
~ZeroCopyStreamByteSink();
virtual void Append(const char* bytes, size_t len);
diff --git a/tests.sh b/tests.sh
index 689b8913..66baeb15 100755
--- a/tests.sh
+++ b/tests.sh
@@ -61,9 +61,8 @@ build_cpp_distcheck() {
make dist
# List all files that should be included in the distribution package.
- git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\)" |\
+ git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
- grep -v "cmake/protobuf.*\.pc\.cmake" |\
grep -v "python/compatibility_tests" | grep -v "csharp/compatibility_tests" > dist.lst
# Unzip the dist tar file.
DIST=`ls *.tar.gz`
@@ -347,18 +346,23 @@ generate_php_test_proto() {
# Generate test file
rm -rf generated
mkdir generated
- ../../src/protoc --php_out=generated \
- proto/test.proto \
- proto/test_include.proto \
- proto/test_no_namespace.proto \
- proto/test_prefix.proto \
- proto/test_php_namespace.proto \
- proto/test_empty_php_namespace.proto \
- proto/test_service.proto \
- proto/test_service_namespace.proto \
+ ../../src/protoc --php_out=generated \
+ proto/test.proto \
+ proto/test_include.proto \
+ proto/test_no_namespace.proto \
+ proto/test_prefix.proto \
+ proto/test_php_namespace.proto \
+ proto/test_empty_php_namespace.proto \
+ proto/test_reserved_enum_lower.proto \
+ proto/test_reserved_enum_upper.proto \
+ proto/test_reserved_enum_value_lower.proto \
+ proto/test_reserved_enum_value_upper.proto \
+ proto/test_reserved_message_lower.proto \
+ proto/test_reserved_message_upper.proto \
+ proto/test_service.proto \
+ proto/test_service_namespace.proto \
proto/test_descriptors.proto
pushd ../../src
- ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto
./protoc --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto
popd
popd