grpc 1.34.0 → 1.35.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.
- checksums.yaml +4 -4
- data/Makefile +808 -2787
- data/etc/roots.pem +257 -573
- data/include/grpc/compression.h +1 -1
- data/include/grpc/grpc.h +14 -0
- data/include/grpc/grpc_security.h +61 -3
- data/include/grpc/impl/codegen/atm_windows.h +4 -0
- data/include/grpc/impl/codegen/byte_buffer.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +1 -1
- data/include/grpc/impl/codegen/log.h +0 -2
- data/include/grpc/impl/codegen/sync_windows.h +4 -0
- data/include/grpc/slice_buffer.h +3 -3
- data/include/grpc/support/sync.h +3 -3
- data/include/grpc/support/time.h +7 -7
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -4
- data/src/core/ext/filters/client_channel/client_channel.cc +2734 -1498
- data/src/core/ext/filters/client_channel/client_channel.h +0 -4
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
- data/src/core/ext/filters/client_channel/config_selector.h +4 -0
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +186 -0
- data/src/core/ext/filters/client_channel/dynamic_filters.h +99 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -6
- data/src/core/ext/filters/client_channel/health/health_check_client.h +2 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +4 -5
- data/src/core/ext/filters/client_channel/http_proxy.cc +21 -20
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +2 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +32 -30
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +162 -20
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +0 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +24 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +5 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +1262 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +7 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -32
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +454 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +6 -9
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +18 -31
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +3 -5
- data/src/core/ext/filters/client_channel/resolver_factory.h +6 -6
- data/src/core/ext/filters/client_channel/resolver_registry.cc +40 -39
- data/src/core/ext/filters/client_channel/resolver_registry.h +2 -2
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +11 -13
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +8 -8
- data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -3
- data/src/core/ext/filters/client_channel/retry_throttle.h +3 -1
- data/src/core/ext/filters/client_channel/service_config_call_data.h +19 -1
- data/src/core/ext/filters/client_channel/subchannel.cc +34 -50
- data/src/core/ext/filters/client_channel/subchannel.h +12 -18
- data/src/core/ext/filters/deadline/deadline_filter.cc +4 -2
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -6
- data/src/core/ext/filters/http/http_filters_plugin.cc +6 -3
- data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
- data/src/core/ext/filters/workarounds/workaround_utils.cc +1 -1
- data/src/core/ext/transport/chttp2/client/authority.cc +3 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +20 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +21 -10
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +26 -14
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +178 -86
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +6 -6
- data/src/core/ext/transport/chttp2/transport/writing.cc +1 -1
- data/src/core/ext/transport/inproc/inproc_transport.cc +42 -8
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -0
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +27 -27
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +139 -40
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +13 -13
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +44 -17
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +111 -111
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +424 -241
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +13 -5
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +22 -22
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +47 -21
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +21 -21
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +88 -39
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +15 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +44 -44
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +200 -78
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +17 -17
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +72 -35
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +27 -11
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +30 -30
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +136 -49
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +39 -39
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +157 -89
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +17 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +47 -47
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +163 -78
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +9 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +13 -13
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +59 -36
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +16 -16
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +61 -29
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +26 -26
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +101 -66
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +28 -28
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +122 -77
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +106 -54
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +13 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +16 -16
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +81 -35
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +38 -22
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +203 -203
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +845 -495
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +26 -6
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +17 -3
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +87 -87
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +343 -204
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +20 -20
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +85 -46
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +33 -11
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +32 -32
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +118 -67
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +29 -29
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +120 -82
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +31 -16
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -11
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +7 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +29 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +16 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +19 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +46 -3
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +41 -8
- data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -0
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +15 -2
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +19 -0
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +7 -0
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +34 -34
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +149 -72
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +34 -34
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +142 -59
- data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
- data/src/core/ext/upb-generated/google/api/http.upb.h +25 -6
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +7 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +90 -90
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +455 -292
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +7 -0
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +7 -0
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +4 -4
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +22 -3
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +7 -0
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +9 -9
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +55 -0
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +10 -3
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +4 -4
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -3
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +41 -41
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +149 -76
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +5 -5
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -6
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +13 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +17 -17
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +82 -25
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +19 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -0
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +2 -2
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +9 -2
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +1 -1
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +1 -1
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +5 -5
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +21 -7
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +2 -2
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +7 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +4 -4
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +17 -8
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +7 -7
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +31 -18
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +5 -5
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +19 -11
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +3 -3
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +7 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +64 -64
- data/src/core/ext/upb-generated/validate/validate.upb.h +296 -157
- data/src/core/ext/xds/certificate_provider_store.cc +10 -7
- data/src/core/ext/xds/certificate_provider_store.h +12 -7
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +25 -0
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -4
- data/src/core/ext/xds/xds_api.cc +220 -31
- data/src/core/ext/xds/xds_api.h +41 -10
- data/src/core/ext/xds/xds_bootstrap.h +0 -1
- data/src/core/ext/xds/xds_certificate_provider.cc +61 -2
- data/src/core/ext/xds/xds_certificate_provider.h +40 -2
- data/src/core/ext/xds/xds_client.cc +31 -29
- data/src/core/ext/xds/xds_client.h +6 -1
- data/src/core/ext/xds/xds_client_stats.cc +2 -2
- data/src/core/ext/xds/xds_server_config_fetcher.cc +131 -0
- data/src/core/lib/channel/channel_args.cc +8 -8
- data/src/core/lib/channel/channel_trace.h +1 -1
- data/src/core/lib/channel/channelz.cc +13 -14
- data/src/core/lib/channel/channelz.h +0 -1
- data/src/core/lib/channel/channelz_registry.h +0 -1
- data/src/core/lib/channel/handshaker.cc +2 -2
- data/src/core/lib/compression/compression_args.cc +3 -2
- data/src/core/lib/debug/stats.h +2 -2
- data/src/core/lib/debug/stats_data.h +13 -13
- data/src/core/lib/gpr/alloc.cc +3 -2
- data/src/core/lib/gpr/log.cc +53 -16
- data/src/core/lib/gpr/log_linux.cc +3 -1
- data/src/core/lib/gpr/log_posix.cc +3 -1
- data/src/core/lib/gpr/log_windows.cc +3 -1
- data/src/core/lib/gpr/spinlock.h +10 -2
- data/src/core/lib/gpr/string.cc +22 -21
- data/src/core/lib/gpr/string.h +5 -6
- data/src/core/lib/gpr/sync.cc +4 -4
- data/src/core/lib/gpr/time.cc +12 -12
- data/src/core/lib/gprpp/arena.h +3 -2
- data/src/core/lib/gprpp/ref_counted.h +2 -2
- data/src/core/lib/gprpp/ref_counted_ptr.h +9 -1
- data/src/core/lib/gprpp/thd_posix.cc +6 -1
- data/src/core/lib/gprpp/thd_windows.cc +3 -1
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli.h +2 -3
- data/src/core/lib/http/httpcli_security_connector.cc +1 -1
- data/src/core/lib/http/parser.cc +1 -2
- data/src/core/lib/iomgr/call_combiner.cc +8 -5
- data/src/core/lib/iomgr/combiner.cc +2 -1
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/error.cc +15 -11
- data/src/core/lib/iomgr/error_internal.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +20 -13
- data/src/core/lib/iomgr/ev_epollex_linux.cc +17 -13
- data/src/core/lib/iomgr/ev_poll_posix.cc +9 -7
- data/src/core/lib/iomgr/exec_ctx.h +6 -4
- data/src/core/lib/iomgr/executor.cc +2 -1
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/executor/threadpool.h +1 -1
- data/src/core/lib/iomgr/iomgr.cc +1 -1
- data/src/core/lib/iomgr/load_file.h +1 -1
- data/src/core/lib/iomgr/lockfree_event.cc +19 -14
- data/src/core/lib/iomgr/lockfree_event.h +2 -2
- data/src/core/lib/iomgr/parse_address.cc +52 -46
- data/src/core/lib/iomgr/parse_address.h +13 -9
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +1 -1
- data/src/core/lib/iomgr/pollset_set_custom.cc +1 -1
- data/src/core/lib/iomgr/python_util.h +1 -1
- data/src/core/lib/iomgr/resolve_address.cc +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +4 -4
- data/src/core/lib/iomgr/sockaddr_utils.cc +10 -10
- data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
- data/src/core/lib/iomgr/socket_factory_posix.cc +3 -2
- data/src/core/lib/iomgr/socket_mutator.cc +3 -2
- data/src/core/lib/iomgr/tcp_client.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_custom.cc +7 -6
- data/src/core/lib/iomgr/tcp_custom.cc +22 -17
- data/src/core/lib/iomgr/tcp_posix.cc +9 -6
- data/src/core/lib/iomgr/tcp_server_custom.cc +28 -22
- data/src/core/lib/iomgr/timer_custom.cc +3 -3
- data/src/core/lib/iomgr/timer_generic.cc +3 -3
- data/src/core/lib/iomgr/timer_manager.cc +2 -2
- data/src/core/lib/iomgr/udp_server.cc +1 -2
- data/src/core/lib/iomgr/udp_server.h +1 -2
- data/src/core/lib/iomgr/unix_sockets_posix.cc +17 -18
- data/src/core/lib/json/json.h +10 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +5 -10
- data/src/core/lib/security/authorization/evaluate_args.h +1 -1
- data/src/core/lib/security/context/security_context.cc +4 -3
- data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
- data/src/core/lib/security/credentials/credentials.cc +6 -6
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +413 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +80 -0
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +15 -10
- data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -2
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +217 -31
- data/src/core/lib/security/credentials/external/external_account_credentials.h +7 -5
- data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -6
- data/src/core/lib/security/credentials/external/file_external_account_credentials.h +3 -4
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +20 -18
- data/src/core/lib/security/credentials/external/url_external_account_credentials.h +5 -6
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +18 -12
- data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +18 -5
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +37 -44
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +5 -5
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +1 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +1 -6
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +1 -6
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +326 -5
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +64 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +1 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +0 -1
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -1
- data/src/core/lib/security/credentials/tls/tls_utils.cc +91 -0
- data/src/core/lib/security/credentials/tls/tls_utils.h +38 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +140 -10
- data/src/core/lib/security/credentials/xds/xds_credentials.h +27 -9
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +46 -13
- data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +23 -6
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -4
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
- data/src/core/lib/security/security_connector/ssl_utils.h +12 -19
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +57 -12
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +2 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
- data/src/core/lib/security/transport/security_handshaker.cc +2 -2
- data/src/core/lib/slice/slice_intern.cc +4 -5
- data/src/core/lib/slice/slice_internal.h +2 -2
- data/src/core/lib/surface/call.cc +32 -24
- data/src/core/lib/surface/call_details.cc +8 -8
- data/src/core/lib/surface/channel.cc +16 -10
- data/src/core/lib/surface/channel.h +3 -2
- data/src/core/lib/surface/channel_init.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +23 -18
- data/src/core/lib/surface/completion_queue.h +16 -16
- data/src/core/lib/surface/init.cc +6 -5
- data/src/core/lib/surface/lame_client.cc +20 -46
- data/src/core/lib/surface/lame_client.h +4 -0
- data/src/core/lib/surface/server.cc +59 -15
- data/src/core/lib/surface/server.h +37 -5
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/authority_override.cc +6 -4
- data/src/core/lib/transport/authority_override.h +5 -2
- data/src/core/lib/transport/connectivity_state.h +6 -4
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata_batch.h +4 -4
- data/src/core/lib/transport/static_metadata.cc +1 -1
- data/src/core/lib/transport/status_metadata.cc +4 -3
- data/src/core/lib/transport/transport.h +7 -7
- data/src/core/lib/uri/uri_parser.cc +131 -249
- data/src/core/lib/uri/uri_parser.h +57 -21
- data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -4
- data/src/core/tsi/alts/crypt/gsec.cc +5 -4
- data/src/core/tsi/alts/frame_protector/frame_handler.cc +8 -6
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +23 -23
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +8 -6
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +4 -4
- data/src/core/tsi/fake_transport_security.cc +5 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +62 -49
- data/src/core/tsi/ssl_transport_security.h +6 -6
- data/src/core/tsi/transport_security.cc +6 -6
- data/src/core/tsi/transport_security_interface.h +1 -1
- data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +31 -13
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +28 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +18 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -6
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +606 -0
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +197 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +399 -0
- data/third_party/abseil-cpp/absl/status/statusor.cc +71 -0
- data/third_party/abseil-cpp/absl/status/statusor.h +760 -0
- data/third_party/upb/third_party/wyhash/wyhash.h +145 -0
- data/third_party/upb/upb/decode.c +248 -167
- data/third_party/upb/upb/decode.h +20 -1
- data/third_party/upb/upb/decode.int.h +163 -0
- data/third_party/upb/upb/decode_fast.c +1040 -0
- data/third_party/upb/upb/decode_fast.h +126 -0
- data/third_party/upb/upb/def.c +525 -516
- data/third_party/upb/upb/def.h +16 -31
- data/third_party/upb/upb/def.hpp +37 -123
- data/third_party/upb/upb/encode.c +227 -169
- data/third_party/upb/upb/encode.h +27 -2
- data/third_party/upb/upb/json_decode.c +1443 -0
- data/third_party/upb/upb/json_decode.h +23 -0
- data/third_party/upb/upb/json_encode.c +713 -0
- data/third_party/upb/upb/json_encode.h +36 -0
- data/third_party/upb/upb/msg.c +167 -88
- data/third_party/upb/upb/msg.h +174 -34
- data/third_party/upb/upb/port_def.inc +74 -61
- data/third_party/upb/upb/port_undef.inc +3 -7
- data/third_party/upb/upb/reflection.c +36 -19
- data/third_party/upb/upb/table.c +34 -197
- data/third_party/upb/upb/table.int.h +14 -5
- data/third_party/upb/upb/text_encode.c +45 -22
- data/third_party/upb/upb/text_encode.h +4 -1
- data/third_party/upb/upb/upb.c +18 -41
- data/third_party/upb/upb/upb.h +36 -7
- data/third_party/upb/upb/upb.hpp +4 -4
- data/third_party/upb/upb/upb.int.h +29 -0
- metadata +60 -46
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +0 -909
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +0 -485
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +0 -68
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +0 -355
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +0 -138
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +0 -265
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +0 -104
- data/src/core/lib/gprpp/map.h +0 -53
- data/third_party/upb/upb/port.c +0 -26
data/third_party/upb/upb/def.h
CHANGED
@@ -117,9 +117,10 @@ typedef upb_inttable_iter upb_oneof_iter;
|
|
117
117
|
|
118
118
|
const char *upb_oneofdef_name(const upb_oneofdef *o);
|
119
119
|
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
|
120
|
-
int upb_oneofdef_numfields(const upb_oneofdef *o);
|
121
120
|
uint32_t upb_oneofdef_index(const upb_oneofdef *o);
|
122
121
|
bool upb_oneofdef_issynthetic(const upb_oneofdef *o);
|
122
|
+
int upb_oneofdef_fieldcount(const upb_oneofdef *o);
|
123
|
+
const upb_fielddef *upb_oneofdef_field(const upb_oneofdef *o, int i);
|
123
124
|
|
124
125
|
/* Oneof lookups:
|
125
126
|
* - ntof: look up a field by name.
|
@@ -133,11 +134,8 @@ UPB_INLINE const upb_fielddef *upb_oneofdef_ntofz(const upb_oneofdef *o,
|
|
133
134
|
}
|
134
135
|
const upb_fielddef *upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num);
|
135
136
|
|
136
|
-
/*
|
137
|
-
|
138
|
-
* // ...
|
139
|
-
* }
|
140
|
-
*/
|
137
|
+
/* DEPRECATED, slated for removal. */
|
138
|
+
int upb_oneofdef_numfields(const upb_oneofdef *o);
|
141
139
|
void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o);
|
142
140
|
void upb_oneof_next(upb_oneof_iter *iter);
|
143
141
|
bool upb_oneof_done(upb_oneof_iter *iter);
|
@@ -145,6 +143,7 @@ upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter);
|
|
145
143
|
void upb_oneof_iter_setdone(upb_oneof_iter *iter);
|
146
144
|
bool upb_oneof_iter_isequal(const upb_oneof_iter *iter1,
|
147
145
|
const upb_oneof_iter *iter2);
|
146
|
+
/* END DEPRECATED */
|
148
147
|
|
149
148
|
/* upb_msgdef *****************************************************************/
|
150
149
|
|
@@ -170,21 +169,21 @@ typedef upb_strtable_iter upb_msg_oneof_iter;
|
|
170
169
|
const char *upb_msgdef_fullname(const upb_msgdef *m);
|
171
170
|
const upb_filedef *upb_msgdef_file(const upb_msgdef *m);
|
172
171
|
const char *upb_msgdef_name(const upb_msgdef *m);
|
173
|
-
int upb_msgdef_numfields(const upb_msgdef *m);
|
174
|
-
int upb_msgdef_numoneofs(const upb_msgdef *m);
|
175
|
-
int upb_msgdef_numrealoneofs(const upb_msgdef *m);
|
176
172
|
upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
|
177
173
|
bool upb_msgdef_mapentry(const upb_msgdef *m);
|
178
174
|
upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m);
|
179
175
|
bool upb_msgdef_iswrapper(const upb_msgdef *m);
|
180
176
|
bool upb_msgdef_isnumberwrapper(const upb_msgdef *m);
|
177
|
+
int upb_msgdef_fieldcount(const upb_msgdef *m);
|
178
|
+
int upb_msgdef_oneofcount(const upb_msgdef *m);
|
179
|
+
const upb_fielddef *upb_msgdef_field(const upb_msgdef *m, int i);
|
180
|
+
const upb_oneofdef *upb_msgdef_oneof(const upb_msgdef *m, int i);
|
181
181
|
const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i);
|
182
182
|
const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,
|
183
183
|
size_t len);
|
184
184
|
const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name,
|
185
185
|
size_t len);
|
186
186
|
const upb_msglayout *upb_msgdef_layout(const upb_msgdef *m);
|
187
|
-
const upb_fielddef *_upb_msgdef_field(const upb_msgdef *m, int i);
|
188
187
|
|
189
188
|
UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m,
|
190
189
|
const char *name) {
|
@@ -216,19 +215,10 @@ UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name,
|
|
216
215
|
const upb_fielddef *upb_msgdef_lookupjsonname(const upb_msgdef *m,
|
217
216
|
const char *name, size_t len);
|
218
217
|
|
219
|
-
/*
|
220
|
-
*
|
221
|
-
|
222
|
-
|
223
|
-
* !upb_msg_field_done(&i);
|
224
|
-
* upb_msg_field_next(&i)) {
|
225
|
-
* upb_fielddef *f = upb_msg_iter_field(&i);
|
226
|
-
* // ...
|
227
|
-
* }
|
228
|
-
*
|
229
|
-
* For C we don't have separate iterators for const and non-const.
|
230
|
-
* It is the caller's responsibility to cast the upb_fielddef* to
|
231
|
-
* const if the upb_msgdef* is const. */
|
218
|
+
/* DEPRECATED, slated for removal */
|
219
|
+
int upb_msgdef_numfields(const upb_msgdef *m);
|
220
|
+
int upb_msgdef_numoneofs(const upb_msgdef *m);
|
221
|
+
int upb_msgdef_numrealoneofs(const upb_msgdef *m);
|
232
222
|
void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m);
|
233
223
|
void upb_msg_field_next(upb_msg_field_iter *iter);
|
234
224
|
bool upb_msg_field_done(const upb_msg_field_iter *iter);
|
@@ -236,9 +226,6 @@ upb_fielddef *upb_msg_iter_field(const upb_msg_field_iter *iter);
|
|
236
226
|
void upb_msg_field_iter_setdone(upb_msg_field_iter *iter);
|
237
227
|
bool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1,
|
238
228
|
const upb_msg_field_iter * iter2);
|
239
|
-
|
240
|
-
/* Similar to above, we also support iterating through the oneofs in a
|
241
|
-
* msgdef. */
|
242
229
|
void upb_msg_oneof_begin(upb_msg_oneof_iter * iter, const upb_msgdef *m);
|
243
230
|
void upb_msg_oneof_next(upb_msg_oneof_iter * iter);
|
244
231
|
bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter);
|
@@ -246,6 +233,7 @@ const upb_oneofdef *upb_msg_iter_oneof(const upb_msg_oneof_iter *iter);
|
|
246
233
|
void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter * iter);
|
247
234
|
bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1,
|
248
235
|
const upb_msg_oneof_iter *iter2);
|
236
|
+
/* END DEPRECATED */
|
249
237
|
|
250
238
|
/* upb_enumdef ****************************************************************/
|
251
239
|
|
@@ -270,11 +258,6 @@ UPB_INLINE bool upb_enumdef_ntoiz(const upb_enumdef *e,
|
|
270
258
|
}
|
271
259
|
const char *upb_enumdef_iton(const upb_enumdef *e, int32_t num);
|
272
260
|
|
273
|
-
/* upb_enum_iter i;
|
274
|
-
* for(upb_enum_begin(&i, e); !upb_enum_done(&i); upb_enum_next(&i)) {
|
275
|
-
* // ...
|
276
|
-
* }
|
277
|
-
*/
|
278
261
|
void upb_enum_begin(upb_enum_iter *iter, const upb_enumdef *e);
|
279
262
|
void upb_enum_next(upb_enum_iter *iter);
|
280
263
|
bool upb_enum_done(upb_enum_iter *iter);
|
@@ -294,6 +277,7 @@ int upb_filedef_enumcount(const upb_filedef *f);
|
|
294
277
|
const upb_filedef *upb_filedef_dep(const upb_filedef *f, int i);
|
295
278
|
const upb_msgdef *upb_filedef_msg(const upb_filedef *f, int i);
|
296
279
|
const upb_enumdef *upb_filedef_enum(const upb_filedef *f, int i);
|
280
|
+
const upb_symtab *upb_filedef_symtab(const upb_filedef *f);
|
297
281
|
|
298
282
|
/* upb_symtab *****************************************************************/
|
299
283
|
|
@@ -310,6 +294,7 @@ int upb_symtab_filecount(const upb_symtab *s);
|
|
310
294
|
const upb_filedef *upb_symtab_addfile(
|
311
295
|
upb_symtab *s, const google_protobuf_FileDescriptorProto *file,
|
312
296
|
upb_status *status);
|
297
|
+
size_t _upb_symtab_bytesloaded(const upb_symtab *s);
|
313
298
|
|
314
299
|
/* For generated code only: loads a generated descriptor. */
|
315
300
|
typedef struct upb_def_init {
|
data/third_party/upb/upb/def.hpp
CHANGED
@@ -129,17 +129,17 @@ class OneofDefPtr {
|
|
129
129
|
explicit OneofDefPtr(const upb_oneofdef* ptr) : ptr_(ptr) {}
|
130
130
|
|
131
131
|
const upb_oneofdef* ptr() const { return ptr_; }
|
132
|
-
explicit operator bool() { return ptr_ != nullptr; }
|
132
|
+
explicit operator bool() const { return ptr_ != nullptr; }
|
133
133
|
|
134
|
-
// Returns the MessageDef that
|
134
|
+
// Returns the MessageDef that contains this OneofDef.
|
135
135
|
MessageDefPtr containing_type() const;
|
136
136
|
|
137
|
-
// Returns the name of this oneof.
|
138
|
-
// by name once added to a message def.
|
137
|
+
// Returns the name of this oneof.
|
139
138
|
const char* name() const { return upb_oneofdef_name(ptr_); }
|
140
139
|
|
141
|
-
// Returns the number of fields
|
140
|
+
// Returns the number of fields in the oneof.
|
142
141
|
int field_count() const { return upb_oneofdef_numfields(ptr_); }
|
142
|
+
FieldDefPtr field(int i) const { return FieldDefPtr(upb_oneofdef_field(ptr_, i)); }
|
143
143
|
|
144
144
|
// Looks up by name.
|
145
145
|
FieldDefPtr FindFieldByName(const char* name, size_t len) const {
|
@@ -159,40 +159,6 @@ class OneofDefPtr {
|
|
159
159
|
return FieldDefPtr(upb_oneofdef_itof(ptr_, num));
|
160
160
|
}
|
161
161
|
|
162
|
-
class const_iterator
|
163
|
-
: public std::iterator<std::forward_iterator_tag, FieldDefPtr> {
|
164
|
-
public:
|
165
|
-
void operator++() { upb_oneof_next(&iter_); }
|
166
|
-
|
167
|
-
FieldDefPtr operator*() const {
|
168
|
-
return FieldDefPtr(upb_oneof_iter_field(&iter_));
|
169
|
-
}
|
170
|
-
|
171
|
-
bool operator!=(const const_iterator& other) const {
|
172
|
-
return !upb_oneof_iter_isequal(&iter_, &other.iter_);
|
173
|
-
}
|
174
|
-
|
175
|
-
bool operator==(const const_iterator& other) const {
|
176
|
-
return upb_oneof_iter_isequal(&iter_, &other.iter_);
|
177
|
-
}
|
178
|
-
|
179
|
-
private:
|
180
|
-
friend class OneofDefPtr;
|
181
|
-
|
182
|
-
const_iterator() {}
|
183
|
-
explicit const_iterator(OneofDefPtr o) { upb_oneof_begin(&iter_, o.ptr()); }
|
184
|
-
static const_iterator end() {
|
185
|
-
const_iterator iter;
|
186
|
-
upb_oneof_iter_setdone(&iter.iter_);
|
187
|
-
return iter;
|
188
|
-
}
|
189
|
-
|
190
|
-
upb_oneof_iter iter_;
|
191
|
-
};
|
192
|
-
|
193
|
-
const_iterator begin() const { return const_iterator(*this); }
|
194
|
-
const_iterator end() const { return const_iterator::end(); }
|
195
|
-
|
196
162
|
private:
|
197
163
|
const upb_oneofdef* ptr_;
|
198
164
|
};
|
@@ -211,9 +177,11 @@ class MessageDefPtr {
|
|
211
177
|
|
212
178
|
// The number of fields that belong to the MessageDef.
|
213
179
|
int field_count() const { return upb_msgdef_numfields(ptr_); }
|
180
|
+
FieldDefPtr field(int i) const { return FieldDefPtr(upb_msgdef_field(ptr_, i)); }
|
214
181
|
|
215
182
|
// The number of oneofs that belong to the MessageDef.
|
216
183
|
int oneof_count() const { return upb_msgdef_numoneofs(ptr_); }
|
184
|
+
OneofDefPtr oneof(int i) const { return OneofDefPtr(upb_msgdef_oneof(ptr_, i)); }
|
217
185
|
|
218
186
|
upb_syntax_t syntax() const { return upb_msgdef_syntax(ptr_); }
|
219
187
|
|
@@ -258,112 +226,58 @@ class MessageDefPtr {
|
|
258
226
|
// Whether is a number wrapper.
|
259
227
|
bool isnumberwrapper() const { return upb_msgdef_isnumberwrapper(ptr_); }
|
260
228
|
|
261
|
-
|
262
|
-
class
|
263
|
-
: public std::iterator<std::forward_iterator_tag, FieldDefPtr> {
|
229
|
+
private:
|
230
|
+
class FieldIter {
|
264
231
|
public:
|
265
|
-
|
266
|
-
|
267
|
-
FieldDefPtr operator*() const {
|
268
|
-
return FieldDefPtr(upb_msg_iter_field(&iter_));
|
269
|
-
}
|
232
|
+
explicit FieldIter(const upb_msgdef *m, int i) : m_(m), i_(i) {}
|
233
|
+
void operator++() { i_++; }
|
270
234
|
|
271
|
-
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
bool operator==(const const_field_iterator& other) const {
|
276
|
-
return upb_msg_field_iter_isequal(&iter_, &other.iter_);
|
277
|
-
}
|
235
|
+
FieldDefPtr operator*() { return FieldDefPtr(upb_msgdef_field(m_, i_)); }
|
236
|
+
bool operator!=(const FieldIter& other) { return i_ != other.i_; }
|
237
|
+
bool operator==(const FieldIter& other) { return i_ == other.i_; }
|
278
238
|
|
279
239
|
private:
|
280
|
-
|
281
|
-
|
282
|
-
explicit const_field_iterator() {}
|
283
|
-
|
284
|
-
explicit const_field_iterator(MessageDefPtr msg) {
|
285
|
-
upb_msg_field_begin(&iter_, msg.ptr());
|
286
|
-
}
|
287
|
-
|
288
|
-
static const_field_iterator end() {
|
289
|
-
const_field_iterator iter;
|
290
|
-
upb_msg_field_iter_setdone(&iter.iter_);
|
291
|
-
return iter;
|
292
|
-
}
|
293
|
-
|
294
|
-
upb_msg_field_iter iter_;
|
240
|
+
const upb_msgdef *m_;
|
241
|
+
int i_;
|
295
242
|
};
|
296
243
|
|
297
|
-
|
298
|
-
class const_oneof_iterator
|
299
|
-
: public std::iterator<std::forward_iterator_tag, OneofDefPtr> {
|
244
|
+
class FieldAccessor {
|
300
245
|
public:
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
return OneofDefPtr(upb_msg_iter_oneof(&iter_));
|
305
|
-
}
|
306
|
-
|
307
|
-
bool operator!=(const const_oneof_iterator& other) const {
|
308
|
-
return !upb_msg_oneof_iter_isequal(&iter_, &other.iter_);
|
309
|
-
}
|
310
|
-
|
311
|
-
bool operator==(const const_oneof_iterator& other) const {
|
312
|
-
return upb_msg_oneof_iter_isequal(&iter_, &other.iter_);
|
313
|
-
}
|
246
|
+
explicit FieldAccessor(const upb_msgdef* md) : md_(md) {}
|
247
|
+
FieldIter begin() { return FieldIter(md_, 0); }
|
248
|
+
FieldIter end() { return FieldIter(md_, upb_msgdef_fieldcount(md_)); }
|
314
249
|
|
315
250
|
private:
|
316
|
-
|
317
|
-
|
318
|
-
const_oneof_iterator() {}
|
319
|
-
|
320
|
-
explicit const_oneof_iterator(MessageDefPtr msg) {
|
321
|
-
upb_msg_oneof_begin(&iter_, msg.ptr());
|
322
|
-
}
|
323
|
-
|
324
|
-
static const_oneof_iterator end() {
|
325
|
-
const_oneof_iterator iter;
|
326
|
-
upb_msg_oneof_iter_setdone(&iter.iter_);
|
327
|
-
return iter;
|
328
|
-
}
|
329
|
-
|
330
|
-
upb_msg_oneof_iter iter_;
|
251
|
+
const upb_msgdef* md_;
|
331
252
|
};
|
332
253
|
|
333
|
-
class
|
254
|
+
class OneofIter {
|
334
255
|
public:
|
335
|
-
explicit
|
336
|
-
|
337
|
-
|
256
|
+
explicit OneofIter(const upb_msgdef *m, int i) : m_(m), i_(i) {}
|
257
|
+
void operator++() { i_++; }
|
258
|
+
|
259
|
+
OneofDefPtr operator*() { return OneofDefPtr(upb_msgdef_oneof(m_, i_)); }
|
260
|
+
bool operator!=(const OneofIter& other) { return i_ != other.i_; }
|
261
|
+
bool operator==(const OneofIter& other) { return i_ == other.i_; }
|
338
262
|
|
339
263
|
private:
|
340
|
-
const upb_msgdef*
|
264
|
+
const upb_msgdef *m_;
|
265
|
+
int i_;
|
341
266
|
};
|
342
267
|
|
343
|
-
class
|
268
|
+
class OneofAccessor {
|
344
269
|
public:
|
345
|
-
explicit
|
346
|
-
|
347
|
-
|
270
|
+
explicit OneofAccessor(const upb_msgdef* md) : md_(md) {}
|
271
|
+
OneofIter begin() { return OneofIter(md_, 0); }
|
272
|
+
OneofIter end() { return OneofIter(md_, upb_msgdef_oneofcount(md_)); }
|
348
273
|
|
349
274
|
private:
|
350
275
|
const upb_msgdef* md_;
|
351
276
|
};
|
352
277
|
|
353
|
-
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
const_field_iterator field_end() const { return const_field_iterator::end(); }
|
358
|
-
|
359
|
-
const_oneof_iterator oneof_begin() const {
|
360
|
-
return const_oneof_iterator(*this);
|
361
|
-
}
|
362
|
-
|
363
|
-
const_oneof_iterator oneof_end() const { return const_oneof_iterator::end(); }
|
364
|
-
|
365
|
-
ConstFieldAccessor fields() const { return ConstFieldAccessor(ptr()); }
|
366
|
-
ConstOneofAccessor oneofs() const { return ConstOneofAccessor(ptr()); }
|
278
|
+
public:
|
279
|
+
FieldAccessor fields() const { return FieldAccessor(ptr()); }
|
280
|
+
OneofAccessor oneofs() const { return OneofAccessor(ptr()); }
|
367
281
|
|
368
282
|
private:
|
369
283
|
const upb_msgdef* ptr_;
|
@@ -2,35 +2,39 @@
|
|
2
2
|
|
3
3
|
#include "upb/encode.h"
|
4
4
|
|
5
|
+
#include <setjmp.h>
|
5
6
|
#include <string.h>
|
6
7
|
|
7
8
|
#include "upb/msg.h"
|
8
9
|
#include "upb/upb.h"
|
9
10
|
|
11
|
+
/* Must be last. */
|
10
12
|
#include "upb/port_def.inc"
|
11
13
|
|
12
14
|
#define UPB_PB_VARINT_MAX_LEN 10
|
13
|
-
#define CHK(x) do { if (!(x)) { return false; } } while(0)
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
while (val) {
|
16
|
+
UPB_NOINLINE
|
17
|
+
static size_t encode_varint64(uint64_t val, char *buf) {
|
18
|
+
size_t i = 0;
|
19
|
+
do {
|
20
20
|
uint8_t byte = val & 0x7fU;
|
21
21
|
val >>= 7;
|
22
22
|
if (val) byte |= 0x80U;
|
23
23
|
buf[i++] = byte;
|
24
|
-
}
|
24
|
+
} while (val);
|
25
25
|
return i;
|
26
26
|
}
|
27
27
|
|
28
|
-
static uint32_t
|
29
|
-
static uint64_t
|
28
|
+
static uint32_t encode_zz32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); }
|
29
|
+
static uint64_t encode_zz64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); }
|
30
30
|
|
31
31
|
typedef struct {
|
32
|
+
jmp_buf err;
|
32
33
|
upb_alloc *alloc;
|
33
34
|
char *buf, *ptr, *limit;
|
35
|
+
int options;
|
36
|
+
int depth;
|
37
|
+
_upb_mapsorter sorter;
|
34
38
|
} upb_encstate;
|
35
39
|
|
36
40
|
static size_t upb_roundup_pow2(size_t bytes) {
|
@@ -41,11 +45,17 @@ static size_t upb_roundup_pow2(size_t bytes) {
|
|
41
45
|
return ret;
|
42
46
|
}
|
43
47
|
|
44
|
-
static
|
48
|
+
UPB_NORETURN static void encode_err(upb_encstate *e) {
|
49
|
+
UPB_LONGJMP(e->err, 1);
|
50
|
+
}
|
51
|
+
|
52
|
+
UPB_NOINLINE
|
53
|
+
static void encode_growbuffer(upb_encstate *e, size_t bytes) {
|
45
54
|
size_t old_size = e->limit - e->buf;
|
46
55
|
size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr));
|
47
56
|
char *new_buf = upb_realloc(e->alloc, e->buf, old_size, new_size);
|
48
|
-
|
57
|
+
|
58
|
+
if (!new_buf) encode_err(e);
|
49
59
|
|
50
60
|
/* We want previous data at the end, realloc() put it at the beginning. */
|
51
61
|
if (old_size > 0) {
|
@@ -55,99 +65,116 @@ static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) {
|
|
55
65
|
e->ptr = new_buf + new_size - (e->limit - e->ptr);
|
56
66
|
e->limit = new_buf + new_size;
|
57
67
|
e->buf = new_buf;
|
58
|
-
|
68
|
+
|
69
|
+
e->ptr -= bytes;
|
59
70
|
}
|
60
71
|
|
61
72
|
/* Call to ensure that at least "bytes" bytes are available for writing at
|
62
73
|
* e->ptr. Returns false if the bytes could not be allocated. */
|
63
|
-
|
64
|
-
|
65
|
-
|
74
|
+
UPB_FORCEINLINE
|
75
|
+
static void encode_reserve(upb_encstate *e, size_t bytes) {
|
76
|
+
if ((size_t)(e->ptr - e->buf) < bytes) {
|
77
|
+
encode_growbuffer(e, bytes);
|
78
|
+
return;
|
79
|
+
}
|
66
80
|
|
67
81
|
e->ptr -= bytes;
|
68
|
-
return true;
|
69
82
|
}
|
70
83
|
|
71
84
|
/* Writes the given bytes to the buffer, handling reserve/advance. */
|
72
|
-
static
|
73
|
-
if (len == 0) return
|
74
|
-
|
85
|
+
static void encode_bytes(upb_encstate *e, const void *data, size_t len) {
|
86
|
+
if (len == 0) return; /* memcpy() with zero size is UB */
|
87
|
+
encode_reserve(e, len);
|
75
88
|
memcpy(e->ptr, data, len);
|
76
|
-
return true;
|
77
89
|
}
|
78
90
|
|
79
|
-
static
|
91
|
+
static void encode_fixed64(upb_encstate *e, uint64_t val) {
|
80
92
|
val = _upb_be_swap64(val);
|
81
|
-
|
93
|
+
encode_bytes(e, &val, sizeof(uint64_t));
|
82
94
|
}
|
83
95
|
|
84
|
-
static
|
96
|
+
static void encode_fixed32(upb_encstate *e, uint32_t val) {
|
85
97
|
val = _upb_be_swap32(val);
|
86
|
-
|
98
|
+
encode_bytes(e, &val, sizeof(uint32_t));
|
87
99
|
}
|
88
100
|
|
89
|
-
|
101
|
+
UPB_NOINLINE
|
102
|
+
static void encode_longvarint(upb_encstate *e, uint64_t val) {
|
90
103
|
size_t len;
|
91
104
|
char *start;
|
92
|
-
|
93
|
-
|
105
|
+
|
106
|
+
encode_reserve(e, UPB_PB_VARINT_MAX_LEN);
|
107
|
+
len = encode_varint64(val, e->ptr);
|
94
108
|
start = e->ptr + UPB_PB_VARINT_MAX_LEN - len;
|
95
109
|
memmove(start, e->ptr, len);
|
96
110
|
e->ptr = start;
|
97
|
-
return true;
|
98
111
|
}
|
99
112
|
|
100
|
-
|
113
|
+
UPB_FORCEINLINE
|
114
|
+
static void encode_varint(upb_encstate *e, uint64_t val) {
|
115
|
+
if (val < 128 && e->ptr != e->buf) {
|
116
|
+
--e->ptr;
|
117
|
+
*e->ptr = val;
|
118
|
+
} else {
|
119
|
+
encode_longvarint(e, val);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
static void encode_double(upb_encstate *e, double d) {
|
101
124
|
uint64_t u64;
|
102
125
|
UPB_ASSERT(sizeof(double) == sizeof(uint64_t));
|
103
126
|
memcpy(&u64, &d, sizeof(uint64_t));
|
104
|
-
|
127
|
+
encode_fixed64(e, u64);
|
105
128
|
}
|
106
129
|
|
107
|
-
static
|
130
|
+
static void encode_float(upb_encstate *e, float d) {
|
108
131
|
uint32_t u32;
|
109
132
|
UPB_ASSERT(sizeof(float) == sizeof(uint32_t));
|
110
133
|
memcpy(&u32, &d, sizeof(uint32_t));
|
111
|
-
|
134
|
+
encode_fixed32(e, u32);
|
112
135
|
}
|
113
136
|
|
114
|
-
static
|
115
|
-
|
137
|
+
static void encode_tag(upb_encstate *e, uint32_t field_number,
|
138
|
+
uint8_t wire_type) {
|
139
|
+
encode_varint(e, (field_number << 3) | wire_type);
|
116
140
|
}
|
117
141
|
|
118
|
-
static
|
142
|
+
static void encode_fixedarray(upb_encstate *e, const upb_array *arr,
|
119
143
|
size_t elem_size, uint32_t tag) {
|
120
144
|
size_t bytes = arr->len * elem_size;
|
121
145
|
const char* data = _upb_array_constptr(arr);
|
122
146
|
const char* ptr = data + bytes - elem_size;
|
123
147
|
if (tag) {
|
124
148
|
while (true) {
|
125
|
-
|
149
|
+
encode_bytes(e, ptr, elem_size);
|
150
|
+
encode_varint(e, tag);
|
126
151
|
if (ptr == data) break;
|
127
152
|
ptr -= elem_size;
|
128
153
|
}
|
129
|
-
return true;
|
130
154
|
} else {
|
131
|
-
|
155
|
+
encode_bytes(e, data, bytes);
|
132
156
|
}
|
133
157
|
}
|
134
158
|
|
135
|
-
|
136
|
-
|
159
|
+
static void encode_message(upb_encstate *e, const char *msg,
|
160
|
+
const upb_msglayout *m, size_t *size);
|
137
161
|
|
138
|
-
static
|
139
|
-
|
140
|
-
|
141
|
-
bool skip_zero_value) {
|
162
|
+
static void encode_scalar(upb_encstate *e, const void *_field_mem,
|
163
|
+
const upb_msglayout *m, const upb_msglayout_field *f,
|
164
|
+
bool skip_zero_value) {
|
142
165
|
const char *field_mem = _field_mem;
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
166
|
+
int wire_type;
|
167
|
+
|
168
|
+
#define CASE(ctype, type, wtype, encodeval) \
|
169
|
+
{ \
|
170
|
+
ctype val = *(ctype *)field_mem; \
|
171
|
+
if (skip_zero_value && val == 0) { \
|
172
|
+
return; \
|
173
|
+
} \
|
174
|
+
encode_##type(e, encodeval); \
|
175
|
+
wire_type = wtype; \
|
176
|
+
break; \
|
177
|
+
}
|
151
178
|
|
152
179
|
switch (f->descriptortype) {
|
153
180
|
case UPB_DESCRIPTOR_TYPE_DOUBLE:
|
@@ -171,90 +198,95 @@ static bool upb_encode_scalarfield(upb_encstate *e, const void *_field_mem,
|
|
171
198
|
case UPB_DESCRIPTOR_TYPE_BOOL:
|
172
199
|
CASE(bool, varint, UPB_WIRE_TYPE_VARINT, val);
|
173
200
|
case UPB_DESCRIPTOR_TYPE_SINT32:
|
174
|
-
CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT,
|
201
|
+
CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz32(val));
|
175
202
|
case UPB_DESCRIPTOR_TYPE_SINT64:
|
176
|
-
CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT,
|
203
|
+
CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz64(val));
|
177
204
|
case UPB_DESCRIPTOR_TYPE_STRING:
|
178
205
|
case UPB_DESCRIPTOR_TYPE_BYTES: {
|
179
206
|
upb_strview view = *(upb_strview*)field_mem;
|
180
207
|
if (skip_zero_value && view.size == 0) {
|
181
|
-
return
|
208
|
+
return;
|
182
209
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
210
|
+
encode_bytes(e, view.data, view.size);
|
211
|
+
encode_varint(e, view.size);
|
212
|
+
wire_type = UPB_WIRE_TYPE_DELIMITED;
|
213
|
+
break;
|
186
214
|
}
|
187
215
|
case UPB_DESCRIPTOR_TYPE_GROUP: {
|
188
216
|
size_t size;
|
189
217
|
void *submsg = *(void **)field_mem;
|
190
218
|
const upb_msglayout *subm = m->submsgs[f->submsg_index];
|
191
219
|
if (submsg == NULL) {
|
192
|
-
return
|
220
|
+
return;
|
193
221
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
222
|
+
if (--e->depth == 0) encode_err(e);
|
223
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP);
|
224
|
+
encode_message(e, submsg, subm, &size);
|
225
|
+
wire_type = UPB_WIRE_TYPE_START_GROUP;
|
226
|
+
e->depth++;
|
227
|
+
break;
|
197
228
|
}
|
198
229
|
case UPB_DESCRIPTOR_TYPE_MESSAGE: {
|
199
230
|
size_t size;
|
200
231
|
void *submsg = *(void **)field_mem;
|
201
232
|
const upb_msglayout *subm = m->submsgs[f->submsg_index];
|
202
233
|
if (submsg == NULL) {
|
203
|
-
return
|
234
|
+
return;
|
204
235
|
}
|
205
|
-
|
206
|
-
|
207
|
-
|
236
|
+
if (--e->depth == 0) encode_err(e);
|
237
|
+
encode_message(e, submsg, subm, &size);
|
238
|
+
encode_varint(e, size);
|
239
|
+
wire_type = UPB_WIRE_TYPE_DELIMITED;
|
240
|
+
e->depth++;
|
241
|
+
break;
|
208
242
|
}
|
243
|
+
default:
|
244
|
+
UPB_UNREACHABLE();
|
209
245
|
}
|
210
246
|
#undef CASE
|
211
|
-
|
247
|
+
|
248
|
+
encode_tag(e, f->number, wire_type);
|
212
249
|
}
|
213
250
|
|
214
|
-
static
|
215
|
-
|
216
|
-
const upb_msglayout_field *f) {
|
251
|
+
static void encode_array(upb_encstate *e, const char *field_mem,
|
252
|
+
const upb_msglayout *m, const upb_msglayout_field *f) {
|
217
253
|
const upb_array *arr = *(const upb_array**)field_mem;
|
218
254
|
bool packed = f->label == _UPB_LABEL_PACKED;
|
255
|
+
size_t pre_len = e->limit - e->ptr;
|
219
256
|
|
220
257
|
if (arr == NULL || arr->len == 0) {
|
221
|
-
return
|
258
|
+
return;
|
222
259
|
}
|
223
260
|
|
224
261
|
#define VARINT_CASE(ctype, encode) \
|
225
262
|
{ \
|
226
263
|
const ctype *start = _upb_array_constptr(arr); \
|
227
264
|
const ctype *ptr = start + arr->len; \
|
228
|
-
size_t pre_len = e->limit - e->ptr; \
|
229
265
|
uint32_t tag = packed ? 0 : (f->number << 3) | UPB_WIRE_TYPE_VARINT; \
|
230
266
|
do { \
|
231
267
|
ptr--; \
|
232
|
-
|
233
|
-
if (tag)
|
268
|
+
encode_varint(e, encode); \
|
269
|
+
if (tag) encode_varint(e, tag); \
|
234
270
|
} while (ptr != start); \
|
235
|
-
if (!tag) CHK(upb_put_varint(e, e->limit - e->ptr - pre_len)); \
|
236
271
|
} \
|
237
|
-
break;
|
238
|
-
do { \
|
239
|
-
; \
|
240
|
-
} while (0)
|
272
|
+
break;
|
241
273
|
|
242
274
|
#define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type))
|
243
275
|
|
244
276
|
switch (f->descriptortype) {
|
245
277
|
case UPB_DESCRIPTOR_TYPE_DOUBLE:
|
246
|
-
|
278
|
+
encode_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT));
|
247
279
|
break;
|
248
280
|
case UPB_DESCRIPTOR_TYPE_FLOAT:
|
249
|
-
|
281
|
+
encode_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT));
|
250
282
|
break;
|
251
283
|
case UPB_DESCRIPTOR_TYPE_SFIXED64:
|
252
284
|
case UPB_DESCRIPTOR_TYPE_FIXED64:
|
253
|
-
|
285
|
+
encode_fixedarray(e, arr, sizeof(uint64_t), TAG(UPB_WIRE_TYPE_64BIT));
|
254
286
|
break;
|
255
287
|
case UPB_DESCRIPTOR_TYPE_FIXED32:
|
256
288
|
case UPB_DESCRIPTOR_TYPE_SFIXED32:
|
257
|
-
|
289
|
+
encode_fixedarray(e, arr, sizeof(uint32_t), TAG(UPB_WIRE_TYPE_32BIT));
|
258
290
|
break;
|
259
291
|
case UPB_DESCRIPTOR_TYPE_INT64:
|
260
292
|
case UPB_DESCRIPTOR_TYPE_UINT64:
|
@@ -267,154 +299,180 @@ static bool upb_encode_array(upb_encstate *e, const char *field_mem,
|
|
267
299
|
case UPB_DESCRIPTOR_TYPE_BOOL:
|
268
300
|
VARINT_CASE(bool, *ptr);
|
269
301
|
case UPB_DESCRIPTOR_TYPE_SINT32:
|
270
|
-
VARINT_CASE(int32_t,
|
302
|
+
VARINT_CASE(int32_t, encode_zz32(*ptr));
|
271
303
|
case UPB_DESCRIPTOR_TYPE_SINT64:
|
272
|
-
VARINT_CASE(int64_t,
|
304
|
+
VARINT_CASE(int64_t, encode_zz64(*ptr));
|
273
305
|
case UPB_DESCRIPTOR_TYPE_STRING:
|
274
306
|
case UPB_DESCRIPTOR_TYPE_BYTES: {
|
275
307
|
const upb_strview *start = _upb_array_constptr(arr);
|
276
308
|
const upb_strview *ptr = start + arr->len;
|
277
309
|
do {
|
278
310
|
ptr--;
|
279
|
-
|
280
|
-
|
281
|
-
|
311
|
+
encode_bytes(e, ptr->data, ptr->size);
|
312
|
+
encode_varint(e, ptr->size);
|
313
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
|
282
314
|
} while (ptr != start);
|
283
|
-
return
|
315
|
+
return;
|
284
316
|
}
|
285
317
|
case UPB_DESCRIPTOR_TYPE_GROUP: {
|
286
318
|
const void *const*start = _upb_array_constptr(arr);
|
287
319
|
const void *const*ptr = start + arr->len;
|
288
320
|
const upb_msglayout *subm = m->submsgs[f->submsg_index];
|
321
|
+
if (--e->depth == 0) encode_err(e);
|
289
322
|
do {
|
290
323
|
size_t size;
|
291
324
|
ptr--;
|
292
|
-
|
293
|
-
|
294
|
-
|
325
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP);
|
326
|
+
encode_message(e, *ptr, subm, &size);
|
327
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP);
|
295
328
|
} while (ptr != start);
|
296
|
-
|
329
|
+
e->depth++;
|
330
|
+
return;
|
297
331
|
}
|
298
332
|
case UPB_DESCRIPTOR_TYPE_MESSAGE: {
|
299
333
|
const void *const*start = _upb_array_constptr(arr);
|
300
334
|
const void *const*ptr = start + arr->len;
|
301
335
|
const upb_msglayout *subm = m->submsgs[f->submsg_index];
|
336
|
+
if (--e->depth == 0) encode_err(e);
|
302
337
|
do {
|
303
338
|
size_t size;
|
304
339
|
ptr--;
|
305
|
-
|
306
|
-
|
307
|
-
|
340
|
+
encode_message(e, *ptr, subm, &size);
|
341
|
+
encode_varint(e, size);
|
342
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
|
308
343
|
} while (ptr != start);
|
309
|
-
|
344
|
+
e->depth++;
|
345
|
+
return;
|
310
346
|
}
|
311
347
|
}
|
312
348
|
#undef VARINT_CASE
|
313
349
|
|
314
350
|
if (packed) {
|
315
|
-
|
351
|
+
encode_varint(e, e->limit - e->ptr - pre_len);
|
352
|
+
encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
|
316
353
|
}
|
317
|
-
return true;
|
318
354
|
}
|
319
355
|
|
320
|
-
static
|
321
|
-
|
322
|
-
|
356
|
+
static void encode_mapentry(upb_encstate *e, uint32_t number,
|
357
|
+
const upb_msglayout *layout,
|
358
|
+
const upb_map_entry *ent) {
|
359
|
+
const upb_msglayout_field *key_field = &layout->fields[0];
|
360
|
+
const upb_msglayout_field *val_field = &layout->fields[1];
|
361
|
+
size_t pre_len = e->limit - e->ptr;
|
362
|
+
size_t size;
|
363
|
+
encode_scalar(e, &ent->v, layout, val_field, false);
|
364
|
+
encode_scalar(e, &ent->k, layout, key_field, false);
|
365
|
+
size = (e->limit - e->ptr) - pre_len;
|
366
|
+
encode_varint(e, size);
|
367
|
+
encode_tag(e, number, UPB_WIRE_TYPE_DELIMITED);
|
368
|
+
}
|
369
|
+
|
370
|
+
static void encode_map(upb_encstate *e, const char *field_mem,
|
371
|
+
const upb_msglayout *m, const upb_msglayout_field *f) {
|
323
372
|
const upb_map *map = *(const upb_map**)field_mem;
|
324
|
-
const upb_msglayout *
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
if (map == NULL) {
|
329
|
-
return true;
|
330
|
-
}
|
373
|
+
const upb_msglayout *layout = m->submsgs[f->submsg_index];
|
374
|
+
UPB_ASSERT(layout->field_count == 2);
|
375
|
+
|
376
|
+
if (map == NULL) return;
|
331
377
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
upb_strview key = upb_strtable_iter_key(&i);
|
337
|
-
const upb_value val = upb_strtable_iter_value(&i);
|
378
|
+
if (e->options & UPB_ENCODE_DETERMINISTIC) {
|
379
|
+
_upb_sortedmap sorted;
|
380
|
+
_upb_mapsorter_pushmap(&e->sorter, layout->fields[0].descriptortype, map,
|
381
|
+
&sorted);
|
338
382
|
upb_map_entry ent;
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
383
|
+
while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) {
|
384
|
+
encode_mapentry(e, f->number, layout, &ent);
|
385
|
+
}
|
386
|
+
_upb_mapsorter_popmap(&e->sorter, &sorted);
|
387
|
+
} else {
|
388
|
+
upb_strtable_iter i;
|
389
|
+
upb_strtable_begin(&i, &map->table);
|
390
|
+
for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
|
391
|
+
upb_strview key = upb_strtable_iter_key(&i);
|
392
|
+
const upb_value val = upb_strtable_iter_value(&i);
|
393
|
+
upb_map_entry ent;
|
394
|
+
_upb_map_fromkey(key, &ent.k, map->key_size);
|
395
|
+
_upb_map_fromvalue(val, &ent.v, map->val_size);
|
396
|
+
encode_mapentry(e, f->number, layout, &ent);
|
397
|
+
}
|
346
398
|
}
|
347
|
-
|
348
|
-
return true;
|
349
399
|
}
|
350
400
|
|
401
|
+
static void encode_scalarfield(upb_encstate *e, const char *msg,
|
402
|
+
const upb_msglayout *m,
|
403
|
+
const upb_msglayout_field *f) {
|
404
|
+
bool skip_empty = false;
|
405
|
+
if (f->presence == 0) {
|
406
|
+
/* Proto3 presence. */
|
407
|
+
skip_empty = true;
|
408
|
+
} else if (f->presence > 0) {
|
409
|
+
/* Proto2 presence: hasbit. */
|
410
|
+
if (!_upb_hasbit_field(msg, f)) return;
|
411
|
+
} else {
|
412
|
+
/* Field is in a oneof. */
|
413
|
+
if (_upb_getoneofcase_field(msg, f) != f->number) return;
|
414
|
+
}
|
415
|
+
encode_scalar(e, msg + f->offset, m, f, skip_empty);
|
416
|
+
}
|
351
417
|
|
352
|
-
|
353
|
-
|
354
|
-
int i;
|
418
|
+
static void encode_message(upb_encstate *e, const char *msg,
|
419
|
+
const upb_msglayout *m, size_t *size) {
|
355
420
|
size_t pre_len = e->limit - e->ptr;
|
356
|
-
const
|
357
|
-
|
421
|
+
const upb_msglayout_field *f = &m->fields[m->field_count];
|
422
|
+
const upb_msglayout_field *first = &m->fields[0];
|
358
423
|
|
359
|
-
|
424
|
+
if ((e->options & UPB_ENCODE_SKIPUNKNOWN) == 0) {
|
425
|
+
size_t unknown_size;
|
426
|
+
const char *unknown = upb_msg_getunknown(msg, &unknown_size);
|
360
427
|
|
361
|
-
|
362
|
-
|
428
|
+
if (unknown) {
|
429
|
+
encode_bytes(e, unknown, unknown_size);
|
430
|
+
}
|
363
431
|
}
|
364
432
|
|
365
|
-
|
366
|
-
|
367
|
-
|
433
|
+
while (f != first) {
|
434
|
+
f--;
|
368
435
|
if (_upb_isrepeated(f)) {
|
369
|
-
|
436
|
+
encode_array(e, msg + f->offset, m, f);
|
370
437
|
} else if (f->label == _UPB_LABEL_MAP) {
|
371
|
-
|
438
|
+
encode_map(e, msg + f->offset, m, f);
|
372
439
|
} else {
|
373
|
-
|
374
|
-
if (f->presence == 0) {
|
375
|
-
/* Proto3 presence. */
|
376
|
-
skip_empty = true;
|
377
|
-
} else if (f->presence > 0) {
|
378
|
-
/* Proto2 presence: hasbit. */
|
379
|
-
if (!_upb_hasbit_field(msg, f)) {
|
380
|
-
continue;
|
381
|
-
}
|
382
|
-
} else {
|
383
|
-
/* Field is in a oneof. */
|
384
|
-
if (_upb_getoneofcase_field(msg, f) != f->number) {
|
385
|
-
continue;
|
386
|
-
}
|
387
|
-
}
|
388
|
-
CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, skip_empty));
|
440
|
+
encode_scalarfield(e, msg, m, f);
|
389
441
|
}
|
390
442
|
}
|
391
443
|
|
392
444
|
*size = (e->limit - e->ptr) - pre_len;
|
393
|
-
return true;
|
394
445
|
}
|
395
446
|
|
396
|
-
char *
|
397
|
-
|
447
|
+
char *upb_encode_ex(const void *msg, const upb_msglayout *m, int options,
|
448
|
+
upb_arena *arena, size_t *size) {
|
398
449
|
upb_encstate e;
|
450
|
+
unsigned depth = (unsigned)options >> 16;
|
451
|
+
|
399
452
|
e.alloc = upb_arena_alloc(arena);
|
400
453
|
e.buf = NULL;
|
401
454
|
e.limit = NULL;
|
402
455
|
e.ptr = NULL;
|
456
|
+
e.depth = depth ? depth : 64;
|
457
|
+
e.options = options;
|
458
|
+
_upb_mapsorter_init(&e.sorter);
|
459
|
+
char *ret = NULL;
|
403
460
|
|
404
|
-
if (
|
461
|
+
if (UPB_SETJMP(e.err)) {
|
405
462
|
*size = 0;
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
*size = e.limit - e.ptr;
|
410
|
-
|
411
|
-
if (*size == 0) {
|
412
|
-
static char ch;
|
413
|
-
return &ch;
|
463
|
+
ret = NULL;
|
414
464
|
} else {
|
415
|
-
|
416
|
-
|
465
|
+
encode_message(&e, msg, m, size);
|
466
|
+
*size = e.limit - e.ptr;
|
467
|
+
if (*size == 0) {
|
468
|
+
static char ch;
|
469
|
+
ret = &ch;
|
470
|
+
} else {
|
471
|
+
UPB_ASSERT(e.ptr);
|
472
|
+
ret = e.ptr;
|
473
|
+
}
|
417
474
|
}
|
418
|
-
}
|
419
475
|
|
420
|
-
|
476
|
+
_upb_mapsorter_destroy(&e.sorter);
|
477
|
+
return ret;
|
478
|
+
}
|