grpc 1.36.0 → 1.37.0.pre1

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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +65 -37
  3. data/include/grpc/grpc.h +15 -1
  4. data/include/grpc/impl/codegen/port_platform.h +2 -0
  5. data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
  6. data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
  7. data/src/core/ext/filters/client_channel/config_selector.h +8 -0
  8. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
  9. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
  10. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
  11. data/src/core/ext/filters/client_channel/lb_policy.cc +3 -0
  12. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +7 -22
  15. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
  17. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
  18. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
  19. data/src/core/ext/filters/client_channel/resolver.cc +3 -0
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
  23. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
  24. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
  25. data/src/core/ext/filters/client_channel/server_address.cc +3 -0
  26. data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
  27. data/src/core/ext/filters/client_channel/subchannel.h +63 -95
  28. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
  29. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
  30. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  31. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
  32. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
  33. data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
  34. data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
  35. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
  36. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  37. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
  38. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  39. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
  40. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
  41. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
  42. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
  43. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
  44. data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
  45. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  46. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  47. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
  48. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
  49. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
  50. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
  51. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
  52. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
  53. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
  54. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
  55. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
  56. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
  57. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -0
  58. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -0
  59. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
  60. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
  61. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
  62. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
  63. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
  64. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
  65. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +6 -5
  66. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
  67. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
  68. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
  69. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
  70. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
  71. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
  72. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
  73. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
  74. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
  75. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
  76. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
  77. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
  78. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
  79. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
  80. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
  81. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
  82. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
  83. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
  84. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
  85. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +13 -7
  86. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  87. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
  88. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
  89. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
  90. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
  91. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
  92. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
  93. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +21 -20
  94. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
  95. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
  96. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
  97. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
  98. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
  99. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
  100. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
  101. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
  102. data/src/core/ext/xds/xds_api.cc +1591 -279
  103. data/src/core/ext/xds/xds_api.h +279 -39
  104. data/src/core/ext/xds/xds_bootstrap.cc +21 -5
  105. data/src/core/ext/xds/xds_bootstrap.h +5 -1
  106. data/src/core/ext/xds/xds_client.cc +168 -23
  107. data/src/core/ext/xds/xds_client.h +26 -0
  108. data/src/core/ext/xds/xds_client_stats.h +2 -2
  109. data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
  110. data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
  111. data/src/core/ext/xds/xds_http_filters.cc +114 -0
  112. data/src/core/ext/xds/xds_http_filters.h +130 -0
  113. data/src/core/ext/xds/xds_server_config_fetcher.cc +391 -126
  114. data/src/core/lib/channel/channel_stack.cc +12 -0
  115. data/src/core/lib/channel/channel_stack.h +7 -0
  116. data/src/core/lib/channel/channelz.cc +92 -4
  117. data/src/core/lib/channel/channelz.h +30 -1
  118. data/src/core/lib/channel/channelz_registry.cc +14 -0
  119. data/src/core/lib/channel/handshaker.cc +0 -39
  120. data/src/core/lib/channel/handshaker.h +0 -17
  121. data/src/core/lib/channel/status_util.cc +12 -2
  122. data/src/core/lib/channel/status_util.h +5 -0
  123. data/src/core/lib/gpr/sync_abseil.cc +3 -6
  124. data/src/core/lib/gpr/sync_windows.cc +2 -2
  125. data/src/core/lib/gprpp/atomic.h +3 -3
  126. data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
  127. data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
  128. data/src/core/lib/gprpp/thd.h +1 -1
  129. data/src/core/lib/iomgr/buffer_list.h +1 -1
  130. data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
  131. data/src/core/lib/iomgr/error.h +1 -1
  132. data/src/core/lib/iomgr/ev_apple.cc +1 -1
  133. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
  134. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  135. data/src/core/lib/iomgr/exec_ctx.cc +6 -2
  136. data/src/core/lib/iomgr/resource_quota.cc +1 -1
  137. data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
  138. data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
  139. data/src/core/lib/iomgr/tcp_posix.cc +1 -4
  140. data/src/core/lib/iomgr/tcp_uv.cc +2 -2
  141. data/src/core/lib/iomgr/timer_generic.cc +2 -2
  142. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  143. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  144. data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
  145. data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
  146. data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
  147. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
  148. data/src/core/lib/security/transport/security_handshaker.cc +32 -2
  149. data/src/core/lib/slice/slice_intern.cc +6 -7
  150. data/src/core/lib/surface/channel.h +3 -3
  151. data/src/core/lib/surface/completion_queue.cc +1 -1
  152. data/src/core/lib/surface/lame_client.cc +38 -19
  153. data/src/core/lib/surface/lame_client.h +4 -3
  154. data/src/core/lib/surface/server.cc +40 -33
  155. data/src/core/lib/surface/server.h +74 -15
  156. data/src/core/lib/surface/version.cc +1 -1
  157. data/src/core/lib/transport/metadata_batch.cc +27 -0
  158. data/src/core/lib/transport/metadata_batch.h +14 -0
  159. data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
  160. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
  161. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  162. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
  163. data/src/core/tsi/fake_transport_security.cc +10 -1
  164. data/src/ruby/ext/grpc/extconf.rb +9 -1
  165. data/src/ruby/ext/grpc/rb_channel.c +10 -1
  166. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
  167. data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
  168. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  169. data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
  170. data/src/ruby/ext/grpc/rb_grpc.c +4 -0
  171. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  172. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  173. data/src/ruby/ext/grpc/rb_server.c +13 -1
  174. data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
  175. data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
  176. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
  177. data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
  178. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
  179. data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
  180. data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
  181. data/src/ruby/lib/grpc/version.rb +1 -1
  182. data/src/ruby/spec/call_spec.rb +1 -1
  183. data/src/ruby/spec/channel_credentials_spec.rb +32 -0
  184. data/src/ruby/spec/channel_spec.rb +17 -6
  185. data/src/ruby/spec/client_auth_spec.rb +27 -1
  186. data/src/ruby/spec/errors_spec.rb +1 -1
  187. data/src/ruby/spec/generic/active_call_spec.rb +2 -2
  188. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  189. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
  190. data/src/ruby/spec/server_credentials_spec.rb +25 -0
  191. data/src/ruby/spec/server_spec.rb +22 -0
  192. data/third_party/boringssl-with-bazel/err_data.c +255 -255
  193. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
  194. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
  195. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
  196. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
  197. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
  198. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  200. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
  201. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
  202. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
  203. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
  204. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
  205. data/third_party/xxhash/xxhash.h +5443 -0
  206. metadata +93 -49
  207. data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
  208. data/src/core/lib/security/authorization/authorization_engine.h +0 -84
  209. data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
  210. data/src/core/lib/security/authorization/evaluate_args.h +0 -59
  211. data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
  212. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
  213. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
  214. data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -99
  215. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
  216. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
  217. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
  218. data/third_party/upb/upb/json_decode.c +0 -1443
  219. data/third_party/upb/upb/json_decode.h +0 -23
  220. data/third_party/upb/upb/json_encode.c +0 -713
  221. data/third_party/upb/upb/json_encode.h +0 -36
@@ -1,23 +0,0 @@
1
-
2
- #ifndef UPB_JSONDECODE_H_
3
- #define UPB_JSONDECODE_H_
4
-
5
- #include "upb/def.h"
6
-
7
- #ifdef __cplusplus
8
- extern "C" {
9
- #endif
10
-
11
- enum {
12
- UPB_JSONDEC_IGNOREUNKNOWN = 1
13
- };
14
-
15
- bool upb_json_decode(const char *buf, size_t size, upb_msg *msg,
16
- const upb_msgdef *m, const upb_symtab *any_pool,
17
- int options, upb_arena *arena, upb_status *status);
18
-
19
- #ifdef __cplusplus
20
- } /* extern "C" */
21
- #endif
22
-
23
- #endif /* UPB_JSONDECODE_H_ */
@@ -1,713 +0,0 @@
1
-
2
- #include "upb/json_encode.h"
3
-
4
- #include <ctype.h>
5
- #include <float.h>
6
- #include <inttypes.h>
7
- #include <math.h>
8
- #include <setjmp.h>
9
- #include <stdarg.h>
10
- #include <stdio.h>
11
- #include <string.h>
12
-
13
- #include "upb/decode.h"
14
- #include "upb/reflection.h"
15
-
16
- /* Must be last. */
17
- #include "upb/port_def.inc"
18
-
19
- typedef struct {
20
- char *buf, *ptr, *end;
21
- size_t overflow;
22
- int indent_depth;
23
- int options;
24
- const upb_symtab *ext_pool;
25
- jmp_buf err;
26
- upb_status *status;
27
- upb_arena *arena;
28
- } jsonenc;
29
-
30
- static void jsonenc_msg(jsonenc *e, const upb_msg *msg, const upb_msgdef *m);
31
- static void jsonenc_scalar(jsonenc *e, upb_msgval val, const upb_fielddef *f);
32
- static void jsonenc_msgfield(jsonenc *e, const upb_msg *msg,
33
- const upb_msgdef *m);
34
- static void jsonenc_msgfields(jsonenc *e, const upb_msg *msg,
35
- const upb_msgdef *m);
36
- static void jsonenc_value(jsonenc *e, const upb_msg *msg, const upb_msgdef *m);
37
-
38
- UPB_NORETURN static void jsonenc_err(jsonenc *e, const char *msg) {
39
- upb_status_seterrmsg(e->status, msg);
40
- longjmp(e->err, 1);
41
- }
42
-
43
- UPB_NORETURN static void jsonenc_errf(jsonenc *e, const char *fmt, ...) {
44
- va_list argp;
45
- va_start(argp, fmt);
46
- upb_status_vseterrf(e->status, fmt, argp);
47
- va_end(argp);
48
- longjmp(e->err, 1);
49
- }
50
-
51
- static upb_arena *jsonenc_arena(jsonenc *e) {
52
- /* Create lazily, since it's only needed for Any */
53
- if (!e->arena) {
54
- e->arena = upb_arena_new();
55
- }
56
- return e->arena;
57
- }
58
-
59
- static void jsonenc_putbytes(jsonenc *e, const void *data, size_t len) {
60
- size_t have = e->end - e->ptr;
61
- if (UPB_LIKELY(have >= len)) {
62
- memcpy(e->ptr, data, len);
63
- e->ptr += len;
64
- } else {
65
- if (have) memcpy(e->ptr, data, have);
66
- e->ptr += have;
67
- e->overflow += (len - have);
68
- }
69
- }
70
-
71
- static void jsonenc_putstr(jsonenc *e, const char *str) {
72
- jsonenc_putbytes(e, str, strlen(str));
73
- }
74
-
75
- static void jsonenc_printf(jsonenc *e, const char *fmt, ...) {
76
- size_t n;
77
- size_t have = e->end - e->ptr;
78
- va_list args;
79
-
80
- va_start(args, fmt);
81
- n = vsnprintf(e->ptr, have, fmt, args);
82
- va_end(args);
83
-
84
- if (UPB_LIKELY(have > n)) {
85
- e->ptr += n;
86
- } else {
87
- e->ptr += have;
88
- e->overflow += (n - have);
89
- }
90
- }
91
-
92
- static void jsonenc_nanos(jsonenc *e, int32_t nanos) {
93
- int digits = 9;
94
-
95
- if (nanos == 0) return;
96
- if (nanos < 0 || nanos >= 1000000000) {
97
- jsonenc_err(e, "error formatting timestamp as JSON: invalid nanos");
98
- }
99
-
100
- while (nanos % 1000 == 0) {
101
- nanos /= 1000;
102
- digits -= 3;
103
- }
104
-
105
- jsonenc_printf(e, ".%0.*" PRId32, digits, nanos);
106
- }
107
-
108
- static void jsonenc_timestamp(jsonenc *e, const upb_msg *msg,
109
- const upb_msgdef *m) {
110
- const upb_fielddef *seconds_f = upb_msgdef_itof(m, 1);
111
- const upb_fielddef *nanos_f = upb_msgdef_itof(m, 2);
112
- int64_t seconds = upb_msg_get(msg, seconds_f).int64_val;
113
- int32_t nanos = upb_msg_get(msg, nanos_f).int32_val;
114
- int L, N, I, J, K, hour, min, sec;
115
-
116
- if (seconds < -62135596800) {
117
- jsonenc_err(e,
118
- "error formatting timestamp as JSON: minimum acceptable value "
119
- "is 0001-01-01T00:00:00Z");
120
- } else if (seconds > 253402300799) {
121
- jsonenc_err(e,
122
- "error formatting timestamp as JSON: maximum acceptable value "
123
- "is 9999-12-31T23:59:59Z");
124
- }
125
-
126
- /* Julian Day -> Y/M/D, Algorithm from:
127
- * Fliegel, H. F., and Van Flandern, T. C., "A Machine Algorithm for
128
- * Processing Calendar Dates," Communications of the Association of
129
- * Computing Machines, vol. 11 (1968), p. 657. */
130
- L = (int)(seconds / 86400) + 68569 + 2440588;
131
- N = 4 * L / 146097;
132
- L = L - (146097 * N + 3) / 4;
133
- I = 4000 * (L + 1) / 1461001;
134
- L = L - 1461 * I / 4 + 31;
135
- J = 80 * L / 2447;
136
- K = L - 2447 * J / 80;
137
- L = J / 11;
138
- J = J + 2 - 12 * L;
139
- I = 100 * (N - 49) + I + L;
140
-
141
- sec = seconds % 60;
142
- min = (seconds / 60) % 60;
143
- hour = (seconds / 3600) % 24;
144
-
145
- jsonenc_printf(e, "\"%04d-%02d-%02dT%02d:%02d:%02d", I, J, K, hour, min, sec);
146
- jsonenc_nanos(e, nanos);
147
- jsonenc_putstr(e, "Z\"");
148
- }
149
-
150
- static void jsonenc_duration(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
151
- const upb_fielddef *seconds_f = upb_msgdef_itof(m, 1);
152
- const upb_fielddef *nanos_f = upb_msgdef_itof(m, 2);
153
- int64_t seconds = upb_msg_get(msg, seconds_f).int64_val;
154
- int32_t nanos = upb_msg_get(msg, nanos_f).int32_val;
155
-
156
- if (seconds > 315576000000 || seconds < -315576000000 ||
157
- (seconds < 0) != (nanos < 0)) {
158
- jsonenc_err(e, "bad duration");
159
- }
160
-
161
- if (nanos < 0) {
162
- nanos = -nanos;
163
- }
164
-
165
- jsonenc_printf(e, "\"%" PRId64, seconds);
166
- jsonenc_nanos(e, nanos);
167
- jsonenc_putstr(e, "s\"");
168
- }
169
-
170
- static void jsonenc_enum(int32_t val, const upb_fielddef *f, jsonenc *e) {
171
- const upb_enumdef *e_def = upb_fielddef_enumsubdef(f);
172
-
173
- if (strcmp(upb_enumdef_fullname(e_def), "google.protobuf.NullValue") == 0) {
174
- jsonenc_putstr(e, "null");
175
- } else {
176
- const char *name = upb_enumdef_iton(e_def, val);
177
-
178
- if (name) {
179
- jsonenc_printf(e, "\"%s\"", name);
180
- } else {
181
- jsonenc_printf(e, "%" PRId32, val);
182
- }
183
- }
184
- }
185
-
186
- static void jsonenc_bytes(jsonenc *e, upb_strview str) {
187
- /* This is the regular base64, not the "web-safe" version. */
188
- static const char base64[] =
189
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
190
- const unsigned char *ptr = (unsigned char*)str.data;
191
- const unsigned char *end = ptr + str.size;
192
- char buf[4];
193
-
194
- jsonenc_putstr(e, "\"");
195
-
196
- while (end - ptr >= 3) {
197
- buf[0] = base64[ptr[0] >> 2];
198
- buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)];
199
- buf[2] = base64[((ptr[1] & 0xf) << 2) | (ptr[2] >> 6)];
200
- buf[3] = base64[ptr[2] & 0x3f];
201
- jsonenc_putbytes(e, buf, 4);
202
- ptr += 3;
203
- }
204
-
205
- switch (end - ptr) {
206
- case 2:
207
- buf[0] = base64[ptr[0] >> 2];
208
- buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)];
209
- buf[2] = base64[(ptr[1] & 0xf) << 2];
210
- buf[3] = '=';
211
- jsonenc_putbytes(e, buf, 4);
212
- break;
213
- case 1:
214
- buf[0] = base64[ptr[0] >> 2];
215
- buf[1] = base64[((ptr[0] & 0x3) << 4)];
216
- buf[2] = '=';
217
- buf[3] = '=';
218
- jsonenc_putbytes(e, buf, 4);
219
- break;
220
- }
221
-
222
- jsonenc_putstr(e, "\"");
223
- }
224
-
225
- static void jsonenc_stringbody(jsonenc *e, upb_strview str) {
226
- const char *ptr = str.data;
227
- const char *end = ptr + str.size;
228
-
229
- while (ptr < end) {
230
- switch (*ptr) {
231
- case '\n':
232
- jsonenc_putstr(e, "\\n");
233
- break;
234
- case '\r':
235
- jsonenc_putstr(e, "\\r");
236
- break;
237
- case '\t':
238
- jsonenc_putstr(e, "\\t");
239
- break;
240
- case '\"':
241
- jsonenc_putstr(e, "\\\"");
242
- break;
243
- case '\f':
244
- jsonenc_putstr(e, "\\f");
245
- break;
246
- case '\b':
247
- jsonenc_putstr(e, "\\b");
248
- break;
249
- case '\\':
250
- jsonenc_putstr(e, "\\\\");
251
- break;
252
- default:
253
- if ((uint8_t)*ptr < 0x20) {
254
- jsonenc_printf(e, "\\u%04x", (int)(uint8_t)*ptr);
255
- } else {
256
- /* This could be a non-ASCII byte. We rely on the string being valid
257
- * UTF-8. */
258
- jsonenc_putbytes(e, ptr, 1);
259
- }
260
- break;
261
- }
262
- ptr++;
263
- }
264
- }
265
-
266
- static void jsonenc_string(jsonenc *e, upb_strview str) {
267
- jsonenc_putstr(e, "\"");
268
- jsonenc_stringbody(e, str);
269
- jsonenc_putstr(e, "\"");
270
- }
271
-
272
- static void jsonenc_double(jsonenc *e, const char *fmt, double val) {
273
- if (val == INFINITY) {
274
- jsonenc_putstr(e, "\"Infinity\"");
275
- } else if (val == -INFINITY) {
276
- jsonenc_putstr(e, "\"-Infinity\"");
277
- } else if (val != val) {
278
- jsonenc_putstr(e, "\"NaN\"");
279
- } else {
280
- jsonenc_printf(e, fmt, val);
281
- }
282
- }
283
-
284
- static void jsonenc_wrapper(jsonenc *e, const upb_msg *msg,
285
- const upb_msgdef *m) {
286
- const upb_fielddef *val_f = upb_msgdef_itof(m, 1);
287
- upb_msgval val = upb_msg_get(msg, val_f);
288
- jsonenc_scalar(e, val, val_f);
289
- }
290
-
291
- static const upb_msgdef *jsonenc_getanymsg(jsonenc *e, upb_strview type_url) {
292
- /* Find last '/', if any. */
293
- const char *end = type_url.data + type_url.size;
294
- const char *ptr = end;
295
- const upb_msgdef *ret;
296
-
297
- if (!e->ext_pool) {
298
- jsonenc_err(e, "Tried to encode Any, but no symtab was provided");
299
- }
300
-
301
- if (type_url.size == 0) goto badurl;
302
-
303
- while (true) {
304
- if (--ptr == type_url.data) {
305
- /* Type URL must contain at least one '/', with host before. */
306
- goto badurl;
307
- }
308
- if (*ptr == '/') {
309
- ptr++;
310
- break;
311
- }
312
- }
313
-
314
- ret = upb_symtab_lookupmsg2(e->ext_pool, ptr, end - ptr);
315
-
316
- if (!ret) {
317
- jsonenc_errf(e, "Couldn't find Any type: %.*s", (int)(end - ptr), ptr);
318
- }
319
-
320
- return ret;
321
-
322
- badurl:
323
- jsonenc_errf(
324
- e, "Bad type URL: " UPB_STRVIEW_FORMAT, UPB_STRVIEW_ARGS(type_url));
325
- }
326
-
327
- static void jsonenc_any(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
328
- const upb_fielddef *type_url_f = upb_msgdef_itof(m, 1);
329
- const upb_fielddef *value_f = upb_msgdef_itof(m, 2);
330
- upb_strview type_url = upb_msg_get(msg, type_url_f).str_val;
331
- upb_strview value = upb_msg_get(msg, value_f).str_val;
332
- const upb_msgdef *any_m = jsonenc_getanymsg(e, type_url);
333
- const upb_msglayout *any_layout = upb_msgdef_layout(any_m);
334
- upb_arena *arena = jsonenc_arena(e);
335
- upb_msg *any = upb_msg_new(any_m, arena);
336
-
337
- if (!upb_decode(value.data, value.size, any, any_layout, arena)) {
338
- jsonenc_err(e, "Error decoding message in Any");
339
- }
340
-
341
- jsonenc_putstr(e, "{\"@type\":");
342
- jsonenc_string(e, type_url);
343
- jsonenc_putstr(e, ",");
344
-
345
- if (upb_msgdef_wellknowntype(any_m) == UPB_WELLKNOWN_UNSPECIFIED) {
346
- /* Regular messages: {"@type": "...","foo": 1, "bar": 2} */
347
- jsonenc_msgfields(e, any, any_m);
348
- } else {
349
- /* Well-known type: {"@type": "...","value": <well-known encoding>} */
350
- jsonenc_putstr(e, "\"value\":");
351
- jsonenc_msgfield(e, any, any_m);
352
- }
353
-
354
- jsonenc_putstr(e, "}");
355
- }
356
-
357
- static void jsonenc_putsep(jsonenc *e, const char *str, bool *first) {
358
- if (*first) {
359
- *first = false;
360
- } else {
361
- jsonenc_putstr(e, str);
362
- }
363
- }
364
-
365
- static void jsonenc_fieldpath(jsonenc *e, upb_strview path) {
366
- const char *ptr = path.data;
367
- const char *end = ptr + path.size;
368
-
369
- while (ptr < end) {
370
- char ch = *ptr;
371
-
372
- if (ch >= 'A' && ch <= 'Z') {
373
- jsonenc_err(e, "Field mask element may not have upper-case letter.");
374
- } else if (ch == '_') {
375
- if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') {
376
- jsonenc_err(e, "Underscore must be followed by a lowercase letter.");
377
- }
378
- ch = *++ptr - 32;
379
- }
380
-
381
- jsonenc_putbytes(e, &ch, 1);
382
- ptr++;
383
- }
384
- }
385
-
386
- static void jsonenc_fieldmask(jsonenc *e, const upb_msg *msg,
387
- const upb_msgdef *m) {
388
- const upb_fielddef *paths_f = upb_msgdef_itof(m, 1);
389
- const upb_array *paths = upb_msg_get(msg, paths_f).array_val;
390
- bool first = true;
391
- size_t i, n = 0;
392
-
393
- if (paths) n = upb_array_size(paths);
394
-
395
- jsonenc_putstr(e, "\"");
396
-
397
- for (i = 0; i < n; i++) {
398
- jsonenc_putsep(e, ",", &first);
399
- jsonenc_fieldpath(e, upb_array_get(paths, i).str_val);
400
- }
401
-
402
- jsonenc_putstr(e, "\"");
403
- }
404
-
405
- static void jsonenc_struct(jsonenc *e, const upb_msg *msg,
406
- const upb_msgdef *m) {
407
- const upb_fielddef *fields_f = upb_msgdef_itof(m, 1);
408
- const upb_map *fields = upb_msg_get(msg, fields_f).map_val;
409
- const upb_msgdef *entry_m = upb_fielddef_msgsubdef(fields_f);
410
- const upb_fielddef *value_f = upb_msgdef_itof(entry_m, 2);
411
- size_t iter = UPB_MAP_BEGIN;
412
- bool first = true;
413
-
414
- jsonenc_putstr(e, "{");
415
-
416
- if (fields) {
417
- while (upb_mapiter_next(fields, &iter)) {
418
- upb_msgval key = upb_mapiter_key(fields, iter);
419
- upb_msgval val = upb_mapiter_value(fields, iter);
420
-
421
- jsonenc_putsep(e, ",", &first);
422
- jsonenc_string(e, key.str_val);
423
- jsonenc_putstr(e, ":");
424
- jsonenc_value(e, val.msg_val, upb_fielddef_msgsubdef(value_f));
425
- }
426
- }
427
-
428
- jsonenc_putstr(e, "}");
429
- }
430
-
431
- static void jsonenc_listvalue(jsonenc *e, const upb_msg *msg,
432
- const upb_msgdef *m) {
433
- const upb_fielddef *values_f = upb_msgdef_itof(m, 1);
434
- const upb_msgdef *values_m = upb_fielddef_msgsubdef(values_f);
435
- const upb_array *values = upb_msg_get(msg, values_f).array_val;
436
- size_t i;
437
- bool first = true;
438
-
439
- jsonenc_putstr(e, "[");
440
-
441
- if (values) {
442
- const size_t size = upb_array_size(values);
443
- for (i = 0; i < size; i++) {
444
- upb_msgval elem = upb_array_get(values, i);
445
-
446
- jsonenc_putsep(e, ",", &first);
447
- jsonenc_value(e, elem.msg_val, values_m);
448
- }
449
- }
450
-
451
- jsonenc_putstr(e, "]");
452
- }
453
-
454
- static void jsonenc_value(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
455
- /* TODO(haberman): do we want a reflection method to get oneof case? */
456
- size_t iter = UPB_MSG_BEGIN;
457
- const upb_fielddef *f;
458
- upb_msgval val;
459
-
460
- if (!upb_msg_next(msg, m, NULL, &f, &val, &iter)) {
461
- jsonenc_err(e, "No value set in Value proto");
462
- }
463
-
464
- switch (upb_fielddef_number(f)) {
465
- case 1:
466
- jsonenc_putstr(e, "null");
467
- break;
468
- case 2:
469
- jsonenc_double(e, "%.17g", val.double_val);
470
- break;
471
- case 3:
472
- jsonenc_string(e, val.str_val);
473
- break;
474
- case 4:
475
- jsonenc_putstr(e, val.bool_val ? "true" : "false");
476
- break;
477
- case 5:
478
- jsonenc_struct(e, val.msg_val, upb_fielddef_msgsubdef(f));
479
- break;
480
- case 6:
481
- jsonenc_listvalue(e, val.msg_val, upb_fielddef_msgsubdef(f));
482
- break;
483
- }
484
- }
485
-
486
- static void jsonenc_msgfield(jsonenc *e, const upb_msg *msg,
487
- const upb_msgdef *m) {
488
- switch (upb_msgdef_wellknowntype(m)) {
489
- case UPB_WELLKNOWN_UNSPECIFIED:
490
- jsonenc_msg(e, msg, m);
491
- break;
492
- case UPB_WELLKNOWN_ANY:
493
- jsonenc_any(e, msg, m);
494
- break;
495
- case UPB_WELLKNOWN_FIELDMASK:
496
- jsonenc_fieldmask(e, msg, m);
497
- break;
498
- case UPB_WELLKNOWN_DURATION:
499
- jsonenc_duration(e, msg, m);
500
- break;
501
- case UPB_WELLKNOWN_TIMESTAMP:
502
- jsonenc_timestamp(e, msg, m);
503
- break;
504
- case UPB_WELLKNOWN_DOUBLEVALUE:
505
- case UPB_WELLKNOWN_FLOATVALUE:
506
- case UPB_WELLKNOWN_INT64VALUE:
507
- case UPB_WELLKNOWN_UINT64VALUE:
508
- case UPB_WELLKNOWN_INT32VALUE:
509
- case UPB_WELLKNOWN_UINT32VALUE:
510
- case UPB_WELLKNOWN_STRINGVALUE:
511
- case UPB_WELLKNOWN_BYTESVALUE:
512
- case UPB_WELLKNOWN_BOOLVALUE:
513
- jsonenc_wrapper(e, msg, m);
514
- break;
515
- case UPB_WELLKNOWN_VALUE:
516
- jsonenc_value(e, msg, m);
517
- break;
518
- case UPB_WELLKNOWN_LISTVALUE:
519
- jsonenc_listvalue(e, msg, m);
520
- break;
521
- case UPB_WELLKNOWN_STRUCT:
522
- jsonenc_struct(e, msg, m);
523
- break;
524
- }
525
- }
526
-
527
- static void jsonenc_scalar(jsonenc *e, upb_msgval val, const upb_fielddef *f) {
528
- switch (upb_fielddef_type(f)) {
529
- case UPB_TYPE_BOOL:
530
- jsonenc_putstr(e, val.bool_val ? "true" : "false");
531
- break;
532
- case UPB_TYPE_FLOAT:
533
- jsonenc_double(e, "%.9g", val.float_val);
534
- break;
535
- case UPB_TYPE_DOUBLE:
536
- jsonenc_double(e, "%.17g", val.double_val);
537
- break;
538
- case UPB_TYPE_INT32:
539
- jsonenc_printf(e, "%" PRId32, val.int32_val);
540
- break;
541
- case UPB_TYPE_UINT32:
542
- jsonenc_printf(e, "%" PRIu32, val.uint32_val);
543
- break;
544
- case UPB_TYPE_INT64:
545
- jsonenc_printf(e, "\"%" PRId64 "\"", val.int64_val);
546
- break;
547
- case UPB_TYPE_UINT64:
548
- jsonenc_printf(e, "\"%" PRIu64 "\"", val.uint64_val);
549
- break;
550
- case UPB_TYPE_STRING:
551
- jsonenc_string(e, val.str_val);
552
- break;
553
- case UPB_TYPE_BYTES:
554
- jsonenc_bytes(e, val.str_val);
555
- break;
556
- case UPB_TYPE_ENUM:
557
- jsonenc_enum(val.int32_val, f, e);
558
- break;
559
- case UPB_TYPE_MESSAGE:
560
- jsonenc_msgfield(e, val.msg_val, upb_fielddef_msgsubdef(f));
561
- break;
562
- }
563
- }
564
-
565
- static void jsonenc_mapkey(jsonenc *e, upb_msgval val, const upb_fielddef *f) {
566
- jsonenc_putstr(e, "\"");
567
-
568
- switch (upb_fielddef_type(f)) {
569
- case UPB_TYPE_BOOL:
570
- jsonenc_putstr(e, val.bool_val ? "true" : "false");
571
- break;
572
- case UPB_TYPE_INT32:
573
- jsonenc_printf(e, "%" PRId32, val.int32_val);
574
- break;
575
- case UPB_TYPE_UINT32:
576
- jsonenc_printf(e, "%" PRIu32, val.uint32_val);
577
- break;
578
- case UPB_TYPE_INT64:
579
- jsonenc_printf(e, "%" PRId64, val.int64_val);
580
- break;
581
- case UPB_TYPE_UINT64:
582
- jsonenc_printf(e, "%" PRIu64, val.uint64_val);
583
- break;
584
- case UPB_TYPE_STRING:
585
- jsonenc_stringbody(e, val.str_val);
586
- break;
587
- default:
588
- UPB_UNREACHABLE();
589
- }
590
-
591
- jsonenc_putstr(e, "\":");
592
- }
593
-
594
- static void jsonenc_array(jsonenc *e, const upb_array *arr,
595
- const upb_fielddef *f) {
596
- size_t i;
597
- size_t size = arr ? upb_array_size(arr) : 0;
598
- bool first = true;
599
-
600
- jsonenc_putstr(e, "[");
601
-
602
- for (i = 0; i < size; i++) {
603
- jsonenc_putsep(e, ",", &first);
604
- jsonenc_scalar(e, upb_array_get(arr, i), f);
605
- }
606
-
607
- jsonenc_putstr(e, "]");
608
- }
609
-
610
- static void jsonenc_map(jsonenc *e, const upb_map *map, const upb_fielddef *f) {
611
- const upb_msgdef *entry = upb_fielddef_msgsubdef(f);
612
- const upb_fielddef *key_f = upb_msgdef_itof(entry, 1);
613
- const upb_fielddef *val_f = upb_msgdef_itof(entry, 2);
614
- size_t iter = UPB_MAP_BEGIN;
615
- bool first = true;
616
-
617
- jsonenc_putstr(e, "{");
618
-
619
- if (map) {
620
- while (upb_mapiter_next(map, &iter)) {
621
- jsonenc_putsep(e, ",", &first);
622
- jsonenc_mapkey(e, upb_mapiter_key(map, iter), key_f);
623
- jsonenc_scalar(e, upb_mapiter_value(map, iter), val_f);
624
- }
625
- }
626
-
627
- jsonenc_putstr(e, "}");
628
- }
629
-
630
- static void jsonenc_fieldval(jsonenc *e, const upb_fielddef *f,
631
- upb_msgval val, bool *first) {
632
- const char *name;
633
-
634
- if (e->options & UPB_JSONENC_PROTONAMES) {
635
- name = upb_fielddef_name(f);
636
- } else {
637
- name = upb_fielddef_jsonname(f);
638
- }
639
-
640
- jsonenc_putsep(e, ",", first);
641
- jsonenc_printf(e, "\"%s\":", name);
642
-
643
- if (upb_fielddef_ismap(f)) {
644
- jsonenc_map(e, val.map_val, f);
645
- } else if (upb_fielddef_isseq(f)) {
646
- jsonenc_array(e, val.array_val, f);
647
- } else {
648
- jsonenc_scalar(e, val, f);
649
- }
650
- }
651
-
652
- static void jsonenc_msgfields(jsonenc *e, const upb_msg *msg,
653
- const upb_msgdef *m) {
654
- upb_msgval val;
655
- const upb_fielddef *f;
656
- bool first = true;
657
-
658
- if (e->options & UPB_JSONENC_EMITDEFAULTS) {
659
- /* Iterate over all fields. */
660
- int i = 0;
661
- int n = upb_msgdef_fieldcount(m);
662
- for (i = 0; i < n; i++) {
663
- f = upb_msgdef_field(m, i);
664
- if (!upb_fielddef_haspresence(f) || upb_msg_has(msg, f)) {
665
- jsonenc_fieldval(e, f, upb_msg_get(msg, f), &first);
666
- }
667
- }
668
- } else {
669
- /* Iterate over non-empty fields. */
670
- size_t iter = UPB_MSG_BEGIN;
671
- while (upb_msg_next(msg, m, e->ext_pool, &f, &val, &iter)) {
672
- jsonenc_fieldval(e, f, val, &first);
673
- }
674
- }
675
- }
676
-
677
- static void jsonenc_msg(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
678
- jsonenc_putstr(e, "{");
679
- jsonenc_msgfields(e, msg, m);
680
- jsonenc_putstr(e, "}");
681
- }
682
-
683
- static size_t jsonenc_nullz(jsonenc *e, size_t size) {
684
- size_t ret = e->ptr - e->buf + e->overflow;
685
-
686
- if (size > 0) {
687
- if (e->ptr == e->end) e->ptr--;
688
- *e->ptr = '\0';
689
- }
690
-
691
- return ret;
692
- }
693
-
694
- size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
695
- const upb_symtab *ext_pool, int options, char *buf,
696
- size_t size, upb_status *status) {
697
- jsonenc e;
698
-
699
- e.buf = buf;
700
- e.ptr = buf;
701
- e.end = buf + size;
702
- e.overflow = 0;
703
- e.options = options;
704
- e.ext_pool = ext_pool;
705
- e.status = status;
706
- e.arena = NULL;
707
-
708
- if (setjmp(e.err)) return -1;
709
-
710
- jsonenc_msgfield(&e, msg, m);
711
- if (e.arena) upb_arena_free(e.arena);
712
- return jsonenc_nullz(&e, size);
713
- }