Browse Source

Merge remote-tracking branch 'upstream/master'

Pete Warden 9 years ago
parent
commit
bc2d6c2504
76 changed files with 3334 additions and 2127 deletions
  1. 15 37
      BUILD
  2. 1 1
      Makefile.am
  3. 19 14
      WORKSPACE
  4. 12 4
      conformance/conformance_ruby.rb
  5. 4 140
      conformance/failure_list_ruby.txt
  6. 1 0
      csharp/.gitignore
  7. 22 0
      csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
  8. 28 0
      csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
  9. 9 0
      csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
  10. 41 5
      csharp/src/Google.Protobuf/CodedInputStream.cs
  11. 60 7
      csharp/src/Google.Protobuf/CodedOutputStream.cs
  12. 4 3
      csharp/src/Google.Protobuf/Collections/MapField.cs
  13. 4 3
      csharp/src/Google.Protobuf/Collections/RepeatedField.cs
  14. 131 117
      csharp/src/Google.Protobuf/JsonFormatter.cs
  15. 9 8
      csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
  16. 1 1
      js/binary/proto_test.js
  17. 52 0
      js/commonjs/import_test.js
  18. 3 2
      js/commonjs/rewrite_tests_for_commonjs.js
  19. 40 0
      js/commonjs/test6/test6.proto
  20. 42 0
      js/commonjs/test7/test7.proto
  21. 7 6
      js/gulpfile.js
  22. 0 1
      js/test.proto
  23. 50 16
      objectivec/GPBCodedInputStream.h
  24. 104 102
      objectivec/GPBCodedOutputStream.h
  25. 3 14
      objectivec/GPBCodedOutputStream.m
  26. 126 0
      objectivec/GPBCodedOutputStream_PackagePrivate.h
  27. 1 1
      objectivec/GPBDictionary.m
  28. 1 1
      objectivec/GPBExtensionInternals.m
  29. 34 19
      objectivec/GPBExtensionRegistry.h
  30. 179 48
      objectivec/GPBMessage.h
  31. 1 1
      objectivec/GPBMessage.m
  32. 4 3
      objectivec/GPBRootObject.h
  33. 31 2
      objectivec/GPBUnknownField.h
  34. 1 1
      objectivec/GPBUnknownField.m
  35. 16 1
      objectivec/GPBUnknownFieldSet.h
  36. 110 40
      objectivec/GPBUtilities.h
  37. 3 1
      objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
  38. 3 1
      objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
  39. 20 1
      objectivec/Tests/GPBCodedOuputStreamTests.m
  40. 18 0
      objectivec/Tests/GPBMessageTests.m
  41. 12 0
      objectivec/Tests/unittest_objc.proto
  42. 59 57
      objectivec/google/protobuf/Any.pbobjc.h
  43. 141 124
      objectivec/google/protobuf/Api.pbobjc.h
  44. 362 300
      objectivec/google/protobuf/Descriptor.pbobjc.h
  45. 56 54
      objectivec/google/protobuf/Duration.pbobjc.h
  46. 17 15
      objectivec/google/protobuf/Empty.pbobjc.h
  47. 132 129
      objectivec/google/protobuf/FieldMask.pbobjc.h
  48. 12 10
      objectivec/google/protobuf/SourceContext.pbobjc.h
  49. 52 37
      objectivec/google/protobuf/Struct.pbobjc.h
  50. 68 66
      objectivec/google/protobuf/Timestamp.pbobjc.h
  51. 118 71
      objectivec/google/protobuf/Type.pbobjc.h
  52. 44 42
      objectivec/google/protobuf/Wrappers.pbobjc.h
  53. 34 50
      protobuf.bzl
  54. 4 1
      python/google/__init__.py
  55. 7 1
      python/google/protobuf/__init__.py
  56. 4 0
      python/google/protobuf/pyext/__init__.py
  57. 44 1
      ruby/Rakefile
  58. 5 0
      ruby/ext/google/protobuf_c/defs.c
  59. 15 4
      ruby/ext/google/protobuf_c/encode_decode.c
  60. 1 0
      ruby/ext/google/protobuf_c/protobuf.h
  61. 479 407
      ruby/ext/google/protobuf_c/upb.c
  62. 307 40
      ruby/ext/google/protobuf_c/upb.h
  63. 1 1
      ruby/tests/basic.rb
  64. 0 74
      ruby/tests/generated_code.rb
  65. 4 2
      src/google/protobuf/compiler/cpp/cpp_enum.cc
  66. 15 1
      src/google/protobuf/compiler/js/js_generator.cc
  67. 5 1
      src/google/protobuf/compiler/objectivec/objectivec_enum.cc
  68. 5 0
      src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
  69. 9 7
      src/google/protobuf/compiler/objectivec/objectivec_field.cc
  70. 8 6
      src/google/protobuf/compiler/objectivec/objectivec_file.cc
  71. 13 12
      src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
  72. 1 0
      src/google/protobuf/compiler/objectivec/objectivec_helpers.h
  73. 1 0
      src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
  74. 73 11
      src/google/protobuf/compiler/ruby/ruby_generator.cc
  75. 5 1
      src/google/protobuf/map.h
  76. 11 1
      util/python/BUILD

+ 15 - 37
BUILD

@@ -22,7 +22,6 @@ load(
     "protobuf",
     "protobuf",
     "cc_proto_library",
     "cc_proto_library",
     "py_proto_library",
     "py_proto_library",
-    "internal_copied_filegroup",
     "internal_protobuf_py_tests",
     "internal_protobuf_py_tests",
 )
 )
 
 
@@ -525,25 +524,7 @@ java_library(
 # Python support
 # Python support
 ################################################################################
 ################################################################################
 
 
-# Hack:
-# protoc generated files contain imports like:
-#   "from google.protobuf.xxx import yyy"
-# However, the sources files of the python runtime are not directly under
-# "google/protobuf" (they are under python/google/protobuf).  We workaround
-# this by copying runtime source files into the desired location to workaround
-# the import issue. Ideally py_library should support something similiar to the
-# "include" attribute in cc_library to inject the PYTHON_PATH for all libraries
-# that depend on the target.
-#
-# If you use python protobuf as a third_party library in your bazel managed
-# project:
-# 1) Please import the whole package to //google/protobuf in your
-# project. Otherwise, bazel disallows generated files out of the current
-# package, thus we won't be able to copy protobuf runtime files into
-# //google/protobuf/.
-# 2) The runtime also requires "six" for Python2/3 compatibility, please see the
-# WORKSPACE file and bind "six" to your workspace as well.
-internal_copied_filegroup(
+py_library(
     name = "python_srcs",
     name = "python_srcs",
     srcs = glob(
     srcs = glob(
         [
         [
@@ -555,7 +536,7 @@ internal_copied_filegroup(
             "python/google/protobuf/internal/test_util.py",
             "python/google/protobuf/internal/test_util.py",
         ],
         ],
     ),
     ),
-    include = "python",
+    imports = ["python"],
 )
 )
 
 
 cc_binary(
 cc_binary(
@@ -568,7 +549,7 @@ cc_binary(
     linkstatic = 1,
     linkstatic = 1,
     deps = select({
     deps = select({
         "//conditions:default": [],
         "//conditions:default": [],
-        ":use_fast_cpp_protos": ["//util/python:python_headers"],
+        ":use_fast_cpp_protos": ["//external:python_headers"],
     }),
     }),
 )
 )
 
 
@@ -594,7 +575,7 @@ cc_binary(
         ":protobuf",
         ":protobuf",
     ] + select({
     ] + select({
         "//conditions:default": [],
         "//conditions:default": [],
-        ":use_fast_cpp_protos": ["//util/python:python_headers"],
+        ":use_fast_cpp_protos": ["//external:python_headers"],
     }),
     }),
 )
 )
 
 
@@ -625,23 +606,14 @@ py_proto_library(
     }),
     }),
     default_runtime = "",
     default_runtime = "",
     protoc = ":protoc",
     protoc = ":protoc",
-    py_extra_srcs = [":python_srcs"],
-    py_libs = ["//external:six"],
+    py_libs = [
+        ":python_srcs",
+        "//external:six"
+    ],
     srcs_version = "PY2AND3",
     srcs_version = "PY2AND3",
     visibility = ["//visibility:public"],
     visibility = ["//visibility:public"],
 )
 )
 
 
-internal_copied_filegroup(
-    name = "python_test_srcs",
-    srcs = glob(
-        [
-            "python/google/protobuf/internal/*_test.py",
-            "python/google/protobuf/internal/test_util.py",
-        ],
-    ),
-    include = "python",
-)
-
 py_proto_library(
 py_proto_library(
     name = "python_common_test_protos",
     name = "python_common_test_protos",
     srcs = LITE_TEST_PROTOS + TEST_PROTOS,
     srcs = LITE_TEST_PROTOS + TEST_PROTOS,
@@ -665,7 +637,13 @@ py_proto_library(
 
 
 py_library(
 py_library(
     name = "python_tests",
     name = "python_tests",
-    srcs = [":python_test_srcs"],
+    srcs = glob(
+        [
+            "python/google/protobuf/internal/*_test.py",
+            "python/google/protobuf/internal/test_util.py",
+        ],
+    ),
+    imports = ["python"],
     srcs_version = "PY2AND3",
     srcs_version = "PY2AND3",
     deps = [
     deps = [
         ":protobuf_python",
         ":protobuf_python",

+ 1 - 1
Makefile.am

@@ -413,6 +413,7 @@ objectivec_EXTRA_DIST=                                                       \
   objectivec/GPBCodedInputStream_PackagePrivate.h                            \
   objectivec/GPBCodedInputStream_PackagePrivate.h                            \
   objectivec/GPBCodedOutputStream.h                                          \
   objectivec/GPBCodedOutputStream.h                                          \
   objectivec/GPBCodedOutputStream.m                                          \
   objectivec/GPBCodedOutputStream.m                                          \
+  objectivec/GPBCodedOutputStream_PackagePrivate.h                           \
   objectivec/GPBDescriptor.h                                                 \
   objectivec/GPBDescriptor.h                                                 \
   objectivec/GPBDescriptor.m                                                 \
   objectivec/GPBDescriptor.m                                                 \
   objectivec/GPBDescriptor_PackagePrivate.h                                  \
   objectivec/GPBDescriptor_PackagePrivate.h                                  \
@@ -653,7 +654,6 @@ ruby_EXTRA_DIST=                                                             \
   ruby/tests/repeated_field_test.rb                                          \
   ruby/tests/repeated_field_test.rb                                          \
   ruby/tests/stress.rb                                                       \
   ruby/tests/stress.rb                                                       \
   ruby/tests/generated_code.proto                                            \
   ruby/tests/generated_code.proto                                            \
-  ruby/tests/generated_code.rb                                               \
   ruby/tests/generated_code_test.rb                                          \
   ruby/tests/generated_code_test.rb                                          \
   ruby/travis-test.sh
   ruby/travis-test.sh
 
 

+ 19 - 14
WORKSPACE

@@ -1,28 +1,33 @@
 new_http_archive(
 new_http_archive(
-  name = "gmock_archive",
-  url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
-  sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
-  build_file = "gmock.BUILD",
+    name = "gmock_archive",
+    url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
+    sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
+    build_file = "gmock.BUILD",
 )
 )
 
 
 new_http_archive(
 new_http_archive(
-  name = "six_archive",
-  url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
-  sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
-  build_file = "six.BUILD",
+    name = "six_archive",
+    url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
+    sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
+    build_file = "six.BUILD",
 )
 )
 
 
 bind(
 bind(
-  name = "gtest",
-  actual = "@gmock_archive//:gtest",
+    name = "python_headers",
+    actual = "//util/python:python_headers",
 )
 )
 
 
 bind(
 bind(
-  name = "gtest_main",
-  actual = "@gmock_archive//:gtest_main",
+    name = "gtest",
+    actual = "@gmock_archive//:gtest",
 )
 )
 
 
 bind(
 bind(
-  name = "six",
-  actual = "@six_archive//:six",
+    name = "gtest_main",
+    actual = "@gmock_archive//:gtest_main",
+)
+
+bind(
+    name = "six",
+    actual = "@six_archive//:six",
 )
 )

+ 12 - 4
conformance/conformance_ruby.rb

@@ -51,7 +51,12 @@ def do_test(request)
       end
       end
 
 
     when :json_payload
     when :json_payload
-      test_message = Conformance::TestAllTypes.decode_json(request.json_payload)
+      begin
+        test_message = Conformance::TestAllTypes.decode_json(request.json_payload)
+      rescue Google::Protobuf::ParseError => err
+        response.parse_error = err.message.encode('utf-8')
+        return response
+      end
 
 
     when nil
     when nil
       fail "Request didn't have payload"
       fail "Request didn't have payload"
@@ -66,6 +71,9 @@ def do_test(request)
 
 
     when :JSON
     when :JSON
       response.json_payload = test_message.to_json
       response.json_payload = test_message.to_json
+
+    when nil
+      fail "Request didn't have requested output format"
     end
     end
   rescue StandardError => err
   rescue StandardError => err
     response.runtime_error = err.message.encode('utf-8')
     response.runtime_error = err.message.encode('utf-8')
@@ -96,8 +104,8 @@ def do_test_io
   STDOUT.flush
   STDOUT.flush
 
 
   if $verbose
   if $verbose
-    STDERR.puts("conformance-cpp: request={request.to_json}, " \
-                                 "response={response.to_json}\n")
+    STDERR.puts("conformance_ruby: request=#{request.to_json}, " \
+                                 "response=#{response.to_json}\n")
   end
   end
 
 
   $test_count += 1
   $test_count += 1
@@ -107,7 +115,7 @@ end
 
 
 loop do
 loop do
   unless do_test_io
   unless do_test_io
-    STDERR.puts('conformance-cpp: received EOF from test runner ' \
+    STDERR.puts('conformance_ruby: received EOF from test runner ' \
                 "after #{$test_count} tests, exiting")
                 "after #{$test_count} tests, exiting")
     break
     break
   end
   end

+ 4 - 140
conformance/failure_list_ruby.txt

@@ -1,18 +1,12 @@
-# Many of the JSON tests are failing due to a simple bug:
-# fields are not camel-cased at all right now.  Once this
-# is fixed, this list should grow a lot shorter.
-
 DurationProtoInputTooLarge.JsonOutput
 DurationProtoInputTooLarge.JsonOutput
 DurationProtoInputTooSmall.JsonOutput
 DurationProtoInputTooSmall.JsonOutput
 FieldMaskNumbersDontRoundTrip.JsonOutput
 FieldMaskNumbersDontRoundTrip.JsonOutput
 FieldMaskPathsDontRoundTrip.JsonOutput
 FieldMaskPathsDontRoundTrip.JsonOutput
 FieldMaskTooManyUnderscore.JsonOutput
 FieldMaskTooManyUnderscore.JsonOutput
-JsonInput.AllFieldAcceptNull.JsonOutput
-JsonInput.AllFieldAcceptNull.ProtobufOutput
 JsonInput.Any.JsonOutput
 JsonInput.Any.JsonOutput
+JsonInput.Any.ProtobufOutput
 JsonInput.AnyNested.JsonOutput
 JsonInput.AnyNested.JsonOutput
 JsonInput.AnyNested.ProtobufOutput
 JsonInput.AnyNested.ProtobufOutput
-JsonInput.Any.ProtobufOutput
 JsonInput.AnyUnorderedTypeTag.JsonOutput
 JsonInput.AnyUnorderedTypeTag.JsonOutput
 JsonInput.AnyUnorderedTypeTag.ProtobufOutput
 JsonInput.AnyUnorderedTypeTag.ProtobufOutput
 JsonInput.AnyWithDuration.JsonOutput
 JsonInput.AnyWithDuration.JsonOutput
@@ -29,31 +23,9 @@ JsonInput.AnyWithValueForInteger.JsonOutput
 JsonInput.AnyWithValueForInteger.ProtobufOutput
 JsonInput.AnyWithValueForInteger.ProtobufOutput
 JsonInput.AnyWithValueForJsonObject.JsonOutput
 JsonInput.AnyWithValueForJsonObject.JsonOutput
 JsonInput.AnyWithValueForJsonObject.ProtobufOutput
 JsonInput.AnyWithValueForJsonObject.ProtobufOutput
-JsonInput.BoolFieldAllCapitalFalse
-JsonInput.BoolFieldAllCapitalTrue
-JsonInput.BoolFieldCamelCaseFalse
-JsonInput.BoolFieldCamelCaseTrue
-JsonInput.BoolFieldDoubleQuotedFalse
-JsonInput.BoolFieldDoubleQuotedTrue
-JsonInput.BoolFieldFalse.JsonOutput
-JsonInput.BoolFieldFalse.ProtobufOutput
 JsonInput.BoolFieldIntegerOne
 JsonInput.BoolFieldIntegerOne
 JsonInput.BoolFieldIntegerZero
 JsonInput.BoolFieldIntegerZero
-JsonInput.BoolFieldTrue.JsonOutput
-JsonInput.BoolFieldTrue.ProtobufOutput
-JsonInput.BoolMapEscapedKey.JsonOutput
-JsonInput.BoolMapEscapedKey.ProtobufOutput
-JsonInput.BoolMapField.JsonOutput
-JsonInput.BoolMapFieldKeyNotQuoted
-JsonInput.BoolMapField.ProtobufOutput
-JsonInput.BytesFieldInvalidBase64Characters
-JsonInput.BytesField.JsonOutput
-JsonInput.BytesFieldNoPadding
-JsonInput.BytesField.ProtobufOutput
-JsonInput.BytesRepeatedField.JsonOutput
-JsonInput.BytesRepeatedField.ProtobufOutput
 JsonInput.DoubleFieldInfinity.JsonOutput
 JsonInput.DoubleFieldInfinity.JsonOutput
-JsonInput.DoubleFieldInfinityNotQuoted
 JsonInput.DoubleFieldInfinity.ProtobufOutput
 JsonInput.DoubleFieldInfinity.ProtobufOutput
 JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
 JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
 JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
 JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
@@ -64,136 +36,74 @@ JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
 JsonInput.DoubleFieldMinPositiveValue.JsonOutput
 JsonInput.DoubleFieldMinPositiveValue.JsonOutput
 JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
 JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
 JsonInput.DoubleFieldNan.JsonOutput
 JsonInput.DoubleFieldNan.JsonOutput
-JsonInput.DoubleFieldNanNotQuoted
 JsonInput.DoubleFieldNan.ProtobufOutput
 JsonInput.DoubleFieldNan.ProtobufOutput
 JsonInput.DoubleFieldNegativeInfinity.JsonOutput
 JsonInput.DoubleFieldNegativeInfinity.JsonOutput
-JsonInput.DoubleFieldNegativeInfinityNotQuoted
 JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
 JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
 JsonInput.DoubleFieldQuotedValue.JsonOutput
 JsonInput.DoubleFieldQuotedValue.JsonOutput
 JsonInput.DoubleFieldQuotedValue.ProtobufOutput
 JsonInput.DoubleFieldQuotedValue.ProtobufOutput
-JsonInput.DoubleFieldTooLarge
-JsonInput.DoubleFieldTooSmall
 JsonInput.DurationHas3FractionalDigits.Validator
 JsonInput.DurationHas3FractionalDigits.Validator
 JsonInput.DurationHas6FractionalDigits.Validator
 JsonInput.DurationHas6FractionalDigits.Validator
 JsonInput.DurationHas9FractionalDigits.Validator
 JsonInput.DurationHas9FractionalDigits.Validator
 JsonInput.DurationHasZeroFractionalDigit.Validator
 JsonInput.DurationHasZeroFractionalDigit.Validator
-JsonInput.DurationJsonInputTooLarge
-JsonInput.DurationJsonInputTooSmall
 JsonInput.DurationMaxValue.JsonOutput
 JsonInput.DurationMaxValue.JsonOutput
 JsonInput.DurationMaxValue.ProtobufOutput
 JsonInput.DurationMaxValue.ProtobufOutput
 JsonInput.DurationMinValue.JsonOutput
 JsonInput.DurationMinValue.JsonOutput
 JsonInput.DurationMinValue.ProtobufOutput
 JsonInput.DurationMinValue.ProtobufOutput
-JsonInput.DurationMissingS
 JsonInput.DurationRepeatedValue.JsonOutput
 JsonInput.DurationRepeatedValue.JsonOutput
 JsonInput.DurationRepeatedValue.ProtobufOutput
 JsonInput.DurationRepeatedValue.ProtobufOutput
-JsonInput.EnumField.JsonOutput
-JsonInput.EnumFieldNotQuoted
 JsonInput.EnumFieldNumericValueNonZero.JsonOutput
 JsonInput.EnumFieldNumericValueNonZero.JsonOutput
 JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
 JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
 JsonInput.EnumFieldNumericValueZero.JsonOutput
 JsonInput.EnumFieldNumericValueZero.JsonOutput
 JsonInput.EnumFieldNumericValueZero.ProtobufOutput
 JsonInput.EnumFieldNumericValueZero.ProtobufOutput
-JsonInput.EnumField.ProtobufOutput
 JsonInput.EnumFieldUnknownValue.Validator
 JsonInput.EnumFieldUnknownValue.Validator
-JsonInput.EnumRepeatedField.JsonOutput
-JsonInput.EnumRepeatedField.ProtobufOutput
-JsonInput.FieldMaskInvalidCharacter
 JsonInput.FieldMask.JsonOutput
 JsonInput.FieldMask.JsonOutput
 JsonInput.FieldMask.ProtobufOutput
 JsonInput.FieldMask.ProtobufOutput
-JsonInput.FieldNameDuplicate
-JsonInput.FieldNameDuplicateDifferentCasing1
-JsonInput.FieldNameDuplicateDifferentCasing2
-JsonInput.FieldNameEscaped.JsonOutput
-JsonInput.FieldNameInLowerCamelCase.Validator
 JsonInput.FieldNameInSnakeCase.JsonOutput
 JsonInput.FieldNameInSnakeCase.JsonOutput
-JsonInput.FieldNameInSnakeCase.ProtobufOutput
-JsonInput.FieldNameNotQuoted
 JsonInput.FieldNameWithMixedCases.JsonOutput
 JsonInput.FieldNameWithMixedCases.JsonOutput
 JsonInput.FieldNameWithMixedCases.ProtobufOutput
 JsonInput.FieldNameWithMixedCases.ProtobufOutput
 JsonInput.FieldNameWithMixedCases.Validator
 JsonInput.FieldNameWithMixedCases.Validator
-JsonInput.FieldNameWithNumbers.JsonOutput
-JsonInput.FieldNameWithNumbers.ProtobufOutput
-JsonInput.FieldNameWithNumbers.Validator
 JsonInput.FloatFieldInfinity.JsonOutput
 JsonInput.FloatFieldInfinity.JsonOutput
-JsonInput.FloatFieldInfinityNotQuoted
 JsonInput.FloatFieldInfinity.ProtobufOutput
 JsonInput.FloatFieldInfinity.ProtobufOutput
-JsonInput.FloatFieldMaxNegativeValue.JsonOutput
-JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput
-JsonInput.FloatFieldMaxPositiveValue.JsonOutput
-JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput
-JsonInput.FloatFieldMinNegativeValue.JsonOutput
-JsonInput.FloatFieldMinNegativeValue.ProtobufOutput
-JsonInput.FloatFieldMinPositiveValue.JsonOutput
-JsonInput.FloatFieldMinPositiveValue.ProtobufOutput
 JsonInput.FloatFieldNan.JsonOutput
 JsonInput.FloatFieldNan.JsonOutput
-JsonInput.FloatFieldNanNotQuoted
 JsonInput.FloatFieldNan.ProtobufOutput
 JsonInput.FloatFieldNan.ProtobufOutput
 JsonInput.FloatFieldNegativeInfinity.JsonOutput
 JsonInput.FloatFieldNegativeInfinity.JsonOutput
-JsonInput.FloatFieldNegativeInfinityNotQuoted
 JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
 JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
 JsonInput.FloatFieldQuotedValue.JsonOutput
 JsonInput.FloatFieldQuotedValue.JsonOutput
 JsonInput.FloatFieldQuotedValue.ProtobufOutput
 JsonInput.FloatFieldQuotedValue.ProtobufOutput
 JsonInput.FloatFieldTooLarge
 JsonInput.FloatFieldTooLarge
 JsonInput.FloatFieldTooSmall
 JsonInput.FloatFieldTooSmall
-JsonInput.HelloWorld.JsonOutput
-JsonInput.HelloWorld.ProtobufOutput
 JsonInput.Int32FieldExponentialFormat.JsonOutput
 JsonInput.Int32FieldExponentialFormat.JsonOutput
 JsonInput.Int32FieldExponentialFormat.ProtobufOutput
 JsonInput.Int32FieldExponentialFormat.ProtobufOutput
 JsonInput.Int32FieldFloatTrailingZero.JsonOutput
 JsonInput.Int32FieldFloatTrailingZero.JsonOutput
 JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
 JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
-JsonInput.Int32FieldLeadingSpace
-JsonInput.Int32FieldLeadingZero
 JsonInput.Int32FieldMaxFloatValue.JsonOutput
 JsonInput.Int32FieldMaxFloatValue.JsonOutput
 JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
 JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Int32FieldMaxValue.JsonOutput
-JsonInput.Int32FieldMaxValue.ProtobufOutput
 JsonInput.Int32FieldMinFloatValue.JsonOutput
 JsonInput.Int32FieldMinFloatValue.JsonOutput
 JsonInput.Int32FieldMinFloatValue.ProtobufOutput
 JsonInput.Int32FieldMinFloatValue.ProtobufOutput
 JsonInput.Int32FieldMinValue.JsonOutput
 JsonInput.Int32FieldMinValue.JsonOutput
-JsonInput.Int32FieldMinValue.ProtobufOutput
-JsonInput.Int32FieldNegativeWithLeadingZero
-JsonInput.Int32FieldNotInteger
-JsonInput.Int32FieldNotNumber
-JsonInput.Int32FieldPlusSign
-JsonInput.Int32FieldStringValueEscaped.JsonOutput
-JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
 JsonInput.Int32FieldStringValue.JsonOutput
 JsonInput.Int32FieldStringValue.JsonOutput
 JsonInput.Int32FieldStringValue.ProtobufOutput
 JsonInput.Int32FieldStringValue.ProtobufOutput
-JsonInput.Int32FieldTooLarge
-JsonInput.Int32FieldTooSmall
-JsonInput.Int32FieldTrailingSpace
+JsonInput.Int32FieldStringValueEscaped.JsonOutput
+JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
 JsonInput.Int32MapEscapedKey.JsonOutput
 JsonInput.Int32MapEscapedKey.JsonOutput
 JsonInput.Int32MapEscapedKey.ProtobufOutput
 JsonInput.Int32MapEscapedKey.ProtobufOutput
 JsonInput.Int32MapField.JsonOutput
 JsonInput.Int32MapField.JsonOutput
-JsonInput.Int32MapFieldKeyNotQuoted
 JsonInput.Int32MapField.ProtobufOutput
 JsonInput.Int32MapField.ProtobufOutput
 JsonInput.Int64FieldBeString.Validator
 JsonInput.Int64FieldBeString.Validator
 JsonInput.Int64FieldMaxValue.JsonOutput
 JsonInput.Int64FieldMaxValue.JsonOutput
-JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
 JsonInput.Int64FieldMaxValue.ProtobufOutput
 JsonInput.Int64FieldMaxValue.ProtobufOutput
 JsonInput.Int64FieldMinValue.JsonOutput
 JsonInput.Int64FieldMinValue.JsonOutput
-JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
-JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput
 JsonInput.Int64FieldMinValue.ProtobufOutput
 JsonInput.Int64FieldMinValue.ProtobufOutput
-JsonInput.Int64FieldNotInteger
-JsonInput.Int64FieldNotNumber
-JsonInput.Int64FieldTooLarge
-JsonInput.Int64FieldTooSmall
 JsonInput.Int64MapEscapedKey.JsonOutput
 JsonInput.Int64MapEscapedKey.JsonOutput
 JsonInput.Int64MapEscapedKey.ProtobufOutput
 JsonInput.Int64MapEscapedKey.ProtobufOutput
 JsonInput.Int64MapField.JsonOutput
 JsonInput.Int64MapField.JsonOutput
-JsonInput.Int64MapFieldKeyNotQuoted
 JsonInput.Int64MapField.ProtobufOutput
 JsonInput.Int64MapField.ProtobufOutput
-JsonInput.JsonWithComments
-JsonInput.MapFieldKeyIsNull
-JsonInput.MapFieldValueIsNull
 JsonInput.MessageField.JsonOutput
 JsonInput.MessageField.JsonOutput
 JsonInput.MessageField.ProtobufOutput
 JsonInput.MessageField.ProtobufOutput
 JsonInput.MessageMapField.JsonOutput
 JsonInput.MessageMapField.JsonOutput
 JsonInput.MessageMapField.ProtobufOutput
 JsonInput.MessageMapField.ProtobufOutput
 JsonInput.MessageRepeatedField.JsonOutput
 JsonInput.MessageRepeatedField.JsonOutput
 JsonInput.MessageRepeatedField.ProtobufOutput
 JsonInput.MessageRepeatedField.ProtobufOutput
-JsonInput.OneofFieldDuplicate
 JsonInput.OptionalBoolWrapper.JsonOutput
 JsonInput.OptionalBoolWrapper.JsonOutput
 JsonInput.OptionalBoolWrapper.ProtobufOutput
 JsonInput.OptionalBoolWrapper.ProtobufOutput
 JsonInput.OptionalBytesWrapper.JsonOutput
 JsonInput.OptionalBytesWrapper.JsonOutput
@@ -215,6 +125,7 @@ JsonInput.OptionalUint64Wrapper.ProtobufOutput
 JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
 JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
 JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
 JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
 JsonInput.OriginalProtoFieldName.JsonOutput
 JsonInput.OriginalProtoFieldName.JsonOutput
+JsonInput.OriginalProtoFieldName.ProtobufOutput
 JsonInput.PrimitiveRepeatedField.JsonOutput
 JsonInput.PrimitiveRepeatedField.JsonOutput
 JsonInput.PrimitiveRepeatedField.ProtobufOutput
 JsonInput.PrimitiveRepeatedField.ProtobufOutput
 JsonInput.RepeatedBoolWrapper.JsonOutput
 JsonInput.RepeatedBoolWrapper.JsonOutput
@@ -223,18 +134,7 @@ JsonInput.RepeatedBytesWrapper.JsonOutput
 JsonInput.RepeatedBytesWrapper.ProtobufOutput
 JsonInput.RepeatedBytesWrapper.ProtobufOutput
 JsonInput.RepeatedDoubleWrapper.JsonOutput
 JsonInput.RepeatedDoubleWrapper.JsonOutput
 JsonInput.RepeatedDoubleWrapper.ProtobufOutput
 JsonInput.RepeatedDoubleWrapper.ProtobufOutput
-JsonInput.RepeatedFieldMessageElementIsNull
-JsonInput.RepeatedFieldPrimitiveElementIsNull
-JsonInput.RepeatedFieldTrailingComma
-JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
-JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
-JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
-JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
-JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
-JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
-JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
 JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
 JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
-JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
 JsonInput.RepeatedFloatWrapper.JsonOutput
 JsonInput.RepeatedFloatWrapper.JsonOutput
 JsonInput.RepeatedFloatWrapper.ProtobufOutput
 JsonInput.RepeatedFloatWrapper.ProtobufOutput
 JsonInput.RepeatedInt32Wrapper.JsonOutput
 JsonInput.RepeatedInt32Wrapper.JsonOutput
@@ -247,39 +147,18 @@ JsonInput.RepeatedUint32Wrapper.JsonOutput
 JsonInput.RepeatedUint32Wrapper.ProtobufOutput
 JsonInput.RepeatedUint32Wrapper.ProtobufOutput
 JsonInput.RepeatedUint64Wrapper.JsonOutput
 JsonInput.RepeatedUint64Wrapper.JsonOutput
 JsonInput.RepeatedUint64Wrapper.ProtobufOutput
 JsonInput.RepeatedUint64Wrapper.ProtobufOutput
-JsonInput.StringFieldEscape.JsonOutput
-JsonInput.StringFieldEscape.ProtobufOutput
-JsonInput.StringFieldInvalidEscape
-JsonInput.StringField.JsonOutput
 JsonInput.StringFieldNotAString
 JsonInput.StringFieldNotAString
-JsonInput.StringField.ProtobufOutput
 JsonInput.StringFieldSurrogateInWrongOrder
 JsonInput.StringFieldSurrogateInWrongOrder
 JsonInput.StringFieldSurrogatePair.JsonOutput
 JsonInput.StringFieldSurrogatePair.JsonOutput
 JsonInput.StringFieldSurrogatePair.ProtobufOutput
 JsonInput.StringFieldSurrogatePair.ProtobufOutput
-JsonInput.StringFieldUnicodeEscape.JsonOutput
-JsonInput.StringFieldUnicodeEscape.ProtobufOutput
-JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
-JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
-JsonInput.StringFieldUnicode.JsonOutput
-JsonInput.StringFieldUnicode.ProtobufOutput
 JsonInput.StringFieldUnpairedHighSurrogate
 JsonInput.StringFieldUnpairedHighSurrogate
 JsonInput.StringFieldUnpairedLowSurrogate
 JsonInput.StringFieldUnpairedLowSurrogate
-JsonInput.StringFieldUnterminatedEscape
-JsonInput.StringFieldUppercaseEscapeLetter
-JsonInput.StringRepeatedField.JsonOutput
-JsonInput.StringRepeatedField.ProtobufOutput
 JsonInput.Struct.JsonOutput
 JsonInput.Struct.JsonOutput
 JsonInput.Struct.ProtobufOutput
 JsonInput.Struct.ProtobufOutput
 JsonInput.TimestampHas3FractionalDigits.Validator
 JsonInput.TimestampHas3FractionalDigits.Validator
 JsonInput.TimestampHas6FractionalDigits.Validator
 JsonInput.TimestampHas6FractionalDigits.Validator
 JsonInput.TimestampHas9FractionalDigits.Validator
 JsonInput.TimestampHas9FractionalDigits.Validator
 JsonInput.TimestampHasZeroFractionalDigit.Validator
 JsonInput.TimestampHasZeroFractionalDigit.Validator
-JsonInput.TimestampJsonInputLowercaseT
-JsonInput.TimestampJsonInputLowercaseZ
-JsonInput.TimestampJsonInputMissingT
-JsonInput.TimestampJsonInputMissingZ
-JsonInput.TimestampJsonInputTooLarge
-JsonInput.TimestampJsonInputTooSmall
 JsonInput.TimestampMaxValue.JsonOutput
 JsonInput.TimestampMaxValue.JsonOutput
 JsonInput.TimestampMaxValue.ProtobufOutput
 JsonInput.TimestampMaxValue.ProtobufOutput
 JsonInput.TimestampMinValue.JsonOutput
 JsonInput.TimestampMinValue.JsonOutput
@@ -291,27 +170,14 @@ JsonInput.TimestampWithNegativeOffset.ProtobufOutput
 JsonInput.TimestampWithPositiveOffset.JsonOutput
 JsonInput.TimestampWithPositiveOffset.JsonOutput
 JsonInput.TimestampWithPositiveOffset.ProtobufOutput
 JsonInput.TimestampWithPositiveOffset.ProtobufOutput
 JsonInput.TimestampZeroNormalized.Validator
 JsonInput.TimestampZeroNormalized.Validator
-JsonInput.TrailingCommaInAnObject
 JsonInput.Uint32FieldMaxFloatValue.JsonOutput
 JsonInput.Uint32FieldMaxFloatValue.JsonOutput
 JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
 JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Uint32FieldMaxValue.JsonOutput
-JsonInput.Uint32FieldMaxValue.ProtobufOutput
-JsonInput.Uint32FieldNotInteger
-JsonInput.Uint32FieldNotNumber
-JsonInput.Uint32FieldTooLarge
 JsonInput.Uint32MapField.JsonOutput
 JsonInput.Uint32MapField.JsonOutput
-JsonInput.Uint32MapFieldKeyNotQuoted
 JsonInput.Uint32MapField.ProtobufOutput
 JsonInput.Uint32MapField.ProtobufOutput
 JsonInput.Uint64FieldBeString.Validator
 JsonInput.Uint64FieldBeString.Validator
 JsonInput.Uint64FieldMaxValue.JsonOutput
 JsonInput.Uint64FieldMaxValue.JsonOutput
-JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
 JsonInput.Uint64FieldMaxValue.ProtobufOutput
 JsonInput.Uint64FieldMaxValue.ProtobufOutput
-JsonInput.Uint64FieldNotInteger
-JsonInput.Uint64FieldNotNumber
-JsonInput.Uint64FieldTooLarge
 JsonInput.Uint64MapField.JsonOutput
 JsonInput.Uint64MapField.JsonOutput
-JsonInput.Uint64MapFieldKeyNotQuoted
 JsonInput.Uint64MapField.ProtobufOutput
 JsonInput.Uint64MapField.ProtobufOutput
 JsonInput.ValueAcceptBool.JsonOutput
 JsonInput.ValueAcceptBool.JsonOutput
 JsonInput.ValueAcceptBool.ProtobufOutput
 JsonInput.ValueAcceptBool.ProtobufOutput
@@ -327,8 +193,6 @@ JsonInput.ValueAcceptObject.JsonOutput
 JsonInput.ValueAcceptObject.ProtobufOutput
 JsonInput.ValueAcceptObject.ProtobufOutput
 JsonInput.ValueAcceptString.JsonOutput
 JsonInput.ValueAcceptString.JsonOutput
 JsonInput.ValueAcceptString.ProtobufOutput
 JsonInput.ValueAcceptString.ProtobufOutput
-JsonInput.WrapperTypesWithNullValue.JsonOutput
-JsonInput.WrapperTypesWithNullValue.ProtobufOutput
 ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
 ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
 ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
 ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
 ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
 ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput

+ 1 - 0
csharp/.gitignore

@@ -33,3 +33,4 @@ mono/.libs
 mono/*.exe
 mono/*.exe
 mono/*.dll
 mono/*.dll
 lib/protoc.exe
 lib/protoc.exe
+*.ncrunch*

+ 22 - 0
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs

@@ -572,5 +572,27 @@ namespace Google.Protobuf
             Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 0, 1));
             Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 0, 1));
             Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 1, 0));
             Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 1, 0));
         }
         }
+
+        [Test]
+        public void Dispose_DisposesUnderlyingStream()
+        {
+            var memoryStream = new MemoryStream();
+            Assert.IsTrue(memoryStream.CanRead);
+            using (var cis = new CodedInputStream(memoryStream))
+            {
+            }
+            Assert.IsFalse(memoryStream.CanRead); // Disposed
+        }
+
+        [Test]
+        public void Dispose_WithLeaveOpen()
+        {
+            var memoryStream = new MemoryStream();
+            Assert.IsTrue(memoryStream.CanRead);
+            using (var cis = new CodedInputStream(memoryStream, true))
+            {
+            }
+            Assert.IsTrue(memoryStream.CanRead); // We left the stream open
+        }
     }
     }
 }
 }

+ 28 - 0
csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs

@@ -387,5 +387,33 @@ namespace Google.Protobuf
                 Assert.IsTrue(cin.IsAtEnd);
                 Assert.IsTrue(cin.IsAtEnd);
             }
             }
         }
         }
+
+        [Test]
+        public void Dispose_DisposesUnderlyingStream()
+        {
+            var memoryStream = new MemoryStream();
+            Assert.IsTrue(memoryStream.CanWrite);
+            using (var cos = new CodedOutputStream(memoryStream))
+            {
+                cos.WriteRawByte(0);
+                Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
+            }
+            Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
+            Assert.IsFalse(memoryStream.CanWrite); // Disposed
+        }
+
+        [Test]
+        public void Dispose_WithLeaveOpen()
+        {
+            var memoryStream = new MemoryStream();
+            Assert.IsTrue(memoryStream.CanWrite);
+            using (var cos = new CodedOutputStream(memoryStream, true))
+            {
+                cos.WriteRawByte(0);
+                Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
+            }
+            Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
+            Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
+        }
     }
     }
 }
 }

+ 9 - 0
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs

@@ -710,5 +710,14 @@ namespace Google.Protobuf
             Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
             Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
             Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
             Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
         }
         }
+
+        [Test]
+        public void CustomDiagnosticMessage_DirectToTextWriterCall()
+        {
+            var message = new ForeignMessage { C = 31 };
+            var writer = new StringWriter();
+            JsonFormatter.Default.Format(message, writer);
+            Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
+        }
     }
     }
 }
 }

+ 41 - 5
csharp/src/Google.Protobuf/CodedInputStream.cs

@@ -51,8 +51,14 @@ namespace Google.Protobuf
     /// and <see cref="MapField{TKey, TValue}"/> to serialize such fields.
     /// and <see cref="MapField{TKey, TValue}"/> to serialize such fields.
     /// </para>
     /// </para>
     /// </remarks>
     /// </remarks>
-    public sealed class CodedInputStream
+    public sealed class CodedInputStream : IDisposable
     {
     {
+        /// <summary>
+        /// Whether to leave the underlying stream open when disposing of this stream.
+        /// This is always true when there's no stream.
+        /// </summary>
+        private readonly bool leaveOpen;
+
         /// <summary>
         /// <summary>
         /// Buffer of data read from the stream or provided at construction time.
         /// Buffer of data read from the stream or provided at construction time.
         /// </summary>
         /// </summary>
@@ -120,7 +126,7 @@ namespace Google.Protobuf
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a new CodedInputStream that reads from the given byte array slice.
+        /// Creates a new <see cref="CodedInputStream"/> that reads from the given byte array slice.
         /// </summary>
         /// </summary>
         public CodedInputStream(byte[] buffer, int offset, int length)
         public CodedInputStream(byte[] buffer, int offset, int length)
             : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length)
             : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length)
@@ -136,13 +142,27 @@ namespace Google.Protobuf
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a new CodedInputStream reading data from the given stream.
+        /// Creates a new <see cref="CodedInputStream"/> reading data from the given stream, which will be disposed
+        /// when the returned object is disposed.
         /// </summary>
         /// </summary>
-        public CodedInputStream(Stream input) : this(input, new byte[BufferSize], 0, 0)
+        /// <param name="input">The stream to read from.</param>
+        public CodedInputStream(Stream input) : this(input, false)
         {
         {
-            ProtoPreconditions.CheckNotNull(input, "input");
         }
         }
 
 
+        /// <summary>
+        /// Creates a new <see cref="CodedInputStream"/> reading data from the given stream.
+        /// </summary>
+        /// <param name="input">The stream to read from.</param>
+        /// <param name="leaveOpen"><c>true</c> to leave <paramref name="input"/> open when the returned
+        /// <c cref="CodedInputStream"/> is disposed; <c>false</c> to dispose of the given stream when the
+        /// returned object is disposed.</param>
+        public CodedInputStream(Stream input, bool leaveOpen)
+            : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0)
+        {
+            this.leaveOpen = leaveOpen;
+        }
+        
         /// <summary>
         /// <summary>
         /// Creates a new CodedInputStream reading data from the given
         /// Creates a new CodedInputStream reading data from the given
         /// stream and buffer, using the default limits.
         /// stream and buffer, using the default limits.
@@ -246,6 +266,22 @@ namespace Google.Protobuf
         /// </value>
         /// </value>
         public int RecursionLimit { get { return recursionLimit; } }
         public int RecursionLimit { get { return recursionLimit; } }
 
 
+        /// <summary>
+        /// Disposes of this instance, potentially closing any underlying stream.
+        /// </summary>
+        /// <remarks>
+        /// As there is no flushing to perform here, disposing of a <see cref="CodedInputStream"/> which
+        /// was constructed with the <c>leaveOpen</c> option parameter set to <c>true</c> (or one which
+        /// was constructed to read from a byte array) has no effect.
+        /// </remarks>
+        public void Dispose()
+        {
+            if (!leaveOpen)
+            {
+                input.Dispose();
+            }
+        }
+
         #region Validation
         #region Validation
         /// <summary>
         /// <summary>
         /// Verifies that the last call to ReadTag() returned tag 0 - in other words,
         /// Verifies that the last call to ReadTag() returned tag 0 - in other words,

+ 60 - 7
csharp/src/Google.Protobuf/CodedOutputStream.cs

@@ -55,7 +55,7 @@ namespace Google.Protobuf
     /// and <c>MapField&lt;TKey, TValue&gt;</c> to serialize such fields.
     /// and <c>MapField&lt;TKey, TValue&gt;</c> to serialize such fields.
     /// </para>
     /// </para>
     /// </remarks>
     /// </remarks>
-    public sealed partial class CodedOutputStream
+    public sealed partial class CodedOutputStream : IDisposable
     {
     {
         // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
         // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.)
         internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
         internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
@@ -65,6 +65,7 @@ namespace Google.Protobuf
         /// </summary>
         /// </summary>
         public static readonly int DefaultBufferSize = 4096;
         public static readonly int DefaultBufferSize = 4096;
 
 
+        private readonly bool leaveOpen;
         private readonly byte[] buffer;
         private readonly byte[] buffer;
         private readonly int limit;
         private readonly int limit;
         private int position;
         private int position;
@@ -91,20 +92,44 @@ namespace Google.Protobuf
             this.buffer = buffer;
             this.buffer = buffer;
             this.position = offset;
             this.position = offset;
             this.limit = offset + length;
             this.limit = offset + length;
+            leaveOpen = true; // Simple way of avoiding trying to dispose of a null reference
         }
         }
 
 
-        private CodedOutputStream(Stream output, byte[] buffer)
+        private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen)
         {
         {
-            this.output = output;
+            this.output = ProtoPreconditions.CheckNotNull(output, nameof(output));
             this.buffer = buffer;
             this.buffer = buffer;
             this.position = 0;
             this.position = 0;
             this.limit = buffer.Length;
             this.limit = buffer.Length;
+            this.leaveOpen = leaveOpen;
+        }
+
+        /// <summary>
+        /// Creates a new <see cref="CodedOutputStream" /> which write to the given stream, and disposes of that
+        /// stream when the returned <c>CodedOutputStream</c> is disposed.
+        /// </summary>
+        /// <param name="output">The stream to write to. It will be disposed when the returned <c>CodedOutputStream is disposed.</c></param>
+        public CodedOutputStream(Stream output) : this(output, DefaultBufferSize, false)
+        {
+        }
+
+        /// <summary>
+        /// Creates a new CodedOutputStream which write to the given stream and uses
+        /// the specified buffer size.
+        /// </summary>
+        /// <param name="output">The stream to write to. It will be disposed when the returned <c>CodedOutputStream is disposed.</c></param>
+        /// <param name="bufferSize">The size of buffer to use internally.</param>
+        public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize], false)
+        {
         }
         }
 
 
         /// <summary>
         /// <summary>
         /// Creates a new CodedOutputStream which write to the given stream.
         /// Creates a new CodedOutputStream which write to the given stream.
         /// </summary>
         /// </summary>
-        public CodedOutputStream(Stream output) : this(output, DefaultBufferSize)
+        /// <param name="output">The stream to write to.</param>
+        /// <param name="leaveOpen">If <c>true</c>, <paramref name="output"/> is left open when the returned <c>CodedOutputStream</c> is disposed;
+        /// if <c>false</c>, the provided stream is disposed as well.</param>
+        public CodedOutputStream(Stream output, bool leaveOpen) : this(output, DefaultBufferSize, leaveOpen)
         {
         {
         }
         }
 
 
@@ -112,9 +137,13 @@ namespace Google.Protobuf
         /// Creates a new CodedOutputStream which write to the given stream and uses
         /// Creates a new CodedOutputStream which write to the given stream and uses
         /// the specified buffer size.
         /// the specified buffer size.
         /// </summary>
         /// </summary>
-        public CodedOutputStream(Stream output, int bufferSize) : this(output, new byte[bufferSize])
+        /// <param name="output">The stream to write to.</param>
+        /// <param name="bufferSize">The size of buffer to use internally.</param>
+        /// <param name="leaveOpen">If <c>true</c>, <paramref name="output"/> is left open when the returned <c>CodedOutputStream</c> is disposed;
+        /// if <c>false</c>, the provided stream is disposed as well.</param>
+        public CodedOutputStream(Stream output, int bufferSize, bool leaveOpen) : this(output, new byte[bufferSize], leaveOpen)
         {
         {
-        }    
+        }
         #endregion
         #endregion
 
 
         /// <summary>
         /// <summary>
@@ -659,6 +688,30 @@ namespace Google.Protobuf
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// Flushes any buffered data and optionally closes the underlying stream, if any.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// By default, any underlying stream is closed by this method. To configure this behaviour,
+        /// use a constructor overload with a <c>leaveOpen</c> parameter. If this instance does not
+        /// have an underlying stream, this method does nothing.
+        /// </para>
+        /// <para>
+        /// For the sake of efficiency, calling this method does not prevent future write calls - but
+        /// if a later write ends up writing to a stream which has been disposed, that is likely to
+        /// fail. It is recommend that you not call any other methods after this.
+        /// </para>
+        /// </remarks>
+        public void Dispose()
+        {
+            Flush();
+            if (!leaveOpen)
+            {
+                output.Dispose();
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// Flushes any buffered data to the underlying stream (if there is one).
         /// Flushes any buffered data to the underlying stream (if there is one).
         /// </summary>
         /// </summary>
@@ -705,4 +758,4 @@ namespace Google.Protobuf
             }
             }
         }
         }
     }
     }
-}
+}

+ 4 - 3
csharp/src/Google.Protobuf/Collections/MapField.cs

@@ -34,6 +34,7 @@ using Google.Protobuf.Reflection;
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using Google.Protobuf.Compatibility;
 using Google.Protobuf.Compatibility;
@@ -474,9 +475,9 @@ namespace Google.Protobuf.Collections
         /// </summary>
         /// </summary>
         public override string ToString()
         public override string ToString()
         {
         {
-            var builder = new StringBuilder();
-            JsonFormatter.Default.WriteDictionary(builder, this);
-            return builder.ToString();
+            var writer = new StringWriter();
+            JsonFormatter.Default.WriteDictionary(writer, this);
+            return writer.ToString();
         }
         }
 
 
         #region IDictionary explicit interface implementation
         #region IDictionary explicit interface implementation

+ 4 - 3
csharp/src/Google.Protobuf/Collections/RepeatedField.cs

@@ -33,6 +33,7 @@
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
 using System.Text;
 
 
 namespace Google.Protobuf.Collections
 namespace Google.Protobuf.Collections
@@ -474,9 +475,9 @@ namespace Google.Protobuf.Collections
         /// </summary>
         /// </summary>
         public override string ToString()
         public override string ToString()
         {
         {
-            var builder = new StringBuilder();
-            JsonFormatter.Default.WriteList(builder, this);
-            return builder.ToString();
+            var writer = new StringWriter();
+            JsonFormatter.Default.WriteList(writer, this);
+            return writer.ToString();
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 131 - 117
csharp/src/Google.Protobuf/JsonFormatter.cs

@@ -36,6 +36,7 @@ using System.Globalization;
 using System.Text;
 using System.Text;
 using Google.Protobuf.Reflection;
 using Google.Protobuf.Reflection;
 using Google.Protobuf.WellKnownTypes;
 using Google.Protobuf.WellKnownTypes;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
@@ -140,18 +141,31 @@ namespace Google.Protobuf
         /// <param name="message">The message to format.</param>
         /// <param name="message">The message to format.</param>
         /// <returns>The formatted message.</returns>
         /// <returns>The formatted message.</returns>
         public string Format(IMessage message)
         public string Format(IMessage message)
+        {
+            var writer = new StringWriter();
+            Format(message, writer);
+            return writer.ToString();
+        }
+
+        /// <summary>
+        /// Formats the specified message as JSON.
+        /// </summary>
+        /// <param name="message">The message to format.</param>
+        /// <param name="writer">The TextWriter to write the formatted message to.</param>
+        /// <returns>The formatted message.</returns>
+        public void Format(IMessage message, TextWriter writer)
         {
         {
             ProtoPreconditions.CheckNotNull(message, nameof(message));
             ProtoPreconditions.CheckNotNull(message, nameof(message));
-            StringBuilder builder = new StringBuilder();
+            ProtoPreconditions.CheckNotNull(writer, nameof(writer));
+
             if (message.Descriptor.IsWellKnownType)
             if (message.Descriptor.IsWellKnownType)
             {
             {
-                WriteWellKnownTypeValue(builder, message.Descriptor, message);
+                WriteWellKnownTypeValue(writer, message.Descriptor, message);
             }
             }
             else
             else
             {
             {
-                WriteMessage(builder, message);
+                WriteMessage(writer, message);
             }
             }
-            return builder.ToString();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -177,11 +191,11 @@ namespace Google.Protobuf
             return diagnosticFormatter.Format(message);
             return diagnosticFormatter.Format(message);
         }
         }
 
 
-        private void WriteMessage(StringBuilder builder, IMessage message)
+        private void WriteMessage(TextWriter writer, IMessage message)
         {
         {
             if (message == null)
             if (message == null)
             {
             {
-                WriteNull(builder);
+                WriteNull(writer);
                 return;
                 return;
             }
             }
             if (DiagnosticOnly)
             if (DiagnosticOnly)
@@ -189,16 +203,16 @@ namespace Google.Protobuf
                 ICustomDiagnosticMessage customDiagnosticMessage = message as ICustomDiagnosticMessage;
                 ICustomDiagnosticMessage customDiagnosticMessage = message as ICustomDiagnosticMessage;
                 if (customDiagnosticMessage != null)
                 if (customDiagnosticMessage != null)
                 {
                 {
-                    builder.Append(customDiagnosticMessage.ToDiagnosticString());
+                    writer.Write(customDiagnosticMessage.ToDiagnosticString());
                     return;
                     return;
                 }
                 }
             }
             }
-            builder.Append("{ ");
-            bool writtenFields = WriteMessageFields(builder, message, false);
-            builder.Append(writtenFields ? " }" : "}");
+            writer.Write("{ ");
+            bool writtenFields = WriteMessageFields(writer, message, false);
+            writer.Write(writtenFields ? " }" : "}");
         }
         }
 
 
-        private bool WriteMessageFields(StringBuilder builder, IMessage message, bool assumeFirstFieldWritten)
+        private bool WriteMessageFields(TextWriter writer, IMessage message, bool assumeFirstFieldWritten)
         {
         {
             var fields = message.Descriptor.Fields;
             var fields = message.Descriptor.Fields;
             bool first = !assumeFirstFieldWritten;
             bool first = !assumeFirstFieldWritten;
@@ -221,11 +235,11 @@ namespace Google.Protobuf
                 // Okay, all tests complete: let's write the field value...
                 // Okay, all tests complete: let's write the field value...
                 if (!first)
                 if (!first)
                 {
                 {
-                    builder.Append(PropertySeparator);
+                    writer.Write(PropertySeparator);
                 }
                 }
-                WriteString(builder, ToCamelCase(accessor.Descriptor.Name));
-                builder.Append(NameValueSeparator);
-                WriteValue(builder, value);
+                WriteString(writer, ToCamelCase(accessor.Descriptor.Name));
+                writer.Write(NameValueSeparator);
+                WriteValue(writer, value);
                 first = false;
                 first = false;
             }            
             }            
             return !first;
             return !first;
@@ -309,9 +323,9 @@ namespace Google.Protobuf
             return result.ToString();
             return result.ToString();
         }
         }
         
         
-        private static void WriteNull(StringBuilder builder)
+        private static void WriteNull(TextWriter writer)
         {
         {
-            builder.Append("null");
+            writer.Write("null");
         }
         }
 
 
         private static bool IsDefaultValue(IFieldAccessor accessor, object value)
         private static bool IsDefaultValue(IFieldAccessor accessor, object value)
@@ -361,56 +375,56 @@ namespace Google.Protobuf
             }
             }
         }
         }
         
         
-        private void WriteValue(StringBuilder builder, object value)
+        private void WriteValue(TextWriter writer, object value)
         {
         {
             if (value == null)
             if (value == null)
             {
             {
-                WriteNull(builder);
+                WriteNull(writer);
             }
             }
             else if (value is bool)
             else if (value is bool)
             {
             {
-                builder.Append((bool) value ? "true" : "false");
+                writer.Write((bool)value ? "true" : "false");
             }
             }
             else if (value is ByteString)
             else if (value is ByteString)
             {
             {
                 // Nothing in Base64 needs escaping
                 // Nothing in Base64 needs escaping
-                builder.Append('"');
-                builder.Append(((ByteString) value).ToBase64());
-                builder.Append('"');
+                writer.Write('"');
+                writer.Write(((ByteString)value).ToBase64());
+                writer.Write('"');
             }
             }
             else if (value is string)
             else if (value is string)
             {
             {
-                WriteString(builder, (string) value);
+                WriteString(writer, (string)value);
             }
             }
             else if (value is IDictionary)
             else if (value is IDictionary)
             {
             {
-                WriteDictionary(builder, (IDictionary) value);
+                WriteDictionary(writer, (IDictionary)value);
             }
             }
             else if (value is IList)
             else if (value is IList)
             {
             {
-                WriteList(builder, (IList) value);
+                WriteList(writer, (IList)value);
             }
             }
             else if (value is int || value is uint)
             else if (value is int || value is uint)
             {
             {
                 IFormattable formattable = (IFormattable) value;
                 IFormattable formattable = (IFormattable) value;
-                builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture));
+                writer.Write(formattable.ToString("d", CultureInfo.InvariantCulture));
             }
             }
             else if (value is long || value is ulong)
             else if (value is long || value is ulong)
             {
             {
-                builder.Append('"');
+                writer.Write('"');
                 IFormattable formattable = (IFormattable) value;
                 IFormattable formattable = (IFormattable) value;
-                builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture));
-                builder.Append('"');
+                writer.Write(formattable.ToString("d", CultureInfo.InvariantCulture));
+                writer.Write('"');
             }
             }
             else if (value is System.Enum)
             else if (value is System.Enum)
             {
             {
                 if (System.Enum.IsDefined(value.GetType(), value))
                 if (System.Enum.IsDefined(value.GetType(), value))
                 {
                 {
-                    WriteString(builder, value.ToString());
+                    WriteString(writer, value.ToString());
                 }
                 }
                 else
                 else
                 {
                 {
-                    WriteValue(builder, (int) value);
+                    WriteValue(writer, (int)value);
                 }
                 }
             }
             }
             else if (value is float || value is double)
             else if (value is float || value is double)
@@ -418,13 +432,13 @@ namespace Google.Protobuf
                 string text = ((IFormattable) value).ToString("r", CultureInfo.InvariantCulture);
                 string text = ((IFormattable) value).ToString("r", CultureInfo.InvariantCulture);
                 if (text == "NaN" || text == "Infinity" || text == "-Infinity")
                 if (text == "NaN" || text == "Infinity" || text == "-Infinity")
                 {
                 {
-                    builder.Append('"');
-                    builder.Append(text);
-                    builder.Append('"');
+                    writer.Write('"');
+                    writer.Write(text);
+                    writer.Write('"');
                 }
                 }
                 else
                 else
                 {
                 {
-                    builder.Append(text);
+                    writer.Write(text);
                 }
                 }
             }
             }
             else if (value is IMessage)
             else if (value is IMessage)
@@ -432,11 +446,11 @@ namespace Google.Protobuf
                 IMessage message = (IMessage) value;
                 IMessage message = (IMessage) value;
                 if (message.Descriptor.IsWellKnownType)
                 if (message.Descriptor.IsWellKnownType)
                 {
                 {
-                    WriteWellKnownTypeValue(builder, message.Descriptor, value);
+                    WriteWellKnownTypeValue(writer, message.Descriptor, value);
                 }
                 }
                 else
                 else
                 {
                 {
-                    WriteMessage(builder, (IMessage) value);
+                    WriteMessage(writer, (IMessage)value);
                 }
                 }
             }
             }
             else
             else
@@ -451,13 +465,13 @@ namespace Google.Protobuf
         /// values are using the embedded well-known types, in order to allow for dynamic messages
         /// values are using the embedded well-known types, in order to allow for dynamic messages
         /// in the future.
         /// in the future.
         /// </summary>
         /// </summary>
-        private void WriteWellKnownTypeValue(StringBuilder builder, MessageDescriptor descriptor, object value)
+        private void WriteWellKnownTypeValue(TextWriter writer, MessageDescriptor descriptor, object value)
         {
         {
             // Currently, we can never actually get here, because null values are always handled by the caller. But if we *could*,
             // Currently, we can never actually get here, because null values are always handled by the caller. But if we *could*,
             // this would do the right thing.
             // this would do the right thing.
             if (value == null)
             if (value == null)
             {
             {
-                WriteNull(builder);
+                WriteNull(writer);
                 return;
                 return;
             }
             }
             // For wrapper types, the value will either be the (possibly boxed) "native" value,
             // For wrapper types, the value will either be the (possibly boxed) "native" value,
@@ -472,49 +486,49 @@ namespace Google.Protobuf
                     var message = (IMessage) value;
                     var message = (IMessage) value;
                     value = message.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.GetValue(message);
                     value = message.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.GetValue(message);
                 }
                 }
-                WriteValue(builder, value);
+                WriteValue(writer, value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == Timestamp.Descriptor.FullName)
             if (descriptor.FullName == Timestamp.Descriptor.FullName)
             {
             {
-                WriteTimestamp(builder, (IMessage) value);
+                WriteTimestamp(writer, (IMessage)value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == Duration.Descriptor.FullName)
             if (descriptor.FullName == Duration.Descriptor.FullName)
             {
             {
-                WriteDuration(builder, (IMessage) value);
+                WriteDuration(writer, (IMessage)value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == FieldMask.Descriptor.FullName)
             if (descriptor.FullName == FieldMask.Descriptor.FullName)
             {
             {
-                WriteFieldMask(builder, (IMessage) value);
+                WriteFieldMask(writer, (IMessage)value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == Struct.Descriptor.FullName)
             if (descriptor.FullName == Struct.Descriptor.FullName)
             {
             {
-                WriteStruct(builder, (IMessage) value);
+                WriteStruct(writer, (IMessage)value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == ListValue.Descriptor.FullName)
             if (descriptor.FullName == ListValue.Descriptor.FullName)
             {
             {
                 var fieldAccessor = descriptor.Fields[ListValue.ValuesFieldNumber].Accessor;
                 var fieldAccessor = descriptor.Fields[ListValue.ValuesFieldNumber].Accessor;
-                WriteList(builder, (IList) fieldAccessor.GetValue((IMessage) value));
+                WriteList(writer, (IList)fieldAccessor.GetValue((IMessage)value));
                 return;
                 return;
             }
             }
             if (descriptor.FullName == Value.Descriptor.FullName)
             if (descriptor.FullName == Value.Descriptor.FullName)
             {
             {
-                WriteStructFieldValue(builder, (IMessage) value);
+                WriteStructFieldValue(writer, (IMessage)value);
                 return;
                 return;
             }
             }
             if (descriptor.FullName == Any.Descriptor.FullName)
             if (descriptor.FullName == Any.Descriptor.FullName)
             {
             {
-                WriteAny(builder, (IMessage) value);
+                WriteAny(writer, (IMessage)value);
                 return;
                 return;
             }
             }
-            WriteMessage(builder, (IMessage) value);
+            WriteMessage(writer, (IMessage)value);
         }
         }
 
 
-        private void WriteTimestamp(StringBuilder builder, IMessage value)
+        private void WriteTimestamp(TextWriter writer, IMessage value)
         {
         {
             // TODO: In the common case where this *is* using the built-in Timestamp type, we could
             // TODO: In the common case where this *is* using the built-in Timestamp type, we could
             // avoid all the reflection at this point, by casting to Timestamp. In the interests of
             // avoid all the reflection at this point, by casting to Timestamp. In the interests of
@@ -522,28 +536,28 @@ namespace Google.Protobuf
             // it still works in that case.
             // it still works in that case.
             int nanos = (int) value.Descriptor.Fields[Timestamp.NanosFieldNumber].Accessor.GetValue(value);
             int nanos = (int) value.Descriptor.Fields[Timestamp.NanosFieldNumber].Accessor.GetValue(value);
             long seconds = (long) value.Descriptor.Fields[Timestamp.SecondsFieldNumber].Accessor.GetValue(value);
             long seconds = (long) value.Descriptor.Fields[Timestamp.SecondsFieldNumber].Accessor.GetValue(value);
-            builder.Append(Timestamp.ToJson(seconds, nanos, DiagnosticOnly));
+            writer.Write(Timestamp.ToJson(seconds, nanos, DiagnosticOnly));
         }
         }
 
 
-        private void WriteDuration(StringBuilder builder, IMessage value)
+        private void WriteDuration(TextWriter writer, IMessage value)
         {
         {
             // TODO: Same as for WriteTimestamp
             // TODO: Same as for WriteTimestamp
             int nanos = (int) value.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.GetValue(value);
             int nanos = (int) value.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.GetValue(value);
             long seconds = (long) value.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.GetValue(value);
             long seconds = (long) value.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.GetValue(value);
-            builder.Append(Duration.ToJson(seconds, nanos, DiagnosticOnly));
+            writer.Write(Duration.ToJson(seconds, nanos, DiagnosticOnly));
         }
         }
 
 
-        private void WriteFieldMask(StringBuilder builder, IMessage value)
+        private void WriteFieldMask(TextWriter writer, IMessage value)
         {
         {
             var paths = (IList<string>) value.Descriptor.Fields[FieldMask.PathsFieldNumber].Accessor.GetValue(value);
             var paths = (IList<string>) value.Descriptor.Fields[FieldMask.PathsFieldNumber].Accessor.GetValue(value);
-            builder.Append(FieldMask.ToJson(paths, DiagnosticOnly));
+            writer.Write(FieldMask.ToJson(paths, DiagnosticOnly));
         }
         }
 
 
-        private void WriteAny(StringBuilder builder, IMessage value)
+        private void WriteAny(TextWriter writer, IMessage value)
         {
         {
             if (DiagnosticOnly)
             if (DiagnosticOnly)
             {
             {
-                WriteDiagnosticOnlyAny(builder, value);
+                WriteDiagnosticOnlyAny(writer, value);
                 return;
                 return;
             }
             }
 
 
@@ -556,40 +570,40 @@ namespace Google.Protobuf
                 throw new InvalidOperationException($"Type registry has no descriptor for type name '{typeName}'");
                 throw new InvalidOperationException($"Type registry has no descriptor for type name '{typeName}'");
             }
             }
             IMessage message = descriptor.Parser.ParseFrom(data);
             IMessage message = descriptor.Parser.ParseFrom(data);
-            builder.Append("{ ");
-            WriteString(builder, AnyTypeUrlField);
-            builder.Append(NameValueSeparator);
-            WriteString(builder, typeUrl);
+            writer.Write("{ ");
+            WriteString(writer, AnyTypeUrlField);
+            writer.Write(NameValueSeparator);
+            WriteString(writer, typeUrl);
 
 
             if (descriptor.IsWellKnownType)
             if (descriptor.IsWellKnownType)
             {
             {
-                builder.Append(PropertySeparator);
-                WriteString(builder, AnyWellKnownTypeValueField);
-                builder.Append(NameValueSeparator);
-                WriteWellKnownTypeValue(builder, descriptor, message);
+                writer.Write(PropertySeparator);
+                WriteString(writer, AnyWellKnownTypeValueField);
+                writer.Write(NameValueSeparator);
+                WriteWellKnownTypeValue(writer, descriptor, message);
             }
             }
             else
             else
             {
             {
-                WriteMessageFields(builder, message, true);
+                WriteMessageFields(writer, message, true);
             }
             }
-            builder.Append(" }");
+            writer.Write(" }");
         }
         }
 
 
-        private void WriteDiagnosticOnlyAny(StringBuilder builder, IMessage value)
+        private void WriteDiagnosticOnlyAny(TextWriter writer, IMessage value)
         {
         {
             string typeUrl = (string) value.Descriptor.Fields[Any.TypeUrlFieldNumber].Accessor.GetValue(value);
             string typeUrl = (string) value.Descriptor.Fields[Any.TypeUrlFieldNumber].Accessor.GetValue(value);
             ByteString data = (ByteString) value.Descriptor.Fields[Any.ValueFieldNumber].Accessor.GetValue(value);
             ByteString data = (ByteString) value.Descriptor.Fields[Any.ValueFieldNumber].Accessor.GetValue(value);
-            builder.Append("{ ");
-            WriteString(builder, AnyTypeUrlField);
-            builder.Append(NameValueSeparator);
-            WriteString(builder, typeUrl);
-            builder.Append(PropertySeparator);
-            WriteString(builder, AnyDiagnosticValueField);
-            builder.Append(NameValueSeparator);
-            builder.Append('"');
-            builder.Append(data.ToBase64());
-            builder.Append('"');
-            builder.Append(" }");
+            writer.Write("{ ");
+            WriteString(writer, AnyTypeUrlField);
+            writer.Write(NameValueSeparator);
+            WriteString(writer, typeUrl);
+            writer.Write(PropertySeparator);
+            WriteString(writer, AnyDiagnosticValueField);
+            writer.Write(NameValueSeparator);
+            writer.Write('"');
+            writer.Write(data.ToBase64());
+            writer.Write('"');
+            writer.Write(" }");
         }
         }
 
 
         internal static string GetTypeName(String typeUrl)
         internal static string GetTypeName(String typeUrl)
@@ -602,9 +616,9 @@ namespace Google.Protobuf
             return parts[1];
             return parts[1];
         }
         }
 
 
-        private void WriteStruct(StringBuilder builder, IMessage message)
+        private void WriteStruct(TextWriter writer, IMessage message)
         {
         {
-            builder.Append("{ ");
+            writer.Write("{ ");
             IDictionary fields = (IDictionary) message.Descriptor.Fields[Struct.FieldsFieldNumber].Accessor.GetValue(message);
             IDictionary fields = (IDictionary) message.Descriptor.Fields[Struct.FieldsFieldNumber].Accessor.GetValue(message);
             bool first = true;
             bool first = true;
             foreach (DictionaryEntry entry in fields)
             foreach (DictionaryEntry entry in fields)
@@ -618,17 +632,17 @@ namespace Google.Protobuf
 
 
                 if (!first)
                 if (!first)
                 {
                 {
-                    builder.Append(PropertySeparator);
+                    writer.Write(PropertySeparator);
                 }
                 }
-                WriteString(builder, key);
-                builder.Append(NameValueSeparator);
-                WriteStructFieldValue(builder, value);
+                WriteString(writer, key);
+                writer.Write(NameValueSeparator);
+                WriteStructFieldValue(writer, value);
                 first = false;
                 first = false;
             }
             }
-            builder.Append(first ? "}" : " }");
+            writer.Write(first ? "}" : " }");
         }
         }
 
 
-        private void WriteStructFieldValue(StringBuilder builder, IMessage message)
+        private void WriteStructFieldValue(TextWriter writer, IMessage message)
         {
         {
             var specifiedField = message.Descriptor.Oneofs[0].Accessor.GetCaseFieldDescriptor(message);
             var specifiedField = message.Descriptor.Oneofs[0].Accessor.GetCaseFieldDescriptor(message);
             if (specifiedField == null)
             if (specifiedField == null)
@@ -643,48 +657,48 @@ namespace Google.Protobuf
                 case Value.BoolValueFieldNumber:
                 case Value.BoolValueFieldNumber:
                 case Value.StringValueFieldNumber:
                 case Value.StringValueFieldNumber:
                 case Value.NumberValueFieldNumber:
                 case Value.NumberValueFieldNumber:
-                    WriteValue(builder, value);
+                    WriteValue(writer, value);
                     return;
                     return;
                 case Value.StructValueFieldNumber:
                 case Value.StructValueFieldNumber:
                 case Value.ListValueFieldNumber:
                 case Value.ListValueFieldNumber:
                     // Structs and ListValues are nested messages, and already well-known types.
                     // Structs and ListValues are nested messages, and already well-known types.
                     var nestedMessage = (IMessage) specifiedField.Accessor.GetValue(message);
                     var nestedMessage = (IMessage) specifiedField.Accessor.GetValue(message);
-                    WriteWellKnownTypeValue(builder, nestedMessage.Descriptor, nestedMessage);
+                    WriteWellKnownTypeValue(writer, nestedMessage.Descriptor, nestedMessage);
                     return;
                     return;
                 case Value.NullValueFieldNumber:
                 case Value.NullValueFieldNumber:
-                    WriteNull(builder);
+                    WriteNull(writer);
                     return;
                     return;
                 default:
                 default:
                     throw new InvalidOperationException("Unexpected case in struct field: " + specifiedField.FieldNumber);
                     throw new InvalidOperationException("Unexpected case in struct field: " + specifiedField.FieldNumber);
             }
             }
         }
         }
 
 
-        internal void WriteList(StringBuilder builder, IList list)
+        internal void WriteList(TextWriter writer, IList list)
         {
         {
-            builder.Append("[ ");
+            writer.Write("[ ");
             bool first = true;
             bool first = true;
             foreach (var value in list)
             foreach (var value in list)
             {
             {
                 if (!first)
                 if (!first)
                 {
                 {
-                    builder.Append(PropertySeparator);
+                    writer.Write(PropertySeparator);
                 }
                 }
-                WriteValue(builder, value);
+                WriteValue(writer, value);
                 first = false;
                 first = false;
             }
             }
-            builder.Append(first ? "]" : " ]");
+            writer.Write(first ? "]" : " ]");
         }
         }
 
 
-        internal void WriteDictionary(StringBuilder builder, IDictionary dictionary)
+        internal void WriteDictionary(TextWriter writer, IDictionary dictionary)
         {
         {
-            builder.Append("{ ");
+            writer.Write("{ ");
             bool first = true;
             bool first = true;
             // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal.
             // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal.
             foreach (DictionaryEntry pair in dictionary)
             foreach (DictionaryEntry pair in dictionary)
             {
             {
                 if (!first)
                 if (!first)
                 {
                 {
-                    builder.Append(PropertySeparator);
+                    writer.Write(PropertySeparator);
                 }
                 }
                 string keyText;
                 string keyText;
                 if (pair.Key is string)
                 if (pair.Key is string)
@@ -707,12 +721,12 @@ namespace Google.Protobuf
                     }
                     }
                     throw new ArgumentException("Unhandled dictionary key type: " + pair.Key.GetType());
                     throw new ArgumentException("Unhandled dictionary key type: " + pair.Key.GetType());
                 }
                 }
-                WriteString(builder, keyText);
-                builder.Append(NameValueSeparator);
-                WriteValue(builder, pair.Value);
+                WriteString(writer, keyText);
+                writer.Write(NameValueSeparator);
+                WriteValue(writer, pair.Value);
                 first = false;
                 first = false;
             }
             }
-            builder.Append(first ? "}" : " }");
+            writer.Write(first ? "}" : " }");
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -735,15 +749,15 @@ namespace Google.Protobuf
         /// <remarks>
         /// <remarks>
         /// Other than surrogate pair handling, this code is mostly taken from src/google/protobuf/util/internal/json_escaping.cc.
         /// Other than surrogate pair handling, this code is mostly taken from src/google/protobuf/util/internal/json_escaping.cc.
         /// </remarks>
         /// </remarks>
-        internal static void WriteString(StringBuilder builder, string text)
+        internal static void WriteString(TextWriter writer, string text)
         {
         {
-            builder.Append('"');
+            writer.Write('"');
             for (int i = 0; i < text.Length; i++)
             for (int i = 0; i < text.Length; i++)
             {
             {
                 char c = text[i];
                 char c = text[i];
                 if (c < 0xa0)
                 if (c < 0xa0)
                 {
                 {
-                    builder.Append(CommonRepresentations[c]);
+                    writer.Write(CommonRepresentations[c]);
                     continue;
                     continue;
                 }
                 }
                 if (char.IsHighSurrogate(c))
                 if (char.IsHighSurrogate(c))
@@ -755,8 +769,8 @@ namespace Google.Protobuf
                     {
                     {
                         throw new ArgumentException("String contains low surrogate not followed by high surrogate");
                         throw new ArgumentException("String contains low surrogate not followed by high surrogate");
                     }
                     }
-                    HexEncodeUtf16CodeUnit(builder, c);
-                    HexEncodeUtf16CodeUnit(builder, text[i]);
+                    HexEncodeUtf16CodeUnit(writer, c);
+                    HexEncodeUtf16CodeUnit(writer, text[i]);
                     continue;
                     continue;
                 }
                 }
                 else if (char.IsLowSurrogate(c))
                 else if (char.IsLowSurrogate(c))
@@ -777,7 +791,7 @@ namespace Google.Protobuf
                     case 0x070f:  // Syriac abbreviation mark
                     case 0x070f:  // Syriac abbreviation mark
                     case 0x17b4:  // Khmer vowel inherent Aq
                     case 0x17b4:  // Khmer vowel inherent Aq
                     case 0x17b5:  // Khmer vowel inherent Aa
                     case 0x17b5:  // Khmer vowel inherent Aa
-                        HexEncodeUtf16CodeUnit(builder, c);
+                        HexEncodeUtf16CodeUnit(writer, c);
                         break;
                         break;
 
 
                     default:
                     default:
@@ -787,27 +801,27 @@ namespace Google.Protobuf
                             (c >= 0x2060 && c <= 0x2064) ||  // Invisible etc.
                             (c >= 0x2060 && c <= 0x2064) ||  // Invisible etc.
                             (c >= 0x206a && c <= 0x206f))
                             (c >= 0x206a && c <= 0x206f))
                         {
                         {
-                            HexEncodeUtf16CodeUnit(builder, c);
+                            HexEncodeUtf16CodeUnit(writer, c);
                         }
                         }
                         else
                         else
                         {
                         {
                             // No handling of surrogates here - that's done earlier
                             // No handling of surrogates here - that's done earlier
-                            builder.Append(c);
+                            writer.Write(c);
                         }
                         }
                         break;
                         break;
                 }
                 }
             }
             }
-            builder.Append('"');
+            writer.Write('"');
         }
         }
 
 
         private const string Hex = "0123456789abcdef";
         private const string Hex = "0123456789abcdef";
-        private static void HexEncodeUtf16CodeUnit(StringBuilder builder, char c)
+        private static void HexEncodeUtf16CodeUnit(TextWriter writer, char c)
         {
         {
-            builder.Append("\\u");
-            builder.Append(Hex[(c >> 12) & 0xf]);
-            builder.Append(Hex[(c >> 8) & 0xf]);
-            builder.Append(Hex[(c >> 4) & 0xf]);
-            builder.Append(Hex[(c >> 0) & 0xf]);
+            writer.Write("\\u");
+            writer.Write(Hex[(c >> 12) & 0xf]);
+            writer.Write(Hex[(c >> 8) & 0xf]);
+            writer.Write(Hex[(c >> 4) & 0xf]);
+            writer.Write(Hex[(c >> 0) & 0xf]);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 9 - 8
csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs

@@ -33,6 +33,7 @@
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
@@ -57,19 +58,19 @@ namespace Google.Protobuf.WellKnownTypes
             var firstInvalid = paths.FirstOrDefault(p => !ValidatePath(p));
             var firstInvalid = paths.FirstOrDefault(p => !ValidatePath(p));
             if (firstInvalid == null)
             if (firstInvalid == null)
             {
             {
-                var builder = new StringBuilder();
-                JsonFormatter.WriteString(builder, string.Join(",", paths.Select(JsonFormatter.ToCamelCase)));
-                return builder.ToString();
+                var writer = new StringWriter();
+                JsonFormatter.WriteString(writer, string.Join(",", paths.Select(JsonFormatter.ToCamelCase)));
+                return writer.ToString();
             }
             }
             else
             else
             {
             {
                 if (diagnosticOnly)
                 if (diagnosticOnly)
                 {
                 {
-                    var builder = new StringBuilder();
-                    builder.Append("{ \"@warning\": \"Invalid FieldMask\", \"paths\": ");
-                    JsonFormatter.Default.WriteList(builder, (IList) paths);
-                    builder.Append(" }");
-                    return builder.ToString();
+                    var writer = new StringWriter();
+                    writer.Write("{ \"@warning\": \"Invalid FieldMask\", \"paths\": ");
+                    JsonFormatter.Default.WriteList(writer, (IList)paths);
+                    writer.Write(" }");
+                    return writer.ToString();
                 }
                 }
                 else
                 else
                 {
                 {

+ 1 - 1
js/binary/proto_test.js

@@ -32,7 +32,7 @@
 
 
 goog.require('goog.testing.asserts');
 goog.require('goog.testing.asserts');
 
 
-// CommonJS-LoadFromFile: testbinary_pb proto.jspb.test
+// CommonJS-LoadFromFile: ../testbinary_pb proto.jspb.test
 goog.require('proto.jspb.test.ExtendsWithMessage');
 goog.require('proto.jspb.test.ExtendsWithMessage');
 goog.require('proto.jspb.test.ForeignEnum');
 goog.require('proto.jspb.test.ForeignEnum');
 goog.require('proto.jspb.test.ForeignMessage');
 goog.require('proto.jspb.test.ForeignMessage');

+ 52 - 0
js/commonjs/import_test.js

@@ -0,0 +1,52 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test suite is written using Jasmine -- see http://jasmine.github.io/
+
+
+
+var googleProtobuf = require('google-protobuf');
+var asserts = require('closure_asserts_commonjs');
+var global = Function('return this')();
+
+// Bring asserts into the global namespace.
+googleProtobuf.object.extend(global, asserts);
+googleProtobuf.exportSymbol('jspb.Message', googleProtobuf.Message, global);
+
+var test7_pb = require('./test7/test7_pb');
+googleProtobuf.exportSymbol('proto.jspb.test.framing.FramingMessage', test7_pb.FramingMessage, global);
+
+describe('Import test suite', function() {
+  it('testImportedMessage', function() {
+    var framing1 = new proto.jspb.test.framing.FramingMessage([]);
+    var framing2 = new proto.jspb.test.framing.FramingMessage([]);
+    assertObjectEquals(framing1.toObject(), framing2.toObject());
+  });
+});

+ 3 - 2
js/commonjs/rewrite_tests_for_commonjs.js

@@ -80,11 +80,12 @@ lineReader.on('line', function(line) {
       console.log("// Bring asserts into the global namespace.");
       console.log("// Bring asserts into the global namespace.");
       console.log("googleProtobuf.object.extend(global, asserts);");
       console.log("googleProtobuf.object.extend(global, asserts);");
     }
     }
-    module = camelCase(isLoadFromFile[1])
+    var module_path = isLoadFromFile[1].split('/');
+    module = camelCase(module_path[module_path.length - 1]);
     pkg = isLoadFromFile[2];
     pkg = isLoadFromFile[2];
 
 
     if (module != "googleProtobuf") {  // We unconditionally require this in the header.
     if (module != "googleProtobuf") {  // We unconditionally require this in the header.
-      console.log("var " + module + " = require('" + isLoadFromFile[1] + "');");
+      console.log("var " + module + " = require('./" + isLoadFromFile[1] + "');");
     }
     }
   } else if (!isSetTestOnly) {  // Remove goog.setTestOnly() lines.
   } else if (!isSetTestOnly) {  // Remove goog.setTestOnly() lines.
     console.log(line);
     console.log(line);

+ 40 - 0
js/commonjs/test6/test6.proto

@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+option java_package = "com.google.apps.jspb.proto";
+option java_multiple_files = true;
+
+package jspb.test.importing;
+
+message ImportedMessage {
+  string string_value = 1;
+}

+ 42 - 0
js/commonjs/test7/test7.proto

@@ -0,0 +1,42 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+option java_package = "com.google.apps.jspb.proto";
+option java_multiple_files = true;
+
+package jspb.test.framing;
+
+import "test6/test6.proto";
+
+message FramingMessage {
+  jspb.test.importing.ImportedMessage imported_message = 1;
+}

+ 7 - 6
js/gulpfile.js

@@ -5,7 +5,7 @@ var glob = require('glob');
 var protoc = process.env.PROTOC || '../src/protoc';
 var protoc = process.env.PROTOC || '../src/protoc';
 
 
 gulp.task('genproto_closure', function (cb) {
 gulp.task('genproto_closure', function (cb) {
-  exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
+  exec(protoc + ' --js_out=library=testproto_libs,binary:.  -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
        function (err, stdout, stderr) {
        function (err, stdout, stderr) {
     console.log(stdout);
     console.log(stdout);
     console.log(stderr);
     console.log(stderr);
@@ -14,7 +14,7 @@ gulp.task('genproto_closure', function (cb) {
 });
 });
 
 
 gulp.task('genproto_commonjs', function (cb) {
 gulp.task('genproto_commonjs', function (cb) {
-  exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
+  exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto',
        function (err, stdout, stderr) {
        function (err, stdout, stderr) {
     console.log(stdout);
     console.log(stdout);
     console.log(stderr);
     console.log(stderr);
@@ -34,7 +34,7 @@ gulp.task('dist', function (cb) {
 });
 });
 
 
 gulp.task('commonjs_asserts', function (cb) {
 gulp.task('commonjs_asserts', function (cb) {
-  exec('mkdir -p commonjs_out && ./node_modules/google-closure-library/closure/bin/calcdeps.py -i commonjs/export_asserts.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > commonjs_out/closure_asserts_commonjs.js',
+  exec('mkdir -p commonjs_out/test_node_modules && ./node_modules/google-closure-library/closure/bin/calcdeps.py -i commonjs/export_asserts.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > commonjs_out/test_node_modules/closure_asserts_commonjs.js',
        function (err, stdout, stderr) {
        function (err, stdout, stderr) {
     console.log(stdout);
     console.log(stdout);
     console.log(stderr);
     console.log(stderr);
@@ -45,7 +45,7 @@ gulp.task('commonjs_asserts', function (cb) {
 gulp.task('make_commonjs_out', ['dist', 'genproto_commonjs', 'commonjs_asserts'], function (cb) {
 gulp.task('make_commonjs_out', ['dist', 'genproto_commonjs', 'commonjs_asserts'], function (cb) {
   // TODO(haberman): minify this more aggressively.
   // TODO(haberman): minify this more aggressively.
   // Will require proper externs/exports.
   // Will require proper externs/exports.
-  var cmd = "mkdir -p commonjs_out/binary && ";
+  var cmd = "mkdir -p commonjs_out/binary && mkdir -p commonjs_out/test_node_modules && ";
   function addTestFile(file) {
   function addTestFile(file) {
     cmd += 'node commonjs/rewrite_tests_for_commonjs.js < ' + file +
     cmd += 'node commonjs/rewrite_tests_for_commonjs.js < ' + file +
            ' > commonjs_out/' + file + '&& ';
            ' > commonjs_out/' + file + '&& ';
@@ -56,7 +56,8 @@ gulp.task('make_commonjs_out', ['dist', 'genproto_commonjs', 'commonjs_asserts']
 
 
   exec(cmd +
   exec(cmd +
        'cp commonjs/jasmine.json commonjs_out/jasmine.json && ' +
        'cp commonjs/jasmine.json commonjs_out/jasmine.json && ' +
-       'cp google-protobuf.js commonjs_out',
+       'cp google-protobuf.js commonjs_out/test_node_modules && ' +
+       'cp commonjs/import_test.js commonjs_out/import_test.js',
        function (err, stdout, stderr) {
        function (err, stdout, stderr) {
     console.log(stdout);
     console.log(stdout);
     console.log(stderr);
     console.log(stderr);
@@ -83,7 +84,7 @@ gulp.task('test_closure', ['genproto_closure', 'deps'], function (cb) {
 });
 });
 
 
 gulp.task('test_commonjs', ['make_commonjs_out'], function (cb) {
 gulp.task('test_commonjs', ['make_commonjs_out'], function (cb) {
-  exec('cd commonjs_out && JASMINE_CONFIG_PATH=jasmine.json NODE_PATH=. ../node_modules/.bin/jasmine',
+  exec('cd commonjs_out && JASMINE_CONFIG_PATH=jasmine.json NODE_PATH=test_node_modules ../node_modules/.bin/jasmine',
        function (err, stdout, stderr) {
        function (err, stdout, stderr) {
     console.log(stdout);
     console.log(stdout);
     console.log(stderr);
     console.log(stderr);

+ 0 - 1
js/test.proto

@@ -216,4 +216,3 @@ message TestMessageWithOneof {
     int32 btwo = 13 [default = 1234];
     int32 btwo = 13 [default = 1234];
   }
   }
 }
 }
-

+ 50 - 16
objectivec/GPBCodedInputStream.h

@@ -35,52 +35,86 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
-// Reads and decodes protocol message fields.
-// Subclassing of GPBCodedInputStream is NOT supported.
+/// Reads and decodes protocol message fields.
+///
+/// The common uses of protocol buffers shouldn't need to use this class.
+/// @c GPBMessage's provide a @c +parseFromData:error: and @c
+/// +parseFromData:extensionRegistry:error: method that will decode a
+/// message for you.
+///
+/// @note Subclassing of GPBCodedInputStream is NOT supported.
 @interface GPBCodedInputStream : NSObject
 @interface GPBCodedInputStream : NSObject
 
 
+/// Creates a new stream wrapping some data.
 + (instancetype)streamWithData:(NSData *)data;
 + (instancetype)streamWithData:(NSData *)data;
+
+/// Initializes a stream wrapping some data.
 - (instancetype)initWithData:(NSData *)data;
 - (instancetype)initWithData:(NSData *)data;
 
 
-// Attempt to read a field tag, returning zero if we have reached EOF.
-// Protocol message parsers use this to read tags, since a protocol message
-// may legally end wherever a tag occurs, and zero is not a valid tag number.
+/// Attempt to read a field tag, returning zero if we have reached EOF.
+/// Protocol message parsers use this to read tags, since a protocol message
+/// may legally end wherever a tag occurs, and zero is not a valid tag number.
 - (int32_t)readTag;
 - (int32_t)readTag;
 
 
+/// Read and return a double.
 - (double)readDouble;
 - (double)readDouble;
+/// Read and return a float.
 - (float)readFloat;
 - (float)readFloat;
+/// Read and return a uint64.
 - (uint64_t)readUInt64;
 - (uint64_t)readUInt64;
+/// Read and return a uint32.
 - (uint32_t)readUInt32;
 - (uint32_t)readUInt32;
+/// Read and return an int64.
 - (int64_t)readInt64;
 - (int64_t)readInt64;
+/// Read and return an int32.
 - (int32_t)readInt32;
 - (int32_t)readInt32;
+/// Read and return a fixed64.
 - (uint64_t)readFixed64;
 - (uint64_t)readFixed64;
+/// Read and return a fixed32.
 - (uint32_t)readFixed32;
 - (uint32_t)readFixed32;
+/// Read and return an enum (int).
 - (int32_t)readEnum;
 - (int32_t)readEnum;
+/// Read and return a sfixed32.
 - (int32_t)readSFixed32;
 - (int32_t)readSFixed32;
+/// Read and return a sfixed64.
 - (int64_t)readSFixed64;
 - (int64_t)readSFixed64;
+/// Read and return a sint32.
 - (int32_t)readSInt32;
 - (int32_t)readSInt32;
+/// Read and return a sint64.
 - (int64_t)readSInt64;
 - (int64_t)readSInt64;
+/// Read and return a boolean.
 - (BOOL)readBool;
 - (BOOL)readBool;
+/// Read and return a string.
 - (NSString *)readString;
 - (NSString *)readString;
+/// Read and return length delimited data.
 - (NSData *)readBytes;
 - (NSData *)readBytes;
 
 
-// Read an embedded message field value from the stream.
+/// Read an embedded message field value from the stream.
+///
+/// @param message           The message to set fields on as they are read.
+/// @param extensionRegistry An optional extension registry to use to lookup
+///                          extensions for @message.
 - (void)readMessage:(GPBMessage *)message
 - (void)readMessage:(GPBMessage *)message
-    extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
+  extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
 
 
-// Reads and discards a single field, given its tag value. Returns NO if the
-// tag is an endgroup tag, in which case nothing is skipped.  Otherwise,
-// returns YES.
+/// Reads and discards a single field, given its tag value.
+///
+/// @param tag The tag number of the field to skip.
+///
+/// @return NO if the tag is an endgroup tag (in which case nothing is skipped),
+///         YES in all other cases.
 - (BOOL)skipField:(int32_t)tag;
 - (BOOL)skipField:(int32_t)tag;
 
 
-// Reads and discards an entire message.  This will read either until EOF
-// or until an endgroup tag, whichever comes first.
+/// Reads and discards an entire message.  This will read either until EOF
+/// or until an endgroup tag, whichever comes first.
 - (void)skipMessage;
 - (void)skipMessage;
 
 
-// Verifies that the last call to readTag() returned the given tag value.
-// This is used to verify that a nested group ended with the correct end tag.
-// Throws NSParseErrorException if value does not match the last tag.
-- (void)checkLastTagWas:(int32_t)value;
+/// Verifies that the last call to @c -readTag returned the given tag value.
+/// This is used to verify that a nested group ended with the correct end tag.
+/// Throws @c NSParseErrorException if value does not match the last tag.
+///
+/// @param expected The tag that was expected.
+- (void)checkLastTagWas:(int32_t)expected;
 
 
 @end
 @end
 
 

+ 104 - 102
objectivec/GPBCodedOutputStream.h

@@ -46,36 +46,63 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
+/// Writes out protocol message fields.
+///
+/// The common uses of protocol buffers shouldn't need to use this class.
+/// @c GPBMessage's provide a @c -data method that will serialize the message
+/// for you.
+///
+/// @note Subclassing of GPBCodedOutputStream is NOT supported.
 @interface GPBCodedOutputStream : NSObject
 @interface GPBCodedOutputStream : NSObject
 
 
-// Creates a new stream to write into data.  Data must be sized to fit or it
-// will error when it runs out of space.
+/// Creates a stream to fill in the given data. Data must be sized to fit or
+/// an error will be raised when out of space.
 + (instancetype)streamWithData:(NSMutableData *)data;
 + (instancetype)streamWithData:(NSMutableData *)data;
+
+/// Creates a stream to write into the given @c NSOutputStream.
 + (instancetype)streamWithOutputStream:(NSOutputStream *)output;
 + (instancetype)streamWithOutputStream:(NSOutputStream *)output;
-+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
-                            bufferSize:(size_t)bufferSize;
 
 
+/// Initializes a stream to fill in the given data. Data must be sized to fit
+/// or an error will be raised when out of space.
 - (instancetype)initWithData:(NSMutableData *)data;
 - (instancetype)initWithData:(NSMutableData *)data;
+
+/// Initializes a stream to write into the given @c NSOutputStream.
 - (instancetype)initWithOutputStream:(NSOutputStream *)output;
 - (instancetype)initWithOutputStream:(NSOutputStream *)output;
-- (instancetype)initWithOutputStream:(NSOutputStream *)output
-                          bufferSize:(size_t)bufferSize;
 
 
+/// Flush any buffered data out.
 - (void)flush;
 - (void)flush;
 
 
+/// Write the raw byte out.
 - (void)writeRawByte:(uint8_t)value;
 - (void)writeRawByte:(uint8_t)value;
 
 
+/// Write the tag for the given field number and wire format.
+///
+/// @param fieldNumber The field number.
+/// @param format      The wire format the data for the field will be in.
 - (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
 - (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
 
 
+/// Write a 32bit value out in little endian format.
 - (void)writeRawLittleEndian32:(int32_t)value;
 - (void)writeRawLittleEndian32:(int32_t)value;
+/// Write a 64bit value out in little endian format.
 - (void)writeRawLittleEndian64:(int64_t)value;
 - (void)writeRawLittleEndian64:(int64_t)value;
 
 
+/// Write a 32bit value out in varint format.
 - (void)writeRawVarint32:(int32_t)value;
 - (void)writeRawVarint32:(int32_t)value;
+/// Write a 64bit value out in varint format.
 - (void)writeRawVarint64:(int64_t)value;
 - (void)writeRawVarint64:(int64_t)value;
 
 
-// Note that this will truncate 64 bit values to 32.
+/// Write a size_t out as a 32bit varint value.
+///
+/// @note This will truncate 64 bit values to 32.
 - (void)writeRawVarintSizeTAs32:(size_t)value;
 - (void)writeRawVarintSizeTAs32:(size_t)value;
 
 
+/// Writes the contents of an @c NSData out.
 - (void)writeRawData:(NSData *)data;
 - (void)writeRawData:(NSData *)data;
+/// Writes out the given data.
+///
+/// @param data   The data blob to write out.
+/// @param offset The offset into the blob to start writing out.
+/// @param length The number of bytes from the blob to write out.
 - (void)writeRawPtr:(const void *)data
 - (void)writeRawPtr:(const void *)data
              offset:(size_t)offset
              offset:(size_t)offset
              length:(size_t)length;
              length:(size_t)length;
@@ -83,238 +110,213 @@ NS_ASSUME_NONNULL_BEGIN
 //%PDDM-EXPAND _WRITE_DECLS()
 //%PDDM-EXPAND _WRITE_DECLS()
 // This block of code is generated, do not edit it directly.
 // This block of code is generated, do not edit it directly.
 
 
+/// Write a double for the given field number.
 - (void)writeDouble:(int32_t)fieldNumber value:(double)value;
 - (void)writeDouble:(int32_t)fieldNumber value:(double)value;
+/// Write a packaged array of double for the given field number.
 - (void)writeDoubleArray:(int32_t)fieldNumber
 - (void)writeDoubleArray:(int32_t)fieldNumber
                   values:(GPBDoubleArray *)values
                   values:(GPBDoubleArray *)values
                      tag:(uint32_t)tag;
                      tag:(uint32_t)tag;
+/// Write a double without any tag.
 - (void)writeDoubleNoTag:(double)value;
 - (void)writeDoubleNoTag:(double)value;
 
 
+/// Write a float for the given field number.
 - (void)writeFloat:(int32_t)fieldNumber value:(float)value;
 - (void)writeFloat:(int32_t)fieldNumber value:(float)value;
+/// Write a packaged array of float for the given field number.
 - (void)writeFloatArray:(int32_t)fieldNumber
 - (void)writeFloatArray:(int32_t)fieldNumber
                  values:(GPBFloatArray *)values
                  values:(GPBFloatArray *)values
                     tag:(uint32_t)tag;
                     tag:(uint32_t)tag;
+/// Write a float without any tag.
 - (void)writeFloatNoTag:(float)value;
 - (void)writeFloatNoTag:(float)value;
 
 
+/// Write a uint64_t for the given field number.
 - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
 - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
+/// Write a packaged array of uint64_t for the given field number.
 - (void)writeUInt64Array:(int32_t)fieldNumber
 - (void)writeUInt64Array:(int32_t)fieldNumber
                   values:(GPBUInt64Array *)values
                   values:(GPBUInt64Array *)values
                      tag:(uint32_t)tag;
                      tag:(uint32_t)tag;
+/// Write a uint64_t without any tag.
 - (void)writeUInt64NoTag:(uint64_t)value;
 - (void)writeUInt64NoTag:(uint64_t)value;
 
 
+/// Write a int64_t for the given field number.
 - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
 - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
+/// Write a packaged array of int64_t for the given field number.
 - (void)writeInt64Array:(int32_t)fieldNumber
 - (void)writeInt64Array:(int32_t)fieldNumber
                  values:(GPBInt64Array *)values
                  values:(GPBInt64Array *)values
                     tag:(uint32_t)tag;
                     tag:(uint32_t)tag;
+/// Write a int64_t without any tag.
 - (void)writeInt64NoTag:(int64_t)value;
 - (void)writeInt64NoTag:(int64_t)value;
 
 
+/// Write a int32_t for the given field number.
 - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
 - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
+/// Write a packaged array of int32_t for the given field number.
 - (void)writeInt32Array:(int32_t)fieldNumber
 - (void)writeInt32Array:(int32_t)fieldNumber
                  values:(GPBInt32Array *)values
                  values:(GPBInt32Array *)values
                     tag:(uint32_t)tag;
                     tag:(uint32_t)tag;
+/// Write a int32_t without any tag.
 - (void)writeInt32NoTag:(int32_t)value;
 - (void)writeInt32NoTag:(int32_t)value;
 
 
+/// Write a uint32_t for the given field number.
 - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
 - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
+/// Write a packaged array of uint32_t for the given field number.
 - (void)writeUInt32Array:(int32_t)fieldNumber
 - (void)writeUInt32Array:(int32_t)fieldNumber
                   values:(GPBUInt32Array *)values
                   values:(GPBUInt32Array *)values
                      tag:(uint32_t)tag;
                      tag:(uint32_t)tag;
+/// Write a uint32_t without any tag.
 - (void)writeUInt32NoTag:(uint32_t)value;
 - (void)writeUInt32NoTag:(uint32_t)value;
 
 
+/// Write a uint64_t for the given field number.
 - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
 - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
+/// Write a packaged array of uint64_t for the given field number.
 - (void)writeFixed64Array:(int32_t)fieldNumber
 - (void)writeFixed64Array:(int32_t)fieldNumber
                    values:(GPBUInt64Array *)values
                    values:(GPBUInt64Array *)values
                       tag:(uint32_t)tag;
                       tag:(uint32_t)tag;
+/// Write a uint64_t without any tag.
 - (void)writeFixed64NoTag:(uint64_t)value;
 - (void)writeFixed64NoTag:(uint64_t)value;
 
 
+/// Write a uint32_t for the given field number.
 - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
 - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
+/// Write a packaged array of uint32_t for the given field number.
 - (void)writeFixed32Array:(int32_t)fieldNumber
 - (void)writeFixed32Array:(int32_t)fieldNumber
                    values:(GPBUInt32Array *)values
                    values:(GPBUInt32Array *)values
                       tag:(uint32_t)tag;
                       tag:(uint32_t)tag;
+/// Write a uint32_t without any tag.
 - (void)writeFixed32NoTag:(uint32_t)value;
 - (void)writeFixed32NoTag:(uint32_t)value;
 
 
+/// Write a int32_t for the given field number.
 - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
 - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
+/// Write a packaged array of int32_t for the given field number.
 - (void)writeSInt32Array:(int32_t)fieldNumber
 - (void)writeSInt32Array:(int32_t)fieldNumber
                   values:(GPBInt32Array *)values
                   values:(GPBInt32Array *)values
                      tag:(uint32_t)tag;
                      tag:(uint32_t)tag;
+/// Write a int32_t without any tag.
 - (void)writeSInt32NoTag:(int32_t)value;
 - (void)writeSInt32NoTag:(int32_t)value;
 
 
+/// Write a int64_t for the given field number.
 - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
 - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
+/// Write a packaged array of int64_t for the given field number.
 - (void)writeSInt64Array:(int32_t)fieldNumber
 - (void)writeSInt64Array:(int32_t)fieldNumber
                   values:(GPBInt64Array *)values
                   values:(GPBInt64Array *)values
                      tag:(uint32_t)tag;
                      tag:(uint32_t)tag;
+/// Write a int64_t without any tag.
 - (void)writeSInt64NoTag:(int64_t)value;
 - (void)writeSInt64NoTag:(int64_t)value;
 
 
+/// Write a int64_t for the given field number.
 - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
 - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
+/// Write a packaged array of int64_t for the given field number.
 - (void)writeSFixed64Array:(int32_t)fieldNumber
 - (void)writeSFixed64Array:(int32_t)fieldNumber
                     values:(GPBInt64Array *)values
                     values:(GPBInt64Array *)values
                        tag:(uint32_t)tag;
                        tag:(uint32_t)tag;
+/// Write a int64_t without any tag.
 - (void)writeSFixed64NoTag:(int64_t)value;
 - (void)writeSFixed64NoTag:(int64_t)value;
 
 
+/// Write a int32_t for the given field number.
 - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
 - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
+/// Write a packaged array of int32_t for the given field number.
 - (void)writeSFixed32Array:(int32_t)fieldNumber
 - (void)writeSFixed32Array:(int32_t)fieldNumber
                     values:(GPBInt32Array *)values
                     values:(GPBInt32Array *)values
                        tag:(uint32_t)tag;
                        tag:(uint32_t)tag;
+/// Write a int32_t without any tag.
 - (void)writeSFixed32NoTag:(int32_t)value;
 - (void)writeSFixed32NoTag:(int32_t)value;
 
 
+/// Write a BOOL for the given field number.
 - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
 - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
+/// Write a packaged array of BOOL for the given field number.
 - (void)writeBoolArray:(int32_t)fieldNumber
 - (void)writeBoolArray:(int32_t)fieldNumber
                 values:(GPBBoolArray *)values
                 values:(GPBBoolArray *)values
                    tag:(uint32_t)tag;
                    tag:(uint32_t)tag;
+/// Write a BOOL without any tag.
 - (void)writeBoolNoTag:(BOOL)value;
 - (void)writeBoolNoTag:(BOOL)value;
 
 
+/// Write a int32_t for the given field number.
 - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
 - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
+/// Write a packaged array of int32_t for the given field number.
 - (void)writeEnumArray:(int32_t)fieldNumber
 - (void)writeEnumArray:(int32_t)fieldNumber
                 values:(GPBEnumArray *)values
                 values:(GPBEnumArray *)values
                    tag:(uint32_t)tag;
                    tag:(uint32_t)tag;
+/// Write a int32_t without any tag.
 - (void)writeEnumNoTag:(int32_t)value;
 - (void)writeEnumNoTag:(int32_t)value;
 
 
+/// Write a NSString for the given field number.
 - (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
 - (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
+/// Write an array of NSString for the given field number.
 - (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
 - (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
+/// Write a NSString without any tag.
 - (void)writeStringNoTag:(NSString *)value;
 - (void)writeStringNoTag:(NSString *)value;
 
 
+/// Write a GPBMessage for the given field number.
 - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
 - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
+/// Write an array of GPBMessage for the given field number.
 - (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
 - (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
+/// Write a GPBMessage without any tag.
 - (void)writeMessageNoTag:(GPBMessage *)value;
 - (void)writeMessageNoTag:(GPBMessage *)value;
 
 
+/// Write a NSData for the given field number.
 - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
 - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
+/// Write an array of NSData for the given field number.
 - (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
 - (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
+/// Write a NSData without any tag.
 - (void)writeBytesNoTag:(NSData *)value;
 - (void)writeBytesNoTag:(NSData *)value;
 
 
+/// Write a GPBMessage for the given field number.
 - (void)writeGroup:(int32_t)fieldNumber
 - (void)writeGroup:(int32_t)fieldNumber
              value:(GPBMessage *)value;
              value:(GPBMessage *)value;
+/// Write an array of GPBMessage for the given field number.
 - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
 - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
+/// Write a GPBMessage without any tag (but does write the endGroup tag).
 - (void)writeGroupNoTag:(int32_t)fieldNumber
 - (void)writeGroupNoTag:(int32_t)fieldNumber
                   value:(GPBMessage *)value;
                   value:(GPBMessage *)value;
 
 
+/// Write a GPBUnknownFieldSet for the given field number.
 - (void)writeUnknownGroup:(int32_t)fieldNumber
 - (void)writeUnknownGroup:(int32_t)fieldNumber
                     value:(GPBUnknownFieldSet *)value;
                     value:(GPBUnknownFieldSet *)value;
+/// Write an array of GPBUnknownFieldSet for the given field number.
 - (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
 - (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
+/// Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
 - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
 - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
                          value:(GPBUnknownFieldSet *)value;
                          value:(GPBUnknownFieldSet *)value;
 
 
 //%PDDM-EXPAND-END _WRITE_DECLS()
 //%PDDM-EXPAND-END _WRITE_DECLS()
 
 
-// Write a MessageSet extension field to the stream.  For historical reasons,
-// the wire format differs from normal fields.
+/// Write a MessageSet extension field to the stream. For historical reasons,
+/// the wire format differs from normal fields.
 - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
 - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
 
 
-// Write an unparsed MessageSet extension field to the stream.  For
-// historical reasons, the wire format differs from normal fields.
+/// Write an unparsed MessageSet extension field to the stream. For
+/// historical reasons, the wire format differs from normal fields.
 - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
 - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
 
 
 @end
 @end
 
 
-CF_EXTERN_C_BEGIN
-
-size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
-    __attribute__((const));
-size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
-    __attribute__((const));
-size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
-    __attribute__((const));
-size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
-    __attribute__((const));
-size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
-    __attribute__((const));
-size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
-    __attribute__((const));
-size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
-    __attribute__((const));
-size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
-    __attribute__((const));
-size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
-    __attribute__((const));
-size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
-    __attribute__((const));
-size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
-                                  GPBUnknownFieldSet *value)
-    __attribute__((const));
-size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
-    __attribute__((const));
-size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
-    __attribute__((const));
-size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
-    __attribute__((const));
-size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
-    __attribute__((const));
-size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
-    __attribute__((const));
-size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
-    __attribute__((const));
-size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
-    __attribute__((const));
-size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
-size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
-    __attribute__((const));
-
-size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
-size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
-size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const));
-size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const));
-size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const));
-size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
-size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
-size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
-size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
-size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
-    __attribute__((const));
-size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
-size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
-size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const));
-size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const));
-size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const));
-
-// Note that this will calculate the size of 64 bit values truncated to 32.
-size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const));
-
-size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
-size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
-
-// Note that this will calculate the size of 64 bit values truncated to 32.
-size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
-    __attribute__((const));
-
-// Compute the number of bytes that would be needed to encode a
-// MessageSet extension to the stream.  For historical reasons,
-// the wire format differs from normal fields.
-size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
-    __attribute__((const));
-
-// Compute the number of bytes that would be needed to encode an
-// unparsed MessageSet extension field to the stream.  For
-// historical reasons, the wire format differs from normal fields.
-size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
-    __attribute__((const));
-
-size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
-    __attribute__((const));
-
-CF_EXTERN_C_END
-
 NS_ASSUME_NONNULL_END
 NS_ASSUME_NONNULL_END
 
 
 // Write methods for types that can be in packed arrays.
 // Write methods for types that can be in packed arrays.
 //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
 //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
+//%/// Write a TYPE for the given field number.
 //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
 //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
+//%/// Write a packaged array of TYPE for the given field number.
 //%- (void)write##NAME##Array:(int32_t)fieldNumber
 //%- (void)write##NAME##Array:(int32_t)fieldNumber
 //%       NAME$S     values:(GPB##ARRAY_TYPE##Array *)values
 //%       NAME$S     values:(GPB##ARRAY_TYPE##Array *)values
 //%       NAME$S        tag:(uint32_t)tag;
 //%       NAME$S        tag:(uint32_t)tag;
+//%/// Write a TYPE without any tag.
 //%- (void)write##NAME##NoTag:(TYPE)value;
 //%- (void)write##NAME##NoTag:(TYPE)value;
 //%
 //%
 // Write methods for types that aren't in packed arrays.
 // Write methods for types that aren't in packed arrays.
 //%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
 //%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
+//%/// Write a TYPE for the given field number.
 //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
 //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
+//%/// Write an array of TYPE for the given field number.
 //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
 //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
+//%/// Write a TYPE without any tag.
 //%- (void)write##NAME##NoTag:(TYPE *)value;
 //%- (void)write##NAME##NoTag:(TYPE *)value;
 //%
 //%
 // Special write methods for Groups.
 // Special write methods for Groups.
 //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
 //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
+//%/// Write a TYPE for the given field number.
 //%- (void)write##NAME:(int32_t)fieldNumber
 //%- (void)write##NAME:(int32_t)fieldNumber
 //%       NAME$S value:(TYPE *)value;
 //%       NAME$S value:(TYPE *)value;
+//%/// Write an array of TYPE for the given field number.
 //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
 //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
+//%/// Write a TYPE without any tag (but does write the endGroup tag).
 //%- (void)write##NAME##NoTag:(int32_t)fieldNumber
 //%- (void)write##NAME##NoTag:(int32_t)fieldNumber
 //%            NAME$S value:(TYPE *)value;
 //%            NAME$S value:(TYPE *)value;
 //%
 //%

+ 3 - 14
objectivec/GPBCodedOutputStream.m

@@ -28,7 +28,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 
 
 #import <mach/vm_param.h>
 #import <mach/vm_param.h>
 
 
@@ -178,12 +178,6 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
   return [self initWithOutputStream:nil data:data];
   return [self initWithOutputStream:nil data:data];
 }
 }
 
 
-- (instancetype)initWithOutputStream:(NSOutputStream *)output
-                          bufferSize:(size_t)bufferSize {
-  NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
-  return [self initWithOutputStream:output data:data];
-}
-
 // This initializer isn't exposed, but it is the designated initializer.
 // This initializer isn't exposed, but it is the designated initializer.
 // Setting OutputStream and NSData is to control the buffering behavior/size
 // Setting OutputStream and NSData is to control the buffering behavior/size
 // of the work, but that is more obvious via the bufferSize: version.
 // of the work, but that is more obvious via the bufferSize: version.
@@ -199,15 +193,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
   return self;
   return self;
 }
 }
 
 
-+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
-                            bufferSize:(size_t)bufferSize {
-  return [[[self alloc] initWithOutputStream:output
-                                  bufferSize:bufferSize] autorelease];
-}
-
 + (instancetype)streamWithOutputStream:(NSOutputStream *)output {
 + (instancetype)streamWithOutputStream:(NSOutputStream *)output {
+  NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE];
   return [[[self alloc] initWithOutputStream:output
   return [[[self alloc] initWithOutputStream:output
-                                  bufferSize:PAGE_SIZE] autorelease];
+                                        data:data] autorelease];
 }
 }
 
 
 + (instancetype)streamWithData:(NSMutableData *)data {
 + (instancetype)streamWithData:(NSMutableData *)data {

+ 126 - 0
objectivec/GPBCodedOutputStream_PackagePrivate.h

@@ -0,0 +1,126 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc.  All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import "GPBCodedOutputStream.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+CF_EXTERN_C_BEGIN
+
+size_t GPBComputeDoubleSize(int32_t fieldNumber, double value)
+    __attribute__((const));
+size_t GPBComputeFloatSize(int32_t fieldNumber, float value)
+    __attribute__((const));
+size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value)
+    __attribute__((const));
+size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value)
+    __attribute__((const));
+size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value)
+    __attribute__((const));
+size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value)
+    __attribute__((const));
+size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value)
+    __attribute__((const));
+size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value)
+    __attribute__((const));
+size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value)
+    __attribute__((const));
+size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value)
+    __attribute__((const));
+size_t GPBComputeUnknownGroupSize(int32_t fieldNumber,
+                                  GPBUnknownFieldSet *value)
+    __attribute__((const));
+size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value)
+    __attribute__((const));
+size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value)
+    __attribute__((const));
+size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value)
+    __attribute__((const));
+size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value)
+    __attribute__((const));
+size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value)
+    __attribute__((const));
+size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value)
+    __attribute__((const));
+size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value)
+    __attribute__((const));
+size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const));
+size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType)
+    __attribute__((const));
+
+size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const));
+size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const));
+size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const));
+size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const));
+size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const));
+size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const));
+size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const));
+size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const));
+size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const));
+size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value)
+    __attribute__((const));
+size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const));
+size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const));
+size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const));
+size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const));
+size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const));
+
+// Note that this will calculate the size of 64 bit values truncated to 32.
+size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const));
+
+size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const));
+size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const));
+
+// Note that this will calculate the size of 64 bit values truncated to 32.
+size_t GPBComputeRawVarint32SizeForInteger(NSInteger value)
+    __attribute__((const));
+
+// Compute the number of bytes that would be needed to encode a
+// MessageSet extension to the stream.  For historical reasons,
+// the wire format differs from normal fields.
+size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value)
+    __attribute__((const));
+
+// Compute the number of bytes that would be needed to encode an
+// unparsed MessageSet extension field to the stream.  For
+// historical reasons, the wire format differs from normal fields.
+size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value)
+    __attribute__((const));
+
+size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value)
+    __attribute__((const));
+
+CF_EXTERN_C_END
+
+NS_ASSUME_NONNULL_END

+ 1 - 1
objectivec/GPBDictionary.m

@@ -31,7 +31,7 @@
 #import "GPBDictionary_PackagePrivate.h"
 #import "GPBDictionary_PackagePrivate.h"
 
 
 #import "GPBCodedInputStream_PackagePrivate.h"
 #import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBMessage_PackagePrivate.h"
 #import "GPBMessage_PackagePrivate.h"
 #import "GPBUtilities_PackagePrivate.h"
 #import "GPBUtilities_PackagePrivate.h"

+ 1 - 1
objectivec/GPBExtensionInternals.m

@@ -33,7 +33,7 @@
 #import <objc/runtime.h>
 #import <objc/runtime.h>
 
 
 #import "GPBCodedInputStream_PackagePrivate.h"
 #import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBMessage_PackagePrivate.h"
 #import "GPBMessage_PackagePrivate.h"
 #import "GPBUtilities_PackagePrivate.h"
 #import "GPBUtilities_PackagePrivate.h"

+ 34 - 19
objectivec/GPBExtensionRegistry.h

@@ -35,30 +35,45 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
-// A table of known extensions, searchable by name or field number.  When
-// parsing a protocol message that might have extensions, you must provide an
-// ExtensionRegistry in which you have registered any extensions that you want
-// to be able to parse.  Otherwise, those extensions will just be treated like
-// unknown fields.
-//
-// The *Root classes provide +extensionRegistry for the extensions defined in a
-// given file *and* all files it imports.  You can also create a
-// GPBExtensionRegistry, and merge those registries to handle parsing extensions
-// defined from non overlapping files.
-//
-//    GPBExtensionRegistry *registry =
-//        [[[MyProtoFileRoot extensionRegistry] copy] autorelease];
-//    [registry addExtension:[OtherMessage neededExtension];  // Not in MyProtoFile
-//    NSError *parseError = nil;
-//    MyMessage *msg = [MyMessage parseData:data
-//                        extensionRegistry:registry
-//                                    error:&parseError];
-//
+/// A table of known extensions, searchable by name or field number.  When
+/// parsing a protocol message that might have extensions, you must provide a
+/// @c GPBExtensionRegistry in which you have registered any extensions that you
+/// want to be able to parse. Otherwise, those extensions will just be treated
+/// like unknown fields.
+///
+/// The @c *Root classes provide @c +extensionRegistry for the extensions defined
+/// in a given file *and* all files it imports. You can also create a
+/// @c GPBExtensionRegistry, and merge those registries to handle parsing
+/// extensions defined from non overlapping files.
+///
+/// @code
+/// GPBExtensionRegistry *registry =
+///     [[[MyProtoFileRoot extensionRegistry] copy] autorelease];
+/// [registry addExtension:[OtherMessage neededExtension];  // Not in MyProtoFile
+/// NSError *parseError = nil;
+/// MyMessage *msg = [MyMessage parseData:data
+///                     extensionRegistry:registry
+///                                 error:&parseError];
+/// @endcode
 @interface GPBExtensionRegistry : NSObject<NSCopying>
 @interface GPBExtensionRegistry : NSObject<NSCopying>
 
 
+/// Add the given @c GPBExtensionDescriptor to this registry.
+///
+/// @param extension The extension description to add.
 - (void)addExtension:(GPBExtensionDescriptor *)extension;
 - (void)addExtension:(GPBExtensionDescriptor *)extension;
+
+/// Adds all the extensions from another registry to this registry.
+///
+/// @param registry The registry to merge into this registry.
 - (void)addExtensions:(GPBExtensionRegistry *)registry;
 - (void)addExtensions:(GPBExtensionRegistry *)registry;
 
 
+/// Looks for the extension registered for the given field number on a given
+/// @c GPBDescriptor.
+///
+/// @param descriptor  The descriptor to look for a registered extension on.
+/// @param fieldNumber The field number of an extension to look for.
+///
+/// @return The registered @c GPBExtensionDescripto or nil if none was found.
 - (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
 - (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
                                                 fieldNumber:(NSInteger)fieldNumber;
                                                 fieldNumber:(NSInteger)fieldNumber;
 
 

+ 179 - 48
objectivec/GPBMessage.h

@@ -44,23 +44,27 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 CF_EXTERN_C_BEGIN
 CF_EXTERN_C_BEGIN
 
 
-// NSError domain used for errors.
+/// NSError domain used for errors.
 extern NSString *const GPBMessageErrorDomain;
 extern NSString *const GPBMessageErrorDomain;
 
 
+/// Error code for NSError with GPBMessageErrorDomain.
 typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
 typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
+  /// The data being parsed is bad and a message can not be created from it.
   GPBMessageErrorCodeMalformedData = -100,
   GPBMessageErrorCodeMalformedData = -100,
+  /// A message can't be serialized because it is missing required fields.
   GPBMessageErrorCodeMissingRequiredField = -101,
   GPBMessageErrorCodeMissingRequiredField = -101,
 };
 };
 
 
-// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't
-// contain required fields. This key allows you to retrieve the parsed message
-// from the exception's |userInfo| dictionary.
 #ifdef DEBUG
 #ifdef DEBUG
+/// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't
+/// contain required fields. This key allows you to retrieve the parsed message
+/// from the exception's @c userInfo dictionary.
 extern NSString *const GPBExceptionMessageKey;
 extern NSString *const GPBExceptionMessageKey;
 #endif  // DEBUG
 #endif  // DEBUG
 
 
 CF_EXTERN_C_END
 CF_EXTERN_C_END
 
 
+/// Base class for all of the generated message classes.
 @interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
 @interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
 
 
 // NOTE: If you add a instance method/property to this class that may conflict
 // NOTE: If you add a instance method/property to this class that may conflict
@@ -68,108 +72,235 @@ CF_EXTERN_C_END
 // The main cases are methods that take no arguments, or setFoo:/hasFoo: type
 // The main cases are methods that take no arguments, or setFoo:/hasFoo: type
 // methods.
 // methods.
 
 
+/// The unknown fields for this message.
+///
+/// Only messages from proto files declared with "proto2" syntax support unknown
+/// fields. For "proto3" syntax, any unknown fields found while parsing are
+/// dropped.
 @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
 @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
 
 
-// Are all required fields in the message and all embedded messages set.
+/// Are all required fields set in the message and all embedded messages.
 @property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
 @property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
 
 
-// Returns an autoreleased instance.
+/// Returns an autoreleased instance.
 + (instancetype)message;
 + (instancetype)message;
 
 
-// Create a message based on a variety of inputs.  If there is a data parse
-// error, nil is returned and if not NULL, errorPtr is filled in.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, the parse will fail (returning nil, filling in errorPtr).
+/// Creates a new instance by parsing the data. This method should be sent to
+/// the generated message class that the data should be interpreted as. If
+/// there is an error the method returns nil and the error is returned in
+/// errorPtr (when provided).
+///
+/// @note In DEBUG builds, the parsed message is checked to be sure all required
+///       fields were provided, and the parse will fail if some are missing.
+///
+/// @param data     The data to parse.
+/// @param errorPtr An optional error pointer to fill in with a failure reason if
+///                 the data can not be parsed.
+///
+/// @return A new instance of the class messaged.
 + (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
 + (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr;
+
+/// Creates a new instance by parsing the data. This method should be sent to
+/// the generated message class that the data should be interpreted as. If
+/// there is an error the method returns nil and the error is returned in
+/// errorPtr (when provided).
+///
+/// @note In DEBUG builds, the parsed message is checked to be sure all required
+///       fields were provided, and the parse will fail if some are missing.
+///
+/// @param data              The data to parse.
+/// @param extensionRegistry The extension registry to use to look up extensions.
+/// @param errorPtr          An optional error pointer to fill in with a failure
+///                          reason if the data can not be parsed.
+///
+/// @return A new instance of the class messaged.
 + (instancetype)parseFromData:(NSData *)data
 + (instancetype)parseFromData:(NSData *)data
             extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
             extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
                         error:(NSError **)errorPtr;
                         error:(NSError **)errorPtr;
+
+/// Creates a new instance by parsing the data from the given input stream. This
+/// method should be sent to the generated message class that the data should
+/// be interpreted as. If there is an error the method returns nil and the error
+/// is returned in errorPtr (when provided).
+///
+/// @note In DEBUG builds, the parsed message is checked to be sure all required
+///       fields were provided, and the parse will fail if some are missing.
+///
+/// @param input             The stream to read data from.
+/// @param extensionRegistry The extension registry to use to look up extensions.
+/// @param errorPtr          An optional error pointer to fill in with a failure
+///                          reason if the data can not be parsed.
+///
+/// @return A new instance of the class messaged.
 + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
 + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
                         extensionRegistry:
                         extensionRegistry:
                             (nullable GPBExtensionRegistry *)extensionRegistry
                             (nullable GPBExtensionRegistry *)extensionRegistry
                                     error:(NSError **)errorPtr;
                                     error:(NSError **)errorPtr;
 
 
-// Create a message based on delimited input.  If there is a data parse
-// error, nil is returned and if not NULL, errorPtr is filled in.
+/// Creates a new instance by parsing the data from the given input stream. This
+/// method should be sent to the generated message class that the data should
+/// be interpreted as. If there is an error the method returns nil and the error
+/// is returned in errorPtr (when provided).
+///
+/// @note Unlike the parseFrom... methods, this never checks to see if all of
+///       the required fields are set. So this method can be used to reload
+///       messages that may not be complete.
+///
+/// @param input             The stream to read data from.
+/// @param extensionRegistry The extension registry to use to look up extensions.
+/// @param errorPtr          An optional error pointer to fill in with a failure
+///                          reason if the data can not be parsed.
+///
+/// @return A new instance of the class messaged.
 + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
 + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
                                  extensionRegistry:
                                  extensionRegistry:
                                      (nullable GPBExtensionRegistry *)extensionRegistry
                                      (nullable GPBExtensionRegistry *)extensionRegistry
                                              error:(NSError **)errorPtr;
                                              error:(NSError **)errorPtr;
 
 
-// If there is a data parse error, nil is returned and if not NULL, errorPtr is
-// filled in.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, the parse will fail (returning nil, filling in errorPtr).
+/// Initializes an instance by parsing the data. This method should be sent to
+/// the generated message class that the data should be interpreted as. If
+/// there is an error the method returns nil and the error is returned in
+/// errorPtr (when provided).
+///
+/// @note In DEBUG builds, the parsed message is checked to be sure all required
+///       fields were provided, and the parse will fail if some are missing.
+///
+/// @param data     The data to parse.
+/// @param errorPtr An optional error pointer to fill in with a failure reason if
+///                 the data can not be parsed.
 - (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
 - (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
+
+/// Initializes an instance by parsing the data. This method should be sent to
+/// the generated message class that the data should be interpreted as. If
+/// there is an error the method returns nil and the error is returned in
+/// errorPtr (when provided).
+///
+/// @note In DEBUG builds, the parsed message is checked to be sure all required
+///       fields were provided, and the parse will fail if some are missing.
+///
+/// @param data              The data to parse.
+/// @param extensionRegistry The extension registry to use to look up extensions.
+/// @param errorPtr          An optional error pointer to fill in with a failure
+///                          reason if the data can not be parsed.
 - (instancetype)initWithData:(NSData *)data
 - (instancetype)initWithData:(NSData *)data
            extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
            extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
                        error:(NSError **)errorPtr;
                        error:(NSError **)errorPtr;
+
+/// Initializes an instance by parsing the data from the given input stream. This
+/// method should be sent to the generated message class that the data should
+/// be interpreted as. If there is an error the method returns nil and the error
+/// is returned in errorPtr (when provided).
+///
+/// @note Unlike the parseFrom... methods, this never checks to see if all of
+///       the required fields are set. So this method can be used to reload
+///       messages that may not be complete.
+///
+/// @param input             The stream to read data from.
+/// @param extensionRegistry The extension registry to use to look up extensions.
+/// @param errorPtr          An optional error pointer to fill in with a failure
+///                          reason if the data can not be parsed.
 - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
 - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
                        extensionRegistry:
                        extensionRegistry:
                            (nullable GPBExtensionRegistry *)extensionRegistry
                            (nullable GPBExtensionRegistry *)extensionRegistry
                                    error:(NSError **)errorPtr;
                                    error:(NSError **)errorPtr;
 
 
-// Serializes the message and writes it to output.
+/// Writes out the message to the given output stream.
 - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
 - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
+/// Writes out the message to the given output stream.
 - (void)writeToOutputStream:(NSOutputStream *)output;
 - (void)writeToOutputStream:(NSOutputStream *)output;
 
 
-// Serializes the message and writes it to output, but writes the size of the
-// message as a variant before writing the message.
+/// Writes out a varint for the message size followed by the the message to
+/// the given output stream.
 - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
 - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
+/// Writes out a varint for the message size followed by the the message to
+/// the given output stream.
 - (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
 - (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
 
 
-// Serializes the message to an NSData. Note that this value is not cached, so
-// if you are using it repeatedly, cache it yourself. If there is an error
-// while generating the data, nil is returned.
-// NOTE: In DEBUG ONLY, the message is also checked for all required field,
-// if one is missing, nil will be returned.
+/// Serializes the message to a @c NSData.
+///
+/// If there is an error while generating the data, nil is returned.
+///
+/// @note This value is not cached, so if you are using it repeatedly, cache
+///       it yourself.
+///
+/// @note In DEBUG ONLY, the message is also checked for all required field,
+///       if one is missing, nil will be returned.
 - (nullable NSData *)data;
 - (nullable NSData *)data;
 
 
-// Same as -[data], except a delimiter is added to the start of the data
-// indicating the size of the message data that follows.
+/// Serializes a varint with the message size followed by the message data,
+/// returning that as a @c NSData.
+///
+/// @note This value is not cached, so if you are using it repeatedly, cache
+///       it yourself.
 - (NSData *)delimitedData;
 - (NSData *)delimitedData;
 
 
-// Returns the size of the object if it were serialized.
-// This is not a cached value. If you are following a pattern like this:
-//   size_t size = [aMsg serializedSize];
-//   NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
-//   [foo writeSize:size];
-//   [foo appendData:[aMsg data]];
-// you would be better doing:
-//   NSData *data = [aMsg data];
-//   NSUInteger size = [aMsg length];
-//   NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
-//   [foo writeSize:size];
-//   [foo appendData:data];
+/// Calculates the size of the object if it were serialized.
+///
+/// This is not a cached value. If you are following a pattern like this:
+/// @code
+///   size_t size = [aMsg serializedSize];
+///   NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
+///   [foo writeSize:size];
+///   [foo appendData:[aMsg data]];
+/// @endcode
+/// you would be better doing:
+/// @code
+///   NSData *data = [aMsg data];
+///   NSUInteger size = [aMsg length];
+///   NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
+///   [foo writeSize:size];
+///   [foo appendData:data];
+/// @endcode
 - (size_t)serializedSize;
 - (size_t)serializedSize;
 
 
-// Return the descriptor for the message
+/// Return the descriptor for the message class.
 + (GPBDescriptor *)descriptor;
 + (GPBDescriptor *)descriptor;
+/// Return the descriptor for the message.
 - (GPBDescriptor *)descriptor;
 - (GPBDescriptor *)descriptor;
 
 
-// Extensions use boxed values (NSNumbers) for PODs, NSMutableArrays for
-// repeated. If the extension is a Message one will be auto created for you
-// and returned similar to fields.
+/// Test to see if the given extension is set on the message.
 - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
 - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
+
+/// Fetches the given extension's value for this message.
+///
+/// Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for
+/// repeated fields. If the extension is a Message one will be auto created for you
+/// and returned similar to fields.
 - (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
 - (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
+
+/// Sets the given extension's value for this message. This is only for single
+/// field extensions (i.e. - not repeated fields).
+///
+/// Extensions use boxed values (@c NSNumbers).
 - (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
 - (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)value;
+
+/// Adds the given value to the extension for this message. This is only for
+/// repeated field extensions. If the field is a repeated POD type the @c value
+/// is a @c NSNumber.
 - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
 - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
+
+/// Replaces the given value at an index for the extension on this message. This
+/// is only for repeated field extensions. If the field is a repeated POD type
+/// the @c value is a @c NSNumber.
 - (void)setExtension:(GPBExtensionDescriptor *)extension
 - (void)setExtension:(GPBExtensionDescriptor *)extension
                index:(NSUInteger)index
                index:(NSUInteger)index
                value:(id)value;
                value:(id)value;
+
+/// Clears the given extension for this message.
 - (void)clearExtension:(GPBExtensionDescriptor *)extension;
 - (void)clearExtension:(GPBExtensionDescriptor *)extension;
 
 
-// Resets all fields to their default values.
+/// Resets all of the fields of this message to their default values.
 - (void)clear;
 - (void)clear;
 
 
-// Parses a message of this type from the input and merges it with this
-// message.
-// NOTE: This will throw if there is an error parsing the data.
+/// Parses a message of this type from the input and merges it with this
+/// message.
+///
+/// @note This will throw if there is an error parsing the data.
 - (void)mergeFromData:(NSData *)data
 - (void)mergeFromData:(NSData *)data
     extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
     extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
 
 
-// Merges the fields from another message (of the same type) into this
-// message.
+/// Merges the fields from another message (of the same type) into this
+/// message.
 - (void)mergeFrom:(GPBMessage *)other;
 - (void)mergeFrom:(GPBMessage *)other;
 
 
 @end
 @end

+ 1 - 1
objectivec/GPBMessage.m

@@ -35,7 +35,7 @@
 
 
 #import "GPBArray_PackagePrivate.h"
 #import "GPBArray_PackagePrivate.h"
 #import "GPBCodedInputStream_PackagePrivate.h"
 #import "GPBCodedInputStream_PackagePrivate.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBDescriptor_PackagePrivate.h"
 #import "GPBDictionary_PackagePrivate.h"
 #import "GPBDictionary_PackagePrivate.h"
 #import "GPBExtensionInternals.h"
 #import "GPBExtensionInternals.h"

+ 4 - 3
objectivec/GPBRootObject.h

@@ -34,11 +34,12 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
-// All Root Objects derive from GPBRootObject. It supplies a registry
-// for derived classes to register their extensions to.
+/// Every generated proto file defines a local "Root" class that exposes a
+/// @c GPBExtensionRegistry for all the extensions defined by that file and
+/// the files it depends on.
 @interface GPBRootObject : NSObject
 @interface GPBRootObject : NSObject
 
 
-// Per class registry.
+/// An extension registry for the given file and all the files it depends on.
 + (GPBExtensionRegistry *)extensionRegistry;
 + (GPBExtensionRegistry *)extensionRegistry;
 
 
 @end
 @end

+ 31 - 2
objectivec/GPBUnknownField.h

@@ -37,22 +37,51 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
+/// Store an unknown field. These are used in conjunction with @c GPBUnknownFieldSet
 @interface GPBUnknownField : NSObject<NSCopying>
 @interface GPBUnknownField : NSObject<NSCopying>
 
 
+/// The field number the data is stored under.
 @property(nonatomic, readonly, assign) int32_t number;
 @property(nonatomic, readonly, assign) int32_t number;
 
 
-// Only one of these will be set.
+/// An array of varint values for this field.
 @property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
 @property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
+
+/// An array of fixed32 values for this field.
 @property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
 @property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
+
+/// An array of fixed64 values for this field.
 @property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
 @property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
+
+/// An array of data values for this field.
 @property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
 @property(nonatomic, readonly, strong) NSArray<NSData*> *lengthDelimitedList;
+
+/// An array of groups of values for this field.
 @property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
 @property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet*> *groupList;
 
 
-// Only one of these should be used per Field.
+
+/// Add a value to the varintList.
+///
+/// @param value The value to add.
 - (void)addVarint:(uint64_t)value;
 - (void)addVarint:(uint64_t)value;
+
+/// Add a value to the fixed32List.
+///
+/// @param value The value to add.
 - (void)addFixed32:(uint32_t)value;
 - (void)addFixed32:(uint32_t)value;
+
+/// Add a value to the fixed64List.
+///
+/// @param value The value to add.
 - (void)addFixed64:(uint64_t)value;
 - (void)addFixed64:(uint64_t)value;
+
+/// Add a value to the lengthDelimitedList.
+///
+/// @param value The value to add.
 - (void)addLengthDelimited:(NSData *)value;
 - (void)addLengthDelimited:(NSData *)value;
+
+/// Add a value to the groupList.
+///
+/// @param value The value to add.
 - (void)addGroup:(GPBUnknownFieldSet *)value;
 - (void)addGroup:(GPBUnknownFieldSet *)value;
 
 
 @end
 @end

+ 1 - 1
objectivec/GPBUnknownField.m

@@ -31,7 +31,7 @@
 #import "GPBUnknownField_PackagePrivate.h"
 #import "GPBUnknownField_PackagePrivate.h"
 
 
 #import "GPBArray.h"
 #import "GPBArray.h"
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 
 
 @implementation GPBUnknownField {
 @implementation GPBUnknownField {
  @protected
  @protected

+ 16 - 1
objectivec/GPBUnknownFieldSet.h

@@ -34,15 +34,30 @@
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
+/// A collection of unknown fields.
 @interface GPBUnknownFieldSet : NSObject<NSCopying>
 @interface GPBUnknownFieldSet : NSObject<NSCopying>
 
 
+/// Tests to see if the given field number has a value.
+///
+/// @param number The field number to check.
+///
+/// @return YES if there is an unknown field for the given field number.
 - (BOOL)hasField:(int32_t)number;
 - (BOOL)hasField:(int32_t)number;
+
+/// Fetches the @c GPBUnknownField for the given field number.
+///
+/// @param number The field number to look up.
+///
+/// @return The @c GPBUnknownField or nil.
 - (nullable GPBUnknownField *)getField:(int32_t)number;
 - (nullable GPBUnknownField *)getField:(int32_t)number;
+
+/// Returns the number of fields in this set.
 - (NSUInteger)countOfFields;
 - (NSUInteger)countOfFields;
 
 
+/// Adds the given field to the set.
 - (void)addField:(GPBUnknownField *)field;
 - (void)addField:(GPBUnknownField *)field;
 
 
-// Returns an NSArray of the GPBUnknownFields sorted by the field numbers.
+/// Returns an NSArray of the @c GPBUnknownFields sorted by the field numbers.
 - (NSArray<GPBUnknownField*> *)sortedFields;
 - (NSArray<GPBUnknownField*> *)sortedFields;
 
 
 @end
 @end

+ 110 - 40
objectivec/GPBUtilities.h

@@ -38,24 +38,34 @@ CF_EXTERN_C_BEGIN
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
-// Generates a string that should be a valid "Text Format" for the C++ version
-// of Protocol Buffers. lineIndent can be nil if no additional line indent is
-// needed. The comments provide the names according to the ObjC library, they
-// most likely won't exactly match the original .proto file.
+/// Generates a string that should be a valid "Text Format" for the C++ version
+/// of Protocol Buffers.
+///
+///  @param message    The message to generate from.
+///  @param lineIndent A string to use as the prefix for all lines generated. Can
+///                    be nil if no extra indent is needed.
+///
+/// @return A @c NSString with the Text Format of the message.
 NSString *GPBTextFormatForMessage(GPBMessage *message,
 NSString *GPBTextFormatForMessage(GPBMessage *message,
                                   NSString * __nullable lineIndent);
                                   NSString * __nullable lineIndent);
+
+/// Generates a string that should be a valid "Text Format" for the C++ version
+/// of Protocol Buffers.
+///
+///  @param unknownSet The unknown field set to generate from.
+///  @param lineIndent A string to use as the prefix for all lines generated. Can
+///                    be nil if no extra indent is needed.
+///
+/// @return A @c NSString with the Text Format of the unknown field set.
 NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
 NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
                                           NSString * __nullable lineIndent);
                                           NSString * __nullable lineIndent);
 
 
-//
-// Test if the given field is set on a message.
-//
+/// Test if the given field is set on a message.
 BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
 BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
+/// Test if the given field is set on a message.
 BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
 BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
 
 
-//
-// Clear the given field of a message.
-//
+/// Clear the given field of a message.
 void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
 void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
 
 
 //%PDDM-EXPAND GPB_ACCESSORS()
 //%PDDM-EXPAND GPB_ACCESSORS()
@@ -68,60 +78,100 @@ void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
 
 
 // Single Fields
 // Single Fields
 
 
+/// Gets the value of a bytes field.
 NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
 NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a bytes field.
 void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
 void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
 
 
+/// Gets the value of a string field.
 NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
 NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a string field.
 void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
 void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
 
 
+/// Gets the value of a message field.
 GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
 GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a message field.
 void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
 void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
 
 
+/// Gets the value of a group field.
 GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
 GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a group field.
 void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
 void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
 
 
+/// Gets the value of a bool field.
 BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
 BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a bool field.
 void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
 void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
 
 
+/// Gets the value of an int32 field.
 int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
 int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of an int32 field.
 void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 
 
+/// Gets the value of an uint32 field.
 uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
 uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of an uint32 field.
 void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
 void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
 
 
+/// Gets the value of an int64 field.
 int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
 int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of an int64 field.
 void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
 void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
 
 
+/// Gets the value of an uint64 field.
 uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
 uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of an uint64 field.
 void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
 void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
 
 
+/// Gets the value of a float field.
 float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
 float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a float field.
 void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
 void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
 
 
+/// Gets the value of a double field.
 double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
 double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a double field.
 void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
 void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
 
 
-// Get/Set the given enum field of a message.  You can only Set values that are
-// members of the enum.  For proto3, when doing a Get, if the value isn't a
-// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
-// the functions with "Raw" in the will bypass all checks.
+/// Get the given enum field of a message. For proto3, if the value isn't a
+/// member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
+/// GPBGetMessageRawEnumField will bypass the check and return whatever value
+/// was set.
 int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
 int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Set the given enum field of a message. You can only set values that are
+/// members of the enum.
 void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+/// Get the given enum field of a message. No check is done to ensure the value
+/// was defined in the enum.
 int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
 int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Set the given enum field of a message. You can set the value to anything,
+/// even a value that is not a member of the enum.
 void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 
 
 // Repeated Fields
 // Repeated Fields
 
 
-// The object will/should be GPB*Array or NSMutableArray based on the field's
-// type.
+/// Gets the value of a repeated field.
+///
+/// The result will be @c GPB*Array or @c NSMutableArray based on the
+/// field's type.
 id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
 id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a repeated field.
+///
+/// The value should be @c GPB*Array or @c NSMutableArray based on the
+/// field's type.
 void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
 void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
 
 
 // Map Fields
 // Map Fields
 
 
-// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
-// field's type.
+/// Gets the value of a map<> field.
+///
+/// The result will be @c GPB*Dictionary or @c NSMutableDictionary based on
+/// the field's type.
 id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
 id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
+/// Sets the value of a map<> field.
+///
+/// The object should be @c GPB*Dictionary or @c NSMutableDictionary based
+/// on the field's type.
 void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
 void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
 
 
 //%PDDM-EXPAND-END GPB_ACCESSORS()
 //%PDDM-EXPAND-END GPB_ACCESSORS()
@@ -144,44 +194,64 @@ CF_EXTERN_C_END
 //%
 //%
 //%// Single Fields
 //%// Single Fields
 //%
 //%
-//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, *)
-//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, *)
-//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, *)
-//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, *)
-//%GPB_ACCESSOR_SINGLE(Bool, BOOL)
-//%GPB_ACCESSOR_SINGLE(Int32, int32_t)
-//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t)
-//%GPB_ACCESSOR_SINGLE(Int64, int64_t)
-//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t)
-//%GPB_ACCESSOR_SINGLE(Float, float)
-//%GPB_ACCESSOR_SINGLE(Double, double)
-//%// Get/Set the given enum field of a message.  You can only Set values that are
-//%// members of the enum.  For proto3, when doing a Get, if the value isn't a
-//%// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
-//%// the functions with "Raw" in the will bypass all checks.
+//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *)
+//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *)
+//%GPB_ACCESSOR_SINGLE(Bool, BOOL, )
+//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n)
+//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n)
+//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n)
+//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n)
+//%GPB_ACCESSOR_SINGLE(Float, float, )
+//%GPB_ACCESSOR_SINGLE(Double, double, )
+//%/// Get the given enum field of a message. For proto3, if the value isn't a
+//%/// member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned.
+//%/// GPBGetMessageRawEnumField will bypass the check and return whatever value
+//%/// was set.
 //%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
 //%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
+//%/// Set the given enum field of a message. You can only set values that are
+//%/// members of the enum.
 //%void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 //%void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
+//%/// Get the given enum field of a message. No check is done to ensure the value
+//%/// was defined in the enum.
 //%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
 //%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
+//%/// Set the given enum field of a message. You can set the value to anything,
+//%/// even a value that is not a member of the enum.
 //%void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 //%void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
 //%
 //%
 //%// Repeated Fields
 //%// Repeated Fields
 //%
 //%
-//%// The object will/should be GPB*Array or NSMutableArray based on the field's
-//%// type.
+//%/// Gets the value of a repeated field.
+//%///
+//%/// The result will be @c GPB*Array or @c NSMutableArray based on the
+//%/// field's type.
 //%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
 //%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
+//%/// Sets the value of a repeated field.
+//%///
+//%/// The value should be @c GPB*Array or @c NSMutableArray based on the
+//%/// field's type.
 //%void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
 //%void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
 //%
 //%
 //%// Map Fields
 //%// Map Fields
 //%
 //%
-//%// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
-//%// field's type.
+//%/// Gets the value of a map<> field.
+//%///
+//%/// The result will be @c GPB*Dictionary or @c NSMutableDictionary based on
+//%/// the field's type.
 //%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
 //%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
+//%/// Sets the value of a map<> field.
+//%///
+//%/// The object should be @c GPB*Dictionary or @c NSMutableDictionary based
+//%/// on the field's type.
 //%void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
 //%void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
 //%
 //%
 
 
-//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE)
-//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, )
-//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, TisP)
+//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN)
+//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, )
+//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP)
+//%/// Gets the value of a##AN NAME$L field.
 //%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
 //%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
+//%/// Sets the value of a##AN NAME$L field.
 //%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
 //%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
 //%
 //%

+ 3 - 1
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj

@@ -188,6 +188,7 @@
 		F4487C7C1AAE06AC00531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
 		F4487C7C1AAE06AC00531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
 		F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
 		F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
 		F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
 		F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
+		F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = "<group>"; };
 		F451D3F51A8AAE8700B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
 		F451D3F51A8AAE8700B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
 		F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
 		F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
 		F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
 		F45E57C61AE6DC6A000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
@@ -368,9 +369,10 @@
 		7461B4860F94F96B00A0C422 /* IO */ = {
 		7461B4860F94F96B00A0C422 /* IO */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
 				51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
 				51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
+				7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
 				7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
 				7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
+				F44929001C866B1900C2548A /* GPBCodedOutputStream_PackagePrivate.h */,
 				7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
 				7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
 				7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
 				7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
 				7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,
 				7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,

+ 3 - 1
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj

@@ -209,6 +209,7 @@
 		F4487C7D1AAE06C500531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
 		F4487C7D1AAE06C500531423 /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUtilities_PackagePrivate.h; sourceTree = "<group>"; };
 		F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
 		F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Serialization.m"; sourceTree = "<group>"; };
 		F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
 		F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GPBMessageTests+Merge.m"; sourceTree = "<group>"; };
+		F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBCodedOutputStream_PackagePrivate.h; sourceTree = "<group>"; };
 		F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
 		F451D3F61A8AAEA600B8A22C /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBProtocolBuffers_RuntimeSupport.h; sourceTree = "<group>"; };
 		F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
 		F45C69CB16DFD08D0081955B /* GPBExtensionInternals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBExtensionInternals.m; sourceTree = "<group>"; };
 		F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
 		F45E57C81AE6DC98000B7D99 /* text_format_map_unittest_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = text_format_map_unittest_data.txt; sourceTree = "<group>"; };
@@ -405,9 +406,10 @@
 		7461B4860F94F96B00A0C422 /* IO */ = {
 		7461B4860F94F96B00A0C422 /* IO */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
 				51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
 				51457B5F18D0B7AF00CCC606 /* GPBCodedInputStream_PackagePrivate.h */,
+				7461B48E0F94F99000A0C422 /* GPBCodedInputStream.h */,
 				7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
 				7461B48F0F94F99000A0C422 /* GPBCodedInputStream.m */,
+				F44929021C866B3B00C2548A /* GPBCodedOutputStream_PackagePrivate.h */,
 				7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
 				7461B4900F94F99000A0C422 /* GPBCodedOutputStream.h */,
 				7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
 				7461B4910F94F99000A0C422 /* GPBCodedOutputStream.m */,
 				7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,
 				7461B4E70F94F99000A0C422 /* GPBWireFormat.h */,

+ 20 - 1
objectivec/Tests/GPBCodedOuputStreamTests.m

@@ -30,11 +30,30 @@
 
 
 #import "GPBTestUtilities.h"
 #import "GPBTestUtilities.h"
 
 
-#import "GPBCodedOutputStream.h"
+#import "GPBCodedOutputStream_PackagePrivate.h"
 #import "GPBCodedInputStream.h"
 #import "GPBCodedInputStream.h"
 #import "GPBUtilities_PackagePrivate.h"
 #import "GPBUtilities_PackagePrivate.h"
 #import "google/protobuf/Unittest.pbobjc.h"
 #import "google/protobuf/Unittest.pbobjc.h"
 
 
+@interface GPBCodedOutputStream (InternalMethods)
+// Declared in the .m file, expose for testing.
+- (instancetype)initWithOutputStream:(NSOutputStream *)output
+                                data:(NSMutableData *)data;
+@end
+
+@interface GPBCodedOutputStream (Helper)
++ (instancetype)streamWithOutputStream:(NSOutputStream *)output
+                            bufferSize:(size_t)bufferSize;
+@end
+
+@implementation GPBCodedOutputStream (Helper)
++ (instancetype)streamWithOutputStream:(NSOutputStream *)output
+                            bufferSize:(size_t)bufferSize {
+  NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
+  return [[[self alloc] initWithOutputStream:output data:data] autorelease];
+}
+@end
+
 @interface CodedOutputStreamTests : GPBTestCase
 @interface CodedOutputStreamTests : GPBTestCase
 @end
 @end
 
 

+ 18 - 0
objectivec/Tests/GPBMessageTests.m

@@ -1820,6 +1820,24 @@
   XCTAssertEqualObjects(enumDescriptor, expectedDescriptor);
   XCTAssertEqualObjects(enumDescriptor, expectedDescriptor);
 }
 }
 
 
+- (void)testPropertyNaming {
+  // objectivec_helpers.cc has some special handing to get proper all caps
+  // for a few cases to meet objc developer expectations.
+  //
+  // This "test" confirms that the expected names are generated, otherwise the
+  // test itself will fail to compile.
+  ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
+  // On their own, at the end, in the middle.
+  msg.URL = @"good";
+  msg.thumbnailURL = @"good";
+  msg.URLFoo = @"good";
+  msg.someURLBlah = @"good";
+  msg.HTTP = @"good";
+  msg.HTTPS = @"good";
+  // No caps since it was "urls".
+  [msg.urlsArray addObject:@"good"];
+}
+
 - (void)testEnumNaming {
 - (void)testEnumNaming {
   // objectivec_helpers.cc has some interesting cases to deal with in
   // objectivec_helpers.cc has some interesting cases to deal with in
   // EnumValueName/EnumValueShortName.  Confirm that things generated as
   // EnumValueName/EnumValueShortName.  Confirm that things generated as

+ 12 - 0
objectivec/Tests/unittest_objc.proto

@@ -112,6 +112,18 @@ enum retain {
   serializedSize = 6;
   serializedSize = 6;
 }
 }
 
 
+message ObjCPropertyNaming {
+  // Test that the properties properly get things all caps.
+  optional string url           = 1;
+  optional string thumbnail_url = 2;
+  optional string url_foo       = 3;
+  optional string some_url_blah = 4;
+  optional string http          = 5;
+  optional string https         = 6;
+  // This one doesn't.
+  repeated string urls          = 7;
+}
+
 // EnumValueShortName: The short names shouldn't get suffixes/prefixes.
 // EnumValueShortName: The short names shouldn't get suffixes/prefixes.
 enum Foo {
 enum Foo {
   SERIALIZED_SIZE = 1;
   SERIALIZED_SIZE = 1;

+ 59 - 57
objectivec/google/protobuf/Any.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBAnyRoot
 #pragma mark - GPBAnyRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBAnyRoot : GPBRootObject
 @interface GPBAnyRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBAny
 #pragma mark - GPBAny
@@ -31,61 +33,61 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
   GPBAny_FieldNumber_Value = 2,
   GPBAny_FieldNumber_Value = 2,
 };
 };
 
 
-// `Any` contains an arbitrary serialized message along with a URL
-// that describes the type of the serialized message.
-//
-//
-// JSON
-// ====
-// The JSON representation of an `Any` value uses the regular
-// representation of the deserialized, embedded message, with an
-// additional field `@type` which contains the type URL. Example:
-//
-//     package google.profile;
-//     message Person {
-//       string first_name = 1;
-//       string last_name = 2;
-//     }
-//
-//     {
-//       "@type": "type.googleapis.com/google.profile.Person",
-//       "firstName": <string>,
-//       "lastName": <string>
-//     }
-//
-// If the embedded message type is well-known and has a custom JSON
-// representation, that representation will be embedded adding a field
-// `value` which holds the custom JSON in addition to the `@type`
-// field. Example (for message [google.protobuf.Duration][]):
-//
-//     {
-//       "@type": "type.googleapis.com/google.protobuf.Duration",
-//       "value": "1.212s"
-//     }
+/// `Any` contains an arbitrary serialized message along with a URL
+/// that describes the type of the serialized message.
+///
+///
+/// JSON
+/// ====
+/// The JSON representation of an `Any` value uses the regular
+/// representation of the deserialized, embedded message, with an
+/// additional field `\@type` which contains the type URL. Example:
+///
+///     package google.profile;
+///     message Person {
+///       string first_name = 1;
+///       string last_name = 2;
+///     }
+///
+///     {
+///       "\@type": "type.googleapis.com/google.profile.Person",
+///       "firstName": <string>,
+///       "lastName": <string>
+///     }
+///
+/// If the embedded message type is well-known and has a custom JSON
+/// representation, that representation will be embedded adding a field
+/// `value` which holds the custom JSON in addition to the `\@type`
+/// field. Example (for message [google.protobuf.Duration][]):
+///
+///     {
+///       "\@type": "type.googleapis.com/google.protobuf.Duration",
+///       "value": "1.212s"
+///     }
 @interface GPBAny : GPBMessage
 @interface GPBAny : GPBMessage
 
 
-// A URL/resource name whose content describes the type of the
-// serialized message.
-//
-// For URLs which use the schema `http`, `https`, or no schema, the
-// following restrictions and interpretations apply:
-//
-// * If no schema is provided, `https` is assumed.
-// * The last segment of the URL's path must represent the fully
-//   qualified name of the type (as in `path/google.protobuf.Duration`).
-// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
-//   value in binary format, or produce an error.
-// * Applications are allowed to cache lookup results based on the
-//   URL, or have them precompiled into a binary to avoid any
-//   lookup. Therefore, binary compatibility needs to be preserved
-//   on changes to types. (Use versioned type names to manage
-//   breaking changes.)
-//
-// Schemas other than `http`, `https` (or the empty schema) might be
-// used with implementation specific semantics.
+/// A URL/resource name whose content describes the type of the
+/// serialized message.
+///
+/// For URLs which use the schema `http`, `https`, or no schema, the
+/// following restrictions and interpretations apply:
+///
+/// * If no schema is provided, `https` is assumed.
+/// * The last segment of the URL's path must represent the fully
+///   qualified name of the type (as in `path/google.protobuf.Duration`).
+/// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+///   value in binary format, or produce an error.
+/// * Applications are allowed to cache lookup results based on the
+///   URL, or have them precompiled into a binary to avoid any
+///   lookup. Therefore, binary compatibility needs to be preserved
+///   on changes to types. (Use versioned type names to manage
+///   breaking changes.)
+///
+/// Schemas other than `http`, `https` (or the empty schema) might be
+/// used with implementation specific semantics.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
 
 
-// Must be valid serialized data of the above specified type.
+/// Must be valid serialized data of the above specified type.
 @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
 @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
 
 
 @end
 @end

+ 141 - 124
objectivec/google/protobuf/Api.pbobjc.h

@@ -21,13 +21,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBApiRoot
 #pragma mark - GPBApiRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBApiRoot : GPBRootObject
 @interface GPBApiRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBApi
 #pragma mark - GPBApi
@@ -42,58 +44,67 @@ typedef GPB_ENUM(GPBApi_FieldNumber) {
   GPBApi_FieldNumber_Syntax = 7,
   GPBApi_FieldNumber_Syntax = 7,
 };
 };
 
 
-// Api is a light-weight descriptor for a protocol buffer service.
+/// Api is a light-weight descriptor for a protocol buffer service.
 @interface GPBApi : GPBMessage
 @interface GPBApi : GPBMessage
 
 
-// The fully qualified name of this api, including package name
-// followed by the api's simple name.
+/// The fully qualified name of this api, including package name
+/// followed by the api's simple name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// The methods of this api, in unspecified order.
+/// The methods of this api, in unspecified order.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMethod*> *methodsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMethod*> *methodsArray;
+/// The number of items in @c methodsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger methodsArray_Count;
 @property(nonatomic, readonly) NSUInteger methodsArray_Count;
 
 
-// Any metadata attached to the API.
+/// Any metadata attached to the API.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
-// A version string for this api. 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
-// API, 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, none-GA apis.
+/// A version string for this api. 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
+/// API, 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, none-GA apis.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *version;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *version;
 
 
-// Source context for the protocol buffer service represented by this
-// message.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/// Source context for the protocol buffer service represented by this
+/// message.
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/// Test to see if @c sourceContext has been set.
+@property(nonatomic, readwrite) BOOL hasSourceContext;
 
 
-// Included APIs. See [Mixin][].
+/// Included APIs. See [Mixin][].
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBMixin*> *mixinsArray;
+/// The number of items in @c mixinsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger mixinsArray_Count;
 @property(nonatomic, readonly) NSUInteger mixinsArray_Count;
 
 
-// The source syntax of the service.
+/// The source syntax of the service.
 @property(nonatomic, readwrite) enum GPBSyntax syntax;
 @property(nonatomic, readwrite) enum GPBSyntax syntax;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBApi's @c syntax property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBApi_Syntax_RawValue(GPBApi *message);
 int32_t GPBApi_Syntax_RawValue(GPBApi *message);
+/// Sets the raw value of an @c GPBApi's @c syntax property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
 void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value);
 
 
 #pragma mark - GPBMethod
 #pragma mark - GPBMethod
@@ -108,34 +119,40 @@ typedef GPB_ENUM(GPBMethod_FieldNumber) {
   GPBMethod_FieldNumber_Syntax = 7,
   GPBMethod_FieldNumber_Syntax = 7,
 };
 };
 
 
-// Method represents a method of an api.
+/// Method represents a method of an api.
 @interface GPBMethod : GPBMessage
 @interface GPBMethod : GPBMessage
 
 
-// The simple name of this method.
+/// The simple name of this method.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// A URL of the input message type.
+/// A URL of the input message type.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL;
 
 
-// If true, the request is streamed.
+/// If true, the request is streamed.
 @property(nonatomic, readwrite) BOOL requestStreaming;
 @property(nonatomic, readwrite) BOOL requestStreaming;
 
 
-// The URL of the output message type.
+/// The URL of the output message type.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL;
 
 
-// If true, the response is streamed.
+/// If true, the response is streamed.
 @property(nonatomic, readwrite) BOOL responseStreaming;
 @property(nonatomic, readwrite) BOOL responseStreaming;
 
 
-// Any metadata attached to the method.
+/// Any metadata attached to the method.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
-// The source syntax of this method.
+/// The source syntax of this method.
 @property(nonatomic, readwrite) enum GPBSyntax syntax;
 @property(nonatomic, readwrite) enum GPBSyntax syntax;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBMethod's @c syntax property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
 int32_t GPBMethod_Syntax_RawValue(GPBMethod *message);
+/// Sets the raw value of an @c GPBMethod's @c syntax property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
 void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value);
 
 
 #pragma mark - GPBMixin
 #pragma mark - GPBMixin
@@ -145,90 +162,90 @@ typedef GPB_ENUM(GPBMixin_FieldNumber) {
   GPBMixin_FieldNumber_Root = 2,
   GPBMixin_FieldNumber_Root = 2,
 };
 };
 
 
-// Declares an API to be included in this API. The including API must
-// redeclare all the methods from the included API, 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 API 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";
-//       }
-//       ...
-//     }
+/// Declares an API to be included in this API. The including API must
+/// redeclare all the methods from the included API, 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 API 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";
+///       }
+///       ...
+///     }
 @interface GPBMixin : GPBMessage
 @interface GPBMixin : GPBMessage
 
 
-// The fully qualified name of the API which is included.
+/// The fully qualified name of the API which is included.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// If non-empty specifies a path under which inherited HTTP paths
-// are rooted.
+/// If non-empty specifies a path under which inherited HTTP paths
+/// are rooted.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *root;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *root;
 
 
 @end
 @end

File diff suppressed because it is too large
+ 362 - 300
objectivec/google/protobuf/Descriptor.pbobjc.h


+ 56 - 54
objectivec/google/protobuf/Duration.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBDurationRoot
 #pragma mark - GPBDurationRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBDurationRoot : GPBRootObject
 @interface GPBDurationRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBDuration
 #pragma mark - GPBDuration
@@ -31,58 +33,58 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) {
   GPBDuration_FieldNumber_Nanos = 2,
   GPBDuration_FieldNumber_Nanos = 2,
 };
 };
 
 
-// A Duration represents a signed, fixed-length span of time represented
-// as a count of seconds and fractions of seconds at nanosecond
-// resolution. It is independent of any calendar and concepts like "day"
-// or "month". It is related to Timestamp in that the difference between
-// two Timestamp values is a Duration and it can be added or subtracted
-// from a Timestamp. Range is approximately +-10,000 years.
-//
-// Example 1: Compute Duration from two Timestamps in pseudo code.
-//
-//     Timestamp start = ...;
-//     Timestamp end = ...;
-//     Duration duration = ...;
-//
-//     duration.seconds = end.seconds - start.seconds;
-//     duration.nanos = end.nanos - start.nanos;
-//
-//     if (duration.seconds < 0 && duration.nanos > 0) {
-//       duration.seconds += 1;
-//       duration.nanos -= 1000000000;
-//     } else if (durations.seconds > 0 && duration.nanos < 0) {
-//       duration.seconds -= 1;
-//       duration.nanos += 1000000000;
-//     }
-//
-// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
-//
-//     Timestamp start = ...;
-//     Duration duration = ...;
-//     Timestamp end = ...;
-//
-//     end.seconds = start.seconds + duration.seconds;
-//     end.nanos = start.nanos + duration.nanos;
-//
-//     if (end.nanos < 0) {
-//       end.seconds -= 1;
-//       end.nanos += 1000000000;
-//     } else if (end.nanos >= 1000000000) {
-//       end.seconds += 1;
-//       end.nanos -= 1000000000;
-//     }
+/// A Duration represents a signed, fixed-length span of time represented
+/// as a count of seconds and fractions of seconds at nanosecond
+/// resolution. It is independent of any calendar and concepts like "day"
+/// or "month". It is related to Timestamp in that the difference between
+/// two Timestamp values is a Duration and it can be added or subtracted
+/// from a Timestamp. Range is approximately +-10,000 years.
+///
+/// Example 1: Compute Duration from two Timestamps in pseudo code.
+///
+///     Timestamp start = ...;
+///     Timestamp end = ...;
+///     Duration duration = ...;
+///
+///     duration.seconds = end.seconds - start.seconds;
+///     duration.nanos = end.nanos - start.nanos;
+///
+///     if (duration.seconds < 0 && duration.nanos > 0) {
+///       duration.seconds += 1;
+///       duration.nanos -= 1000000000;
+///     } else if (durations.seconds > 0 && duration.nanos < 0) {
+///       duration.seconds -= 1;
+///       duration.nanos += 1000000000;
+///     }
+///
+/// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
+///
+///     Timestamp start = ...;
+///     Duration duration = ...;
+///     Timestamp end = ...;
+///
+///     end.seconds = start.seconds + duration.seconds;
+///     end.nanos = start.nanos + duration.nanos;
+///
+///     if (end.nanos < 0) {
+///       end.seconds -= 1;
+///       end.nanos += 1000000000;
+///     } else if (end.nanos >= 1000000000) {
+///       end.seconds += 1;
+///       end.nanos -= 1000000000;
+///     }
 @interface GPBDuration : GPBMessage
 @interface GPBDuration : GPBMessage
 
 
-// Signed seconds of the span of time. Must be from -315,576,000,000
-// to +315,576,000,000 inclusive.
+/// Signed seconds of the span of time. Must be from -315,576,000,000
+/// to +315,576,000,000 inclusive.
 @property(nonatomic, readwrite) int64_t seconds;
 @property(nonatomic, readwrite) int64_t seconds;
 
 
-// Signed fractions of a second at nanosecond resolution of the span
-// of time. Durations less than one second are represented with a 0
-// `seconds` field and a positive or negative `nanos` field. For durations
-// of one second or more, a non-zero value for the `nanos` field must be
-// of the same sign as the `seconds` field. Must be from -999,999,999
-// to +999,999,999 inclusive.
+/// Signed fractions of a second at nanosecond resolution of the span
+/// of time. Durations less than one second are represented with a 0
+/// `seconds` field and a positive or negative `nanos` field. For durations
+/// of one second or more, a non-zero value for the `nanos` field must be
+/// of the same sign as the `seconds` field. Must be from -999,999,999
+/// to +999,999,999 inclusive.
 @property(nonatomic, readwrite) int32_t nanos;
 @property(nonatomic, readwrite) int32_t nanos;
 
 
 @end
 @end

+ 17 - 15
objectivec/google/protobuf/Empty.pbobjc.h

@@ -15,26 +15,28 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBEmptyRoot
 #pragma mark - GPBEmptyRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBEmptyRoot : GPBRootObject
 @interface GPBEmptyRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBEmpty
 #pragma mark - GPBEmpty
 
 
-// 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 `{}`.
+/// 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 `{}`.
 @interface GPBEmpty : GPBMessage
 @interface GPBEmpty : GPBMessage
 
 
 @end
 @end

+ 132 - 129
objectivec/google/protobuf/FieldMask.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBFieldMaskRoot
 #pragma mark - GPBFieldMaskRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBFieldMaskRoot : GPBRootObject
 @interface GPBFieldMaskRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBFieldMask
 #pragma mark - GPBFieldMask
@@ -30,132 +32,133 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
   GPBFieldMask_FieldNumber_PathsArray = 1,
   GPBFieldMask_FieldNumber_PathsArray = 1,
 };
 };
 
 
-// `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
-// field mask.
-//
-// 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 applies 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.
-//
-// 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"
-//     }
+/// `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
+/// field mask.
+///
+/// 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 applies 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.
+///
+/// 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"
+///     }
 @interface GPBFieldMask : GPBMessage
 @interface GPBFieldMask : GPBMessage
 
 
-// The set of field mask paths.
+/// The set of field mask paths.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *pathsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *pathsArray;
+/// The number of items in @c pathsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger pathsArray_Count;
 @property(nonatomic, readonly) NSUInteger pathsArray_Count;
 
 
 @end
 @end

+ 12 - 10
objectivec/google/protobuf/SourceContext.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBSourceContextRoot
 #pragma mark - GPBSourceContextRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBSourceContextRoot : GPBRootObject
 @interface GPBSourceContextRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBSourceContext
 #pragma mark - GPBSourceContext
@@ -30,12 +32,12 @@ typedef GPB_ENUM(GPBSourceContext_FieldNumber) {
   GPBSourceContext_FieldNumber_FileName = 1,
   GPBSourceContext_FieldNumber_FileName = 1,
 };
 };
 
 
-// `SourceContext` represents information about the source of a
-// protobuf element, like the file in which it is defined.
+/// `SourceContext` represents information about the source of a
+/// protobuf element, like the file in which it is defined.
 @interface GPBSourceContext : GPBMessage
 @interface GPBSourceContext : GPBMessage
 
 
-// The path-qualified name of the .proto file that contained the associated
-// protobuf element.  For example: `"google/protobuf/source.proto"`.
+/// The path-qualified name of the .proto file that contained the associated
+/// protobuf element.  For example: `"google/protobuf/source.proto"`.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *fileName;
 
 
 @end
 @end

+ 52 - 37
objectivec/google/protobuf/Struct.pbobjc.h

@@ -19,29 +19,36 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - Enum GPBNullValue
 #pragma mark - Enum GPBNullValue
 
 
-// `NullValue` is a singleton enumeration to represent the null value for the
-// `Value` type union.
-//
-//  The JSON representation for `NullValue` is JSON `null`.
+/// `NullValue` is a singleton enumeration to represent the null value for the
+/// `Value` type union.
+///
+///  The JSON representation for `NullValue` is JSON `null`.
 typedef GPB_ENUM(GPBNullValue) {
 typedef GPB_ENUM(GPBNullValue) {
+  /// Value used if any message's field encounters a value that is not defined
+  /// by this enum. The message will also have C functions to get/set the rawValue
+  /// of the field.
   GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
   GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
-  // Null value.
+  /// Null value.
   GPBNullValue_NullValue = 0,
   GPBNullValue_NullValue = 0,
 };
 };
 
 
 GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
 GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void);
 
 
+/// Checks to see if the given value is defined by the enum or was not known at
+/// the time this source was generated.
 BOOL GPBNullValue_IsValidValue(int32_t value);
 BOOL GPBNullValue_IsValidValue(int32_t value);
 
 
 #pragma mark - GPBStructRoot
 #pragma mark - GPBStructRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBStructRoot : GPBRootObject
 @interface GPBStructRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBStruct
 #pragma mark - GPBStruct
@@ -50,18 +57,19 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) {
   GPBStruct_FieldNumber_Fields = 1,
   GPBStruct_FieldNumber_Fields = 1,
 };
 };
 
 
-// `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.
+/// `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.
 @interface GPBStruct : GPBMessage
 @interface GPBStruct : GPBMessage
 
 
-// Map of dynamically typed values.
+/// Map of dynamically typed values.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
+/// The number of items in @c fields without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger fields_Count;
 @property(nonatomic, readonly) NSUInteger fields_Count;
 
 
 @end
 @end
@@ -87,40 +95,46 @@ typedef GPB_ENUM(GPBValue_Kind_OneOfCase) {
   GPBValue_Kind_OneOfCase_ListValue = 6,
   GPBValue_Kind_OneOfCase_ListValue = 6,
 };
 };
 
 
-// `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.
+/// `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.
 @interface GPBValue : GPBMessage
 @interface GPBValue : GPBMessage
 
 
-// The kind of value.
+/// The kind of value.
 @property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
 @property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase;
 
 
-// Represents a null value.
+/// Represents a null value.
 @property(nonatomic, readwrite) GPBNullValue nullValue;
 @property(nonatomic, readwrite) GPBNullValue nullValue;
 
 
-// Represents a double value.
+/// Represents a double value.
 @property(nonatomic, readwrite) double numberValue;
 @property(nonatomic, readwrite) double numberValue;
 
 
-// Represents a string value.
+/// Represents a string value.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue;
 
 
-// Represents a boolean value.
+/// Represents a boolean value.
 @property(nonatomic, readwrite) BOOL boolValue;
 @property(nonatomic, readwrite) BOOL boolValue;
 
 
-// Represents a structured value.
+/// Represents a structured value.
 @property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
 @property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue;
 
 
-// Represents a repeated `Value`.
+/// Represents a repeated `Value`.
 @property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
 @property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBValue's @c nullValue property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBValue_NullValue_RawValue(GPBValue *message);
 int32_t GPBValue_NullValue_RawValue(GPBValue *message);
+/// Sets the raw value of an @c GPBValue's @c nullValue property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value);
 void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value);
 
 
+/// Clears whatever value was set for the oneof 'kind'.
 void GPBValue_ClearKindOneOfCase(GPBValue *message);
 void GPBValue_ClearKindOneOfCase(GPBValue *message);
 
 
 #pragma mark - GPBListValue
 #pragma mark - GPBListValue
@@ -129,13 +143,14 @@ typedef GPB_ENUM(GPBListValue_FieldNumber) {
   GPBListValue_FieldNumber_ValuesArray = 1,
   GPBListValue_FieldNumber_ValuesArray = 1,
 };
 };
 
 
-// `ListValue` is a wrapper around a repeated field of values.
-//
-// The JSON representation for `ListValue` is JSON array.
+/// `ListValue` is a wrapper around a repeated field of values.
+///
+/// The JSON representation for `ListValue` is JSON array.
 @interface GPBListValue : GPBMessage
 @interface GPBListValue : GPBMessage
 
 
-// Repeated field of dynamically typed values.
+/// Repeated field of dynamically typed values.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBValue*> *valuesArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBValue*> *valuesArray;
+/// The number of items in @c valuesArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger valuesArray_Count;
 @property(nonatomic, readonly) NSUInteger valuesArray_Count;
 
 
 @end
 @end

+ 68 - 66
objectivec/google/protobuf/Timestamp.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBTimestampRoot
 #pragma mark - GPBTimestampRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBTimestampRoot : GPBRootObject
 @interface GPBTimestampRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBTimestamp
 #pragma mark - GPBTimestamp
@@ -31,70 +33,70 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
   GPBTimestamp_FieldNumber_Nanos = 2,
   GPBTimestamp_FieldNumber_Nanos = 2,
 };
 };
 
 
-// A Timestamp represents a point in time independent of any time zone
-// or calendar, represented as seconds and fractions of seconds at
-// nanosecond resolution in UTC Epoch time. It is encoded using the
-// Proleptic Gregorian Calendar which extends the Gregorian calendar
-// backwards to year one. It is encoded assuming all minutes are 60
-// seconds long, i.e. leap seconds are "smeared" so that no leap second
-// table is needed for interpretation. Range is from
-// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
-// By restricting to that range, we ensure that we can convert to
-// and from  RFC 3339 date strings.
-// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
-//
-// Example 1: Compute Timestamp from POSIX `time()`.
-//
-//     Timestamp timestamp;
-//     timestamp.set_seconds(time(NULL));
-//     timestamp.set_nanos(0);
-//
-// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
-//
-//     struct timeval tv;
-//     gettimeofday(&tv, NULL);
-//
-//     Timestamp timestamp;
-//     timestamp.set_seconds(tv.tv_sec);
-//     timestamp.set_nanos(tv.tv_usec * 1000);
-//
-// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
-//
-//     FILETIME ft;
-//     GetSystemTimeAsFileTime(&ft);
-//     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
-//
-//     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
-//     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
-//     Timestamp timestamp;
-//     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
-//     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
-//
-// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
-//
-//     long millis = System.currentTimeMillis();
-//
-//     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
-//         .setNanos((int) ((millis % 1000) * 1000000)).build();
-//
-//
-// Example 5: Compute Timestamp from current time in Python.
-//
-//     now = time.time()
-//     seconds = int(now)
-//     nanos = int((now - seconds) * 10**9)
-//     timestamp = Timestamp(seconds=seconds, nanos=nanos)
+/// A Timestamp represents a point in time independent of any time zone
+/// or calendar, represented as seconds and fractions of seconds at
+/// nanosecond resolution in UTC Epoch time. It is encoded using the
+/// Proleptic Gregorian Calendar which extends the Gregorian calendar
+/// backwards to year one. It is encoded assuming all minutes are 60
+/// seconds long, i.e. leap seconds are "smeared" so that no leap second
+/// table is needed for interpretation. Range is from
+/// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
+/// By restricting to that range, we ensure that we can convert to
+/// and from  RFC 3339 date strings.
+/// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
+///
+/// Example 1: Compute Timestamp from POSIX `time()`.
+///
+///     Timestamp timestamp;
+///     timestamp.set_seconds(time(NULL));
+///     timestamp.set_nanos(0);
+///
+/// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
+///
+///     struct timeval tv;
+///     gettimeofday(&tv, NULL);
+///
+///     Timestamp timestamp;
+///     timestamp.set_seconds(tv.tv_sec);
+///     timestamp.set_nanos(tv.tv_usec * 1000);
+///
+/// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
+///
+///     FILETIME ft;
+///     GetSystemTimeAsFileTime(&ft);
+///     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
+///
+///     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
+///     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
+///     Timestamp timestamp;
+///     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
+///     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
+///
+/// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
+///
+///     long millis = System.currentTimeMillis();
+///
+///     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
+///         .setNanos((int) ((millis % 1000) * 1000000)).build();
+///
+///
+/// Example 5: Compute Timestamp from current time in Python.
+///
+///     now = time.time()
+///     seconds = int(now)
+///     nanos = int((now - seconds) * 10**9)
+///     timestamp = Timestamp(seconds=seconds, nanos=nanos)
 @interface GPBTimestamp : GPBMessage
 @interface GPBTimestamp : GPBMessage
 
 
-// Represents seconds of UTC time since Unix epoch
-// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
-// 9999-12-31T23:59:59Z inclusive.
+/// Represents seconds of UTC time since Unix epoch
+/// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
+/// 9999-12-31T23:59:59Z inclusive.
 @property(nonatomic, readwrite) int64_t seconds;
 @property(nonatomic, readwrite) int64_t seconds;
 
 
-// Non-negative fractions of a second at nanosecond resolution. Negative
-// second values with fractions must still have non-negative nanos values
-// that count forward in time. Must be from 0 to 999,999,999
-// inclusive.
+/// Non-negative fractions of a second at nanosecond resolution. Negative
+/// second values with fractions must still have non-negative nanos values
+/// that count forward in time. Must be from 0 to 999,999,999
+/// inclusive.
 @property(nonatomic, readwrite) int32_t nanos;
 @property(nonatomic, readwrite) int32_t nanos;
 
 
 @end
 @end

+ 118 - 71
objectivec/google/protobuf/Type.pbobjc.h

@@ -21,118 +21,135 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - Enum GPBSyntax
 #pragma mark - Enum GPBSyntax
 
 
-// The syntax in which a protocol buffer element is defined.
+/// The syntax in which a protocol buffer element is defined.
 typedef GPB_ENUM(GPBSyntax) {
 typedef GPB_ENUM(GPBSyntax) {
+  /// Value used if any message's field encounters a value that is not defined
+  /// by this enum. The message will also have C functions to get/set the rawValue
+  /// of the field.
   GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
   GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
-  // Syntax `proto2`.
+  /// Syntax `proto2`.
   GPBSyntax_SyntaxProto2 = 0,
   GPBSyntax_SyntaxProto2 = 0,
 
 
-  // Syntax `proto3`.
+  /// Syntax `proto3`.
   GPBSyntax_SyntaxProto3 = 1,
   GPBSyntax_SyntaxProto3 = 1,
 };
 };
 
 
 GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
 GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void);
 
 
+/// Checks to see if the given value is defined by the enum or was not known at
+/// the time this source was generated.
 BOOL GPBSyntax_IsValidValue(int32_t value);
 BOOL GPBSyntax_IsValidValue(int32_t value);
 
 
 #pragma mark - Enum GPBField_Kind
 #pragma mark - Enum GPBField_Kind
 
 
-// Basic field types.
+/// Basic field types.
 typedef GPB_ENUM(GPBField_Kind) {
 typedef GPB_ENUM(GPBField_Kind) {
+  /// Value used if any message's field encounters a value that is not defined
+  /// by this enum. The message will also have C functions to get/set the rawValue
+  /// of the field.
   GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
   GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
-  // Field type unknown.
+  /// Field type unknown.
   GPBField_Kind_TypeUnknown = 0,
   GPBField_Kind_TypeUnknown = 0,
 
 
-  // Field type double.
+  /// Field type double.
   GPBField_Kind_TypeDouble = 1,
   GPBField_Kind_TypeDouble = 1,
 
 
-  // Field type float.
+  /// Field type float.
   GPBField_Kind_TypeFloat = 2,
   GPBField_Kind_TypeFloat = 2,
 
 
-  // Field type int64.
+  /// Field type int64.
   GPBField_Kind_TypeInt64 = 3,
   GPBField_Kind_TypeInt64 = 3,
 
 
-  // Field type uint64.
+  /// Field type uint64.
   GPBField_Kind_TypeUint64 = 4,
   GPBField_Kind_TypeUint64 = 4,
 
 
-  // Field type int32.
+  /// Field type int32.
   GPBField_Kind_TypeInt32 = 5,
   GPBField_Kind_TypeInt32 = 5,
 
 
-  // Field type fixed64.
+  /// Field type fixed64.
   GPBField_Kind_TypeFixed64 = 6,
   GPBField_Kind_TypeFixed64 = 6,
 
 
-  // Field type fixed32.
+  /// Field type fixed32.
   GPBField_Kind_TypeFixed32 = 7,
   GPBField_Kind_TypeFixed32 = 7,
 
 
-  // Field type bool.
+  /// Field type bool.
   GPBField_Kind_TypeBool = 8,
   GPBField_Kind_TypeBool = 8,
 
 
-  // Field type string.
+  /// Field type string.
   GPBField_Kind_TypeString = 9,
   GPBField_Kind_TypeString = 9,
 
 
-  // Field type group. Proto2 syntax only, and deprecated.
+  /// Field type group. Proto2 syntax only, and deprecated.
   GPBField_Kind_TypeGroup = 10,
   GPBField_Kind_TypeGroup = 10,
 
 
-  // Field type message.
+  /// Field type message.
   GPBField_Kind_TypeMessage = 11,
   GPBField_Kind_TypeMessage = 11,
 
 
-  // Field type bytes.
+  /// Field type bytes.
   GPBField_Kind_TypeBytes = 12,
   GPBField_Kind_TypeBytes = 12,
 
 
-  // Field type uint32.
+  /// Field type uint32.
   GPBField_Kind_TypeUint32 = 13,
   GPBField_Kind_TypeUint32 = 13,
 
 
-  // Field type enum.
+  /// Field type enum.
   GPBField_Kind_TypeEnum = 14,
   GPBField_Kind_TypeEnum = 14,
 
 
-  // Field type sfixed32.
+  /// Field type sfixed32.
   GPBField_Kind_TypeSfixed32 = 15,
   GPBField_Kind_TypeSfixed32 = 15,
 
 
-  // Field type sfixed64.
+  /// Field type sfixed64.
   GPBField_Kind_TypeSfixed64 = 16,
   GPBField_Kind_TypeSfixed64 = 16,
 
 
-  // Field type sint32.
+  /// Field type sint32.
   GPBField_Kind_TypeSint32 = 17,
   GPBField_Kind_TypeSint32 = 17,
 
 
-  // Field type sint64.
+  /// Field type sint64.
   GPBField_Kind_TypeSint64 = 18,
   GPBField_Kind_TypeSint64 = 18,
 };
 };
 
 
 GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void);
 GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void);
 
 
+/// Checks to see if the given value is defined by the enum or was not known at
+/// the time this source was generated.
 BOOL GPBField_Kind_IsValidValue(int32_t value);
 BOOL GPBField_Kind_IsValidValue(int32_t value);
 
 
 #pragma mark - Enum GPBField_Cardinality
 #pragma mark - Enum GPBField_Cardinality
 
 
-// Whether a field is optional, required, or repeated.
+/// Whether a field is optional, required, or repeated.
 typedef GPB_ENUM(GPBField_Cardinality) {
 typedef GPB_ENUM(GPBField_Cardinality) {
+  /// Value used if any message's field encounters a value that is not defined
+  /// by this enum. The message will also have C functions to get/set the rawValue
+  /// of the field.
   GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
   GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,
-  // For fields with unknown cardinality.
+  /// For fields with unknown cardinality.
   GPBField_Cardinality_CardinalityUnknown = 0,
   GPBField_Cardinality_CardinalityUnknown = 0,
 
 
-  // For optional fields.
+  /// For optional fields.
   GPBField_Cardinality_CardinalityOptional = 1,
   GPBField_Cardinality_CardinalityOptional = 1,
 
 
-  // For required fields. Proto2 syntax only.
+  /// For required fields. Proto2 syntax only.
   GPBField_Cardinality_CardinalityRequired = 2,
   GPBField_Cardinality_CardinalityRequired = 2,
 
 
-  // For repeated fields.
+  /// For repeated fields.
   GPBField_Cardinality_CardinalityRepeated = 3,
   GPBField_Cardinality_CardinalityRepeated = 3,
 };
 };
 
 
 GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
 GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void);
 
 
+/// Checks to see if the given value is defined by the enum or was not known at
+/// the time this source was generated.
 BOOL GPBField_Cardinality_IsValidValue(int32_t value);
 BOOL GPBField_Cardinality_IsValidValue(int32_t value);
 
 
 #pragma mark - GPBTypeRoot
 #pragma mark - GPBTypeRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBTypeRoot : GPBRootObject
 @interface GPBTypeRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBType
 #pragma mark - GPBType
@@ -146,34 +163,43 @@ typedef GPB_ENUM(GPBType_FieldNumber) {
   GPBType_FieldNumber_Syntax = 6,
   GPBType_FieldNumber_Syntax = 6,
 };
 };
 
 
-// A protocol buffer message type.
+/// A protocol buffer message type.
 @interface GPBType : GPBMessage
 @interface GPBType : GPBMessage
 
 
-// The fully qualified message name.
+/// The fully qualified message name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// The list of fields.
+/// The list of fields.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBField*> *fieldsArray;
+/// The number of items in @c fieldsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger fieldsArray_Count;
 @property(nonatomic, readonly) NSUInteger fieldsArray_Count;
 
 
-// The list of types appearing in `oneof` definitions in this type.
+/// The list of types appearing in `oneof` definitions in this type.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *oneofsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *oneofsArray;
+/// The number of items in @c oneofsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger oneofsArray_Count;
 @property(nonatomic, readonly) NSUInteger oneofsArray_Count;
 
 
-// The protocol buffer options.
+/// The protocol buffer options.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
-// The source context.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/// The source context.
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/// Test to see if @c sourceContext has been set.
+@property(nonatomic, readwrite) BOOL hasSourceContext;
 
 
-// The source syntax.
+/// The source syntax.
 @property(nonatomic, readwrite) GPBSyntax syntax;
 @property(nonatomic, readwrite) GPBSyntax syntax;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBType's @c syntax property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBType_Syntax_RawValue(GPBType *message);
 int32_t GPBType_Syntax_RawValue(GPBType *message);
+/// Sets the raw value of an @c GPBType's @c syntax property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
 void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value);
 
 
 #pragma mark - GPBField
 #pragma mark - GPBField
@@ -191,48 +217,59 @@ typedef GPB_ENUM(GPBField_FieldNumber) {
   GPBField_FieldNumber_DefaultValue = 11,
   GPBField_FieldNumber_DefaultValue = 11,
 };
 };
 
 
-// A single field of a message type.
+/// A single field of a message type.
 @interface GPBField : GPBMessage
 @interface GPBField : GPBMessage
 
 
-// The field type.
+/// The field type.
 @property(nonatomic, readwrite) GPBField_Kind kind;
 @property(nonatomic, readwrite) GPBField_Kind kind;
 
 
-// The field cardinality.
+/// The field cardinality.
 @property(nonatomic, readwrite) GPBField_Cardinality cardinality;
 @property(nonatomic, readwrite) GPBField_Cardinality cardinality;
 
 
-// The field number.
+/// The field number.
 @property(nonatomic, readwrite) int32_t number;
 @property(nonatomic, readwrite) int32_t number;
 
 
-// The field name.
+/// The field name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// The field type URL, without the scheme, for message or enumeration
-// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+/// The field type URL, without the scheme, for message or enumeration
+/// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
 
 
-// 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.
+/// 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.
 @property(nonatomic, readwrite) int32_t oneofIndex;
 @property(nonatomic, readwrite) int32_t oneofIndex;
 
 
-// Whether to use alternative packed wire representation.
+/// Whether to use alternative packed wire representation.
 @property(nonatomic, readwrite) BOOL packed;
 @property(nonatomic, readwrite) BOOL packed;
 
 
-// The protocol buffer options.
+/// The protocol buffer options.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
-// The field JSON name.
+/// The field JSON name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName;
 
 
-// The string value of the default value of this field. Proto2 syntax only.
+/// The string value of the default value of this field. Proto2 syntax only.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBField's @c kind property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBField_Kind_RawValue(GPBField *message);
 int32_t GPBField_Kind_RawValue(GPBField *message);
+/// Sets the raw value of an @c GPBField's @c kind property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBField_Kind_RawValue(GPBField *message, int32_t value);
 void SetGPBField_Kind_RawValue(GPBField *message, int32_t value);
 
 
+/// Fetches the raw value of a @c GPBField's @c cardinality property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBField_Cardinality_RawValue(GPBField *message);
 int32_t GPBField_Cardinality_RawValue(GPBField *message);
+/// Sets the raw value of an @c GPBField's @c cardinality property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value);
 void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value);
 
 
 #pragma mark - GPBEnum
 #pragma mark - GPBEnum
@@ -245,30 +282,38 @@ typedef GPB_ENUM(GPBEnum_FieldNumber) {
   GPBEnum_FieldNumber_Syntax = 5,
   GPBEnum_FieldNumber_Syntax = 5,
 };
 };
 
 
-// Enum type definition.
+/// Enum type definition.
 @interface GPBEnum : GPBMessage
 @interface GPBEnum : GPBMessage
 
 
-// Enum type name.
+/// Enum type name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// Enum value definitions.
+/// Enum value definitions.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBEnumValue*> *enumvalueArray;
+/// The number of items in @c enumvalueArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
 @property(nonatomic, readonly) NSUInteger enumvalueArray_Count;
 
 
-// Protocol buffer options.
+/// Protocol buffer options.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
-// The source context.
-@property(nonatomic, readwrite) BOOL hasSourceContext;
+/// The source context.
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
 @property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext;
+/// Test to see if @c sourceContext has been set.
+@property(nonatomic, readwrite) BOOL hasSourceContext;
 
 
-// The source syntax.
+/// The source syntax.
 @property(nonatomic, readwrite) GPBSyntax syntax;
 @property(nonatomic, readwrite) GPBSyntax syntax;
 
 
 @end
 @end
 
 
+/// Fetches the raw value of a @c GPBEnum's @c syntax property, even
+/// if the value was not defined by the enum at the time the code was generated.
 int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
 int32_t GPBEnum_Syntax_RawValue(GPBEnum *message);
+/// Sets the raw value of an @c GPBEnum's @c syntax property, allowing
+/// it to be set to a value that was not defined by the enum at the time the code
+/// was generated.
 void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
 void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value);
 
 
 #pragma mark - GPBEnumValue
 #pragma mark - GPBEnumValue
@@ -279,17 +324,18 @@ typedef GPB_ENUM(GPBEnumValue_FieldNumber) {
   GPBEnumValue_FieldNumber_OptionsArray = 3,
   GPBEnumValue_FieldNumber_OptionsArray = 3,
 };
 };
 
 
-// Enum value definition.
+/// Enum value definition.
 @interface GPBEnumValue : GPBMessage
 @interface GPBEnumValue : GPBMessage
 
 
-// Enum value name.
+/// Enum value name.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// Enum value number.
+/// Enum value number.
 @property(nonatomic, readwrite) int32_t number;
 @property(nonatomic, readwrite) int32_t number;
 
 
-// Protocol buffer options.
+/// Protocol buffer options.
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
 @property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<GPBOption*> *optionsArray;
+/// The number of items in @c optionsArray without causing the array to be created.
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 @property(nonatomic, readonly) NSUInteger optionsArray_Count;
 
 
 @end
 @end
@@ -301,16 +347,17 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
   GPBOption_FieldNumber_Value = 2,
   GPBOption_FieldNumber_Value = 2,
 };
 };
 
 
-// A protocol buffer option, which can be attached to a message, field,
-// enumeration, etc.
+/// A protocol buffer option, which can be attached to a message, field,
+/// enumeration, etc.
 @interface GPBOption : GPBMessage
 @interface GPBOption : GPBMessage
 
 
-// The option's name. For example, `"java_package"`.
+/// The option's name. For example, `"java_package"`.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *name;
 
 
-// The option's value. For example, `"com.google.protobuf"`.
-@property(nonatomic, readwrite) BOOL hasValue;
+/// The option's value. For example, `"com.google.protobuf"`.
 @property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
 @property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
+/// Test to see if @c value has been set.
+@property(nonatomic, readwrite) BOOL hasValue;
 
 
 @end
 @end
 
 

+ 44 - 42
objectivec/google/protobuf/Wrappers.pbobjc.h

@@ -15,13 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 #pragma mark - GPBWrappersRoot
 #pragma mark - GPBWrappersRoot
 
 
+/// Exposes the extension registry for this file.
+///
+/// The base class provides:
+/// @code
+///   + (GPBExtensionRegistry *)extensionRegistry;
+/// @endcode
+/// which is a @c GPBExtensionRegistry that includes all the extensions defined by
+/// this file and all files that it depends on.
 @interface GPBWrappersRoot : GPBRootObject
 @interface GPBWrappersRoot : GPBRootObject
-
-// The base class provides:
-//   + (GPBExtensionRegistry *)extensionRegistry;
-// which is an GPBExtensionRegistry that includes all the extensions defined by
-// this file and all files that it depends on.
-
 @end
 @end
 
 
 #pragma mark - GPBDoubleValue
 #pragma mark - GPBDoubleValue
@@ -30,12 +32,12 @@ typedef GPB_ENUM(GPBDoubleValue_FieldNumber) {
   GPBDoubleValue_FieldNumber_Value = 1,
   GPBDoubleValue_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `double`.
-//
-// The JSON representation for `DoubleValue` is JSON number.
+/// Wrapper message for `double`.
+///
+/// The JSON representation for `DoubleValue` is JSON number.
 @interface GPBDoubleValue : GPBMessage
 @interface GPBDoubleValue : GPBMessage
 
 
-// The double value.
+/// The double value.
 @property(nonatomic, readwrite) double value;
 @property(nonatomic, readwrite) double value;
 
 
 @end
 @end
@@ -46,12 +48,12 @@ typedef GPB_ENUM(GPBFloatValue_FieldNumber) {
   GPBFloatValue_FieldNumber_Value = 1,
   GPBFloatValue_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `float`.
-//
-// The JSON representation for `FloatValue` is JSON number.
+/// Wrapper message for `float`.
+///
+/// The JSON representation for `FloatValue` is JSON number.
 @interface GPBFloatValue : GPBMessage
 @interface GPBFloatValue : GPBMessage
 
 
-// The float value.
+/// The float value.
 @property(nonatomic, readwrite) float value;
 @property(nonatomic, readwrite) float value;
 
 
 @end
 @end
@@ -62,12 +64,12 @@ typedef GPB_ENUM(GPBInt64Value_FieldNumber) {
   GPBInt64Value_FieldNumber_Value = 1,
   GPBInt64Value_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `int64`.
-//
-// The JSON representation for `Int64Value` is JSON string.
+/// Wrapper message for `int64`.
+///
+/// The JSON representation for `Int64Value` is JSON string.
 @interface GPBInt64Value : GPBMessage
 @interface GPBInt64Value : GPBMessage
 
 
-// The int64 value.
+/// The int64 value.
 @property(nonatomic, readwrite) int64_t value;
 @property(nonatomic, readwrite) int64_t value;
 
 
 @end
 @end
@@ -78,12 +80,12 @@ typedef GPB_ENUM(GPBUInt64Value_FieldNumber) {
   GPBUInt64Value_FieldNumber_Value = 1,
   GPBUInt64Value_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `uint64`.
-//
-// The JSON representation for `UInt64Value` is JSON string.
+/// Wrapper message for `uint64`.
+///
+/// The JSON representation for `UInt64Value` is JSON string.
 @interface GPBUInt64Value : GPBMessage
 @interface GPBUInt64Value : GPBMessage
 
 
-// The uint64 value.
+/// The uint64 value.
 @property(nonatomic, readwrite) uint64_t value;
 @property(nonatomic, readwrite) uint64_t value;
 
 
 @end
 @end
@@ -94,12 +96,12 @@ typedef GPB_ENUM(GPBInt32Value_FieldNumber) {
   GPBInt32Value_FieldNumber_Value = 1,
   GPBInt32Value_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `int32`.
-//
-// The JSON representation for `Int32Value` is JSON number.
+/// Wrapper message for `int32`.
+///
+/// The JSON representation for `Int32Value` is JSON number.
 @interface GPBInt32Value : GPBMessage
 @interface GPBInt32Value : GPBMessage
 
 
-// The int32 value.
+/// The int32 value.
 @property(nonatomic, readwrite) int32_t value;
 @property(nonatomic, readwrite) int32_t value;
 
 
 @end
 @end
@@ -110,12 +112,12 @@ typedef GPB_ENUM(GPBUInt32Value_FieldNumber) {
   GPBUInt32Value_FieldNumber_Value = 1,
   GPBUInt32Value_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `uint32`.
-//
-// The JSON representation for `UInt32Value` is JSON number.
+/// Wrapper message for `uint32`.
+///
+/// The JSON representation for `UInt32Value` is JSON number.
 @interface GPBUInt32Value : GPBMessage
 @interface GPBUInt32Value : GPBMessage
 
 
-// The uint32 value.
+/// The uint32 value.
 @property(nonatomic, readwrite) uint32_t value;
 @property(nonatomic, readwrite) uint32_t value;
 
 
 @end
 @end
@@ -126,12 +128,12 @@ typedef GPB_ENUM(GPBBoolValue_FieldNumber) {
   GPBBoolValue_FieldNumber_Value = 1,
   GPBBoolValue_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `bool`.
-//
-// The JSON representation for `BoolValue` is JSON `true` and `false`.
+/// Wrapper message for `bool`.
+///
+/// The JSON representation for `BoolValue` is JSON `true` and `false`.
 @interface GPBBoolValue : GPBMessage
 @interface GPBBoolValue : GPBMessage
 
 
-// The bool value.
+/// The bool value.
 @property(nonatomic, readwrite) BOOL value;
 @property(nonatomic, readwrite) BOOL value;
 
 
 @end
 @end
@@ -142,12 +144,12 @@ typedef GPB_ENUM(GPBStringValue_FieldNumber) {
   GPBStringValue_FieldNumber_Value = 1,
   GPBStringValue_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `string`.
-//
-// The JSON representation for `StringValue` is JSON string.
+/// Wrapper message for `string`.
+///
+/// The JSON representation for `StringValue` is JSON string.
 @interface GPBStringValue : GPBMessage
 @interface GPBStringValue : GPBMessage
 
 
-// The string value.
+/// The string value.
 @property(nonatomic, readwrite, copy, null_resettable) NSString *value;
 @property(nonatomic, readwrite, copy, null_resettable) NSString *value;
 
 
 @end
 @end
@@ -158,12 +160,12 @@ typedef GPB_ENUM(GPBBytesValue_FieldNumber) {
   GPBBytesValue_FieldNumber_Value = 1,
   GPBBytesValue_FieldNumber_Value = 1,
 };
 };
 
 
-// Wrapper message for `bytes`.
-//
-// The JSON representation for `BytesValue` is JSON string.
+/// Wrapper message for `bytes`.
+///
+/// The JSON representation for `BytesValue` is JSON string.
 @interface GPBBytesValue : GPBMessage
 @interface GPBBytesValue : GPBMessage
 
 
-// The bytes value.
+/// The bytes value.
 @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
 @property(nonatomic, readwrite, copy, null_resettable) NSData *value;
 
 
 @end
 @end

+ 34 - 50
protobuf.bzl

@@ -15,9 +15,13 @@ def _GenDir(ctx):
     return _GetPath(ctx, ctx.attr.includes[0])
     return _GetPath(ctx, ctx.attr.includes[0])
   return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])
   return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])
 
 
-def _CcOuts(srcs):
-  return [s[:-len(".proto")] +  ".pb.h" for s in srcs] + \
-         [s[:-len(".proto")] + ".pb.cc" for s in srcs]
+def _CcOuts(srcs, use_grpc_plugin=False):
+  ret = [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
+        [s[:-len(".proto")] + ".pb.cc" for s in srcs]
+  if use_grpc_plugin:
+    ret += [s[:-len(".proto")] + ".grpc.pb.h" for s in srcs] + \
+           [s[:-len(".proto")] + ".grpc.pb.cc" for s in srcs]
+  return ret
 
 
 def _PyOuts(srcs):
 def _PyOuts(srcs):
   return [s[:-len(".proto")] + "_pb2.py" for s in srcs]
   return [s[:-len(".proto")] + "_pb2.py" for s in srcs]
@@ -63,6 +67,10 @@ def _proto_gen_impl(ctx):
   if ctx.attr.gen_py:
   if ctx.attr.gen_py:
     args += ["--python_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
     args += ["--python_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
 
 
+  if ctx.executable.grpc_cpp_plugin:
+    args += ["--plugin=protoc-gen-grpc=" + ctx.executable.grpc_cpp_plugin.path]
+    args += ["--grpc_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
+
   if args:
   if args:
     ctx.action(
     ctx.action(
         inputs=srcs + deps,
         inputs=srcs + deps,
@@ -90,6 +98,11 @@ _proto_gen = rule(
             single_file = True,
             single_file = True,
             mandatory = True,
             mandatory = True,
         ),
         ),
+        "grpc_cpp_plugin": attr.label(
+            cfg = HOST_CFG,
+            executable = True,
+            single_file = True,
+        ),
         "gen_cc": attr.bool(),
         "gen_cc": attr.bool(),
         "gen_py": attr.bool(),
         "gen_py": attr.bool(),
         "outs": attr.output_list(),
         "outs": attr.output_list(),
@@ -104,9 +117,10 @@ def cc_proto_library(
         deps=[],
         deps=[],
         cc_libs=[],
         cc_libs=[],
         include=None,
         include=None,
-        protoc="//google/protobuf:protoc",
+        protoc="//:protoc",
         internal_bootstrap_hack=False,
         internal_bootstrap_hack=False,
-        default_runtime="//google/protobuf:protobuf",
+        use_grpc_plugin=False,
+        default_runtime="//:protobuf",
         **kargs):
         **kargs):
   """Bazel rule to create a C++ protobuf library from proto source files
   """Bazel rule to create a C++ protobuf library from proto source files
 
 
@@ -126,6 +140,8 @@ def cc_proto_library(
         for bootstraping. When it is set to True, no files will be generated.
         for bootstraping. When it is set to True, no files will be generated.
         The rule will simply be a provider for .proto files, so that other
         The rule will simply be a provider for .proto files, so that other
         cc_proto_library can depend on it.
         cc_proto_library can depend on it.
+    use_grpc_plugin: a flag to indicate whether to call the grpc C++ plugin
+        when processing the proto files.
     default_runtime: the implicitly default runtime which will be depended on by
     default_runtime: the implicitly default runtime which will be depended on by
         the generated cc_library target.
         the generated cc_library target.
     **kargs: other keyword arguments that are passed to cc_library.
     **kargs: other keyword arguments that are passed to cc_library.
@@ -153,13 +169,19 @@ def cc_proto_library(
         **kargs)
         **kargs)
     return
     return
 
 
-  outs = _CcOuts(srcs)
+  grpc_cpp_plugin = None
+  if use_grpc_plugin:
+    grpc_cpp_plugin = "//external:grpc_cpp_plugin"
+
+  outs = _CcOuts(srcs, use_grpc_plugin)
+
   _proto_gen(
   _proto_gen(
       name=name + "_genproto",
       name=name + "_genproto",
       srcs=srcs,
       srcs=srcs,
       deps=[s + "_genproto" for s in deps],
       deps=[s + "_genproto" for s in deps],
       includes=includes,
       includes=includes,
       protoc=protoc,
       protoc=protoc,
+      grpc_cpp_plugin=grpc_cpp_plugin,
       gen_cc=1,
       gen_cc=1,
       outs=outs,
       outs=outs,
       visibility=["//visibility:public"],
       visibility=["//visibility:public"],
@@ -167,6 +189,8 @@ def cc_proto_library(
 
 
   if default_runtime and not default_runtime in cc_libs:
   if default_runtime and not default_runtime in cc_libs:
     cc_libs += [default_runtime]
     cc_libs += [default_runtime]
+  if use_grpc_plugin:
+    cc_libs += ["//external:grpc_lib"]
 
 
   native.cc_library(
   native.cc_library(
       name=name,
       name=name,
@@ -175,37 +199,6 @@ def cc_proto_library(
       includes=includes,
       includes=includes,
       **kargs)
       **kargs)
 
 
-
-def internal_copied_filegroup(
-        name,
-        srcs,
-        include,
-        **kargs):
-  """Bazel rule to fix sources file to workaround with python path issues.
-
-  Args:
-    name: the name of the internal_copied_filegroup rule, which will be the
-        name of the generated filegroup.
-    srcs: the source files to be copied.
-    include: the expected import root of the source.
-    **kargs: extra arguments that will be passed into the filegroup.
-  """
-  outs = [_RelativeOutputPath(s, include) for s in srcs]
-
-  native.genrule(
-      name=name+"_genrule",
-      srcs=srcs,
-      outs=outs,
-      cmd=" && ".join(["cp $(location %s) $(location %s)" %
-                       (s, _RelativeOutputPath(s, include))
-                       for s in srcs]))
-
-  native.filegroup(
-      name=name,
-      srcs=outs,
-      **kargs)
-
-
 def py_proto_library(
 def py_proto_library(
         name,
         name,
         srcs=[],
         srcs=[],
@@ -213,8 +206,8 @@ def py_proto_library(
         py_libs=[],
         py_libs=[],
         py_extra_srcs=[],
         py_extra_srcs=[],
         include=None,
         include=None,
-        default_runtime="//google/protobuf:protobuf_python",
-        protoc="//google/protobuf:protoc",
+        default_runtime="//:protobuf_python",
+        protoc="//:protoc",
         **kargs):
         **kargs):
   """Bazel rule to create a Python protobuf library from proto source files
   """Bazel rule to create a Python protobuf library from proto source files
 
 
@@ -254,15 +247,6 @@ def py_proto_library(
       visibility=["//visibility:public"],
       visibility=["//visibility:public"],
   )
   )
 
 
-  if include != None:
-    # Copy the output files to the desired location to make the import work.
-    internal_copied_filegroup_name=name + "_internal_copied_filegroup"
-    internal_copied_filegroup(
-        name=internal_copied_filegroup_name,
-        srcs=outs,
-        include=include)
-    outs=[internal_copied_filegroup_name]
-
   if default_runtime and not default_runtime in py_libs + deps:
   if default_runtime and not default_runtime in py_libs + deps:
     py_libs += [default_runtime]
     py_libs += [default_runtime]
 
 
@@ -270,6 +254,7 @@ def py_proto_library(
       name=name,
       name=name,
       srcs=outs+py_extra_srcs,
       srcs=outs+py_extra_srcs,
       deps=py_libs+deps,
       deps=py_libs+deps,
+      imports=includes,
       **kargs)
       **kargs)
 
 
 def internal_protobuf_py_tests(
 def internal_protobuf_py_tests(
@@ -286,8 +271,7 @@ def internal_protobuf_py_tests(
 
 
   """
   """
   for m in modules:
   for m in modules:
-    s = _RelativeOutputPath(
-        "python/google/protobuf/internal/%s.py" % m, "python")
+    s = "python/google/protobuf/internal/%s.py" % m
     native.py_test(
     native.py_test(
         name="py_%s" % m,
         name="py_%s" % m,
         srcs=[s],
         srcs=[s],

+ 4 - 1
python/google/__init__.py

@@ -1 +1,4 @@
-__import__('pkg_resources').declare_namespace(__name__)
+try:
+  __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+  __path__ = __import__('pkgutil').extend_path(__path__, __name__)

+ 7 - 1
python/google/protobuf/__init__.py

@@ -30,4 +30,10 @@
 
 
 # Copyright 2007 Google Inc. All Rights Reserved.
 # Copyright 2007 Google Inc. All Rights Reserved.
 
 
-__version__ = '3.0.0b2'
+__version__ = '3.0.0b2.post2'
+
+if __name__ != '__main__':
+  try:
+    __import__('pkg_resources').declare_namespace(__name__)
+  except ImportError:
+    __path__ = __import__('pkgutil').extend_path(__path__, __name__)

+ 4 - 0
python/google/protobuf/pyext/__init__.py

@@ -0,0 +1,4 @@
+try:
+  __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+  __path__ = __import__('pkgutil').extend_path(__path__, __name__)

+ 44 - 1
ruby/Rakefile

@@ -34,6 +34,49 @@ else
   end
   end
 end
 end
 
 
+well_known_protos = %w[
+  google/protobuf/any.proto
+  google/protobuf/api.proto
+  google/protobuf/duration.proto
+  google/protobuf/empty.proto
+  google/protobuf/field_mask.proto
+  google/protobuf/source_context.proto
+  google/protobuf/struct.proto
+  google/protobuf/timestamp.proto
+  google/protobuf/type.proto
+  google/protobuf/wrappers.proto
+]
+
+# These are omitted for now because we don't support proto2.
+proto2_protos = %w[
+  google/protobuf/descriptor.proto
+  google/protobuf/compiler/plugin.proto
+]
+
+genproto_output = []
+
+well_known_protos.each do |proto_file|
+  input_file = "../src/" + proto_file
+  output_file = "lib/" + proto_file.sub(/\.proto$/, ".rb")
+  genproto_output << output_file
+  file output_file => input_file do |file_task|
+    sh "../src/protoc -I../src --ruby_out=lib #{input_file}"
+  end
+end
+
+
+# Proto for tests.
+genproto_output << "tests/generated_code.rb"
+file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task|
+  sh "../src/protoc --ruby_out=. tests/generated_code.proto"
+end
+
+task :genproto => genproto_output
+
+task :clean do
+  sh "rm -f #{genproto_output.join(' ')}"
+end
+
 Gem::PackageTask.new(spec) do |pkg|
 Gem::PackageTask.new(spec) do |pkg|
 end
 end
 
 
@@ -41,7 +84,7 @@ Rake::TestTask.new(:test => :build) do |t|
   t.test_files = FileList["tests/*.rb"]
   t.test_files = FileList["tests/*.rb"]
 end
 end
 
 
-task :build => [:clean, :compile]
+task :build => [:clean, :compile, :genproto]
 task :default => [:build]
 task :default => [:build]
 
 
 # vim:sw=2:et
 # vim:sw=2:et

+ 5 - 0
ruby/ext/google/protobuf_c/defs.c

@@ -243,6 +243,10 @@ void Descriptor_free(void* _self) {
   if (self->fill_method) {
   if (self->fill_method) {
     upb_pbdecodermethod_unref(self->fill_method, &self->fill_method);
     upb_pbdecodermethod_unref(self->fill_method, &self->fill_method);
   }
   }
+  if (self->json_fill_method) {
+    upb_json_parsermethod_unref(self->json_fill_method,
+                                &self->json_fill_method);
+  }
   if (self->pb_serialize_handlers) {
   if (self->pb_serialize_handlers) {
     upb_handlers_unref(self->pb_serialize_handlers,
     upb_handlers_unref(self->pb_serialize_handlers,
                        &self->pb_serialize_handlers);
                        &self->pb_serialize_handlers);
@@ -271,6 +275,7 @@ VALUE Descriptor_alloc(VALUE klass) {
   self->layout = NULL;
   self->layout = NULL;
   self->fill_handlers = NULL;
   self->fill_handlers = NULL;
   self->fill_method = NULL;
   self->fill_method = NULL;
+  self->json_fill_method = NULL;
   self->pb_serialize_handlers = NULL;
   self->pb_serialize_handlers = NULL;
   self->json_serialize_handlers = NULL;
   self->json_serialize_handlers = NULL;
   self->typeclass_references = rb_ary_new();
   self->typeclass_references = rb_ary_new();

+ 15 - 4
ruby/ext/google/protobuf_c/encode_decode.c

@@ -640,6 +640,14 @@ static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) {
   return desc->fill_method;
   return desc->fill_method;
 }
 }
 
 
+static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) {
+  if (desc->json_fill_method == NULL) {
+    desc->json_fill_method =
+        upb_json_parsermethod_new(desc->msgdef, &desc->json_fill_method);
+  }
+  return desc->json_fill_method;
+}
+
 
 
 // Stack-allocated context during an encode/decode operation. Contains the upb
 // Stack-allocated context during an encode/decode operation. Contains the upb
 // environment and its stack-based allocator, an initial buffer for allocations
 // environment and its stack-based allocator, an initial buffer for allocations
@@ -752,13 +760,14 @@ VALUE Message_decode_json(VALUE klass, VALUE data) {
   TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
   TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
 
 
   {
   {
+    const upb_json_parsermethod* method = msgdef_jsonparsermethod(desc);
     stackenv se;
     stackenv se;
     upb_sink sink;
     upb_sink sink;
     upb_json_parser* parser;
     upb_json_parser* parser;
     stackenv_init(&se, "Error occurred during parsing: %s");
     stackenv_init(&se, "Error occurred during parsing: %s");
 
 
     upb_sink_reset(&sink, get_fill_handlers(desc), msg);
     upb_sink_reset(&sink, get_fill_handlers(desc), msg);
-    parser = upb_json_parser_create(&se.env, &sink);
+    parser = upb_json_parser_create(&se.env, method, &sink);
     upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data),
     upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data),
                       upb_json_parser_input(parser));
                       upb_json_parser_input(parser));
 
 
@@ -1041,6 +1050,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
        !upb_msg_field_done(&i);
        !upb_msg_field_done(&i);
        upb_msg_field_next(&i)) {
        upb_msg_field_next(&i)) {
     upb_fielddef *f = upb_msg_iter_field(&i);
     upb_fielddef *f = upb_msg_iter_field(&i);
+    bool is_matching_oneof = false;
     uint32_t offset =
     uint32_t offset =
         desc->layout->fields[upb_fielddef_index(f)].offset +
         desc->layout->fields[upb_fielddef_index(f)].offset +
         sizeof(MessageHeader);
         sizeof(MessageHeader);
@@ -1057,6 +1067,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
       }
       }
       // Otherwise, fall through to the appropriate singular-field handler
       // Otherwise, fall through to the appropriate singular-field handler
       // below.
       // below.
+      is_matching_oneof = true;
     }
     }
 
 
     if (is_map_field(f)) {
     if (is_map_field(f)) {
@@ -1071,7 +1082,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
       }
       }
     } else if (upb_fielddef_isstring(f)) {
     } else if (upb_fielddef_isstring(f)) {
       VALUE str = DEREF(msg, offset, VALUE);
       VALUE str = DEREF(msg, offset, VALUE);
-      if (RSTRING_LEN(str) > 0) {
+      if (is_matching_oneof || RSTRING_LEN(str) > 0) {
         putstr(str, f, sink);
         putstr(str, f, sink);
       }
       }
     } else if (upb_fielddef_issubmsg(f)) {
     } else if (upb_fielddef_issubmsg(f)) {
@@ -1082,7 +1093,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
 #define T(upbtypeconst, upbtype, ctype, default_value)                \
 #define T(upbtypeconst, upbtype, ctype, default_value)                \
   case upbtypeconst: {                                                \
   case upbtypeconst: {                                                \
       ctype value = DEREF(msg, offset, ctype);                        \
       ctype value = DEREF(msg, offset, ctype);                        \
-      if (value != default_value) {                                   \
+      if (is_matching_oneof || value != default_value) {              \
         upb_sink_put##upbtype(sink, sel, value);                      \
         upb_sink_put##upbtype(sink, sel, value);                      \
       }                                                               \
       }                                                               \
     }                                                                 \
     }                                                                 \
@@ -1189,7 +1200,7 @@ VALUE Message_encode_json(VALUE klass, VALUE msg_rb) {
 
 
     putmsg(msg_rb, desc, upb_json_printer_input(printer), 0);
     putmsg(msg_rb, desc, upb_json_printer_input(printer), 0);
 
 
-    ret = rb_str_new(sink.ptr, sink.len);
+    ret = rb_enc_str_new(sink.ptr, sink.len, rb_utf8_encoding());
 
 
     stackenv_uninit(&se);
     stackenv_uninit(&se);
     stringsink_uninit(&sink);
     stringsink_uninit(&sink);

+ 1 - 0
ruby/ext/google/protobuf_c/protobuf.h

@@ -112,6 +112,7 @@ struct Descriptor {
   VALUE klass;  // begins as nil
   VALUE klass;  // begins as nil
   const upb_handlers* fill_handlers;
   const upb_handlers* fill_handlers;
   const upb_pbdecodermethod* fill_method;
   const upb_pbdecodermethod* fill_method;
+  const upb_json_parsermethod* json_fill_method;
   const upb_handlers* pb_serialize_handlers;
   const upb_handlers* pb_serialize_handlers;
   const upb_handlers* json_serialize_handlers;
   const upb_handlers* json_serialize_handlers;
   // Handlers hold type class references for sub-message fields directly in some
   // Handlers hold type class references for sub-message fields directly in some

File diff suppressed because it is too large
+ 479 - 407
ruby/ext/google/protobuf_c/upb.c


+ 307 - 40
ruby/ext/google/protobuf_c/upb.h

@@ -193,13 +193,15 @@
   template <>                                                     \
   template <>                                                     \
   class Pointer<cppname> : public PointerBase<cppname, cppbase> { \
   class Pointer<cppname> : public PointerBase<cppname, cppbase> { \
    public:                                                        \
    public:                                                        \
-    explicit Pointer(cppname* ptr) : PointerBase(ptr) {}          \
+    explicit Pointer(cppname* ptr)                                \
+        : PointerBase<cppname, cppbase>(ptr) {}                   \
   };                                                              \
   };                                                              \
   template <>                                                     \
   template <>                                                     \
   class Pointer<const cppname>                                    \
   class Pointer<const cppname>                                    \
       : public PointerBase<const cppname, const cppbase> {        \
       : public PointerBase<const cppname, const cppbase> {        \
    public:                                                        \
    public:                                                        \
-    explicit Pointer(const cppname* ptr) : PointerBase(ptr) {}    \
+    explicit Pointer(const cppname* ptr)                          \
+        : PointerBase<const cppname, const cppbase>(ptr) {}       \
   };                                                              \
   };                                                              \
   }
   }
 
 
@@ -211,13 +213,15 @@
   template <>                                                                \
   template <>                                                                \
   class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \
   class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \
    public:                                                                   \
    public:                                                                   \
-    explicit Pointer(cppname* ptr) : PointerBase2(ptr) {}                    \
+    explicit Pointer(cppname* ptr)                                           \
+        : PointerBase2<cppname, cppbase, cppbase2>(ptr) {}                   \
   };                                                                         \
   };                                                                         \
   template <>                                                                \
   template <>                                                                \
   class Pointer<const cppname>                                               \
   class Pointer<const cppname>                                               \
       : public PointerBase2<const cppname, const cppbase, const cppbase2> {  \
       : public PointerBase2<const cppname, const cppbase, const cppbase2> {  \
    public:                                                                   \
    public:                                                                   \
-    explicit Pointer(const cppname* ptr) : PointerBase2(ptr) {}              \
+    explicit Pointer(const cppname* ptr)                                     \
+        : PointerBase2<const cppname, const cppbase, const cppbase2>(ptr) {} \
   };                                                                         \
   };                                                                         \
   }
   }
 
 
@@ -1537,6 +1541,27 @@ class upb::FieldDef {
   uint32_t number() const;   /* Returns 0 if uninitialized. */
   uint32_t number() const;   /* Returns 0 if uninitialized. */
   bool is_extension() const;
   bool is_extension() const;
 
 
+  /* Copies the JSON name for this field into the given buffer.  Returns the
+   * actual size of the JSON name, including the NULL terminator.  If the
+   * return value is 0, the JSON name is unset.  If the return value is
+   * greater than len, the JSON name was truncated.  The buffer is always
+   * NULL-terminated if len > 0.
+   *
+   * The JSON name always defaults to a camelCased version of the regular
+   * name.  However if the regular name is unset, the JSON name will be unset
+   * also.
+   */
+  size_t GetJsonName(char* buf, size_t len) const;
+
+  /* Convenience version of the above function which copies the JSON name
+   * into the given string, returning false if the name is not set. */
+  template <class T>
+  bool GetJsonName(T* str) {
+    str->resize(GetJsonName(NULL, 0));
+    GetJsonName(&(*str)[0], str->size());
+    return str->size() > 0;
+  }
+
   /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
   /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
    * indicates whether this field should have lazy parsing handlers that yield
    * indicates whether this field should have lazy parsing handlers that yield
    * the unparsed string for the submessage.
    * the unparsed string for the submessage.
@@ -1589,6 +1614,18 @@ class upb::FieldDef {
   bool IsPrimitive() const;
   bool IsPrimitive() const;
   bool IsMap() const;
   bool IsMap() const;
 
 
+  /* Whether this field must be able to explicitly represent presence:
+   *
+   * * This is always false for repeated fields (an empty repeated field is
+   *   equivalent to a repeated field with zero entries).
+   *
+   * * This is always true for submessages.
+   *
+   * * For other fields, it depends on the message (see
+   *   MessageDef::SetPrimitivesHavePresence())
+   */
+  bool HasPresence() const;
+
   /* How integers are encoded.  Only meaningful for integer types.
   /* How integers are encoded.  Only meaningful for integer types.
    * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */
    * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */
   IntegerFormat integer_format() const;
   IntegerFormat integer_format() const;
@@ -1690,6 +1727,16 @@ class upb::FieldDef {
   bool set_name(const char* name, upb::Status* s);
   bool set_name(const char* name, upb::Status* s);
   bool set_name(const std::string& name, upb::Status* s);
   bool set_name(const std::string& name, upb::Status* s);
 
 
+  /* Sets the JSON name to the given string. */
+  /* TODO(haberman): implement.  Right now only default json_name (camelCase)
+   * is supported. */
+  bool set_json_name(const char* json_name, upb::Status* s);
+  bool set_json_name(const std::string& name, upb::Status* s);
+
+  /* Clears the JSON name. This will make it revert to its default, which is
+   * a camelCased version of the regular field name. */
+  void clear_json_name();
+
   void set_integer_format(IntegerFormat format);
   void set_integer_format(IntegerFormat format);
   bool set_tag_delimited(bool tag_delimited, upb::Status* s);
   bool set_tag_delimited(bool tag_delimited, upb::Status* s);
 
 
@@ -1754,6 +1801,7 @@ const char *upb_fielddef_name(const upb_fielddef *f);
 bool upb_fielddef_isextension(const upb_fielddef *f);
 bool upb_fielddef_isextension(const upb_fielddef *f);
 bool upb_fielddef_lazy(const upb_fielddef *f);
 bool upb_fielddef_lazy(const upb_fielddef *f);
 bool upb_fielddef_packed(const upb_fielddef *f);
 bool upb_fielddef_packed(const upb_fielddef *f);
+size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len);
 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
@@ -1766,6 +1814,7 @@ bool upb_fielddef_isstring(const upb_fielddef *f);
 bool upb_fielddef_isseq(const upb_fielddef *f);
 bool upb_fielddef_isseq(const upb_fielddef *f);
 bool upb_fielddef_isprimitive(const upb_fielddef *f);
 bool upb_fielddef_isprimitive(const upb_fielddef *f);
 bool upb_fielddef_ismap(const upb_fielddef *f);
 bool upb_fielddef_ismap(const upb_fielddef *f);
+bool upb_fielddef_haspresence(const upb_fielddef *f);
 int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
 int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
 int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
 int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
@@ -1787,6 +1836,8 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type);
 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label);
 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label);
 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s);
 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s);
 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s);
 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s);
+bool upb_fielddef_setjsonname(upb_fielddef *f, const char *name, upb_status *s);
+bool upb_fielddef_clearjsonname(upb_fielddef *f);
 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
                                         upb_status *s);
                                         upb_status *s);
 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension);
 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension);
@@ -1884,6 +1935,11 @@ class upb::MessageDef {
   bool AddOneof(OneofDef* o, Status* s);
   bool AddOneof(OneofDef* o, Status* s);
   bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
   bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
 
 
+  /* Set this to false to indicate that primitive fields should not have
+   * explicit presence information associated with them.  This will affect all
+   * fields added to this message.  Defaults to true. */
+  void SetPrimitivesHavePresence(bool have_presence);
+
   /* These return NULL if the field is not found. */
   /* These return NULL if the field is not found. */
   FieldDef* FindFieldByNumber(uint32_t number);
   FieldDef* FindFieldByNumber(uint32_t number);
   FieldDef* FindFieldByName(const char *name, size_t len);
   FieldDef* FindFieldByName(const char *name, size_t len);
@@ -2077,6 +2133,7 @@ bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
                          upb_status *s);
                          upb_status *s);
 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
                          upb_status *s);
                          upb_status *s);
+void upb_msgdef_setprimitiveshavepresence(upb_msgdef *m, bool have_presence);
 
 
 /* Field lookup in a couple of different variations:
 /* Field lookup in a couple of different variations:
  *   - itof = int to field
  *   - itof = int to field
@@ -2527,6 +2584,9 @@ inline const char* FieldDef::name() const { return upb_fielddef_name(this); }
 inline bool FieldDef::is_extension() const {
 inline bool FieldDef::is_extension() const {
   return upb_fielddef_isextension(this);
   return upb_fielddef_isextension(this);
 }
 }
+inline size_t FieldDef::GetJsonName(char* buf, size_t len) const {
+  return upb_fielddef_getjsonname(this, buf, len);
+}
 inline bool FieldDef::lazy() const {
 inline bool FieldDef::lazy() const {
   return upb_fielddef_lazy(this);
   return upb_fielddef_lazy(this);
 }
 }
@@ -2557,6 +2617,15 @@ inline bool FieldDef::set_name(const char *name, Status* s) {
 inline bool FieldDef::set_name(const std::string& name, Status* s) {
 inline bool FieldDef::set_name(const std::string& name, Status* s) {
   return upb_fielddef_setname(this, upb_safecstr(name), s);
   return upb_fielddef_setname(this, upb_safecstr(name), s);
 }
 }
+inline bool FieldDef::set_json_name(const char *name, Status* s) {
+  return upb_fielddef_setjsonname(this, name, s);
+}
+inline bool FieldDef::set_json_name(const std::string& name, Status* s) {
+  return upb_fielddef_setjsonname(this, upb_safecstr(name), s);
+}
+inline void FieldDef::clear_json_name() {
+  upb_fielddef_clearjsonname(this);
+}
 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) {
 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) {
   return upb_fielddef_setcontainingtypename(this, name, s);
   return upb_fielddef_setcontainingtypename(this, name, s);
 }
 }
@@ -3107,6 +3176,11 @@ struct upb_msgdef {
    * descriptor.upb.c. */
    * descriptor.upb.c. */
   bool map_entry;
   bool map_entry;
 
 
+  /* Do primitive values in this message have explicit presence or not?
+   * TODO: set this flag properly for static descriptors; regenerate
+   * descriptor.upb.c. */
+  bool primitives_have_presence;
+
   /* TODO(haberman): proper extension ranges (there can be multiple). */
   /* TODO(haberman): proper extension ranges (there can be multiple). */
 };
 };
 
 
@@ -3117,7 +3191,7 @@ struct upb_msgdef {
   {                                                                           \
   {                                                                           \
     UPB_DEF_INIT(name, UPB_DEF_MSG, refs, ref2s), selector_count,             \
     UPB_DEF_INIT(name, UPB_DEF_MSG, refs, ref2s), selector_count,             \
         submsg_field_count, itof, ntof,                                       \
         submsg_field_count, itof, ntof,                                       \
-        UPB_EMPTY_STRTABLE_INIT(UPB_CTYPE_PTR), false                         \
+        UPB_EMPTY_STRTABLE_INIT(UPB_CTYPE_PTR), false, true                   \
   }
   }
 
 
 
 
@@ -6278,6 +6352,12 @@ typedef enum {
   GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2
   GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2
 } google_protobuf_FieldOptions_CType;
 } google_protobuf_FieldOptions_CType;
 
 
+typedef enum {
+  GOOGLE_PROTOBUF_FIELDOPTIONS_JS_NORMAL = 0,
+  GOOGLE_PROTOBUF_FIELDOPTIONS_JS_STRING = 1,
+  GOOGLE_PROTOBUF_FIELDOPTIONS_JS_NUMBER = 2
+} google_protobuf_FieldOptions_JSType;
+
 typedef enum {
 typedef enum {
   GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1,
   GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1,
   GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2,
   GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2,
@@ -6293,30 +6373,47 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 8
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 9
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 10
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 11
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 12
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 13
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 14
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 15
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 16
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 17
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 18
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 19
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 20
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 21
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 22
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 23
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 24
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 25
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 26
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_STARTSUBMSG 8
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_STARTSUBMSG 9
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 10
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 11
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 12
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 13
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 14
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 15
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 16
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 17
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 18
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 19
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 20
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 21
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 22
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 23
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 24
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 25
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_STARTSEQ 26
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_ENDSEQ 27
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_ENDSUBMSG 28
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_STARTSEQ 29
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_ENDSEQ 30
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_ENDSUBMSG 31
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 32
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 33
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 34
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STARTSEQ 35
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_ENDSEQ 36
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STRING 37
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STARTSTR 38
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_ENDSTR 39
 
 
 /* google.protobuf.DescriptorProto.ExtensionRange */
 /* google.protobuf.DescriptorProto.ExtensionRange */
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3
 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3
 
 
+/* google.protobuf.DescriptorProto.ReservedRange */
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVEDRANGE_START_INT32 2
+#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVEDRANGE_END_INT32 3
+
 /* google.protobuf.EnumDescriptorProto */
 /* google.protobuf.EnumDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
@@ -6334,6 +6431,7 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6
 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6
+#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_DEPRECATED_BOOL 7
 
 
 /* google.protobuf.EnumValueDescriptorProto */
 /* google.protobuf.EnumValueDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
@@ -6348,6 +6446,7 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
+#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_DEPRECATED_BOOL 6
 
 
 /* google.protobuf.FieldDescriptorProto */
 /* google.protobuf.FieldDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
@@ -6367,6 +6466,10 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18
 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18
+#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_ONEOF_INDEX_INT32 19
+#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_STRING 20
+#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_STARTSTR 21
+#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_ENDSTR 22
 
 
 /* google.protobuf.FieldOptions */
 /* google.protobuf.FieldOptions */
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
@@ -6377,10 +6480,8 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9
 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 10
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 11
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 12
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 13
+#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_JSTYPE_INT32 10
+#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 11
 
 
 /* google.protobuf.FileDescriptorProto */
 /* google.protobuf.FileDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2
@@ -6420,6 +6521,9 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38
+#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_STRING 39
+#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_STARTSTR 40
+#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_ENDSTR 41
 
 
 /* google.protobuf.FileDescriptorSet */
 /* google.protobuf.FileDescriptorSet */
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2
@@ -6447,6 +6551,16 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20
 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_DEPRECATED_BOOL 21
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_STRING_CHECK_UTF8_BOOL 22
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_ENABLE_ARENAS_BOOL 23
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_STRING 24
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_STARTSTR 25
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_ENDSTR 26
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_STRING 27
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_STARTSTR 28
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_ENDSTR 29
+#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVANANO_USE_DEPRECATED_PACKAGE_BOOL 30
 
 
 /* google.protobuf.MessageOptions */
 /* google.protobuf.MessageOptions */
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
@@ -6455,6 +6569,8 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 7
 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 7
+#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_DEPRECATED_BOOL 8
+#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MAP_ENTRY_BOOL 9
 
 
 /* google.protobuf.MethodDescriptorProto */
 /* google.protobuf.MethodDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
@@ -6468,12 +6584,20 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12
 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12
+#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_CLIENT_STREAMING_BOOL 13
+#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_SERVER_STREAMING_BOOL 14
 
 
 /* google.protobuf.MethodOptions */
 /* google.protobuf.MethodOptions */
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
+#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_DEPRECATED_BOOL 6
+
+/* google.protobuf.OneofDescriptorProto */
+#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_STRING 2
+#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_STARTSTR 3
+#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_ENDSTR 4
 
 
 /* google.protobuf.ServiceDescriptorProto */
 /* google.protobuf.ServiceDescriptorProto */
 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2
@@ -6491,6 +6615,7 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
+#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_DEPRECATED_BOOL 6
 
 
 /* google.protobuf.SourceCodeInfo */
 /* google.protobuf.SourceCodeInfo */
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2
@@ -6511,6 +6636,11 @@ typedef enum {
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STRING 11
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STRING 11
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STARTSTR 12
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STARTSTR 12
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_ENDSTR 13
 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_ENDSTR 13
+#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STARTSEQ 14
+#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_ENDSEQ 15
+#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STRING 16
+#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STARTSTR 17
+#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_ENDSTR 18
 
 
 /* google.protobuf.UninterpretedOption */
 /* google.protobuf.UninterpretedOption */
 #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 2
 #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 2
@@ -6549,6 +6679,11 @@ UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRa
   assert(m);
   assert(m);
   return m;
   return m;
 }
 }
+UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange(const upb_symtab *s) {
+  const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ReservedRange");
+  assert(m);
+  return m;
+}
 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto(const upb_symtab *s) {
 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto(const upb_symtab *s) {
   const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto");
   const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto");
   assert(m);
   assert(m);
@@ -6609,6 +6744,11 @@ UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodOptions(const upb_sym
   assert(m);
   assert(m);
   return m;
   return m;
 }
 }
+UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto(const upb_symtab *s) {
+  const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.OneofDescriptorProto");
+  assert(m);
+  return m;
+}
 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto(const upb_symtab *s) {
 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto(const upb_symtab *s) {
   const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto");
   const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto");
   assert(m);
   assert(m);
@@ -6657,6 +6797,11 @@ UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType(const u
   assert(e);
   assert(e);
   return e;
   return e;
 }
 }
+UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType(const upb_symtab *s) {
+  const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldOptions.JSType");
+  assert(e);
+  return e;
+}
 UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode(const upb_symtab *s) {
 UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode(const upb_symtab *s) {
   const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FileOptions.OptimizeMode");
   const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FileOptions.OptimizeMode");
   assert(e);
   assert(e);
@@ -6665,33 +6810,42 @@ UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode(c
 
 
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ReservedRange(s), 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ReservedRange(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_field(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_field(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_nested_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_nested_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_oneof_decl(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 8); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 7); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_reserved_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_reserved_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 9); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_allow_alias(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_allow_alias(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_default_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 7); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_default_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 7); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_extendee(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_extendee(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_json_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 10); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_label(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_label(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_oneof_index(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 9); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 8); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 8); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_ctype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_ctype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_experimental_map_key(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_jstype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_lazy(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_lazy(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_packed(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_packed(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 999); }
@@ -6706,31 +6860,46 @@ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_packa
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_public_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 10); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_public_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 10); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_service(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_service(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_source_code_info(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 9); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_source_code_info(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_syntax(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 12); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_weak_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 11); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_weak_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 11); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_file(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorSet(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_file(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorSet(s), 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_enable_arenas(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 31); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 16); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 16); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_csharp_namespace(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 37); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 23); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_go_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 11); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_go_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 11); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 20); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 20); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 17); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 17); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_multiple_files(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 10); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_multiple_files(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 10); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_outer_classname(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 8); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_outer_classname(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 8); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_string_check_utf8(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 27); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_javanano_use_deprecated_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 38); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_objc_class_prefix(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 36); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_optimize_for(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 9); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_optimize_for(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 9); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_py_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 18); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_py_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 18); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_map_entry(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 7); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_message_set_wire_format(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_message_set_wire_format(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_client_streaming(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 5); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_input_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_input_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_output_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_output_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_server_streaming(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 33); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_OneofDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_method(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_method(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 33); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 999); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 3); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 6); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_path(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_path(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 1); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_span(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_span(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 2); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 4); }
 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 4); }
@@ -6775,7 +6944,10 @@ inline upb::reffed_ptr<const upb::FieldDef> extension_range() { RETURN_REFFED(up
 inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_field) }
 inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_field) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) }
 inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) }
+inline upb::reffed_ptr<const upb::FieldDef> oneof_decl() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_oneof_decl) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_options) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_options) }
+inline upb::reffed_ptr<const upb::FieldDef> reserved_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_reserved_name) }
+inline upb::reffed_ptr<const upb::FieldDef> reserved_range() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_reserved_range) }
 }  /* namespace DescriptorProto */
 }  /* namespace DescriptorProto */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
 }  /* namespace google */
 }  /* namespace google */
@@ -6792,6 +6964,18 @@ inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDe
 }  /* namespace protobuf */
 }  /* namespace protobuf */
 }  /* namespace google */
 }  /* namespace google */
 
 
+namespace google {
+namespace protobuf {
+namespace DescriptorProto {
+namespace ReservedRange {
+inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange) }
+inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange_end) }
+inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange_start) }
+}  /* namespace ReservedRange */
+}  /* namespace DescriptorProto */
+}  /* namespace protobuf */
+}  /* namespace google */
+
 namespace google {
 namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace EnumDescriptorProto {
 namespace EnumDescriptorProto {
@@ -6808,6 +6992,7 @@ namespace protobuf {
 namespace EnumOptions {
 namespace EnumOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumOptions) }
 inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) }
 inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) }
 }  /* namespace EnumOptions */
 }  /* namespace EnumOptions */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
@@ -6828,6 +7013,7 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace EnumValueOptions {
 namespace EnumValueOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueOptions) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option) }
 }  /* namespace EnumValueOptions */
 }  /* namespace EnumValueOptions */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
@@ -6839,9 +7025,11 @@ namespace FieldDescriptorProto {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) }
 inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) }
 inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) }
 inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) }
 inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) }
+inline upb::reffed_ptr<const upb::FieldDef> json_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_json_name) }
 inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_label) }
 inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_label) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_number) }
 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_number) }
+inline upb::reffed_ptr<const upb::FieldDef> oneof_index() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_oneof_index) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_options) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_options) }
 inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type) }
 inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type) }
 inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) }
 inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) }
@@ -6857,12 +7045,13 @@ namespace FieldOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldOptions) }
 inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_ctype) }
 inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_ctype) }
 inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> experimental_map_key() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_experimental_map_key) }
+inline upb::reffed_ptr<const upb::FieldDef> jstype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_jstype) }
 inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_lazy) }
 inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_lazy) }
 inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_packed) }
 inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_packed) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_weak) }
 inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_weak) }
 inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_CType) }
 inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_CType) }
+inline upb::reffed_ptr<const upb::EnumDef> JSType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_JSType) }
 }  /* namespace FieldOptions */
 }  /* namespace FieldOptions */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
 }  /* namespace google */
 }  /* namespace google */
@@ -6881,6 +7070,7 @@ inline upb::reffed_ptr<const upb::FieldDef> package() { RETURN_REFFED(upb::Field
 inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) }
 inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) }
 inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_service) }
 inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_service) }
 inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) }
 inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) }
+inline upb::reffed_ptr<const upb::FieldDef> syntax() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_syntax) }
 inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) }
 inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) }
 }  /* namespace FileDescriptorProto */
 }  /* namespace FileDescriptorProto */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
@@ -6899,13 +7089,19 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace FileOptions {
 namespace FileOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileOptions) }
+inline upb::reffed_ptr<const upb::FieldDef> cc_enable_arenas() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_enable_arenas) }
 inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) }
 inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) }
+inline upb::reffed_ptr<const upb::FieldDef> csharp_namespace() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_csharp_namespace) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_go_package) }
 inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_go_package) }
 inline upb::reffed_ptr<const upb::FieldDef> java_generate_equals_and_hash() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash) }
 inline upb::reffed_ptr<const upb::FieldDef> java_generate_equals_and_hash() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash) }
 inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) }
 inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) }
 inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) }
 inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) }
 inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) }
 inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) }
 inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_package) }
 inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_package) }
+inline upb::reffed_ptr<const upb::FieldDef> java_string_check_utf8() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_string_check_utf8) }
+inline upb::reffed_ptr<const upb::FieldDef> javanano_use_deprecated_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_javanano_use_deprecated_package) }
+inline upb::reffed_ptr<const upb::FieldDef> objc_class_prefix() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_objc_class_prefix) }
 inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) }
 inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) }
 inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) }
 inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) }
@@ -6918,6 +7114,8 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace MessageOptions {
 namespace MessageOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MessageOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MessageOptions) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_deprecated) }
+inline upb::reffed_ptr<const upb::FieldDef> map_entry() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_map_entry) }
 inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_format) }
 inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_format) }
 inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor) }
 inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) }
@@ -6929,10 +7127,12 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace MethodDescriptorProto {
 namespace MethodDescriptorProto {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) }
+inline upb::reffed_ptr<const upb::FieldDef> client_streaming() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_client_streaming) }
 inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) }
 inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_name) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_options) }
 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_options) }
 inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) }
 inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) }
+inline upb::reffed_ptr<const upb::FieldDef> server_streaming() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_server_streaming) }
 }  /* namespace MethodDescriptorProto */
 }  /* namespace MethodDescriptorProto */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
 }  /* namespace google */
 }  /* namespace google */
@@ -6941,11 +7141,21 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace MethodOptions {
 namespace MethodOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodOptions) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) }
 }  /* namespace MethodOptions */
 }  /* namespace MethodOptions */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
 }  /* namespace google */
 }  /* namespace google */
 
 
+namespace google {
+namespace protobuf {
+namespace OneofDescriptorProto {
+inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_OneofDescriptorProto) }
+inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_OneofDescriptorProto_name) }
+}  /* namespace OneofDescriptorProto */
+}  /* namespace protobuf */
+}  /* namespace google */
+
 namespace google {
 namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace ServiceDescriptorProto {
 namespace ServiceDescriptorProto {
@@ -6961,6 +7171,7 @@ namespace google {
 namespace protobuf {
 namespace protobuf {
 namespace ServiceOptions {
 namespace ServiceOptions {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceOptions) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceOptions) }
+inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_deprecated) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) }
 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) }
 }  /* namespace ServiceOptions */
 }  /* namespace ServiceOptions */
 }  /* namespace protobuf */
 }  /* namespace protobuf */
@@ -6981,6 +7192,7 @@ namespace SourceCodeInfo {
 namespace Location {
 namespace Location {
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) }
 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) }
 inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments) }
 inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments) }
+inline upb::reffed_ptr<const upb::FieldDef> leading_detached_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_detached_comments) }
 inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_path) }
 inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_path) }
 inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_span) }
 inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_span) }
 inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments) }
 inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments) }
@@ -7067,6 +7279,13 @@ UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts)
 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted,
 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted,
                          upb_pbdecodermethod, upb_refcounted)
                          upb_pbdecodermethod, upb_refcounted)
 
 
+/* The maximum number of bytes we are required to buffer internally between
+ * calls to the decoder.  The value is 14: a 5 byte unknown tag plus ten-byte
+ * varint, less one because we are buffering an incomplete value.
+ *
+ * Should only be used by unit tests. */
+#define UPB_DECODER_MAX_RESIDUAL_BYTES 14
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 
 
 /* The parameters one uses to construct a DecoderMethod.
 /* The parameters one uses to construct a DecoderMethod.
@@ -7541,11 +7760,8 @@ struct upb_pbdecoder {
   /* Overall stream offset of "buf." */
   /* Overall stream offset of "buf." */
   uint64_t bufstart_ofs;
   uint64_t bufstart_ofs;
 
 
-  /* Buffer for residual bytes not parsed from the previous buffer.
-   * The maximum number of residual bytes we require is 12; a five-byte
-   * unknown tag plus an eight-byte value, less one because the value
-   * is only a partial value. */
-  char residual[12];
+  /* Buffer for residual bytes not parsed from the previous buffer. */
+  char residual[UPB_DECODER_MAX_RESIDUAL_BYTES];
   char *residual_end;
   char *residual_end;
 
 
   /* Bytes of data that should be discarded from the input beore we start
   /* Bytes of data that should be discarded from the input beore we start
@@ -8083,11 +8299,14 @@ inline reffed_ptr<const Handlers> TextPrinter::NewHandlers(
 namespace upb {
 namespace upb {
 namespace json {
 namespace json {
 class Parser;
 class Parser;
+class ParserMethod;
 }  /* namespace json */
 }  /* namespace json */
 }  /* namespace upb */
 }  /* namespace upb */
 #endif
 #endif
 
 
 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
+UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted,
+                         upb_json_parsermethod, upb_refcounted)
 
 
 /* upb::json::Parser **********************************************************/
 /* upb::json::Parser **********************************************************/
 
 
@@ -8095,7 +8314,7 @@ UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
  * constructed.  This hint may be an overestimate for some build configurations.
  * constructed.  This hint may be an overestimate for some build configurations.
  * But if the parser library is upgraded without recompiling the application,
  * But if the parser library is upgraded without recompiling the application,
  * it may be an underestimate. */
  * it may be an underestimate. */
-#define UPB_JSON_PARSER_SIZE 3704
+#define UPB_JSON_PARSER_SIZE 4104
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 
 
@@ -8103,7 +8322,8 @@ UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
  * sink. */
  * sink. */
 class upb::json::Parser {
 class upb::json::Parser {
  public:
  public:
-  static Parser* Create(Environment* env, Sink* output);
+  static Parser* Create(Environment* env, const ParserMethod* method,
+                        Sink* output);
 
 
   BytesSink* input();
   BytesSink* input();
 
 
@@ -8111,25 +8331,72 @@ class upb::json::Parser {
   UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser)
   UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser)
 };
 };
 
 
+class upb::json::ParserMethod {
+ public:
+  /* Include base methods from upb::ReferenceCounted. */
+  UPB_REFCOUNTED_CPPMETHODS
+
+  /* Returns handlers for parsing according to the specified schema. */
+  static reffed_ptr<const ParserMethod> New(const upb::MessageDef* md);
+
+  /* The destination handlers that are statically bound to this method.
+   * This method is only capable of outputting to a sink that uses these
+   * handlers. */
+  const Handlers* dest_handlers() const;
+
+  /* The input handlers for this decoder method. */
+  const BytesHandler* input_handler() const;
+
+ private:
+  UPB_DISALLOW_POD_OPS(ParserMethod, upb::json::ParserMethod)
+};
+
 #endif
 #endif
 
 
 UPB_BEGIN_EXTERN_C
 UPB_BEGIN_EXTERN_C
 
 
-upb_json_parser *upb_json_parser_create(upb_env *e, upb_sink *output);
+upb_json_parser* upb_json_parser_create(upb_env* e,
+                                        const upb_json_parsermethod* m,
+                                        upb_sink* output);
 upb_bytessink *upb_json_parser_input(upb_json_parser *p);
 upb_bytessink *upb_json_parser_input(upb_json_parser *p);
 
 
+upb_json_parsermethod* upb_json_parsermethod_new(const upb_msgdef* md,
+                                                 const void* owner);
+const upb_handlers *upb_json_parsermethod_desthandlers(
+    const upb_json_parsermethod *m);
+const upb_byteshandler *upb_json_parsermethod_inputhandler(
+    const upb_json_parsermethod *m);
+
+/* Include refcounted methods like upb_json_parsermethod_ref(). */
+UPB_REFCOUNTED_CMETHODS(upb_json_parsermethod, upb_json_parsermethod_upcast)
+
 UPB_END_EXTERN_C
 UPB_END_EXTERN_C
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 
 
 namespace upb {
 namespace upb {
 namespace json {
 namespace json {
-inline Parser* Parser::Create(Environment* env, Sink* output) {
-  return upb_json_parser_create(env, output);
+inline Parser* Parser::Create(Environment* env, const ParserMethod* method,
+                              Sink* output) {
+  return upb_json_parser_create(env, method, output);
 }
 }
 inline BytesSink* Parser::input() {
 inline BytesSink* Parser::input() {
   return upb_json_parser_input(this);
   return upb_json_parser_input(this);
 }
 }
+
+inline const Handlers* ParserMethod::dest_handlers() const {
+  return upb_json_parsermethod_desthandlers(this);
+}
+inline const BytesHandler* ParserMethod::input_handler() const {
+  return upb_json_parsermethod_inputhandler(this);
+}
+/* static */
+inline reffed_ptr<const ParserMethod> ParserMethod::New(
+    const MessageDef* md) {
+  const upb_json_parsermethod *m = upb_json_parsermethod_new(md, &m);
+  return reffed_ptr<const ParserMethod>(m, &m);
+}
+
 }  /* namespace json */
 }  /* namespace json */
 }  /* namespace upb */
 }  /* namespace upb */
 
 

+ 1 - 1
ruby/tests/basic.rb

@@ -1160,7 +1160,7 @@ module BasicTest
       # TODO: Fix JSON in JRuby version.
       # TODO: Fix JSON in JRuby version.
       return if RUBY_PLATFORM == "java"
       return if RUBY_PLATFORM == "java"
       m = MapMessage.new(:map_string_int32 => {"a" => 1})
       m = MapMessage.new(:map_string_int32 => {"a" => 1})
-      expected = '{"map_string_int32":{"a":1},"map_string_msg":{}}'
+      expected = '{"mapStringInt32":{"a":1},"mapStringMsg":{}}'
       assert MapMessage.encode_json(m) == expected
       assert MapMessage.encode_json(m) == expected
       m2 = MapMessage.decode_json(MapMessage.encode_json(m))
       m2 = MapMessage.decode_json(MapMessage.encode_json(m))
       assert m == m2
       assert m == m2

+ 0 - 74
ruby/tests/generated_code.rb

@@ -1,74 +0,0 @@
-# Generated by the protocol buffer compiler.  DO NOT EDIT!
-# source: generated_code.proto
-
-require 'google/protobuf'
-
-Google::Protobuf::DescriptorPool.generated_pool.build do
-  add_message "A.B.C.TestMessage" do
-    optional :optional_int32, :int32, 1
-    optional :optional_int64, :int64, 2
-    optional :optional_uint32, :uint32, 3
-    optional :optional_uint64, :uint64, 4
-    optional :optional_bool, :bool, 5
-    optional :optional_double, :double, 6
-    optional :optional_float, :float, 7
-    optional :optional_string, :string, 8
-    optional :optional_bytes, :string, 9
-    optional :optional_enum, :enum, 10, "A.B.C.TestEnum"
-    optional :optional_msg, :message, 11, "A.B.C.TestMessage"
-    repeated :repeated_int32, :int32, 21
-    repeated :repeated_int64, :int64, 22
-    repeated :repeated_uint32, :uint32, 23
-    repeated :repeated_uint64, :uint64, 24
-    repeated :repeated_bool, :bool, 25
-    repeated :repeated_double, :double, 26
-    repeated :repeated_float, :float, 27
-    repeated :repeated_string, :string, 28
-    repeated :repeated_bytes, :string, 29
-    repeated :repeated_enum, :enum, 30, "A.B.C.TestEnum"
-    repeated :repeated_msg, :message, 31, "A.B.C.TestMessage"
-    map :map_int32_string, :int32, :string, 61
-    map :map_int64_string, :int64, :string, 62
-    map :map_uint32_string, :uint32, :string, 63
-    map :map_uint64_string, :uint64, :string, 64
-    map :map_bool_string, :bool, :string, 65
-    map :map_string_string, :string, :string, 66
-    map :map_string_msg, :string, :message, 67, "A.B.C.TestMessage"
-    map :map_string_enum, :string, :enum, 68, "A.B.C.TestEnum"
-    map :map_string_int32, :string, :int32, 69
-    map :map_string_bool, :string, :bool, 70
-    optional :nested_message, :message, 80, "A.B.C.TestMessage.NestedMessage"
-    oneof :my_oneof do
-      optional :oneof_int32, :int32, 41
-      optional :oneof_int64, :int64, 42
-      optional :oneof_uint32, :uint32, 43
-      optional :oneof_uint64, :uint64, 44
-      optional :oneof_bool, :bool, 45
-      optional :oneof_double, :double, 46
-      optional :oneof_float, :float, 47
-      optional :oneof_string, :string, 48
-      optional :oneof_bytes, :string, 49
-      optional :oneof_enum, :enum, 50, "A.B.C.TestEnum"
-      optional :oneof_msg, :message, 51, "A.B.C.TestMessage"
-    end
-  end
-  add_message "A.B.C.TestMessage.NestedMessage" do
-    optional :foo, :int32, 1
-  end
-  add_enum "A.B.C.TestEnum" do
-    value :Default, 0
-    value :A, 1
-    value :B, 2
-    value :C, 3
-  end
-end
-
-module A
-  module B
-    module C
-      TestMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestMessage").msgclass
-      TestMessage::NestedMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestMessage.NestedMessage").msgclass
-      TestEnum = Google::Protobuf::DescriptorPool.generated_pool.lookup("A.B.C.TestEnum").enummodule
-    end
-  end
-end

+ 4 - 2
src/google/protobuf/compiler/cpp/cpp_enum.cc

@@ -178,12 +178,13 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
   map<string, string> vars;
   map<string, string> vars;
   vars["nested_name"] = descriptor_->name();
   vars["nested_name"] = descriptor_->name();
   vars["classname"] = classname_;
   vars["classname"] = classname_;
+  vars["constexpr"] = options_.proto_h ? "constexpr " : "";
   printer->Print(vars, "typedef $classname$ $nested_name$;\n");
   printer->Print(vars, "typedef $classname$ $nested_name$;\n");
 
 
   for (int j = 0; j < descriptor_->value_count(); j++) {
   for (int j = 0; j < descriptor_->value_count(); j++) {
     vars["tag"] = EnumValueName(descriptor_->value(j));
     vars["tag"] = EnumValueName(descriptor_->value(j));
     printer->Print(vars,
     printer->Print(vars,
-      "static const $nested_name$ $tag$ = $classname$_$tag$;\n");
+      "static $constexpr$const $nested_name$ $tag$ = $classname$_$tag$;\n");
   }
   }
 
 
   printer->Print(vars,
   printer->Print(vars,
@@ -237,6 +238,7 @@ void EnumGenerator::GenerateDescriptorInitializer(
 void EnumGenerator::GenerateMethods(io::Printer* printer) {
 void EnumGenerator::GenerateMethods(io::Printer* printer) {
   map<string, string> vars;
   map<string, string> vars;
   vars["classname"] = classname_;
   vars["classname"] = classname_;
+  vars["constexpr"] = options_.proto_h ? "constexpr " : "";
 
 
   if (HasDescriptorMethods(descriptor_->file())) {
   if (HasDescriptorMethods(descriptor_->file())) {
     printer->Print(vars,
     printer->Print(vars,
@@ -287,7 +289,7 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) {
     for (int i = 0; i < descriptor_->value_count(); i++) {
     for (int i = 0; i < descriptor_->value_count(); i++) {
       vars["value"] = EnumValueName(descriptor_->value(i));
       vars["value"] = EnumValueName(descriptor_->value(i));
       printer->Print(vars,
       printer->Print(vars,
-        "const $classname$ $parent$::$value$;\n");
+        "$constexpr$const $classname$ $parent$::$value$;\n");
     }
     }
     printer->Print(vars,
     printer->Print(vars,
       "const $classname$ $parent$::$nested_name$_MIN;\n"
       "const $classname$ $parent$::$nested_name$_MIN;\n"

+ 15 - 1
src/google/protobuf/compiler/js/js_generator.cc

@@ -149,6 +149,20 @@ string GetJSFilename(const string& filename) {
   return StripSuffixString(filename, suffix) + "_pb.js";
   return StripSuffixString(filename, suffix) + "_pb.js";
 }
 }
 
 
+// Given a filename like foo/bar/baz.proto, returns the root directory
+// path ../../
+string GetRootPath(const string& filename) {
+  size_t slashes = std::count(filename.begin(), filename.end(), '/');
+  if (slashes == 0) {
+    return "./";
+  }
+  string result = "";
+  for (size_t i = 0; i < slashes; i++) {
+    result += "../";
+  }
+  return result;
+}
+
 // Returns the alias we assign to the module of the given .proto filename
 // Returns the alias we assign to the module of the given .proto filename
 // when importing.
 // when importing.
 string ModuleAlias(const string& filename) {
 string ModuleAlias(const string& filename) {
@@ -2518,7 +2532,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
       printer->Print(
       printer->Print(
           "var $alias$ = require('$file$');\n",
           "var $alias$ = require('$file$');\n",
           "alias", ModuleAlias(name),
           "alias", ModuleAlias(name),
-          "file", GetJSFilename(name));
+          "file", GetRootPath(file->name()) + GetJSFilename(name));
     }
     }
   }
   }
 
 

+ 5 - 1
src/google/protobuf/compiler/objectivec/objectivec_enum.cc

@@ -80,10 +80,12 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
   if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
   if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
     // Include the unknown value.
     // Include the unknown value.
     printer->Print(
     printer->Print(
+      "/// Value used if any message's field encounters a value that is not defined\n"
+      "/// by this enum. The message will also have C functions to get/set the rawValue\n"
+      "/// of the field.\n"
       "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n",
       "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\n",
       "name", name_);
       "name", name_);
   }
   }
-
   for (int i = 0; i < all_values_.size(); i++) {
   for (int i = 0; i < all_values_.size(); i++) {
     SourceLocation location;
     SourceLocation location;
     if (all_values_[i]->GetSourceLocation(&location)) {
     if (all_values_[i]->GetSourceLocation(&location)) {
@@ -107,6 +109,8 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
       "\n"
       "\n"
       "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n"
       "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n"
       "\n"
       "\n"
+      "/// Checks to see if the given value is defined by the enum or was not known at\n"
+      "/// the time this source was generated.\n"
       "BOOL $name$_IsValidValue(int32_t value);\n"
       "BOOL $name$_IsValidValue(int32_t value);\n"
       "\n",
       "\n",
       "name", name_);
       "name", name_);

+ 5 - 0
src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc

@@ -87,7 +87,12 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations(
 
 
   printer->Print(
   printer->Print(
       variables_,
       variables_,
+      "/// Fetches the raw value of a @c $owning_message_class$'s @c $name$ property, even\n"
+      "/// if the value was not defined by the enum at the time the code was generated.\n"
       "int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message);\n"
       "int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message);\n"
+      "/// Sets the raw value of an @c $owning_message_class$'s @c $name$ property, allowing\n"
+      "/// it to be set to a value that was not defined by the enum at the time the code\n"
+      "/// was generated.\n"
       "void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\n"
       "void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\n"
       "\n");
       "\n");
 }
 }

+ 9 - 7
src/google/protobuf/compiler/objectivec/objectivec_field.cc

@@ -270,15 +270,15 @@ void SingleFieldGenerator::GenerateFieldStorageDeclaration(
 void SingleFieldGenerator::GeneratePropertyDeclaration(
 void SingleFieldGenerator::GeneratePropertyDeclaration(
     io::Printer* printer) const {
     io::Printer* printer) const {
   printer->Print(variables_, "$comments$");
   printer->Print(variables_, "$comments$");
+  printer->Print(
+      variables_,
+      "@property(nonatomic, readwrite) $property_type$ $name$;\n"
+      "\n");
   if (WantsHasProperty()) {
   if (WantsHasProperty()) {
     printer->Print(
     printer->Print(
         variables_,
         variables_,
         "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n");
         "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n");
   }
   }
-  printer->Print(
-      variables_,
-      "@property(nonatomic, readwrite) $property_type$ $name$;\n"
-      "\n");
 }
 }
 
 
 void SingleFieldGenerator::GeneratePropertyImplementation(
 void SingleFieldGenerator::GeneratePropertyImplementation(
@@ -326,14 +326,15 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
   // conventions (init*, new*, etc.)
   // conventions (init*, new*, etc.)
 
 
   printer->Print(variables_, "$comments$");
   printer->Print(variables_, "$comments$");
+  printer->Print(
+      variables_,
+      "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n");
   if (WantsHasProperty()) {
   if (WantsHasProperty()) {
     printer->Print(
     printer->Print(
         variables_,
         variables_,
+        "/// Test to see if @c $name$ has been set.\n"
         "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n");
         "@property(nonatomic, readwrite) BOOL has$capitalized_name$;\n");
   }
   }
-  printer->Print(
-      variables_,
-      "@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$;\n");
   if (IsInitName(variables_.find("name")->second)) {
   if (IsInitName(variables_.find("name")->second)) {
     // If property name starts with init we need to annotate it to get past ARC.
     // If property name starts with init we need to annotate it to get past ARC.
     // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
     // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
@@ -385,6 +386,7 @@ void RepeatedFieldGenerator::GeneratePropertyDeclaration(
       "$comments$"
       "$comments$"
       "$array_comment$"
       "$array_comment$"
       "@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$;\n"
       "@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$;\n"
+      "/// The number of items in @c $name$ without causing the array to be created.\n"
       "@property(nonatomic, readonly) NSUInteger $name$_Count;\n");
       "@property(nonatomic, readonly) NSUInteger $name$_Count;\n");
   if (IsInitName(variables_.find("name")->second)) {
   if (IsInitName(variables_.find("name")->second)) {
     // If property name starts with init we need to annotate it to get past ARC.
     // If property name starts with init we need to annotate it to get past ARC.

+ 8 - 6
src/google/protobuf/compiler/objectivec/objectivec_file.cc

@@ -151,13 +151,15 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
   printer->Print(
   printer->Print(
       "#pragma mark - $root_class_name$\n"
       "#pragma mark - $root_class_name$\n"
       "\n"
       "\n"
+      "/// Exposes the extension registry for this file.\n"
+      "///\n"
+      "/// The base class provides:\n"
+      "/// @code\n"
+      "///   + (GPBExtensionRegistry *)extensionRegistry;\n"
+      "/// @endcode\n"
+      "/// which is a @c GPBExtensionRegistry that includes all the extensions defined by\n"
+      "/// this file and all files that it depends on.\n"
       "@interface $root_class_name$ : GPBRootObject\n"
       "@interface $root_class_name$ : GPBRootObject\n"
-      "\n"
-      "// The base class provides:\n"
-      "//   + (GPBExtensionRegistry *)extensionRegistry;\n"
-      "// which is an GPBExtensionRegistry that includes all the extensions defined by\n"
-      "// this file and all files that it depends on.\n"
-      "\n"
       "@end\n"
       "@end\n"
       "\n",
       "\n",
       "root_class_name", root_class_name_);
       "root_class_name", root_class_name_);

+ 13 - 12
src/google/protobuf/compiler/objectivec/objectivec_helpers.cc

@@ -124,9 +124,14 @@ string UnderscoresToCamelCase(const string& input, bool first_capitalized) {
   }
   }
   values.push_back(current);
   values.push_back(current);
 
 
+  string result;
+  bool first_segment_forces_upper = false;
   for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) {
   for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) {
     string value = *i;
     string value = *i;
     bool all_upper = (kUpperSegments.count(value) > 0);
     bool all_upper = (kUpperSegments.count(value) > 0);
+    if (all_upper && (result.length() == 0)) {
+      first_segment_forces_upper = true;
+    }
     for (int j = 0; j < value.length(); j++) {
     for (int j = 0; j < value.length(); j++) {
       if (j == 0 || all_upper) {
       if (j == 0 || all_upper) {
         value[j] = ascii_toupper(value[j]);
         value[j] = ascii_toupper(value[j]);
@@ -134,13 +139,11 @@ string UnderscoresToCamelCase(const string& input, bool first_capitalized) {
         // Nothing, already in lower.
         // Nothing, already in lower.
       }
       }
     }
     }
-    *i = value;
-  }
-  string result;
-  for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) {
-    result += *i;
+    result += value;
   }
   }
-  if ((result.length() != 0) && !first_capitalized) {
+  if ((result.length() != 0) &&
+      !first_capitalized &&
+      !first_segment_forces_upper) {
     result[0] = ascii_tolower(result[0]);
     result[0] = ascii_tolower(result[0]);
   }
   }
   return result;
   return result;
@@ -771,16 +774,14 @@ string BuildCommentsString(const SourceLocation& location) {
   while (!lines.empty() && lines.back().empty()) {
   while (!lines.empty() && lines.back().empty()) {
     lines.pop_back();
     lines.pop_back();
   }
   }
-  string prefix("//");
+  string prefix("///");
   string suffix("\n");
   string suffix("\n");
   string final_comments;
   string final_comments;
   for (int i = 0; i < lines.size(); i++) {
   for (int i = 0; i < lines.size(); i++) {
-    // We use $ for delimiters, so replace comments with dollars with
-    // html escaped version.
-    // None of the other compilers handle this (as of this writing) but we
-    // ran into it once, so just to be safe.
+    // HeaderDoc uses '\' and '@' for markers; escape them.
+    const string line = StringReplace(lines[i], "\\", "\\\\", true);
     final_comments +=
     final_comments +=
-        prefix + StringReplace(lines[i], "$", "&#36;", true) + suffix;
+        prefix + StringReplace(line, "@", "\\@", true) + suffix;
   }
   }
   return final_comments;
   return final_comments;
 }
 }

+ 1 - 0
src/google/protobuf/compiler/objectivec/objectivec_helpers.h

@@ -146,6 +146,7 @@ string DefaultValue(const FieldDescriptor* field);
 
 
 string BuildFlagsString(const vector<string>& strings);
 string BuildFlagsString(const vector<string>& strings);
 
 
+// Builds a HeaderDoc style comment out of the comments in the .proto file.
 string BuildCommentsString(const SourceLocation& location);
 string BuildCommentsString(const SourceLocation& location);
 
 
 // Checks the prefix for a given file and outputs any warnings needed, if
 // Checks the prefix for a given file and outputs any warnings needed, if

+ 1 - 0
src/google/protobuf/compiler/objectivec/objectivec_oneof.cc

@@ -104,6 +104,7 @@ void OneofGenerator::GeneratePublicCasePropertyDeclaration(
 void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {
 void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {
   printer->Print(
   printer->Print(
       variables_,
       variables_,
+      "/// Clears whatever value was set for the oneof '$name$'.\n"
       "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\n");
       "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\n");
 }
 }
 
 

+ 73 - 11
src/google/protobuf/compiler/ruby/ruby_generator.cc

@@ -75,6 +75,10 @@ std::string StripDotProto(const std::string& proto_file) {
   return proto_file.substr(0, lastindex);
   return proto_file.substr(0, lastindex);
 }
 }
 
 
+std::string GetOutputFilename(const std::string& proto_file) {
+  return StripDotProto(proto_file) + ".rb";
+}
+
 std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
 std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
   switch (field->label()) {
   switch (field->label()) {
     case FieldDescriptor::LABEL_OPTIONAL: return "optional";
     case FieldDescriptor::LABEL_OPTIONAL: return "optional";
@@ -331,8 +335,69 @@ void EndPackageModules(
   }
   }
 }
 }
 
 
-void GenerateFile(const google::protobuf::FileDescriptor* file,
-                  google::protobuf::io::Printer* printer) {
+bool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file,
+                      string* error) {
+  for (int i = 0; i < message->field_count(); i++) {
+    const FieldDescriptor* field = message->field(i);
+    if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+         field->message_type()->file() == file) ||
+        (field->type() == FieldDescriptor::TYPE_ENUM &&
+         field->enum_type()->file() == file)) {
+      *error = "proto3 message field " + field->full_name() + " in file " +
+               file->name() + " has a dependency on a type from proto2 file " +
+               file->name() +
+               ".  Ruby doesn't support proto2 yet, so we must fail.";
+      return true;
+    }
+  }
+
+  for (int i = 0; i < message->nested_type_count(); i++) {
+    if (UsesTypeFromFile(message->nested_type(i), file, error)) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+// Ruby doesn't currently support proto2.  This causes a failure even for proto3
+// files that import proto2.  But in some cases, the proto2 file is only being
+// imported to extend another proto2 message.  The prime example is declaring
+// custom options by extending FileOptions/FieldOptions/etc.
+//
+// If the proto3 messages don't have any proto2 submessages, it is safe to omit
+// the dependency completely.  Users won't be able to use any proto2 extensions,
+// but they already couldn't because proto2 messages aren't supported.
+//
+// If/when we add proto2 support, we should remove this.
+bool MaybeEmitDependency(const FileDescriptor* import,
+                         const FileDescriptor* from,
+                         io::Printer* printer,
+                         string* error) {
+  if (import->syntax() == FileDescriptor::SYNTAX_PROTO2) {
+    for (int i = 0; i < from->message_type_count(); i++) {
+      if (UsesTypeFromFile(from->message_type(i), import, error)) {
+        // Error text was already set by UsesTypeFromFile().
+        return false;
+      }
+    }
+
+    // Ok to omit this proto2 dependency -- so we won't print anything.
+    GOOGLE_LOG(WARNING) << "Omitting proto2 dependency '" << import->name()
+                        << "' from proto3 output file '"
+                        << GetOutputFilename(from->name())
+                        << "' because we don't support proto2 and no proto2 "
+                           "types from that file are being used.";
+    return true;
+  } else {
+    printer->Print(
+      "require '$name$'\n", "name", StripDotProto(import->name()));
+    return true;
+  }
+}
+
+bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
+                  string* error) {
   printer->Print(
   printer->Print(
     "# Generated by the protocol buffer compiler.  DO NOT EDIT!\n"
     "# Generated by the protocol buffer compiler.  DO NOT EDIT!\n"
     "# source: $filename$\n"
     "# source: $filename$\n"
@@ -343,9 +408,9 @@ void GenerateFile(const google::protobuf::FileDescriptor* file,
     "require 'google/protobuf'\n\n");
     "require 'google/protobuf'\n\n");
 
 
   for (int i = 0; i < file->dependency_count(); i++) {
   for (int i = 0; i < file->dependency_count(); i++) {
-    const std::string& name = file->dependency(i)->name();
-    printer->Print(
-      "require '$name$'\n", "name", StripDotProto(name));
+    if (!MaybeEmitDependency(file->dependency(i), file, printer, error)) {
+      return false;
+    }
   }
   }
 
 
   printer->Print(
   printer->Print(
@@ -369,6 +434,7 @@ void GenerateFile(const google::protobuf::FileDescriptor* file,
     GenerateEnumAssignment("", file->enum_type(i), printer);
     GenerateEnumAssignment("", file->enum_type(i), printer);
   }
   }
   EndPackageModules(levels, printer);
   EndPackageModules(levels, printer);
+  return true;
 }
 }
 
 
 bool Generator::Generate(
 bool Generator::Generate(
@@ -384,15 +450,11 @@ bool Generator::Generate(
     return false;
     return false;
   }
   }
 
 
-  std::string filename =
-      StripDotProto(file->name()) + ".rb";
   scoped_ptr<io::ZeroCopyOutputStream> output(
   scoped_ptr<io::ZeroCopyOutputStream> output(
-      generator_context->Open(filename));
+      generator_context->Open(GetOutputFilename(file->name())));
   io::Printer printer(output.get(), '$');
   io::Printer printer(output.get(), '$');
 
 
-  GenerateFile(file, &printer);
-
-  return true;
+  return GenerateFile(file, &printer, error);
 }
 }
 
 
 }  // namespace ruby
 }  // namespace ruby

+ 5 - 1
src/google/protobuf/map.h

@@ -548,7 +548,11 @@ class Map {
     !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID)
     !defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID)
     template<class NodeType, class... Args>
     template<class NodeType, class... Args>
     void construct(NodeType* p, Args&&... args) {
     void construct(NodeType* p, Args&&... args) {
-      new (static_cast<void*>(p)) NodeType(std::forward<Args>(args)...);
+      // Clang 3.6 doesn't compile static casting to void* directly. (Issue #1266)
+      // According C++ standard 5.2.9/1: "The static_cast operator shall not cast
+      // away constness". So first the maybe const pointer is casted to const void* and
+      // after the const void* is const casted.
+      new (const_cast<void*>(static_cast<const void*>(p))) NodeType(std::forward<Args>(args)...);
     }
     }
 
 
     template<class NodeType>
     template<class NodeType>

+ 11 - 1
util/python/BUILD

@@ -1,7 +1,17 @@
 # This is a placeholder for python headers. Projects needing to use
 # This is a placeholder for python headers. Projects needing to use
 # fast cpp protos in protobuf's python interface should build with
 # fast cpp protos in protobuf's python interface should build with
 # --define=use_fast_cpp_protos=true, and in addition, provide
 # --define=use_fast_cpp_protos=true, and in addition, provide
-# //util/python:python_headers dependency that in turn provides Python.h.
+# //external:python_headers dependency that in turn provides Python.h.
+#
+# Projects that include protobuf using a Bazel external repository will need to
+# add a workspace rule to their WORKSPACE files to add an external workspace
+# that includes the Python headers. For example, the protobuf WORKSPACE file
+# includes the following local_repository rule that points to this directory:
+#
+# new_local_repository(
+#   name = "python",
+#   path = __workspace_dir__ + "/util/python",
+# )
 cc_library(
 cc_library(
     name = "python_headers",
     name = "python_headers",
     visibility = ["//visibility:public"],
     visibility = ["//visibility:public"],

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