grpc 1.27.0 → 1.28.0.pre2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (678) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +707 -629
  3. data/include/grpc/impl/codegen/grpc_types.h +5 -0
  4. data/include/grpc/impl/codegen/port_platform.h +7 -0
  5. data/include/grpc/impl/codegen/sync.h +5 -3
  6. data/include/grpc/impl/codegen/sync_abseil.h +36 -0
  7. data/include/grpc/module.modulemap +3 -0
  8. data/include/grpc/support/sync_abseil.h +26 -0
  9. data/src/core/ext/filters/client_channel/client_channel.cc +47 -29
  10. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +31 -47
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -3
  12. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  13. data/src/core/ext/filters/client_channel/http_proxy.cc +4 -1
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +21 -28
  15. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +18 -21
  16. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +9 -13
  17. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +46 -72
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +413 -422
  19. data/src/core/ext/filters/client_channel/lb_policy_factory.h +3 -3
  20. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +43 -75
  21. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +57 -70
  23. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +1 -1
  24. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +1 -1
  25. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +1 -1
  26. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
  27. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +2 -2
  28. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  29. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +3 -3
  30. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +4 -2
  31. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +228 -286
  32. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  33. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +13 -14
  34. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -7
  35. data/src/core/ext/filters/client_channel/service_config.cc +91 -160
  36. data/src/core/ext/filters/client_channel/service_config.h +14 -21
  37. data/src/core/ext/filters/client_channel/xds/xds_api.cc +581 -251
  38. data/src/core/ext/filters/client_channel/xds/xds_api.h +189 -151
  39. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +133 -350
  40. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +18 -39
  41. data/src/core/ext/filters/client_channel/xds/xds_channel.h +3 -1
  42. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +12 -9
  43. data/src/core/ext/filters/client_channel/xds/xds_client.cc +559 -242
  44. data/src/core/ext/filters/client_channel/xds/xds_client.h +54 -34
  45. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +53 -128
  46. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +105 -132
  47. data/src/core/ext/filters/message_size/message_size_filter.cc +32 -35
  48. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  49. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +3 -6
  50. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +4 -6
  51. data/src/core/ext/transport/chttp2/transport/writing.cc +1 -1
  52. data/src/core/ext/transport/inproc/inproc_transport.cc +22 -42
  53. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +17 -0
  54. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +30 -0
  55. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +27 -0
  56. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +54 -0
  57. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +46 -21
  58. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +116 -29
  59. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +4 -362
  60. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +14 -1337
  61. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +390 -0
  62. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +1411 -0
  63. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +29 -8
  64. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +60 -0
  65. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +1 -0
  66. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +1 -0
  67. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +5 -3
  68. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +6 -2
  69. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +48 -5
  70. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +154 -4
  71. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +19 -15
  72. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +46 -32
  73. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +26 -4
  74. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +70 -0
  75. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +42 -25
  76. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +83 -25
  77. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +1 -0
  78. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +43 -7
  79. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +115 -0
  80. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +1 -0
  81. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +7 -68
  82. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +14 -201
  83. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +91 -0
  84. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +240 -0
  85. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +1 -71
  86. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +3 -228
  87. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +88 -0
  88. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +258 -0
  89. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +1 -0
  90. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +30 -0
  91. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +53 -0
  92. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +104 -0
  93. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +383 -0
  94. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +17 -0
  95. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +33 -0
  96. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +144 -0
  97. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +527 -0
  98. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +42 -0
  99. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +112 -0
  100. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +29 -0
  101. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +53 -0
  102. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +62 -0
  103. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +199 -0
  104. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +17 -0
  105. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +33 -0
  106. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +793 -0
  107. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +2936 -0
  108. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +58 -0
  109. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +134 -0
  110. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +27 -0
  111. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +53 -0
  112. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +227 -0
  113. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +725 -0
  114. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +296 -0
  115. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +1072 -0
  116. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +32 -0
  117. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +65 -0
  118. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +47 -0
  119. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +108 -0
  120. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +52 -0
  121. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +133 -0
  122. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +87 -0
  123. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +258 -0
  124. data/src/core/ext/upb-generated/envoy/type/range.upb.c +11 -0
  125. data/src/core/ext/upb-generated/envoy/type/range.upb.h +27 -0
  126. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +28 -0
  127. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +62 -0
  128. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +88 -0
  129. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +249 -0
  130. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +30 -27
  131. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +64 -52
  132. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +48 -0
  133. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +104 -0
  134. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +17 -0
  135. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +30 -0
  136. data/src/core/ext/upb-generated/validate/validate.upb.c +38 -34
  137. data/src/core/ext/upb-generated/validate/validate.upb.h +129 -99
  138. data/src/core/lib/channel/channel_trace.cc +32 -41
  139. data/src/core/lib/channel/channel_trace.h +3 -3
  140. data/src/core/lib/channel/channelz.cc +158 -248
  141. data/src/core/lib/channel/channelz.h +12 -15
  142. data/src/core/lib/channel/channelz_registry.cc +47 -74
  143. data/src/core/lib/channel/channelz_registry.h +4 -4
  144. data/src/core/lib/gpr/sync_abseil.cc +114 -0
  145. data/src/core/lib/gpr/sync_posix.cc +8 -5
  146. data/src/core/lib/gpr/sync_windows.cc +4 -2
  147. data/src/core/lib/gprpp/host_port.cc +1 -1
  148. data/src/core/lib/gprpp/inlined_vector.h +1 -210
  149. data/src/core/lib/gprpp/memory.h +2 -6
  150. data/src/core/lib/gprpp/optional.h +0 -41
  151. data/src/core/lib/gprpp/string_view.h +5 -114
  152. data/src/core/lib/iomgr/buffer_list.cc +36 -35
  153. data/src/core/lib/iomgr/error.h +4 -4
  154. data/src/core/lib/iomgr/ev_epollex_linux.cc +12 -4
  155. data/src/core/lib/iomgr/load_file.cc +1 -0
  156. data/src/core/lib/iomgr/tcp_client_posix.cc +17 -17
  157. data/src/core/lib/iomgr/tcp_client_posix.h +6 -6
  158. data/src/core/lib/iomgr/tcp_posix.cc +2 -1
  159. data/src/core/lib/iomgr/work_serializer.cc +155 -0
  160. data/src/core/lib/iomgr/work_serializer.h +65 -0
  161. data/src/core/lib/json/json.h +209 -79
  162. data/src/core/lib/json/json_reader.cc +469 -455
  163. data/src/core/lib/json/json_writer.cc +173 -169
  164. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +10 -8
  166. data/src/core/lib/security/credentials/jwt/json_token.cc +26 -56
  167. data/src/core/lib/security/credentials/jwt/json_token.h +2 -1
  168. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +8 -18
  169. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +149 -159
  170. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -3
  171. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +37 -34
  172. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
  173. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +2 -1
  174. data/src/core/lib/security/security_connector/local/local_security_connector.cc +5 -7
  175. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +3 -15
  176. data/src/core/lib/security/security_connector/ssl_utils.cc +3 -1
  177. data/src/core/lib/security/security_connector/ssl_utils.h +0 -1
  178. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +24 -1
  179. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +5 -1
  180. data/src/core/lib/security/transport/security_handshaker.cc +2 -2
  181. data/src/core/lib/security/util/json_util.cc +22 -15
  182. data/src/core/lib/security/util/json_util.h +2 -2
  183. data/src/core/lib/surface/version.cc +1 -1
  184. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  185. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +1 -1
  186. data/src/core/tsi/grpc_shadow_boringssl.h +1333 -1319
  187. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  188. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
  189. data/src/core/tsi/ssl_transport_security.cc +2 -1
  190. data/src/ruby/lib/grpc/version.rb +1 -1
  191. data/third_party/abseil-cpp/absl/base/attributes.h +1 -1
  192. data/third_party/abseil-cpp/absl/base/config.h +10 -4
  193. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +30 -9
  194. data/third_party/abseil-cpp/absl/base/internal/errno_saver.h +43 -0
  195. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +7 -5
  196. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +2 -1
  197. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +2 -2
  198. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +2 -3
  199. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +3 -3
  200. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +37 -0
  201. data/third_party/abseil-cpp/absl/base/options.h +2 -10
  202. data/third_party/abseil-cpp/absl/strings/charconv.cc +0 -1
  203. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +388 -0
  204. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +432 -0
  205. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +245 -0
  206. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +209 -0
  207. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +326 -0
  208. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +51 -0
  209. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +415 -0
  210. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +493 -0
  211. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +23 -0
  212. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +72 -0
  213. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +104 -0
  214. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +334 -0
  215. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +333 -0
  216. data/third_party/abseil-cpp/absl/strings/str_format.h +537 -0
  217. data/third_party/abseil-cpp/absl/strings/string_view.h +19 -11
  218. data/{src/boringssl → third_party/boringssl-with-bazel}/err_data.c +0 -0
  219. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_bitstr.c +0 -0
  220. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_bool.c +0 -0
  221. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_d2i_fp.c +0 -0
  222. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_dup.c +0 -0
  223. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_enum.c +0 -0
  224. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_gentm.c +0 -0
  225. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_i2d_fp.c +0 -0
  226. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_int.c +0 -0
  227. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_mbstr.c +0 -0
  228. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_object.c +0 -0
  229. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_octet.c +0 -0
  230. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_print.c +0 -0
  231. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_strnid.c +0 -0
  232. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_time.c +3 -4
  233. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_type.c +0 -0
  234. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_utctm.c +0 -0
  235. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/a_utf8.c +0 -0
  236. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/asn1_lib.c +0 -0
  237. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/asn1_locl.h +0 -0
  238. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/asn1_par.c +0 -0
  239. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/asn_pack.c +0 -0
  240. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/f_enum.c +0 -0
  241. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/f_int.c +0 -0
  242. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/f_string.c +0 -0
  243. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_dec.c +0 -0
  244. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_enc.c +0 -0
  245. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_fre.c +0 -0
  246. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_new.c +0 -0
  247. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_typ.c +0 -0
  248. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/tasn_utl.c +0 -0
  249. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/asn1/time_support.c +0 -0
  250. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/base64/base64.c +0 -0
  251. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/bio.c +0 -0
  252. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/bio_mem.c +0 -0
  253. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/connect.c +3 -4
  254. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/fd.c +0 -1
  255. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/file.c +5 -6
  256. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/hexdump.c +0 -0
  257. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/internal.h +0 -0
  258. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/pair.c +0 -1
  259. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/printf.c +0 -0
  260. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/socket.c +0 -0
  261. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bio/socket_helper.c +0 -0
  262. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bn_extra/bn_asn1.c +0 -0
  263. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bn_extra/convert.c +0 -0
  264. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/buf/buf.c +10 -69
  265. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/asn1_compat.c +0 -0
  266. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/ber.c +0 -0
  267. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/cbb.c +41 -2
  268. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/cbs.c +60 -3
  269. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/internal.h +0 -0
  270. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/bytestring/unicode.c +0 -0
  271. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/chacha/chacha.c +0 -0
  272. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/chacha/internal.h +0 -0
  273. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/cipher_extra.c +0 -0
  274. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/derive_key.c +0 -0
  275. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_aesccm.c +0 -0
  276. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_aesctrhmac.c +0 -0
  277. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_aesgcmsiv.c +8 -0
  278. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_chacha20poly1305.c +0 -0
  279. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_null.c +0 -0
  280. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_rc2.c +0 -0
  281. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_rc4.c +0 -0
  282. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/e_tls.c +0 -0
  283. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/internal.h +0 -0
  284. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cipher_extra/tls_cbc.c +0 -0
  285. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cmac/cmac.c +0 -0
  286. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/conf/conf.c +0 -0
  287. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/conf/conf_def.h +0 -0
  288. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/conf/internal.h +0 -0
  289. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-aarch64-fuchsia.c +0 -0
  290. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-aarch64-linux.c +0 -0
  291. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-arm-linux.c +0 -1
  292. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-arm-linux.h +0 -0
  293. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-arm.c +0 -0
  294. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-intel.c +0 -0
  295. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/cpu-ppc64le.c +0 -0
  296. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/crypto.c +0 -0
  297. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/curve25519/spake25519.c +0 -0
  298. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dh/check.c +3 -3
  299. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dh/dh.c +1 -2
  300. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dh/dh_asn1.c +0 -0
  301. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dh/params.c +0 -0
  302. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/digest_extra/digest_extra.c +0 -0
  303. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dsa/dsa.c +0 -0
  304. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/dsa/dsa_asn1.c +0 -0
  305. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/ec_extra/ec_asn1.c +0 -0
  306. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/ec_extra/ec_derive.c +2 -3
  307. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/ecdh_extra/ecdh_extra.c +0 -0
  308. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/ecdsa_extra/ecdsa_asn1.c +0 -0
  309. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/engine/engine.c +0 -0
  310. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/err/err.c +6 -6
  311. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/err/internal.h +0 -0
  312. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/digestsign.c +0 -0
  313. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/evp.c +0 -0
  314. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/evp_asn1.c +0 -0
  315. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/evp_ctx.c +0 -0
  316. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/internal.h +0 -0
  317. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_dsa_asn1.c +0 -0
  318. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_ec.c +0 -1
  319. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_ec_asn1.c +0 -0
  320. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_ed25519.c +0 -0
  321. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_ed25519_asn1.c +0 -0
  322. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_rsa.c +14 -2
  323. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_rsa_asn1.c +0 -0
  324. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_x25519.c +0 -0
  325. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/p_x25519_asn1.c +1 -2
  326. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/pbkdf.c +0 -0
  327. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/print.c +0 -0
  328. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/scrypt.c +0 -0
  329. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/evp/sign.c +0 -0
  330. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/ex_data.c +0 -0
  331. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c +108 -0
  332. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1282 -0
  333. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/aes/internal.h +5 -7
  334. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/aes/key_wrap.c +0 -0
  335. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/aes/mode_wrappers.c +0 -2
  336. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bcm.c +2 -0
  337. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/add.c +0 -0
  338. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/asm/x86_64-gcc.c +0 -0
  339. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/bn.c +0 -0
  340. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/bytes.c +0 -0
  341. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/cmp.c +0 -0
  342. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/ctx.c +0 -0
  343. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/div.c +0 -0
  344. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/div_extra.c +0 -0
  345. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/exponentiation.c +0 -0
  346. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/gcd.c +0 -0
  347. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/gcd_extra.c +0 -0
  348. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/generic.c +0 -0
  349. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/internal.h +0 -0
  350. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/jacobi.c +0 -0
  351. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/montgomery.c +0 -0
  352. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/montgomery_inv.c +0 -0
  353. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/mul.c +0 -0
  354. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/prime.c +11 -12
  355. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/random.c +0 -0
  356. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/rsaz_exp.c +0 -0
  357. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/rsaz_exp.h +0 -0
  358. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/shift.c +0 -0
  359. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/bn/sqrt.c +0 -0
  360. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/cipher/aead.c +0 -0
  361. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/cipher/cipher.c +0 -0
  362. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/cipher/e_aes.c +3 -5
  363. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/cipher/e_des.c +0 -0
  364. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/cipher/internal.h +0 -0
  365. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/delocate.h +0 -0
  366. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/des/des.c +0 -0
  367. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/des/internal.h +0 -0
  368. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/digest/digest.c +0 -0
  369. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/digest/digests.c +0 -0
  370. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/digest/internal.h +0 -0
  371. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/digest/md32_common.h +0 -0
  372. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/ec.c +0 -0
  373. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/ec_key.c +1 -1
  374. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/ec_montgomery.c +0 -0
  375. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/felem.c +0 -0
  376. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/internal.h +0 -0
  377. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/oct.c +0 -0
  378. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/p224-64.c +0 -0
  379. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/p256-x86_64-table.h +0 -0
  380. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/p256-x86_64.c +0 -0
  381. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/p256-x86_64.h +0 -0
  382. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/scalar.c +0 -0
  383. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/simple.c +0 -0
  384. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/simple_mul.c +0 -0
  385. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/util.c +0 -0
  386. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ec/wnaf.c +0 -0
  387. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ecdh/ecdh.c +0 -0
  388. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/ecdsa/ecdsa.c +0 -0
  389. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/fips_shared_support.c +0 -0
  390. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/hmac/hmac.c +0 -0
  391. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/is_fips.c +0 -0
  392. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/md4/md4.c +0 -0
  393. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/md5/internal.h +0 -0
  394. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/md5/md5.c +0 -0
  395. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/cbc.c +0 -0
  396. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/cfb.c +0 -0
  397. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/ctr.c +0 -0
  398. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/gcm.c +45 -193
  399. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +304 -0
  400. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/internal.h +8 -18
  401. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/ofb.c +0 -0
  402. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/modes/polyval.c +0 -0
  403. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rand/ctrdrbg.c +0 -0
  404. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rand/internal.h +0 -0
  405. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rand/rand.c +0 -0
  406. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rand/urandom.c +0 -0
  407. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rsa/blinding.c +0 -0
  408. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rsa/internal.h +0 -0
  409. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rsa/padding.c +0 -0
  410. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rsa/rsa.c +7 -1
  411. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/rsa/rsa_impl.c +60 -51
  412. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/self_check/self_check.c +0 -0
  413. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/sha/internal.h +0 -0
  414. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/sha/sha1-altivec.c +0 -0
  415. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/sha/sha1.c +0 -0
  416. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/sha/sha256.c +0 -0
  417. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/sha/sha512.c +0 -0
  418. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/tls/internal.h +0 -0
  419. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/fipsmodule/tls/kdf.c +0 -0
  420. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/hkdf/hkdf.c +0 -0
  421. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/hrss/hrss.c +210 -311
  422. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/hrss/internal.h +0 -1
  423. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/internal.h +21 -1
  424. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/lhash/lhash.c +0 -0
  425. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/mem.c +70 -0
  426. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/obj/obj.c +16 -21
  427. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/obj/obj_dat.h +27 -6
  428. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/obj/obj_xref.c +0 -0
  429. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_all.c +0 -0
  430. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_info.c +0 -1
  431. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_lib.c +7 -7
  432. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_oth.c +0 -1
  433. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_pk8.c +0 -1
  434. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_pkey.c +0 -1
  435. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_x509.c +0 -0
  436. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pem/pem_xaux.c +0 -0
  437. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs7/internal.h +0 -0
  438. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs7/pkcs7.c +0 -0
  439. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs7/pkcs7_x509.c +1 -1
  440. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs8/internal.h +0 -0
  441. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs8/p5_pbev2.c +0 -0
  442. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs8/pkcs8.c +0 -0
  443. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pkcs8/pkcs8_x509.c +0 -0
  444. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/poly1305/internal.h +0 -0
  445. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/poly1305/poly1305.c +2 -2
  446. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/poly1305/poly1305_arm.c +21 -20
  447. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/poly1305/poly1305_vec.c +34 -17
  448. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pool/internal.h +0 -0
  449. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/pool/pool.c +1 -2
  450. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rand_extra/deterministic.c +0 -0
  451. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rand_extra/forkunsafe.c +0 -0
  452. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rand_extra/fuchsia.c +0 -0
  453. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rand_extra/rand_extra.c +0 -0
  454. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rand_extra/windows.c +0 -0
  455. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rc4/rc4.c +0 -0
  456. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/refcount_c11.c +0 -0
  457. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/refcount_lock.c +0 -0
  458. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rsa_extra/rsa_asn1.c +0 -0
  459. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/rsa_extra/rsa_print.c +0 -0
  460. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/siphash/siphash.c +3 -1
  461. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/stack/stack.c +0 -0
  462. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/thread.c +0 -0
  463. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/thread_none.c +0 -0
  464. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/thread_pthread.c +0 -0
  465. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/thread_win.c +0 -0
  466. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/a_digest.c +0 -0
  467. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/a_sign.c +0 -0
  468. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/a_strex.c +0 -0
  469. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/a_verify.c +0 -1
  470. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/algorithm.c +0 -0
  471. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/asn1_gen.c +0 -0
  472. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/by_dir.c +1 -1
  473. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/by_file.c +0 -1
  474. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/charmap.h +0 -0
  475. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/i2d_pr.c +0 -0
  476. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/internal.h +0 -0
  477. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/rsa_pss.c +0 -0
  478. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/t_crl.c +0 -0
  479. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/t_req.c +0 -0
  480. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/t_x509.c +0 -0
  481. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/t_x509a.c +0 -0
  482. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/vpm_int.h +0 -0
  483. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509.c +0 -0
  484. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_att.c +0 -0
  485. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_cmp.c +0 -1
  486. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_d2.c +0 -0
  487. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_def.c +0 -0
  488. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_ext.c +0 -0
  489. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_lu.c +0 -0
  490. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_obj.c +1 -1
  491. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_r2x.c +0 -1
  492. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_req.c +0 -1
  493. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_set.c +0 -0
  494. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_trs.c +1 -2
  495. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_txt.c +0 -0
  496. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_v3.c +0 -0
  497. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_vfy.c +0 -1
  498. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509_vpm.c +3 -4
  499. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509cset.c +0 -0
  500. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509name.c +0 -0
  501. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509rset.c +0 -0
  502. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x509spki.c +0 -0
  503. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_algor.c +0 -0
  504. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_all.c +0 -1
  505. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_attrib.c +0 -0
  506. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_crl.c +0 -0
  507. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_exten.c +0 -0
  508. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_info.c +0 -0
  509. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_name.c +0 -0
  510. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_pkey.c +0 -0
  511. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_pubkey.c +0 -0
  512. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_req.c +0 -0
  513. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_sig.c +0 -0
  514. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_spki.c +0 -0
  515. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_val.c +0 -0
  516. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_x509.c +0 -0
  517. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509/x_x509a.c +0 -0
  518. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/ext_dat.h +0 -0
  519. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/internal.h +0 -0
  520. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_cache.c +0 -0
  521. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_data.c +0 -0
  522. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_int.h +0 -0
  523. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_lib.c +0 -0
  524. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_map.c +0 -0
  525. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_node.c +0 -0
  526. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/pcy_tree.c +0 -0
  527. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_akey.c +0 -0
  528. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_akeya.c +0 -0
  529. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_alt.c +3 -3
  530. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_bcons.c +0 -0
  531. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_bitst.c +0 -0
  532. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_conf.c +0 -0
  533. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_cpols.c +0 -0
  534. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_crld.c +0 -0
  535. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_enum.c +2 -2
  536. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_extku.c +0 -0
  537. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_genn.c +0 -0
  538. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_ia5.c +0 -0
  539. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_info.c +4 -5
  540. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_int.c +0 -0
  541. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_lib.c +0 -0
  542. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_ncons.c +0 -0
  543. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_ocsp.c +0 -0
  544. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_pci.c +0 -0
  545. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_pcia.c +0 -0
  546. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_pcons.c +0 -0
  547. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_pku.c +0 -0
  548. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_pmaps.c +0 -0
  549. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_prn.c +0 -0
  550. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_purp.c +2 -3
  551. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_skey.c +0 -0
  552. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_sxnet.c +0 -0
  553. data/third_party/{boringssl → boringssl-with-bazel/src}/crypto/x509v3/v3_utl.c +11 -12
  554. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/aead.h +0 -0
  555. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/aes.h +0 -0
  556. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/arm_arch.h +0 -0
  557. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/asn1.h +0 -0
  558. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/asn1_mac.h +0 -0
  559. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/asn1t.h +0 -0
  560. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/base.h +0 -0
  561. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/base64.h +0 -0
  562. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/bio.h +0 -0
  563. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/blowfish.h +0 -0
  564. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/bn.h +32 -20
  565. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/buf.h +9 -9
  566. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/buffer.h +0 -0
  567. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/bytestring.h +34 -0
  568. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/cast.h +0 -0
  569. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/chacha.h +0 -0
  570. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/cipher.h +0 -0
  571. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/cmac.h +0 -0
  572. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/conf.h +0 -0
  573. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/cpu.h +0 -0
  574. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/crypto.h +0 -0
  575. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/curve25519.h +0 -0
  576. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/des.h +0 -0
  577. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/dh.h +0 -0
  578. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/digest.h +0 -0
  579. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/dsa.h +0 -0
  580. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/dtls1.h +0 -0
  581. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/e_os2.h +0 -0
  582. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ec.h +11 -4
  583. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ec_key.h +4 -2
  584. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ecdh.h +0 -0
  585. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ecdsa.h +0 -0
  586. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/engine.h +0 -0
  587. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/err.h +11 -9
  588. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/evp.h +20 -0
  589. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ex_data.h +0 -0
  590. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/hkdf.h +0 -0
  591. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/hmac.h +0 -0
  592. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/hrss.h +0 -0
  593. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/is_boringssl.h +0 -0
  594. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/lhash.h +0 -0
  595. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/md4.h +0 -0
  596. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/md5.h +0 -0
  597. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/mem.h +17 -2
  598. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/nid.h +9 -0
  599. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/obj.h +0 -0
  600. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/obj_mac.h +0 -0
  601. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/objects.h +0 -0
  602. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/opensslconf.h +0 -0
  603. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/opensslv.h +0 -0
  604. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ossl_typ.h +0 -0
  605. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/pem.h +0 -0
  606. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/pkcs12.h +0 -0
  607. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/pkcs7.h +0 -0
  608. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/pkcs8.h +0 -0
  609. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/poly1305.h +5 -7
  610. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/pool.h +0 -0
  611. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/rand.h +0 -0
  612. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/rc4.h +0 -0
  613. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ripemd.h +0 -0
  614. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/rsa.h +0 -0
  615. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/safestack.h +0 -0
  616. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/sha.h +0 -0
  617. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/siphash.h +0 -0
  618. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/span.h +0 -0
  619. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/srtp.h +0 -0
  620. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ssl.h +10 -20
  621. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/ssl3.h +0 -0
  622. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/stack.h +0 -0
  623. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/thread.h +0 -0
  624. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/tls1.h +0 -3
  625. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/type_check.h +0 -0
  626. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/x509.h +0 -0
  627. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/x509_vfy.h +0 -0
  628. data/third_party/{boringssl → boringssl-with-bazel/src}/include/openssl/x509v3.h +0 -0
  629. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/bio_ssl.cc +0 -0
  630. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/d1_both.cc +0 -1
  631. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/d1_lib.cc +0 -0
  632. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/d1_pkt.cc +0 -1
  633. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/d1_srtp.cc +0 -0
  634. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/dtls_method.cc +0 -1
  635. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/dtls_record.cc +0 -0
  636. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/handoff.cc +126 -29
  637. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/handshake.cc +5 -4
  638. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/handshake_client.cc +24 -13
  639. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/handshake_server.cc +1 -5
  640. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/internal.h +32 -26
  641. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/s3_both.cc +0 -0
  642. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/s3_lib.cc +2 -3
  643. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/s3_pkt.cc +0 -1
  644. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_aead_ctx.cc +0 -0
  645. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_asn1.cc +1 -2
  646. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_buffer.cc +34 -15
  647. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_cert.cc +0 -1
  648. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_cipher.cc +0 -1
  649. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_file.cc +0 -0
  650. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_key_share.cc +0 -0
  651. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_lib.cc +13 -14
  652. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_privkey.cc +0 -0
  653. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_session.cc +2 -1
  654. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_stat.cc +0 -0
  655. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_transcript.cc +0 -0
  656. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_versions.cc +1 -1
  657. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/ssl_x509.cc +0 -0
  658. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/t1_enc.cc +0 -0
  659. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/t1_lib.cc +11 -171
  660. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls13_both.cc +0 -0
  661. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls13_client.cc +3 -4
  662. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls13_enc.cc +5 -1
  663. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls13_server.cc +78 -101
  664. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls_method.cc +1 -1
  665. data/third_party/{boringssl → boringssl-with-bazel/src}/ssl/tls_record.cc +7 -2
  666. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/curve25519.c +0 -0
  667. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/curve25519_32.h +0 -0
  668. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/curve25519_64.h +0 -0
  669. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/curve25519_tables.h +0 -0
  670. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/internal.h +0 -0
  671. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/p256.c +0 -0
  672. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/p256_32.h +0 -0
  673. data/third_party/{boringssl → boringssl-with-bazel/src}/third_party/fiat/p256_64.h +0 -0
  674. metadata +562 -491
  675. data/src/core/lib/iomgr/logical_thread.cc +0 -103
  676. data/src/core/lib/iomgr/logical_thread.h +0 -52
  677. data/src/core/lib/json/json.cc +0 -94
  678. data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +0 -860
@@ -0,0 +1,65 @@
1
+ /*
2
+ *
3
+ * Copyright 2019 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include <functional>
22
+
23
+ #include "src/core/lib/debug/trace.h"
24
+ #include "src/core/lib/gprpp/atomic.h"
25
+ #include "src/core/lib/gprpp/debug_location.h"
26
+ #include "src/core/lib/gprpp/mpscq.h"
27
+ #include "src/core/lib/gprpp/orphanable.h"
28
+ #include "src/core/lib/gprpp/ref_counted.h"
29
+ #include "src/core/lib/iomgr/exec_ctx.h"
30
+
31
+ #ifndef GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
32
+ #define GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H
33
+
34
+ namespace grpc_core {
35
+
36
+ // WorkSerializer is a mechanism to schedule callbacks in a synchronized manner.
37
+ // All callbacks scheduled on a WorkSerializer instance will be executed
38
+ // serially in a borrowed thread. The API provides a FIFO guarantee to the
39
+ // execution of callbacks scheduled on the thread.
40
+ // When a thread calls Run() with a callback, the thread is considered borrowed.
41
+ // The callback might run inline, or it might run asynchronously in a different
42
+ // thread that is already inside of Run(). If the callback runs directly inline,
43
+ // other callbacks from other threads might also be executed before Run()
44
+ // returns. Since an arbitrary set of callbacks might be executed when Run() is
45
+ // called, generally no locks should be held while calling Run().
46
+ class WorkSerializer {
47
+ public:
48
+ WorkSerializer();
49
+
50
+ ~WorkSerializer();
51
+
52
+ // TODO(yashkt): Replace grpc_core::DebugLocation with absl::SourceLocation
53
+ // once we can start using it directly.
54
+ void Run(std::function<void()> callback,
55
+ const grpc_core::DebugLocation& location);
56
+
57
+ private:
58
+ class WorkSerializerImpl;
59
+
60
+ OrphanablePtr<WorkSerializerImpl> impl_;
61
+ };
62
+
63
+ } /* namespace grpc_core */
64
+
65
+ #endif /* GRPC_CORE_LIB_IOMGR_WORK_SERIALIZER_H */
@@ -21,89 +21,219 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
- #include <stdbool.h>
25
24
  #include <stdlib.h>
26
25
 
27
- /* The various json types. */
28
- typedef enum {
29
- GRPC_JSON_OBJECT,
30
- GRPC_JSON_ARRAY,
31
- GRPC_JSON_STRING,
32
- GRPC_JSON_NUMBER,
33
- GRPC_JSON_TRUE,
34
- GRPC_JSON_FALSE,
35
- GRPC_JSON_NULL,
36
- GRPC_JSON_TOP_LEVEL
37
- } grpc_json_type;
38
-
39
- /* A tree-like structure to hold json values. The key and value pointers
40
- * are not owned by it.
41
- */
42
- typedef struct grpc_json {
43
- struct grpc_json* next;
44
- struct grpc_json* prev;
45
- struct grpc_json* child;
46
- struct grpc_json* parent;
47
-
48
- grpc_json_type type;
49
- const char* key;
50
- const char* value;
51
-
52
- /* if set, destructor will free value */
53
- bool owns_value;
54
- } grpc_json;
55
-
56
- /* The next two functions are going to parse the input string, and
57
- * modify it in the process, in order to use its space to store
58
- * all of the keys and values for the returned object tree.
59
- *
60
- * They assume UTF-8 input stream, and will output UTF-8 encoded
61
- * strings in the tree. The input stream's UTF-8 isn't validated,
62
- * as in, what you input is what you get as an output.
63
- *
64
- * All the keys and values in the grpc_json objects will be strings
65
- * pointing at your input buffer.
66
- *
67
- * Delete the allocated tree afterward using grpc_json_destroy().
68
- */
69
- grpc_json* grpc_json_parse_string_with_len(char* input, size_t size);
70
- grpc_json* grpc_json_parse_string(char* input);
26
+ #include <map>
27
+ #include <string>
28
+ #include <vector>
71
29
 
72
- /* This function will create a new string using gpr_realloc, and will
73
- * deserialize the grpc_json tree into it. It'll be zero-terminated,
74
- * but will be allocated in chunks of 256 bytes.
75
- *
76
- * The indent parameter controls the way the output is formatted.
77
- * If indent is 0, then newlines will be suppressed as well, and the
78
- * output will be condensed at its maximum.
79
- */
80
- char* grpc_json_dump_to_string(const grpc_json* json, int indent);
30
+ #include "src/core/lib/gprpp/string_view.h"
31
+ #include "src/core/lib/iomgr/error.h"
81
32
 
82
- /* Use these to create or delete a grpc_json object.
83
- * Deletion is recursive. We will not attempt to free any of the strings
84
- * in any of the objects of that tree, unless the boolean, owns_value,
85
- * is true.
86
- */
87
- grpc_json* grpc_json_create(grpc_json_type type);
88
- void grpc_json_destroy(grpc_json* json);
33
+ namespace grpc_core {
89
34
 
90
- /* Links the child json object into the parent's json tree. If the parent
91
- * already has children, then passing in the most recently added child as the
92
- * sibling parameter is an optimization. For if sibling is NULL, this function
93
- * will manually traverse the tree in order to find the right most sibling.
94
- */
95
- grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child,
96
- grpc_json* sibling);
97
-
98
- /* Creates a child json object into the parent's json tree then links it in
99
- * as described above. */
100
- grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent,
101
- const char* key, const char* value,
102
- grpc_json_type type, bool owns_value);
103
-
104
- /* Creates a child json string object from the integer num, then links the
105
- json object into the parent's json tree */
106
- grpc_json* grpc_json_add_number_string_child(grpc_json* parent, grpc_json* it,
107
- const char* name, int64_t num);
35
+ // A JSON value, which can be any one of object, array, string,
36
+ // number, true, false, or null.
37
+ class Json {
38
+ public:
39
+ // TODO(roth): Currently, numbers are stored internally as strings,
40
+ // which makes the API a bit cumbersome to use. When we have time,
41
+ // consider whether there's a better alternative (e.g., maybe storing
42
+ // each numeric type as the native C++ type and automatically converting
43
+ // to string as needed).
44
+ enum class Type {
45
+ JSON_NULL,
46
+ JSON_TRUE,
47
+ JSON_FALSE,
48
+ NUMBER,
49
+ STRING,
50
+ OBJECT,
51
+ ARRAY
52
+ };
53
+
54
+ using Object = std::map<std::string, Json>;
55
+ using Array = std::vector<Json>;
56
+
57
+ // Parses JSON string from json_str. On error, sets *error.
58
+ static Json Parse(StringView json_str, grpc_error** error);
59
+
60
+ Json() = default;
61
+
62
+ // Copyable.
63
+ Json(const Json& other) { CopyFrom(other); }
64
+ Json& operator=(const Json& other) {
65
+ CopyFrom(other);
66
+ return *this;
67
+ }
68
+
69
+ // Moveable.
70
+ Json(Json&& other) { MoveFrom(std::move(other)); }
71
+ Json& operator=(Json&& other) {
72
+ MoveFrom(std::move(other));
73
+ return *this;
74
+ }
75
+
76
+ // Construct from copying a string.
77
+ // If is_number is true, the type will be NUMBER instead of STRING.
78
+ Json(const std::string& string, bool is_number = false)
79
+ : type_(is_number ? Type::NUMBER : Type::STRING), string_value_(string) {}
80
+ Json& operator=(const std::string& string) {
81
+ type_ = Type::STRING;
82
+ string_value_ = string;
83
+ return *this;
84
+ }
85
+
86
+ // Same thing for C-style strings, both const and mutable.
87
+ Json(const char* string, bool is_number = false)
88
+ : Json(std::string(string), is_number) {}
89
+ Json& operator=(const char* string) {
90
+ *this = std::string(string);
91
+ return *this;
92
+ }
93
+ Json(char* string, bool is_number = false)
94
+ : Json(std::string(string), is_number) {}
95
+ Json& operator=(char* string) {
96
+ *this = std::string(string);
97
+ return *this;
98
+ }
99
+
100
+ // Construct by moving a string.
101
+ Json(std::string&& string)
102
+ : type_(Type::STRING), string_value_(std::move(string)) {}
103
+ Json& operator=(std::string&& string) {
104
+ type_ = Type::STRING;
105
+ string_value_ = std::move(string);
106
+ return *this;
107
+ }
108
+
109
+ // Construct from bool.
110
+ Json(bool b) : type_(b ? Type::JSON_TRUE : Type::JSON_FALSE) {}
111
+ Json& operator=(bool b) {
112
+ type_ = b ? Type::JSON_TRUE : Type::JSON_FALSE;
113
+ return *this;
114
+ }
115
+
116
+ // Construct from any numeric type.
117
+ template <typename NumericType>
118
+ Json(NumericType number)
119
+ : type_(Type::NUMBER), string_value_(std::to_string(number)) {}
120
+ template <typename NumericType>
121
+ Json& operator=(NumericType number) {
122
+ type_ = Type::NUMBER;
123
+ string_value_ = std::to_string(number);
124
+ return *this;
125
+ }
126
+
127
+ // Construct by copying object.
128
+ Json(const Object& object) : type_(Type::OBJECT), object_value_(object) {}
129
+ Json& operator=(const Object& object) {
130
+ type_ = Type::OBJECT;
131
+ object_value_ = object;
132
+ return *this;
133
+ }
134
+
135
+ // Construct by moving object.
136
+ Json(Object&& object)
137
+ : type_(Type::OBJECT), object_value_(std::move(object)) {}
138
+ Json& operator=(Object&& object) {
139
+ type_ = Type::OBJECT;
140
+ object_value_ = std::move(object);
141
+ return *this;
142
+ }
143
+
144
+ // Construct by copying array.
145
+ Json(const Array& array) : type_(Type::ARRAY), array_value_(array) {}
146
+ Json& operator=(const Array& array) {
147
+ type_ = Type::ARRAY;
148
+ array_value_ = array;
149
+ return *this;
150
+ }
151
+
152
+ // Construct by moving array.
153
+ Json(Array&& array) : type_(Type::ARRAY), array_value_(std::move(array)) {}
154
+ Json& operator=(Array&& array) {
155
+ type_ = Type::ARRAY;
156
+ array_value_ = std::move(array);
157
+ return *this;
158
+ }
159
+
160
+ // Dumps JSON from value to string form.
161
+ std::string Dump(int indent = 0) const;
162
+
163
+ // Accessor methods.
164
+ Type type() const { return type_; }
165
+ const std::string& string_value() const { return string_value_; }
166
+ std::string* mutable_string_value() { return &string_value_; }
167
+ const Object& object_value() const { return object_value_; }
168
+ Object* mutable_object() { return &object_value_; }
169
+ const Array& array_value() const { return array_value_; }
170
+ Array* mutable_array() { return &array_value_; }
171
+
172
+ bool operator==(const Json& other) const {
173
+ if (type_ != other.type_) return false;
174
+ switch (type_) {
175
+ case Type::NUMBER:
176
+ case Type::STRING:
177
+ if (string_value_ != other.string_value_) return false;
178
+ break;
179
+ case Type::OBJECT:
180
+ if (object_value_ != other.object_value_) return false;
181
+ break;
182
+ case Type::ARRAY:
183
+ if (array_value_ != other.array_value_) return false;
184
+ break;
185
+ default:
186
+ break;
187
+ }
188
+ return true;
189
+ }
190
+
191
+ bool operator!=(const Json& other) const { return !(*this == other); }
192
+
193
+ private:
194
+ void CopyFrom(const Json& other) {
195
+ type_ = other.type_;
196
+ switch (type_) {
197
+ case Type::NUMBER:
198
+ case Type::STRING:
199
+ string_value_ = other.string_value_;
200
+ break;
201
+ case Type::OBJECT:
202
+ object_value_ = other.object_value_;
203
+ break;
204
+ case Type::ARRAY:
205
+ array_value_ = other.array_value_;
206
+ break;
207
+ default:
208
+ break;
209
+ }
210
+ }
211
+
212
+ void MoveFrom(Json&& other) {
213
+ type_ = other.type_;
214
+ other.type_ = Type::JSON_NULL;
215
+ switch (type_) {
216
+ case Type::NUMBER:
217
+ case Type::STRING:
218
+ string_value_ = std::move(other.string_value_);
219
+ break;
220
+ case Type::OBJECT:
221
+ object_value_ = std::move(other.object_value_);
222
+ break;
223
+ case Type::ARRAY:
224
+ array_value_ = std::move(other.array_value_);
225
+ break;
226
+ default:
227
+ break;
228
+ }
229
+ }
230
+
231
+ Type type_ = Type::JSON_NULL;
232
+ std::string string_value_;
233
+ Object object_value_;
234
+ Array array_value_;
235
+ };
236
+
237
+ } // namespace grpc_core
108
238
 
109
239
  #endif /* GRPC_CORE_LIB_JSON_JSON_H */
@@ -21,246 +21,264 @@
21
21
  #include <string.h>
22
22
 
23
23
  #include <grpc/support/log.h>
24
+ #include <grpc/support/string_util.h>
24
25
 
25
26
  #include "src/core/lib/json/json.h"
26
27
 
27
- typedef enum {
28
- GRPC_JSON_STATE_OBJECT_KEY_BEGIN,
29
- GRPC_JSON_STATE_OBJECT_KEY_STRING,
30
- GRPC_JSON_STATE_OBJECT_KEY_END,
31
- GRPC_JSON_STATE_VALUE_BEGIN,
32
- GRPC_JSON_STATE_VALUE_STRING,
33
- GRPC_JSON_STATE_STRING_ESCAPE,
34
- GRPC_JSON_STATE_STRING_ESCAPE_U1,
35
- GRPC_JSON_STATE_STRING_ESCAPE_U2,
36
- GRPC_JSON_STATE_STRING_ESCAPE_U3,
37
- GRPC_JSON_STATE_STRING_ESCAPE_U4,
38
- GRPC_JSON_STATE_VALUE_NUMBER,
39
- GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL,
40
- GRPC_JSON_STATE_VALUE_NUMBER_ZERO,
41
- GRPC_JSON_STATE_VALUE_NUMBER_DOT,
42
- GRPC_JSON_STATE_VALUE_NUMBER_E,
43
- GRPC_JSON_STATE_VALUE_NUMBER_EPM,
44
- GRPC_JSON_STATE_VALUE_TRUE_R,
45
- GRPC_JSON_STATE_VALUE_TRUE_U,
46
- GRPC_JSON_STATE_VALUE_TRUE_E,
47
- GRPC_JSON_STATE_VALUE_FALSE_A,
48
- GRPC_JSON_STATE_VALUE_FALSE_L,
49
- GRPC_JSON_STATE_VALUE_FALSE_S,
50
- GRPC_JSON_STATE_VALUE_FALSE_E,
51
- GRPC_JSON_STATE_VALUE_NULL_U,
52
- GRPC_JSON_STATE_VALUE_NULL_L1,
53
- GRPC_JSON_STATE_VALUE_NULL_L2,
54
- GRPC_JSON_STATE_VALUE_END,
55
- GRPC_JSON_STATE_END
56
- } grpc_json_reader_state;
57
-
58
- enum {
28
+ #define GRPC_JSON_MAX_DEPTH 255
29
+ #define GRPC_JSON_MAX_ERRORS 16
30
+
31
+ namespace grpc_core {
32
+
33
+ namespace {
34
+
35
+ class JsonReader {
36
+ public:
37
+ static grpc_error* Parse(StringView input, Json* output);
38
+
39
+ private:
40
+ enum class Status {
41
+ GRPC_JSON_DONE, /* The parser finished successfully. */
42
+ GRPC_JSON_PARSE_ERROR, /* The parser found an error in the json stream. */
43
+ GRPC_JSON_INTERNAL_ERROR /* The parser got an internal error. */
44
+ };
45
+
46
+ enum class State {
47
+ GRPC_JSON_STATE_OBJECT_KEY_BEGIN,
48
+ GRPC_JSON_STATE_OBJECT_KEY_STRING,
49
+ GRPC_JSON_STATE_OBJECT_KEY_END,
50
+ GRPC_JSON_STATE_VALUE_BEGIN,
51
+ GRPC_JSON_STATE_VALUE_STRING,
52
+ GRPC_JSON_STATE_STRING_ESCAPE,
53
+ GRPC_JSON_STATE_STRING_ESCAPE_U1,
54
+ GRPC_JSON_STATE_STRING_ESCAPE_U2,
55
+ GRPC_JSON_STATE_STRING_ESCAPE_U3,
56
+ GRPC_JSON_STATE_STRING_ESCAPE_U4,
57
+ GRPC_JSON_STATE_VALUE_NUMBER,
58
+ GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL,
59
+ GRPC_JSON_STATE_VALUE_NUMBER_ZERO,
60
+ GRPC_JSON_STATE_VALUE_NUMBER_DOT,
61
+ GRPC_JSON_STATE_VALUE_NUMBER_E,
62
+ GRPC_JSON_STATE_VALUE_NUMBER_EPM,
63
+ GRPC_JSON_STATE_VALUE_TRUE_R,
64
+ GRPC_JSON_STATE_VALUE_TRUE_U,
65
+ GRPC_JSON_STATE_VALUE_TRUE_E,
66
+ GRPC_JSON_STATE_VALUE_FALSE_A,
67
+ GRPC_JSON_STATE_VALUE_FALSE_L,
68
+ GRPC_JSON_STATE_VALUE_FALSE_S,
69
+ GRPC_JSON_STATE_VALUE_FALSE_E,
70
+ GRPC_JSON_STATE_VALUE_NULL_U,
71
+ GRPC_JSON_STATE_VALUE_NULL_L1,
72
+ GRPC_JSON_STATE_VALUE_NULL_L2,
73
+ GRPC_JSON_STATE_VALUE_END,
74
+ GRPC_JSON_STATE_END
75
+ };
76
+
59
77
  /* The first non-unicode value is 0x110000. But let's pick
60
78
  * a value high enough to start our error codes from. These
61
79
  * values are safe to return from the read_char function.
62
80
  */
63
- GRPC_JSON_READ_CHAR_EOF = 0x7ffffff0,
64
- GRPC_JSON_READ_CHAR_EAGAIN,
65
- GRPC_JSON_READ_CHAR_ERROR
81
+ static constexpr uint32_t GRPC_JSON_READ_CHAR_EOF = 0x7ffffff0;
82
+
83
+ explicit JsonReader(StringView input)
84
+ : original_input_(reinterpret_cast<const uint8_t*>(input.data())),
85
+ input_(original_input_),
86
+ remaining_input_(input.size()) {}
87
+
88
+ Status Run();
89
+ uint32_t ReadChar();
90
+ bool IsComplete();
91
+
92
+ size_t CurrentIndex() const { return input_ - original_input_ - 1; }
93
+
94
+ void StringAddChar(uint32_t c);
95
+ void StringAddUtf32(uint32_t c);
96
+
97
+ Json* CreateAndLinkValue();
98
+ bool StartContainer(Json::Type type);
99
+ void EndContainer();
100
+ void SetKey();
101
+ void SetString();
102
+ bool SetNumber();
103
+ void SetTrue();
104
+ void SetFalse();
105
+ void SetNull();
106
+
107
+ const uint8_t* original_input_;
108
+ const uint8_t* input_;
109
+ size_t remaining_input_;
110
+
111
+ State state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
112
+ bool escaped_string_was_key_ = false;
113
+ bool container_just_begun_ = false;
114
+ uint16_t unicode_char_ = 0;
115
+ uint16_t unicode_high_surrogate_ = 0;
116
+ std::vector<grpc_error*> errors_;
117
+ bool truncated_errors_ = false;
118
+
119
+ Json root_value_;
120
+ std::vector<Json*> stack_;
121
+
122
+ std::string key_;
123
+ std::string string_;
66
124
  };
67
125
 
68
- typedef struct grpc_json_reader {
69
- /* That structure is fully private, and initialized by grpc_json_reader_init.
70
- * The definition is public so you can put it on your stack.
71
- */
72
-
73
- int depth;
74
- int in_object;
75
- int in_array;
76
- int escaped_string_was_key;
77
- int container_just_begun;
78
- uint16_t unicode_char, unicode_high_surrogate;
79
- grpc_json_reader_state state;
80
-
81
- grpc_json* top;
82
- grpc_json* current_container;
83
- grpc_json* current_value;
84
- uint8_t* input;
85
- uint8_t* key;
86
- uint8_t* string;
87
- uint8_t* string_ptr;
88
- size_t remaining_input;
89
- } grpc_json_reader;
90
-
91
- /* The return type of the parser. */
92
- typedef enum {
93
- GRPC_JSON_DONE, /* The parser finished successfully. */
94
- GRPC_JSON_EAGAIN, /* The parser yields to get more data. */
95
- GRPC_JSON_READ_ERROR, /* The parser passes through a read error. */
96
- GRPC_JSON_PARSE_ERROR, /* The parser found an error in the json stream. */
97
- GRPC_JSON_INTERNAL_ERROR /* The parser got an internal error. */
98
- } grpc_json_reader_status;
99
-
100
- static void json_reader_string_clear(grpc_json_reader* reader) {
101
- if (reader->string) {
102
- GPR_ASSERT(reader->string_ptr < reader->input);
103
- *reader->string_ptr++ = 0;
104
- }
105
- reader->string = reader->string_ptr;
106
- }
107
-
108
- static void json_reader_string_add_char(grpc_json_reader* reader, uint32_t c) {
109
- GPR_ASSERT(reader->string_ptr < reader->input);
110
- GPR_ASSERT(c <= 0xff);
111
- *reader->string_ptr++ = static_cast<uint8_t>(c);
126
+ void JsonReader::StringAddChar(uint32_t c) {
127
+ string_.push_back(static_cast<uint8_t>(c));
112
128
  }
113
129
 
114
- static void json_reader_string_add_utf32(grpc_json_reader* reader, uint32_t c) {
130
+ void JsonReader::StringAddUtf32(uint32_t c) {
115
131
  if (c <= 0x7f) {
116
- json_reader_string_add_char(reader, c);
132
+ StringAddChar(c);
117
133
  } else if (c <= 0x7ff) {
118
134
  uint32_t b1 = 0xc0 | ((c >> 6) & 0x1f);
119
135
  uint32_t b2 = 0x80 | (c & 0x3f);
120
- json_reader_string_add_char(reader, b1);
121
- json_reader_string_add_char(reader, b2);
136
+ StringAddChar(b1);
137
+ StringAddChar(b2);
122
138
  } else if (c <= 0xffff) {
123
139
  uint32_t b1 = 0xe0 | ((c >> 12) & 0x0f);
124
140
  uint32_t b2 = 0x80 | ((c >> 6) & 0x3f);
125
141
  uint32_t b3 = 0x80 | (c & 0x3f);
126
- json_reader_string_add_char(reader, b1);
127
- json_reader_string_add_char(reader, b2);
128
- json_reader_string_add_char(reader, b3);
142
+ StringAddChar(b1);
143
+ StringAddChar(b2);
144
+ StringAddChar(b3);
129
145
  } else if (c <= 0x1fffff) {
130
146
  uint32_t b1 = 0xf0 | ((c >> 18) & 0x07);
131
147
  uint32_t b2 = 0x80 | ((c >> 12) & 0x3f);
132
148
  uint32_t b3 = 0x80 | ((c >> 6) & 0x3f);
133
149
  uint32_t b4 = 0x80 | (c & 0x3f);
134
- json_reader_string_add_char(reader, b1);
135
- json_reader_string_add_char(reader, b2);
136
- json_reader_string_add_char(reader, b3);
137
- json_reader_string_add_char(reader, b4);
150
+ StringAddChar(b1);
151
+ StringAddChar(b2);
152
+ StringAddChar(b3);
153
+ StringAddChar(b4);
138
154
  }
139
155
  }
140
156
 
141
- static uint32_t grpc_json_reader_read_char(grpc_json_reader* reader) {
142
- if (reader->remaining_input == 0) return GRPC_JSON_READ_CHAR_EOF;
143
- uint32_t r = *reader->input++;
144
- reader->remaining_input--;
157
+ uint32_t JsonReader::ReadChar() {
158
+ if (remaining_input_ == 0) return GRPC_JSON_READ_CHAR_EOF;
159
+ const uint32_t r = *input_++;
160
+ --remaining_input_;
145
161
  if (r == 0) {
146
- reader->remaining_input = 0;
162
+ remaining_input_ = 0;
147
163
  return GRPC_JSON_READ_CHAR_EOF;
148
164
  }
149
165
  return r;
150
166
  }
151
167
 
152
- /* Helper function to create a new grpc_json object and link it into
153
- * our tree-in-progress inside our opaque structure.
154
- */
155
- static grpc_json* json_create_and_link(grpc_json_reader* reader,
156
- grpc_json_type type) {
157
- grpc_json* json = grpc_json_create(type);
158
- json->parent = reader->current_container;
159
- json->prev = reader->current_value;
160
- reader->current_value = json;
161
- if (json->prev) {
162
- json->prev->next = json;
163
- }
164
- if (json->parent) {
165
- if (!json->parent->child) {
166
- json->parent->child = json;
167
- }
168
- if (json->parent->type == GRPC_JSON_OBJECT) {
169
- json->key = reinterpret_cast<char*>(reader->key);
168
+ Json* JsonReader::CreateAndLinkValue() {
169
+ Json* value;
170
+ if (stack_.empty()) {
171
+ value = &root_value_;
172
+ } else {
173
+ Json* parent = stack_.back();
174
+ if (parent->type() == Json::Type::OBJECT) {
175
+ if (parent->object_value().find(key_) != parent->object_value().end()) {
176
+ if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
177
+ truncated_errors_ = true;
178
+ } else {
179
+ char* msg;
180
+ gpr_asprintf(&msg, "duplicate key \"%s\" at index %" PRIuPTR,
181
+ key_.c_str(), CurrentIndex());
182
+ errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
183
+ gpr_free(msg);
184
+ }
185
+ }
186
+ value = &(*parent->mutable_object())[std::move(key_)];
187
+ } else {
188
+ GPR_ASSERT(parent->type() == Json::Type::ARRAY);
189
+ parent->mutable_array()->emplace_back();
190
+ value = &parent->mutable_array()->back();
170
191
  }
171
192
  }
172
- if (!reader->top) {
173
- reader->top = json;
174
- }
175
- return json;
193
+ return value;
176
194
  }
177
195
 
178
- static void json_reader_container_begins(grpc_json_reader* reader,
179
- grpc_json_type type) {
180
- GPR_ASSERT(type == GRPC_JSON_ARRAY || type == GRPC_JSON_OBJECT);
181
- grpc_json* container = json_create_and_link(reader, type);
182
- reader->current_container = container;
183
- reader->current_value = nullptr;
184
- }
185
-
186
- static grpc_json_type grpc_json_reader_container_ends(
187
- grpc_json_reader* reader) {
188
- grpc_json_type container_type = GRPC_JSON_TOP_LEVEL;
189
- GPR_ASSERT(reader->current_container);
190
- reader->current_value = reader->current_container;
191
- reader->current_container = reader->current_container->parent;
192
- if (reader->current_container) {
193
- container_type = reader->current_container->type;
196
+ bool JsonReader::StartContainer(Json::Type type) {
197
+ if (stack_.size() == GRPC_JSON_MAX_DEPTH) {
198
+ if (errors_.size() == GRPC_JSON_MAX_ERRORS) {
199
+ truncated_errors_ = true;
200
+ } else {
201
+ char* msg;
202
+ gpr_asprintf(&msg, "exceeded max stack depth (%d) at index %" PRIuPTR,
203
+ GRPC_JSON_MAX_DEPTH, CurrentIndex());
204
+ errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
205
+ gpr_free(msg);
206
+ }
207
+ return false;
194
208
  }
195
- return container_type;
209
+ Json* value = CreateAndLinkValue();
210
+ if (type == Json::Type::OBJECT) {
211
+ *value = Json::Object();
212
+ } else {
213
+ GPR_ASSERT(type == Json::Type::ARRAY);
214
+ *value = Json::Array();
215
+ }
216
+ stack_.push_back(value);
217
+ return true;
196
218
  }
197
219
 
198
- static void json_reader_set_key(grpc_json_reader* reader) {
199
- reader->key = reader->string;
220
+ void JsonReader::EndContainer() {
221
+ GPR_ASSERT(!stack_.empty());
222
+ stack_.pop_back();
200
223
  }
201
224
 
202
- static void json_reader_set_string(grpc_json_reader* reader) {
203
- grpc_json* json = json_create_and_link(reader, GRPC_JSON_STRING);
204
- json->value = reinterpret_cast<char*>(reader->string);
225
+ void JsonReader::SetKey() {
226
+ key_ = std::move(string_);
227
+ string_.clear();
205
228
  }
206
229
 
207
- static int json_reader_set_number(grpc_json_reader* reader) {
208
- grpc_json* json = json_create_and_link(reader, GRPC_JSON_NUMBER);
209
- json->value = reinterpret_cast<char*>(reader->string);
210
- return 1;
230
+ void JsonReader::SetString() {
231
+ Json* value = CreateAndLinkValue();
232
+ *value = std::move(string_);
233
+ string_.clear();
211
234
  }
212
235
 
213
- static void json_reader_set_true(grpc_json_reader* reader) {
214
- json_create_and_link(reader, GRPC_JSON_TRUE);
236
+ bool JsonReader::SetNumber() {
237
+ Json* value = CreateAndLinkValue();
238
+ *value = Json(std::move(string_), /*is_number=*/true);
239
+ string_.clear();
240
+ return true;
215
241
  }
216
242
 
217
- static void json_reader_set_false(grpc_json_reader* reader) {
218
- json_create_and_link(reader, GRPC_JSON_FALSE);
243
+ void JsonReader::SetTrue() {
244
+ Json* value = CreateAndLinkValue();
245
+ *value = true;
246
+ string_.clear();
219
247
  }
220
248
 
221
- static void json_reader_set_null(grpc_json_reader* reader) {
222
- json_create_and_link(reader, GRPC_JSON_NULL);
249
+ void JsonReader::SetFalse() {
250
+ Json* value = CreateAndLinkValue();
251
+ *value = false;
252
+ string_.clear();
223
253
  }
224
254
 
225
- static int json_reader_is_complete(grpc_json_reader* reader) {
226
- return ((reader->depth == 0) &&
227
- ((reader->state == GRPC_JSON_STATE_END) ||
228
- (reader->state == GRPC_JSON_STATE_VALUE_END)));
255
+ void JsonReader::SetNull() { CreateAndLinkValue(); }
256
+
257
+ bool JsonReader::IsComplete() {
258
+ return (stack_.empty() && (state_ == State::GRPC_JSON_STATE_END ||
259
+ state_ == State::GRPC_JSON_STATE_VALUE_END));
229
260
  }
230
261
 
231
262
  /* Call this function to start parsing the input. It will return the following:
232
263
  * . GRPC_JSON_DONE if the input got eof, and the parsing finished
233
264
  * successfully.
234
- * . GRPC_JSON_EAGAIN if the read_char function returned again. Call the
235
- * parser again as needed. It is okay to call the parser in polling mode,
236
- * although a bit dull.
237
- * . GRPC_JSON_READ_ERROR if the read_char function returned an error. The
238
- * state isn't broken however, and the function can be called again if the
239
- * error has been corrected. But please use the EAGAIN feature instead for
240
- * consistency.
241
265
  * . GRPC_JSON_PARSE_ERROR if the input was somehow invalid.
242
266
  * . GRPC_JSON_INTERNAL_ERROR if the parser somehow ended into an invalid
243
267
  * internal state.
244
268
  */
245
- static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
246
- uint32_t c, success;
269
+ JsonReader::Status JsonReader::Run() {
270
+ uint32_t c;
247
271
 
248
272
  /* This state-machine is a strict implementation of ECMA-404 */
249
- for (;;) {
250
- c = grpc_json_reader_read_char(reader);
273
+ while (true) {
274
+ c = ReadChar();
251
275
  switch (c) {
252
- /* Let's process the error cases first. */
253
- case GRPC_JSON_READ_CHAR_ERROR:
254
- return GRPC_JSON_READ_ERROR;
255
-
256
- case GRPC_JSON_READ_CHAR_EAGAIN:
257
- return GRPC_JSON_EAGAIN;
258
-
276
+ /* Let's process the error case first. */
259
277
  case GRPC_JSON_READ_CHAR_EOF:
260
- if (json_reader_is_complete(reader)) {
261
- return GRPC_JSON_DONE;
278
+ if (IsComplete()) {
279
+ return Status::GRPC_JSON_DONE;
262
280
  } else {
263
- return GRPC_JSON_PARSE_ERROR;
281
+ return Status::GRPC_JSON_PARSE_ERROR;
264
282
  }
265
283
  break;
266
284
 
@@ -269,34 +287,33 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
269
287
  case '\t':
270
288
  case '\n':
271
289
  case '\r':
272
- switch (reader->state) {
273
- case GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
274
- case GRPC_JSON_STATE_OBJECT_KEY_END:
275
- case GRPC_JSON_STATE_VALUE_BEGIN:
276
- case GRPC_JSON_STATE_VALUE_END:
277
- case GRPC_JSON_STATE_END:
278
- break;
279
-
280
- case GRPC_JSON_STATE_OBJECT_KEY_STRING:
281
- case GRPC_JSON_STATE_VALUE_STRING:
282
- if (c != ' ') return GRPC_JSON_PARSE_ERROR;
283
- if (reader->unicode_high_surrogate != 0)
284
- return GRPC_JSON_PARSE_ERROR;
285
- json_reader_string_add_char(reader, c);
290
+ switch (state_) {
291
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
292
+ case State::GRPC_JSON_STATE_OBJECT_KEY_END:
293
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
294
+ case State::GRPC_JSON_STATE_VALUE_END:
295
+ case State::GRPC_JSON_STATE_END:
296
+ break;
297
+
298
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
299
+ case State::GRPC_JSON_STATE_VALUE_STRING:
300
+ if (c != ' ') return Status::GRPC_JSON_PARSE_ERROR;
301
+ if (unicode_high_surrogate_ != 0) {
302
+ return Status::GRPC_JSON_PARSE_ERROR;
303
+ }
304
+ StringAddChar(c);
286
305
  break;
287
306
 
288
- case GRPC_JSON_STATE_VALUE_NUMBER:
289
- case GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
290
- case GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
291
- case GRPC_JSON_STATE_VALUE_NUMBER_EPM:
292
- success = static_cast<uint32_t>(json_reader_set_number(reader));
293
- if (!success) return GRPC_JSON_PARSE_ERROR;
294
- json_reader_string_clear(reader);
295
- reader->state = GRPC_JSON_STATE_VALUE_END;
307
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
308
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
309
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
310
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
311
+ if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
312
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
296
313
  break;
297
314
 
298
315
  default:
299
- return GRPC_JSON_PARSE_ERROR;
316
+ return Status::GRPC_JSON_PARSE_ERROR;
300
317
  }
301
318
  break;
302
319
 
@@ -304,182 +321,171 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
304
321
  case ',':
305
322
  case '}':
306
323
  case ']':
307
- switch (reader->state) {
308
- case GRPC_JSON_STATE_OBJECT_KEY_STRING:
309
- case GRPC_JSON_STATE_VALUE_STRING:
310
- if (reader->unicode_high_surrogate != 0) {
311
- return GRPC_JSON_PARSE_ERROR;
324
+ switch (state_) {
325
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
326
+ case State::GRPC_JSON_STATE_VALUE_STRING:
327
+ if (unicode_high_surrogate_ != 0) {
328
+ return Status::GRPC_JSON_PARSE_ERROR;
312
329
  }
313
- json_reader_string_add_char(reader, c);
314
- break;
315
-
316
- case GRPC_JSON_STATE_VALUE_NUMBER:
317
- case GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
318
- case GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
319
- case GRPC_JSON_STATE_VALUE_NUMBER_EPM:
320
- if (reader->depth == 0) {
321
- return GRPC_JSON_PARSE_ERROR;
322
- } else if ((c == '}') && !reader->in_object) {
323
- return GRPC_JSON_PARSE_ERROR;
324
- } else if ((c == ']') && !reader->in_array) {
325
- return GRPC_JSON_PARSE_ERROR;
330
+ StringAddChar(c);
331
+ break;
332
+
333
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
334
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
335
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
336
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
337
+ if (stack_.empty()) {
338
+ return Status::GRPC_JSON_PARSE_ERROR;
339
+ } else if (c == '}' &&
340
+ stack_.back()->type() != Json::Type::OBJECT) {
341
+ return Status::GRPC_JSON_PARSE_ERROR;
342
+ return Status::GRPC_JSON_PARSE_ERROR;
343
+ } else if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
344
+ return Status::GRPC_JSON_PARSE_ERROR;
326
345
  }
327
- success = static_cast<uint32_t>(json_reader_set_number(reader));
328
- if (!success) return GRPC_JSON_PARSE_ERROR;
329
- json_reader_string_clear(reader);
330
- reader->state = GRPC_JSON_STATE_VALUE_END;
346
+ if (!SetNumber()) return Status::GRPC_JSON_PARSE_ERROR;
347
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
331
348
  /* The missing break here is intentional. */
332
349
  /* fallthrough */
333
350
 
334
- case GRPC_JSON_STATE_VALUE_END:
335
- case GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
336
- case GRPC_JSON_STATE_VALUE_BEGIN:
351
+ case State::GRPC_JSON_STATE_VALUE_END:
352
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
353
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
337
354
  if (c == ',') {
338
- if (reader->state != GRPC_JSON_STATE_VALUE_END) {
339
- return GRPC_JSON_PARSE_ERROR;
355
+ if (state_ != State::GRPC_JSON_STATE_VALUE_END) {
356
+ return Status::GRPC_JSON_PARSE_ERROR;
340
357
  }
341
- if (reader->in_object) {
342
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
343
- } else if (reader->in_array) {
344
- reader->state = GRPC_JSON_STATE_VALUE_BEGIN;
358
+ if (!stack_.empty() &&
359
+ stack_.back()->type() == Json::Type::OBJECT) {
360
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
361
+ } else if (!stack_.empty() &&
362
+ stack_.back()->type() == Json::Type::ARRAY) {
363
+ state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
345
364
  } else {
346
- return GRPC_JSON_PARSE_ERROR;
365
+ return Status::GRPC_JSON_PARSE_ERROR;
347
366
  }
348
367
  } else {
349
- if (reader->depth-- == 0) return GRPC_JSON_PARSE_ERROR;
350
- if ((c == '}') && !reader->in_object) {
351
- return GRPC_JSON_PARSE_ERROR;
368
+ if (stack_.empty()) {
369
+ return Status::GRPC_JSON_PARSE_ERROR;
370
+ }
371
+ if (c == '}' && stack_.back()->type() != Json::Type::OBJECT) {
372
+ return Status::GRPC_JSON_PARSE_ERROR;
352
373
  }
353
- if ((c == '}') &&
354
- (reader->state == GRPC_JSON_STATE_OBJECT_KEY_BEGIN) &&
355
- !reader->container_just_begun) {
356
- return GRPC_JSON_PARSE_ERROR;
374
+ if (c == '}' &&
375
+ state_ == State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN &&
376
+ !container_just_begun_) {
377
+ return Status::GRPC_JSON_PARSE_ERROR;
357
378
  }
358
- if ((c == ']') && !reader->in_array) return GRPC_JSON_PARSE_ERROR;
359
- if ((c == ']') &&
360
- (reader->state == GRPC_JSON_STATE_VALUE_BEGIN) &&
361
- !reader->container_just_begun) {
362
- return GRPC_JSON_PARSE_ERROR;
379
+ if (c == ']' && stack_.back()->type() != Json::Type::ARRAY) {
380
+ return Status::GRPC_JSON_PARSE_ERROR;
363
381
  }
364
- reader->state = GRPC_JSON_STATE_VALUE_END;
365
- switch (grpc_json_reader_container_ends(reader)) {
366
- case GRPC_JSON_OBJECT:
367
- reader->in_object = 1;
368
- reader->in_array = 0;
369
- break;
370
- case GRPC_JSON_ARRAY:
371
- reader->in_object = 0;
372
- reader->in_array = 1;
373
- break;
374
- case GRPC_JSON_TOP_LEVEL:
375
- GPR_ASSERT(reader->depth == 0);
376
- reader->in_object = 0;
377
- reader->in_array = 0;
378
- reader->state = GRPC_JSON_STATE_END;
379
- break;
380
- default:
381
- GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR);
382
+ if (c == ']' && state_ == State::GRPC_JSON_STATE_VALUE_BEGIN &&
383
+ !container_just_begun_) {
384
+ return Status::GRPC_JSON_PARSE_ERROR;
385
+ }
386
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
387
+ EndContainer();
388
+ if (stack_.empty()) {
389
+ state_ = State::GRPC_JSON_STATE_END;
382
390
  }
383
391
  }
384
392
  break;
385
393
 
386
394
  default:
387
- return GRPC_JSON_PARSE_ERROR;
395
+ return Status::GRPC_JSON_PARSE_ERROR;
388
396
  }
389
397
  break;
390
398
 
391
399
  /* In-string escaping. */
392
400
  case '\\':
393
- switch (reader->state) {
394
- case GRPC_JSON_STATE_OBJECT_KEY_STRING:
395
- reader->escaped_string_was_key = 1;
396
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE;
401
+ switch (state_) {
402
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
403
+ escaped_string_was_key_ = true;
404
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
397
405
  break;
398
406
 
399
- case GRPC_JSON_STATE_VALUE_STRING:
400
- reader->escaped_string_was_key = 0;
401
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE;
407
+ case State::GRPC_JSON_STATE_VALUE_STRING:
408
+ escaped_string_was_key_ = false;
409
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE;
402
410
  break;
403
411
 
404
412
  /* This is the \\ case. */
405
- case GRPC_JSON_STATE_STRING_ESCAPE:
406
- if (reader->unicode_high_surrogate != 0)
407
- return GRPC_JSON_PARSE_ERROR;
408
- json_reader_string_add_char(reader, '\\');
409
- if (reader->escaped_string_was_key) {
410
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_STRING;
413
+ case State::GRPC_JSON_STATE_STRING_ESCAPE:
414
+ if (unicode_high_surrogate_ != 0)
415
+ return Status::GRPC_JSON_PARSE_ERROR;
416
+ StringAddChar('\\');
417
+ if (escaped_string_was_key_) {
418
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
411
419
  } else {
412
- reader->state = GRPC_JSON_STATE_VALUE_STRING;
420
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
413
421
  }
414
422
  break;
415
423
 
416
424
  default:
417
- return GRPC_JSON_PARSE_ERROR;
425
+ return Status::GRPC_JSON_PARSE_ERROR;
418
426
  }
419
427
  break;
420
428
 
421
429
  default:
422
- reader->container_just_begun = 0;
423
- switch (reader->state) {
424
- case GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
425
- if (c != '"') return GRPC_JSON_PARSE_ERROR;
426
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_STRING;
430
+ container_just_begun_ = false;
431
+ switch (state_) {
432
+ case State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN:
433
+ if (c != '"') return Status::GRPC_JSON_PARSE_ERROR;
434
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
427
435
  break;
428
436
 
429
- case GRPC_JSON_STATE_OBJECT_KEY_STRING:
430
- if (reader->unicode_high_surrogate != 0) {
431
- return GRPC_JSON_PARSE_ERROR;
437
+ case State::GRPC_JSON_STATE_OBJECT_KEY_STRING:
438
+ if (unicode_high_surrogate_ != 0) {
439
+ return Status::GRPC_JSON_PARSE_ERROR;
432
440
  }
433
441
  if (c == '"') {
434
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_END;
435
- json_reader_set_key(reader);
436
- json_reader_string_clear(reader);
442
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_END;
443
+ SetKey();
437
444
  } else {
438
- if (c < 32) return GRPC_JSON_PARSE_ERROR;
439
- json_reader_string_add_char(reader, c);
445
+ if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
446
+ StringAddChar(c);
440
447
  }
441
448
  break;
442
449
 
443
- case GRPC_JSON_STATE_VALUE_STRING:
444
- if (reader->unicode_high_surrogate != 0) {
445
- return GRPC_JSON_PARSE_ERROR;
450
+ case State::GRPC_JSON_STATE_VALUE_STRING:
451
+ if (unicode_high_surrogate_ != 0) {
452
+ return Status::GRPC_JSON_PARSE_ERROR;
446
453
  }
447
454
  if (c == '"') {
448
- reader->state = GRPC_JSON_STATE_VALUE_END;
449
- json_reader_set_string(reader);
450
- json_reader_string_clear(reader);
455
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
456
+ SetString();
451
457
  } else {
452
- if (c < 32) return GRPC_JSON_PARSE_ERROR;
453
- json_reader_string_add_char(reader, c);
458
+ if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
459
+ StringAddChar(c);
454
460
  }
455
461
  break;
456
462
 
457
- case GRPC_JSON_STATE_OBJECT_KEY_END:
458
- if (c != ':') return GRPC_JSON_PARSE_ERROR;
459
- reader->state = GRPC_JSON_STATE_VALUE_BEGIN;
463
+ case State::GRPC_JSON_STATE_OBJECT_KEY_END:
464
+ if (c != ':') return Status::GRPC_JSON_PARSE_ERROR;
465
+ state_ = State::GRPC_JSON_STATE_VALUE_BEGIN;
460
466
  break;
461
467
 
462
- case GRPC_JSON_STATE_VALUE_BEGIN:
468
+ case State::GRPC_JSON_STATE_VALUE_BEGIN:
463
469
  switch (c) {
464
470
  case 't':
465
- reader->state = GRPC_JSON_STATE_VALUE_TRUE_R;
471
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_R;
466
472
  break;
467
473
 
468
474
  case 'f':
469
- reader->state = GRPC_JSON_STATE_VALUE_FALSE_A;
475
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_A;
470
476
  break;
471
477
 
472
478
  case 'n':
473
- reader->state = GRPC_JSON_STATE_VALUE_NULL_U;
479
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_U;
474
480
  break;
475
481
 
476
482
  case '"':
477
- reader->state = GRPC_JSON_STATE_VALUE_STRING;
483
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
478
484
  break;
479
485
 
480
486
  case '0':
481
- json_reader_string_add_char(reader, c);
482
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_ZERO;
487
+ StringAddChar(c);
488
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO;
483
489
  break;
484
490
 
485
491
  case '1':
@@ -492,73 +498,71 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
492
498
  case '8':
493
499
  case '9':
494
500
  case '-':
495
- json_reader_string_add_char(reader, c);
496
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER;
501
+ StringAddChar(c);
502
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER;
497
503
  break;
498
504
 
499
505
  case '{':
500
- reader->container_just_begun = 1;
501
- json_reader_container_begins(reader, GRPC_JSON_OBJECT);
502
- reader->depth++;
503
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
504
- reader->in_object = 1;
505
- reader->in_array = 0;
506
+ container_just_begun_ = true;
507
+ if (!StartContainer(Json::Type::OBJECT)) {
508
+ return Status::GRPC_JSON_PARSE_ERROR;
509
+ }
510
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_BEGIN;
506
511
  break;
507
512
 
508
513
  case '[':
509
- reader->container_just_begun = 1;
510
- json_reader_container_begins(reader, GRPC_JSON_ARRAY);
511
- reader->depth++;
512
- reader->in_object = 0;
513
- reader->in_array = 1;
514
+ container_just_begun_ = true;
515
+ if (!StartContainer(Json::Type::ARRAY)) {
516
+ return Status::GRPC_JSON_PARSE_ERROR;
517
+ }
514
518
  break;
515
519
  default:
516
- return GRPC_JSON_PARSE_ERROR;
520
+ return Status::GRPC_JSON_PARSE_ERROR;
517
521
  }
518
522
  break;
519
523
 
520
- case GRPC_JSON_STATE_STRING_ESCAPE:
521
- if (reader->escaped_string_was_key) {
522
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_STRING;
524
+ case State::GRPC_JSON_STATE_STRING_ESCAPE:
525
+ if (escaped_string_was_key_) {
526
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
523
527
  } else {
524
- reader->state = GRPC_JSON_STATE_VALUE_STRING;
528
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
525
529
  }
526
- if (reader->unicode_high_surrogate && c != 'u') {
527
- return GRPC_JSON_PARSE_ERROR;
530
+ if (unicode_high_surrogate_ && c != 'u') {
531
+ return Status::GRPC_JSON_PARSE_ERROR;
528
532
  }
529
533
  switch (c) {
530
534
  case '"':
531
535
  case '/':
532
- json_reader_string_add_char(reader, c);
536
+ StringAddChar(c);
533
537
  break;
534
538
  case 'b':
535
- json_reader_string_add_char(reader, '\b');
539
+ StringAddChar('\b');
536
540
  break;
537
541
  case 'f':
538
- json_reader_string_add_char(reader, '\f');
542
+ StringAddChar('\f');
539
543
  break;
540
544
  case 'n':
541
- json_reader_string_add_char(reader, '\n');
545
+ StringAddChar('\n');
542
546
  break;
543
547
  case 'r':
544
- json_reader_string_add_char(reader, '\r');
548
+ StringAddChar('\r');
545
549
  break;
546
550
  case 't':
547
- json_reader_string_add_char(reader, '\t');
551
+ StringAddChar('\t');
548
552
  break;
549
553
  case 'u':
550
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE_U1;
551
- reader->unicode_char = 0;
554
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U1;
555
+ unicode_char_ = 0;
552
556
  break;
553
557
  default:
554
- return GRPC_JSON_PARSE_ERROR;
558
+ return Status::GRPC_JSON_PARSE_ERROR;
555
559
  }
556
560
  break;
557
561
 
558
- case GRPC_JSON_STATE_STRING_ESCAPE_U1:
559
- case GRPC_JSON_STATE_STRING_ESCAPE_U2:
560
- case GRPC_JSON_STATE_STRING_ESCAPE_U3:
561
- case GRPC_JSON_STATE_STRING_ESCAPE_U4:
562
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
563
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
564
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
565
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
562
566
  if ((c >= '0') && (c <= '9')) {
563
567
  c -= '0';
564
568
  } else if ((c >= 'A') && (c <= 'F')) {
@@ -566,62 +570,60 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
566
570
  } else if ((c >= 'a') && (c <= 'f')) {
567
571
  c -= 'a' - 10;
568
572
  } else {
569
- return GRPC_JSON_PARSE_ERROR;
573
+ return Status::GRPC_JSON_PARSE_ERROR;
570
574
  }
571
- reader->unicode_char =
572
- static_cast<uint16_t>(reader->unicode_char << 4);
573
- reader->unicode_char =
574
- static_cast<uint16_t>(reader->unicode_char | c);
575
-
576
- switch (reader->state) {
577
- case GRPC_JSON_STATE_STRING_ESCAPE_U1:
578
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE_U2;
575
+ unicode_char_ = static_cast<uint16_t>(unicode_char_ << 4);
576
+ unicode_char_ = static_cast<uint16_t>(unicode_char_ | c);
577
+
578
+ switch (state_) {
579
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U1:
580
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U2;
579
581
  break;
580
- case GRPC_JSON_STATE_STRING_ESCAPE_U2:
581
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE_U3;
582
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U2:
583
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U3;
582
584
  break;
583
- case GRPC_JSON_STATE_STRING_ESCAPE_U3:
584
- reader->state = GRPC_JSON_STATE_STRING_ESCAPE_U4;
585
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U3:
586
+ state_ = State::GRPC_JSON_STATE_STRING_ESCAPE_U4;
585
587
  break;
586
- case GRPC_JSON_STATE_STRING_ESCAPE_U4:
588
+ case State::GRPC_JSON_STATE_STRING_ESCAPE_U4:
587
589
  /* See grpc_json_writer_escape_string to have a description
588
590
  * of what's going on here.
589
591
  */
590
- if ((reader->unicode_char & 0xfc00) == 0xd800) {
592
+ if ((unicode_char_ & 0xfc00) == 0xd800) {
591
593
  /* high surrogate utf-16 */
592
- if (reader->unicode_high_surrogate != 0)
593
- return GRPC_JSON_PARSE_ERROR;
594
- reader->unicode_high_surrogate = reader->unicode_char;
595
- } else if ((reader->unicode_char & 0xfc00) == 0xdc00) {
594
+ if (unicode_high_surrogate_ != 0)
595
+ return Status::GRPC_JSON_PARSE_ERROR;
596
+ unicode_high_surrogate_ = unicode_char_;
597
+ } else if ((unicode_char_ & 0xfc00) == 0xdc00) {
596
598
  /* low surrogate utf-16 */
597
599
  uint32_t utf32;
598
- if (reader->unicode_high_surrogate == 0)
599
- return GRPC_JSON_PARSE_ERROR;
600
+ if (unicode_high_surrogate_ == 0)
601
+ return Status::GRPC_JSON_PARSE_ERROR;
600
602
  utf32 = 0x10000;
601
603
  utf32 += static_cast<uint32_t>(
602
- (reader->unicode_high_surrogate - 0xd800) * 0x400);
603
- utf32 += static_cast<uint32_t>(reader->unicode_char - 0xdc00);
604
- json_reader_string_add_utf32(reader, utf32);
605
- reader->unicode_high_surrogate = 0;
604
+ (unicode_high_surrogate_ - 0xd800) * 0x400);
605
+ utf32 += static_cast<uint32_t>(unicode_char_ - 0xdc00);
606
+ StringAddUtf32(utf32);
607
+ unicode_high_surrogate_ = 0;
606
608
  } else {
607
609
  /* anything else */
608
- if (reader->unicode_high_surrogate != 0)
609
- return GRPC_JSON_PARSE_ERROR;
610
- json_reader_string_add_utf32(reader, reader->unicode_char);
610
+ if (unicode_high_surrogate_ != 0)
611
+ return Status::GRPC_JSON_PARSE_ERROR;
612
+ StringAddUtf32(unicode_char_);
611
613
  }
612
- if (reader->escaped_string_was_key) {
613
- reader->state = GRPC_JSON_STATE_OBJECT_KEY_STRING;
614
+ if (escaped_string_was_key_) {
615
+ state_ = State::GRPC_JSON_STATE_OBJECT_KEY_STRING;
614
616
  } else {
615
- reader->state = GRPC_JSON_STATE_VALUE_STRING;
617
+ state_ = State::GRPC_JSON_STATE_VALUE_STRING;
616
618
  }
617
619
  break;
618
620
  default:
619
- GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR);
621
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
620
622
  }
621
623
  break;
622
624
 
623
- case GRPC_JSON_STATE_VALUE_NUMBER:
624
- json_reader_string_add_char(reader, c);
625
+ case State::GRPC_JSON_STATE_VALUE_NUMBER:
626
+ StringAddChar(c);
625
627
  switch (c) {
626
628
  case '0':
627
629
  case '1':
@@ -636,18 +638,18 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
636
638
  break;
637
639
  case 'e':
638
640
  case 'E':
639
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_E;
641
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
640
642
  break;
641
643
  case '.':
642
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_DOT;
644
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
643
645
  break;
644
646
  default:
645
- return GRPC_JSON_PARSE_ERROR;
647
+ return Status::GRPC_JSON_PARSE_ERROR;
646
648
  }
647
649
  break;
648
650
 
649
- case GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
650
- json_reader_string_add_char(reader, c);
651
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL:
652
+ StringAddChar(c);
651
653
  switch (c) {
652
654
  case '0':
653
655
  case '1':
@@ -662,21 +664,21 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
662
664
  break;
663
665
  case 'e':
664
666
  case 'E':
665
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_E;
667
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_E;
666
668
  break;
667
669
  default:
668
- return GRPC_JSON_PARSE_ERROR;
670
+ return Status::GRPC_JSON_PARSE_ERROR;
669
671
  }
670
672
  break;
671
673
 
672
- case GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
673
- if (c != '.') return GRPC_JSON_PARSE_ERROR;
674
- json_reader_string_add_char(reader, c);
675
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_DOT;
674
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_ZERO:
675
+ if (c != '.') return Status::GRPC_JSON_PARSE_ERROR;
676
+ StringAddChar(c);
677
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_DOT;
676
678
  break;
677
679
 
678
- case GRPC_JSON_STATE_VALUE_NUMBER_DOT:
679
- json_reader_string_add_char(reader, c);
680
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_DOT:
681
+ StringAddChar(c);
680
682
  switch (c) {
681
683
  case '0':
682
684
  case '1':
@@ -688,15 +690,15 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
688
690
  case '7':
689
691
  case '8':
690
692
  case '9':
691
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL;
693
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_WITH_DECIMAL;
692
694
  break;
693
695
  default:
694
- return GRPC_JSON_PARSE_ERROR;
696
+ return Status::GRPC_JSON_PARSE_ERROR;
695
697
  }
696
698
  break;
697
699
 
698
- case GRPC_JSON_STATE_VALUE_NUMBER_E:
699
- json_reader_string_add_char(reader, c);
700
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_E:
701
+ StringAddChar(c);
700
702
  switch (c) {
701
703
  case '0':
702
704
  case '1':
@@ -710,15 +712,15 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
710
712
  case '9':
711
713
  case '+':
712
714
  case '-':
713
- reader->state = GRPC_JSON_STATE_VALUE_NUMBER_EPM;
715
+ state_ = State::GRPC_JSON_STATE_VALUE_NUMBER_EPM;
714
716
  break;
715
717
  default:
716
- return GRPC_JSON_PARSE_ERROR;
718
+ return Status::GRPC_JSON_PARSE_ERROR;
717
719
  }
718
720
  break;
719
721
 
720
- case GRPC_JSON_STATE_VALUE_NUMBER_EPM:
721
- json_reader_string_add_char(reader, c);
722
+ case State::GRPC_JSON_STATE_VALUE_NUMBER_EPM:
723
+ StringAddChar(c);
722
724
  switch (c) {
723
725
  case '0':
724
726
  case '1':
@@ -732,110 +734,122 @@ static grpc_json_reader_status grpc_json_reader_run(grpc_json_reader* reader) {
732
734
  case '9':
733
735
  break;
734
736
  default:
735
- return GRPC_JSON_PARSE_ERROR;
737
+ return Status::GRPC_JSON_PARSE_ERROR;
736
738
  }
737
739
  break;
738
740
 
739
- case GRPC_JSON_STATE_VALUE_TRUE_R:
740
- if (c != 'r') return GRPC_JSON_PARSE_ERROR;
741
- reader->state = GRPC_JSON_STATE_VALUE_TRUE_U;
741
+ case State::GRPC_JSON_STATE_VALUE_TRUE_R:
742
+ if (c != 'r') return Status::GRPC_JSON_PARSE_ERROR;
743
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_U;
742
744
  break;
743
745
 
744
- case GRPC_JSON_STATE_VALUE_TRUE_U:
745
- if (c != 'u') return GRPC_JSON_PARSE_ERROR;
746
- reader->state = GRPC_JSON_STATE_VALUE_TRUE_E;
746
+ case State::GRPC_JSON_STATE_VALUE_TRUE_U:
747
+ if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
748
+ state_ = State::GRPC_JSON_STATE_VALUE_TRUE_E;
747
749
  break;
748
750
 
749
- case GRPC_JSON_STATE_VALUE_TRUE_E:
750
- if (c != 'e') return GRPC_JSON_PARSE_ERROR;
751
- json_reader_set_true(reader);
752
- reader->state = GRPC_JSON_STATE_VALUE_END;
751
+ case State::GRPC_JSON_STATE_VALUE_TRUE_E:
752
+ if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
753
+ SetTrue();
754
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
753
755
  break;
754
756
 
755
- case GRPC_JSON_STATE_VALUE_FALSE_A:
756
- if (c != 'a') return GRPC_JSON_PARSE_ERROR;
757
- reader->state = GRPC_JSON_STATE_VALUE_FALSE_L;
757
+ case State::GRPC_JSON_STATE_VALUE_FALSE_A:
758
+ if (c != 'a') return Status::GRPC_JSON_PARSE_ERROR;
759
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_L;
758
760
  break;
759
761
 
760
- case GRPC_JSON_STATE_VALUE_FALSE_L:
761
- if (c != 'l') return GRPC_JSON_PARSE_ERROR;
762
- reader->state = GRPC_JSON_STATE_VALUE_FALSE_S;
762
+ case State::GRPC_JSON_STATE_VALUE_FALSE_L:
763
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
764
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_S;
763
765
  break;
764
766
 
765
- case GRPC_JSON_STATE_VALUE_FALSE_S:
766
- if (c != 's') return GRPC_JSON_PARSE_ERROR;
767
- reader->state = GRPC_JSON_STATE_VALUE_FALSE_E;
767
+ case State::GRPC_JSON_STATE_VALUE_FALSE_S:
768
+ if (c != 's') return Status::GRPC_JSON_PARSE_ERROR;
769
+ state_ = State::GRPC_JSON_STATE_VALUE_FALSE_E;
768
770
  break;
769
771
 
770
- case GRPC_JSON_STATE_VALUE_FALSE_E:
771
- if (c != 'e') return GRPC_JSON_PARSE_ERROR;
772
- json_reader_set_false(reader);
773
- reader->state = GRPC_JSON_STATE_VALUE_END;
772
+ case State::GRPC_JSON_STATE_VALUE_FALSE_E:
773
+ if (c != 'e') return Status::GRPC_JSON_PARSE_ERROR;
774
+ SetFalse();
775
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
774
776
  break;
775
777
 
776
- case GRPC_JSON_STATE_VALUE_NULL_U:
777
- if (c != 'u') return GRPC_JSON_PARSE_ERROR;
778
- reader->state = GRPC_JSON_STATE_VALUE_NULL_L1;
778
+ case State::GRPC_JSON_STATE_VALUE_NULL_U:
779
+ if (c != 'u') return Status::GRPC_JSON_PARSE_ERROR;
780
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_L1;
779
781
  break;
780
782
 
781
- case GRPC_JSON_STATE_VALUE_NULL_L1:
782
- if (c != 'l') return GRPC_JSON_PARSE_ERROR;
783
- reader->state = GRPC_JSON_STATE_VALUE_NULL_L2;
783
+ case State::GRPC_JSON_STATE_VALUE_NULL_L1:
784
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
785
+ state_ = State::GRPC_JSON_STATE_VALUE_NULL_L2;
784
786
  break;
785
787
 
786
- case GRPC_JSON_STATE_VALUE_NULL_L2:
787
- if (c != 'l') return GRPC_JSON_PARSE_ERROR;
788
- json_reader_set_null(reader);
789
- reader->state = GRPC_JSON_STATE_VALUE_END;
788
+ case State::GRPC_JSON_STATE_VALUE_NULL_L2:
789
+ if (c != 'l') return Status::GRPC_JSON_PARSE_ERROR;
790
+ SetNull();
791
+ state_ = State::GRPC_JSON_STATE_VALUE_END;
790
792
  break;
791
793
 
792
794
  /* All of the VALUE_END cases are handled in the specialized case
793
795
  * above. */
794
- case GRPC_JSON_STATE_VALUE_END:
796
+ case State::GRPC_JSON_STATE_VALUE_END:
795
797
  switch (c) {
796
798
  case ',':
797
799
  case '}':
798
800
  case ']':
799
- GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR);
801
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
800
802
  break;
801
803
 
802
804
  default:
803
- return GRPC_JSON_PARSE_ERROR;
805
+ return Status::GRPC_JSON_PARSE_ERROR;
804
806
  }
805
807
  break;
806
808
 
807
- case GRPC_JSON_STATE_END:
808
- return GRPC_JSON_PARSE_ERROR;
809
+ case State::GRPC_JSON_STATE_END:
810
+ return Status::GRPC_JSON_PARSE_ERROR;
809
811
  }
810
812
  }
811
813
  }
812
814
 
813
- GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR);
815
+ GPR_UNREACHABLE_CODE(return Status::GRPC_JSON_INTERNAL_ERROR);
814
816
  }
815
817
 
816
- /* And finally, let's define our public API. */
817
- grpc_json* grpc_json_parse_string_with_len(char* input, size_t size) {
818
- if (input == nullptr) return nullptr;
819
- // Initialize reader.
820
- grpc_json_reader reader;
821
- memset(&reader, 0, sizeof(reader));
822
- reader.string_ptr = reader.input = reinterpret_cast<uint8_t*>(input);
823
- reader.remaining_input = size;
824
- json_reader_string_clear(&reader);
825
- reader.state = GRPC_JSON_STATE_VALUE_BEGIN;
826
- // Perform read.
827
- grpc_json_reader_status status = grpc_json_reader_run(&reader);
828
- // Process results.
829
- grpc_json* json = reader.top;
830
- if ((status != GRPC_JSON_DONE) && json != nullptr) {
831
- grpc_json_destroy(json);
832
- json = nullptr;
818
+ grpc_error* JsonReader::Parse(StringView input, Json* output) {
819
+ JsonReader reader(input);
820
+ Status status = reader.Run();
821
+ if (reader.truncated_errors_) {
822
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
823
+ "too many errors encountered during JSON parsing -- fix reported "
824
+ "errors and try again to see additional errors"));
833
825
  }
834
- return json;
826
+ if (status == Status::GRPC_JSON_INTERNAL_ERROR) {
827
+ char* msg;
828
+ gpr_asprintf(&msg, "internal error in JSON parser at index %" PRIuPTR,
829
+ reader.CurrentIndex());
830
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
831
+ gpr_free(msg);
832
+ } else if (status == Status::GRPC_JSON_PARSE_ERROR) {
833
+ char* msg;
834
+ gpr_asprintf(&msg, "JSON parse error at index %" PRIuPTR,
835
+ reader.CurrentIndex());
836
+ reader.errors_.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
837
+ gpr_free(msg);
838
+ }
839
+ if (!reader.errors_.empty()) {
840
+ return GRPC_ERROR_CREATE_FROM_VECTOR("JSON parsing failed",
841
+ &reader.errors_);
842
+ }
843
+ *output = std::move(reader.root_value_);
844
+ return GRPC_ERROR_NONE;
835
845
  }
836
846
 
837
- #define UNBOUND_JSON_STRING_LENGTH 0x7fffffff
847
+ } // namespace
838
848
 
839
- grpc_json* grpc_json_parse_string(char* input) {
840
- return grpc_json_parse_string_with_len(input, UNBOUND_JSON_STRING_LENGTH);
849
+ Json Json::Parse(StringView json_str, grpc_error** error) {
850
+ Json value;
851
+ *error = JsonReader::Parse(json_str, &value);
852
+ return value;
841
853
  }
854
+
855
+ } // namespace grpc_core