diff --git a/apps/rebar/src/vendored/r3_hex_api.erl b/apps/rebar/src/vendored/r3_hex_api.erl index 51bae96bc..e5f2c817f 100644 --- a/apps/rebar/src/vendored/r3_hex_api.erl +++ b/apps/rebar/src/vendored/r3_hex_api.erl @@ -1,7 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually - -%% @hidden +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API -module(r3_hex_api). -export([ @@ -16,35 +16,40 @@ ]). -define(ERL_CONTENT_TYPE, <<"application/vnd.hex+erlang">>). --export_type([body/0, response/0]). +-export_type([response/0]). -type response() :: {ok, {r3_hex_http:status(), r3_hex_http:headers(), body() | nil}} | {error, term()}. -type body() :: [body()] | #{binary() => body() | binary()}. +%% @private get(Config, Path) -> request(Config, get, Path, undefined). +%% @private post(Config, Path, Body) -> request(Config, post, Path, encode_body(Body)). +%% @private put(Config, Path, Body) -> request(Config, put, Path, encode_body(Body)). +%% @private delete(Config, Path) -> request(Config, delete, Path, undefined). %% @private encode_query_string(List) -> - Pairs = lists:map(fun ({K, V}) -> {to_list(K), to_list(V)} end, List), + Pairs = lists:map(fun({K, V}) -> {to_list(K), to_list(V)} end, List), list_to_binary(compose_query(Pairs)). %% OTP 21+ --ifdef (OTP_RELEASE). +%% @private +-ifdef(OTP_RELEASE). compose_query(Pairs) -> uri_string:compose_query(Pairs). -else. compose_query(Pairs) -> - String = join("&", lists:map(fun ({K, V}) -> K ++ "=" ++ V end, Pairs)), + String = join("&", lists:map(fun({K, V}) -> K ++ "=" ++ V end, Pairs)), http_uri:encode(String). -endif. @@ -65,7 +70,8 @@ join_path_segments(Segments) -> iolist_to_binary(recompose(Segments)). %% OTP 21+ --ifdef (OTP_RELEASE). +%% @private +-ifdef(OTP_RELEASE). recompose(Segments) -> Concatenated = join(<<"/">>, Segments), %% uri_string:recompose/1 accepts path segments as a list, @@ -75,6 +81,7 @@ recompose(Segments) -> recompose(Segments) -> join(<<"/">>, lists:map(fun encode_segment/1, Segments)). +%% @private encode_segment(Binary) when is_binary(Binary) -> encode_segment(binary_to_list(Binary)); encode_segment(String) when is_list(String) -> @@ -99,43 +106,59 @@ request(Config, Method, Path, Body) when is_binary(Path) and is_map(Config) -> case binary:match(ContentType, ?ERL_CONTENT_TYPE) of {_, _} -> {ok, {Status, RespHeaders, binary_to_term(RespBody)}}; - nomatch -> {ok, {Status, RespHeaders, nil}} end; - Other -> Other end. +%% TODO: not needed after exdoc is fixed +%% @private build_url(Path, #{api_url := URI}) -> <>. +%% TODO: not needed after exdoc is fixed +%% @private encode_body({_ContentType, _Body} = Body) -> Body; encode_body(Body) -> {binary_to_list(?ERL_CONTENT_TYPE), term_to_binary(Body)}. +%% TODO: not needed after exdoc is fixed +%% @private %% TODO: copy-pasted from r3_hex_repo make_headers(Config) -> maps:fold(fun set_header/3, #{}, Config). -set_header(api_key, Token, Headers) when is_binary(Token) -> maps:put(<<"authorization">>, Token, Headers); -set_header(_, _, Headers) -> Headers. +%% TODO: not needed after exdoc is fixed +%% @private +set_header(api_key, Token, Headers) when is_binary(Token) -> + maps:put(<<"authorization">>, Token, Headers); +set_header(_, _, Headers) -> + Headers. +%% TODO: not needed after exdoc is fixed +%% @private put_new(Key, Value, Map) -> case maps:find(Key, Map) of {ok, _} -> Map; error -> maps:put(Key, Value, Map) end. +%% TODO: not needed after exdoc is fixed +%% @private %% https://github.com/erlang/otp/blob/OTP-20.3/lib/stdlib/src/lists.erl#L1449:L1453 join(_Sep, []) -> []; -join(Sep, [H|T]) -> [H|join_prepend(Sep, T)]. +join(Sep, [H | T]) -> [H | join_prepend(Sep, T)]. +%% TODO: not needed after exdoc is fixed +%% @private join_prepend(_Sep, []) -> []; -join_prepend(Sep, [H|T]) -> [Sep,H|join_prepend(Sep,T)]. +join_prepend(Sep, [H | T]) -> [Sep, H | join_prepend(Sep, T)]. +%% TODO: not needed after exdoc is fixed +%% @private to_list(A) when is_atom(A) -> atom_to_list(A); to_list(B) when is_binary(B) -> unicode:characters_to_list(B); to_list(I) when is_integer(I) -> integer_to_list(I); diff --git a/apps/rebar/src/vendored/r3_hex_api_key.erl b/apps/rebar/src/vendored/r3_hex_api_key.erl index 8c93022a6..b96956bba 100644 --- a/apps/rebar/src/vendored/r3_hex_api_key.erl +++ b/apps/rebar/src/vendored/r3_hex_api_key.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API - Keys. -module(r3_hex_api_key). -export([ list/1, @@ -11,16 +13,7 @@ -export_type([permission/0]). --type permission() :: api_permission() | repo_permission() | repos_permission(). --ifdef(OTP_19). --type api_permission() :: #{domain := api, resource => read | write}. --type repo_permission() :: #{domain := repository, resource := binary()}. --type repos_permission() :: #{domain := repositories}. --else. --type api_permission() :: #{domain => api, resource => read | write}. --type repo_permission() :: #{domain => repository, resource => binary()}. --type repos_permission() :: #{domain => repositories}. --endif. +-type permission() :: #{binary() := binary()}. %% @doc %% Lists the user's or organization's API and repository keys. @@ -79,6 +72,12 @@ get(Config, Name) when is_map(Config) and is_binary(Name) -> %% @doc %% Adds a new API or repository key. %% +%% A permission is a map of `#{<<"domain">> => Domain, <<"resource"> => Resource}'. +%% +%% Valid `Domain' values: `<<"api">> | <<"repository">> | <<"repositories">>'. +%% +%% Valid `Resource' values: `<<"read">> | <<"write">>'. +%% %% Examples: %% %% ``` diff --git a/apps/rebar/src/vendored/r3_hex_api_package.erl b/apps/rebar/src/vendored/r3_hex_api_package.erl index 71c1ad10f..75141cee9 100644 --- a/apps/rebar/src/vendored/r3_hex_api_package.erl +++ b/apps/rebar/src/vendored/r3_hex_api_package.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API - Packages. -module(r3_hex_api_package). -export([get/2, search/3]). @@ -27,7 +29,7 @@ %% ''' %% @end -spec get(r3_hex_core:config(), binary()) -> r3_hex_api:response(). -get(Config, Name) when is_map(Config) and is_binary(Name)-> +get(Config, Name) when is_map(Config) and is_binary(Name) -> Path = r3_hex_api:build_repository_path(Config, ["packages", Name]), r3_hex_api:get(Config, Path). @@ -37,14 +39,16 @@ get(Config, Name) when is_map(Config) and is_binary(Name)-> %% Examples: %% %% ``` -%% > r3_hex_api_package:search(r3_hex_core:default_config(), <<"package">>, []). +%% > r3_hex_api_package:search(r3_hex_core:default_config(), <<"package">>, [{page, 1}]). %% {ok, {200, ..., [ %% #{<<"name">> => <<"package1">>, ...}, %% ... %% ]}} %% ''' --spec search(r3_hex_core:config(), binary(), list(binary())) -> r3_hex_api:response(). -search(Config, Query, SearchParams) when is_map(Config) and is_binary(Query) and is_list(SearchParams) -> +-spec search(r3_hex_core:config(), binary(), [{term(), term()}]) -> r3_hex_api:response(). +search(Config, Query, SearchParams) when + is_map(Config) and is_binary(Query) and is_list(SearchParams) +-> QueryString = r3_hex_api:encode_query_string([{search, Query} | SearchParams]), Path = r3_hex_api:join_path_segments(r3_hex_api:build_repository_path(Config, ["packages"])), PathQuery = <>, diff --git a/apps/rebar/src/vendored/r3_hex_api_package_owner.erl b/apps/rebar/src/vendored/r3_hex_api_package_owner.erl index 396b23087..d8c8eb740 100644 --- a/apps/rebar/src/vendored/r3_hex_api_package_owner.erl +++ b/apps/rebar/src/vendored/r3_hex_api_package_owner.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API - Package Owners. -module(r3_hex_api_package_owner). -export([ add/5, @@ -52,8 +54,12 @@ list(Config, PackageName) when is_binary(PackageName) -> %% ''' %% @end -spec get(r3_hex_core:config(), binary(), binary()) -> r3_hex_api:response(). -get(Config, PackageName, UsernameOrEmail) when is_map(Config) and is_binary(PackageName) and is_binary(UsernameOrEmail) -> - Path = r3_hex_api:build_repository_path(Config, ["packages", PackageName, "owners", UsernameOrEmail]), +get(Config, PackageName, UsernameOrEmail) when + is_map(Config) and is_binary(PackageName) and is_binary(UsernameOrEmail) +-> + Path = r3_hex_api:build_repository_path(Config, [ + "packages", PackageName, "owners", UsernameOrEmail + ]), r3_hex_api:get(Config, Path). %% @doc @@ -76,12 +82,15 @@ get(Config, PackageName, UsernameOrEmail) when is_map(Config) and is_binary(Pack %% ''' %% @end -spec add(r3_hex_core:config(), binary(), binary(), binary(), boolean()) -> r3_hex_api:response(). -add(Config, PackageName, UsernameOrEmail, Level, Transfer) -when is_binary(PackageName) and is_binary(UsernameOrEmail) and is_map(Config) and is_binary(Level) and is_boolean(Transfer) -> - Path = r3_hex_api:build_repository_path(Config, ["packages", PackageName, "owners", UsernameOrEmail]), +add(Config, PackageName, UsernameOrEmail, Level, Transfer) when + is_binary(PackageName) and is_binary(UsernameOrEmail) and is_map(Config) and is_binary(Level) and + is_boolean(Transfer) +-> + Path = r3_hex_api:build_repository_path(Config, [ + "packages", PackageName, "owners", UsernameOrEmail + ]), r3_hex_api:put(Config, Path, #{<<"level">> => Level, <<"transfer">> => Transfer}). - %% @doc %% Deletes a packages owner. %% @@ -93,6 +102,10 @@ when is_binary(PackageName) and is_binary(UsernameOrEmail) and is_map(Config) an %% ''' %% @end -spec delete(r3_hex_core:config(), binary(), binary()) -> r3_hex_api:response(). -delete(Config, PackageName, UsernameOrEmail) when is_map(Config) and is_binary(PackageName) and is_binary(UsernameOrEmail) -> - Path = r3_hex_api:build_repository_path(Config, ["packages", PackageName, "owners", UsernameOrEmail]), +delete(Config, PackageName, UsernameOrEmail) when + is_map(Config) and is_binary(PackageName) and is_binary(UsernameOrEmail) +-> + Path = r3_hex_api:build_repository_path(Config, [ + "packages", PackageName, "owners", UsernameOrEmail + ]), r3_hex_api:delete(Config, Path). diff --git a/apps/rebar/src/vendored/r3_hex_api_release.erl b/apps/rebar/src/vendored/r3_hex_api_release.erl index 92d9fdd2f..c07fb6b78 100644 --- a/apps/rebar/src/vendored/r3_hex_api_release.erl +++ b/apps/rebar/src/vendored/r3_hex_api_release.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API - Releases. -module(r3_hex_api_release). -export([ delete/3, @@ -16,11 +18,7 @@ -type retirement_reason() :: other | invalid | security | deprecated | renamed. --ifdef(OTP_19). -type retirement_params() :: #{reason := retirement_reason(), message => binary()}. --else. --type retirement_params() :: #{reason => retirement_reason(), message => binary()}. --endif. %% @doc %% Gets a package release. %% @@ -79,7 +77,6 @@ get(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_binary -spec publish(r3_hex_core:config(), binary()) -> r3_hex_api:response(). publish(Config, Tarball) -> publish(Config, Tarball, []). - %% @doc %% Publishes a new package release with query parameters. %% @@ -109,8 +106,12 @@ publish(Config, Tarball) -> publish(Config, Tarball, []). %% ''' %% @end -spec publish(r3_hex_core:config(), binary(), publish_params()) -> r3_hex_api:response(). -publish(Config, Tarball, Params) when is_map(Config) andalso is_binary(Tarball) andalso is_list(Params)-> - QueryString = r3_hex_api:encode_query_string([{replace, proplists:get_value(replace, Params, false)}]), +publish(Config, Tarball, Params) when + is_map(Config) andalso is_binary(Tarball) andalso is_list(Params) +-> + QueryString = r3_hex_api:encode_query_string([ + {replace, proplists:get_value(replace, Params, false)} + ]), Path = r3_hex_api:join_path_segments(r3_hex_api:build_repository_path(Config, ["publish"])), PathWithQuery = <>, TarballContentType = "application/octet-stream", @@ -144,7 +145,9 @@ delete(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_bin %% ''' %% @end -spec retire(r3_hex_core:config(), binary(), binary(), retirement_params()) -> r3_hex_api:response(). -retire(Config, Name, Version, Params) when is_map(Config) and is_binary(Name) and is_binary(Version) -> +retire(Config, Name, Version, Params) when + is_map(Config) and is_binary(Name) and is_binary(Version) +-> Path = r3_hex_api:build_repository_path(Config, ["packages", Name, "releases", Version, "retire"]), r3_hex_api:post(Config, Path, Params). @@ -167,6 +170,7 @@ unretire(Config, Name, Version) when is_map(Config) and is_binary(Name) and is_b %% Internal functions %%==================================================================== +%% @private put_header(Name, Value, Config) -> Headers = maps:get(http_headers, Config, #{}), Headers2 = maps:put(Name, Value, Headers), diff --git a/apps/rebar/src/vendored/r3_hex_api_user.erl b/apps/rebar/src/vendored/r3_hex_api_user.erl index 526f62b83..a9bbd6e08 100644 --- a/apps/rebar/src/vendored/r3_hex_api_user.erl +++ b/apps/rebar/src/vendored/r3_hex_api_user.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Hex HTTP API - Users. -module(r3_hex_api_user). -export([ create/4, @@ -51,12 +53,13 @@ me(Config) when is_map(Config) -> %% ''' %% @end -spec create(r3_hex_core:config(), binary(), binary(), binary()) -> r3_hex_api:response(). -create(Config, Username, Password, Email) -when is_map(Config) and is_binary(Username) and is_binary(Password) and is_binary(Email) -> +create(Config, Username, Password, Email) when + is_map(Config) and is_binary(Username) and is_binary(Password) and is_binary(Email) +-> Params = #{ - <<"username">> => Username, - <<"password">> => Password, - <<"email">> => Email + <<"username">> => Username, + <<"password">> => Password, + <<"email">> => Email }, r3_hex_api:post(Config, ["users"], Params). diff --git a/apps/rebar/src/vendored/r3_hex_core.erl b/apps/rebar/src/vendored/r3_hex_core.erl index de7c89343..9e184ff00 100644 --- a/apps/rebar/src/vendored/r3_hex_core.erl +++ b/apps/rebar/src/vendored/r3_hex_core.erl @@ -1,37 +1,51 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% @doc -%% hex_core entrypoint module. +%% `hex_core' entrypoint module. %% -%% ### Config +%% === Config === %% -%% Most functions in the hex_core API takes a configuration. The configuration sets things +%% Most functions in the `hex_core' API takes a configuration. The configuration sets things %% like HTTP client to use, and API and repository URL. Some of these configuration options %% will likely be static for your application and some may change depending on the function %% you call. %% -%% ##### Options +%% === Options === %% %% * `api_key' - Authentication key used when accessing the HTTP API. +%% %% * `api_organization' - Name of the organization endpoint in the API, this should %% for example be set when accessing key for a specific organization. +%% %% * `api_repository' - Name of the repository endpoint in the API, this should %% for example be set when accessing packages from a specific repository. +%% %% * `api_url' - URL to the HTTP API (default: `https://hex.pm/api'). -%% * `http_adapter' - A tuple of a callback module used for HTTP requests, see [`r3_hex_http'](r3_hex_http.html) -%% (default: `r3_hex_http_httpc') and the configuration to pass to the HTTP adapter. +%% +%% * `http_adapter' - A tuple of a callback module and its configuration used +%% for HTTP requests (default: `{r3_hex_http_httpc, #{profile => default}}'). See +%% {@link r3_hex_http} and {@link r3_hex_http_httpc} for more information. +%% %% * `http_etag' - Sets the `if-none-match' HTTP header with the given value to do a %% conditional HTTP request. -%% * `http_user_agent_fragment' - Will be appended to the `user-agent` HTTP header (default: `(httpc)'). +%% +%% * `http_user_agent_fragment' - Will be appended to the `user-agent' HTTP header (default: `<<"(httpc)">>'). +%% %% * `repo_key' - Authentication key used when accessing the repository. +%% %% * `repo_name' - Name of the repository, used for verifying the repository signature %% authenticity (default: `hexpm'). +%% %% * `repo_public_key' - Public key used to verify the repository signature %% (defaults to hexpm public key `https://hex.pm/docs/public_keys'). +%% %% * `repo_url' - URL to the repository (default: `https://repo.hex.pm'). +%% %% * `repo_organization' - Name of the organization repository, appends `/repos/:name' %% to the repository URL and overrides the `repo_name' option. +%% %% * `repo_verify' - If `true' will verify the repository signature (default: `true'). +%% %% * `repo_verify_origin' - If `true' will verify the repository signature origin, %% requires protobuf messages as of hex_core v0.4.0 (default: `true'). @@ -41,16 +55,17 @@ -export_type([config/0]). %% https://hex.pm/docs/public_keys --define(HEXPM_PUBLIC_KEY, <<"-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApqREcFDt5vV21JVe2QNB -Edvzk6w36aNFhVGWN5toNJRjRJ6m4hIuG4KaXtDWVLjnvct6MYMfqhC79HAGwyF+ -IqR6Q6a5bbFSsImgBJwz1oadoVKD6ZNetAuCIK84cjMrEFRkELtEIPNHblCzUkkM -3rS9+DPlnfG8hBvGi6tvQIuZmXGCxF/73hU0/MyGhbmEjIKRtG6b0sJYKelRLTPW -XgK7s5pESgiwf2YC/2MGDXjAJfpfCd0RpLdvd4eRiXtVlE9qO9bND94E7PgQ/xqZ -J1i2xWFndWa6nfFnRxZmCStCOZWYYPlaxr+FZceFbpMwzTNs4g3d4tLNUcbKAIH4 -0wIDAQAB ------END PUBLIC KEY-----">>). - +-define(HEXPM_PUBLIC_KEY, << + "-----BEGIN PUBLIC KEY-----\n" + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApqREcFDt5vV21JVe2QNB\n" + "Edvzk6w36aNFhVGWN5toNJRjRJ6m4hIuG4KaXtDWVLjnvct6MYMfqhC79HAGwyF+\n" + "IqR6Q6a5bbFSsImgBJwz1oadoVKD6ZNetAuCIK84cjMrEFRkELtEIPNHblCzUkkM\n" + "3rS9+DPlnfG8hBvGi6tvQIuZmXGCxF/73hU0/MyGhbmEjIKRtG6b0sJYKelRLTPW\n" + "XgK7s5pESgiwf2YC/2MGDXjAJfpfCd0RpLdvd4eRiXtVlE9qO9bND94E7PgQ/xqZ\n" + "J1i2xWFndWa6nfFnRxZmCStCOZWYYPlaxr+FZceFbpMwzTNs4g3d4tLNUcbKAIH4\n" + "0wIDAQAB\n" + "-----END PUBLIC KEY-----" +>>). -type config() :: #{ api_key => binary() | undefined, diff --git a/apps/rebar/src/vendored/r3_hex_core.hrl b/apps/rebar/src/vendored/r3_hex_core.hrl index e3dacdab1..28713fbbd 100644 --- a/apps/rebar/src/vendored/r3_hex_core.hrl +++ b/apps/rebar/src/vendored/r3_hex_core.hrl @@ -1,3 +1,3 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually --define(HEX_CORE_VERSION, "0.7.1"). +-define(HEX_CORE_VERSION, "0.10.0"). diff --git a/apps/rebar/src/vendored/r3_hex_erl_tar.erl b/apps/rebar/src/vendored/r3_hex_erl_tar.erl index a015d23f1..f38e7a75a 100644 --- a/apps/rebar/src/vendored/r3_hex_erl_tar.erl +++ b/apps/rebar/src/vendored/r3_hex_erl_tar.erl @@ -1,4 +1,4 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% @private %% Copied from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/erl_tar.erl diff --git a/apps/rebar/src/vendored/r3_hex_erl_tar.hrl b/apps/rebar/src/vendored/r3_hex_erl_tar.hrl index e3f7bab2b..334a4ac2d 100644 --- a/apps/rebar/src/vendored/r3_hex_erl_tar.hrl +++ b/apps/rebar/src/vendored/r3_hex_erl_tar.hrl @@ -1,4 +1,4 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually % Copied from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/erl_tar.hrl @@ -36,7 +36,7 @@ %% Options used when reading a tar archive. -record(read_opts, { cwd :: string(), %% Current working directory. - keep_old_files = false :: boolean(), %% Overwrite or not. + keep_old_files = false :: boolean(), %% Owerwrite or not. files = all, %% Set of files to extract (or all) output = file :: 'file' | 'memory', open_mode = [], %% Open mode options. @@ -202,7 +202,7 @@ %% These constants (except S_IFMT) are %% used to determine what type of device %% a file is. Namely, `S_IFMT band file_info.mode` -%% will equal one of these constants, and tells us +%% will equal one of these contants, and tells us %% which type it is. The stdlib file_info record %% does not differentiate between device types, and %% will not allow us to differentiate between sockets diff --git a/apps/rebar/src/vendored/r3_hex_filename.erl b/apps/rebar/src/vendored/r3_hex_filename.erl index 34ebc0880..a10fa91c1 100644 --- a/apps/rebar/src/vendored/r3_hex_filename.erl +++ b/apps/rebar/src/vendored/r3_hex_filename.erl @@ -1,4 +1,4 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually % @private % Excerpt from https://github.com/erlang/otp/blob/OTP-20.0.1/lib/stdlib/src/filename.erl#L761-L788 @@ -39,16 +39,16 @@ safe_relative_path(Path) -> unsafe end. -safe_relative_path_1(["."|T], Acc) -> +safe_relative_path_1(["." | T], Acc) -> safe_relative_path_1(T, Acc); -safe_relative_path_1([<<".">>|T], Acc) -> +safe_relative_path_1([<<".">> | T], Acc) -> safe_relative_path_1(T, Acc); -safe_relative_path_1([".."|T], Acc) -> +safe_relative_path_1([".." | T], Acc) -> climb(T, Acc); -safe_relative_path_1([<<"..">>|T], Acc) -> +safe_relative_path_1([<<"..">> | T], Acc) -> climb(T, Acc); -safe_relative_path_1([H|T], Acc) -> - safe_relative_path_1(T, [H|Acc]); +safe_relative_path_1([H | T], Acc) -> + safe_relative_path_1(T, [H | Acc]); safe_relative_path_1([], []) -> []; safe_relative_path_1([], Acc) -> @@ -56,5 +56,5 @@ safe_relative_path_1([], Acc) -> climb(_, []) -> unsafe; -climb(T, [_|Acc]) -> +climb(T, [_ | Acc]) -> safe_relative_path_1(T, Acc). diff --git a/apps/rebar/src/vendored/r3_hex_http.erl b/apps/rebar/src/vendored/r3_hex_http.erl index 19ea90b53..57a0b75e8 100644 --- a/apps/rebar/src/vendored/r3_hex_http.erl +++ b/apps/rebar/src/vendored/r3_hex_http.erl @@ -1,5 +1,7 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% HTTP contract. -module(r3_hex_http). -export([request/5]). -ifdef(TEST). @@ -16,26 +18,30 @@ -type adapter_config() :: map(). -callback request(method(), URI :: binary(), headers(), body(), adapter_config()) -> - {ok, status(), headers(), binary()} | - {error, term()}. + {ok, status(), headers(), binary()} + | {error, term()}. -spec request(r3_hex_core:config(), method(), URI :: binary(), headers(), body()) -> {ok, {status(), headers(), binary()}} | {error, term()}. request(Config, Method, URI, Headers, Body) when is_binary(URI) and is_map(Headers) -> - {Adapter, AdapterConfig} = case maps:get(http_adapter, Config, {r3_hex_http_httpc, #{}}) of - {Adapter0, AdapterConfig0} -> - {Adapter0, AdapterConfig0}; - %% TODO: remove in v0.9 - Adapter0 when is_atom(Adapter0) -> - AdapterConfig0 = maps:get(http_adapter_config, Config, #{}), - io:format("[r3_hex_http] setting #{http_adapter => Module, http_adapter_config => Map} " - "is deprecated in favour of #{http_adapter => {Module, Map}}~n"), - {Adapter0, AdapterConfig0} - end, + {Adapter, AdapterConfig} = + case maps:get(http_adapter, Config, {r3_hex_http_httpc, #{}}) of + {Adapter0, AdapterConfig0} -> + {Adapter0, AdapterConfig0}; + %% TODO: remove in v0.9 + Adapter0 when is_atom(Adapter0) -> + AdapterConfig0 = maps:get(http_adapter_config, Config, #{}), + io:format( + "[r3_hex_http] setting #{http_adapter => Module, http_adapter_config => Map} " + "is deprecated in favour of #{http_adapter => {Module, Map}}~n" + ), + {Adapter0, AdapterConfig0} + end, UserAgentFragment = maps:get(http_user_agent_fragment, Config), Headers2 = put_new(<<"user-agent">>, user_agent(UserAgentFragment), Headers), Adapter:request(Method, URI, Headers2, Body, AdapterConfig). +%% @private user_agent(UserAgentFragment) -> OTPRelease = erlang:system_info(otp_release), ERTSVersion = erlang:system_info(version), @@ -46,6 +52,7 @@ user_agent(UserAgentFragment) -> %% Internal functions %%==================================================================== +%% @private put_new(Key, Value, Map) -> case maps:find(Key, Map) of {ok, _} -> Map; diff --git a/apps/rebar/src/vendored/r3_hex_http_httpc.erl b/apps/rebar/src/vendored/r3_hex_http_httpc.erl index 79a354779..71c6ed937 100644 --- a/apps/rebar/src/vendored/r3_hex_http_httpc.erl +++ b/apps/rebar/src/vendored/r3_hex_http_httpc.erl @@ -1,6 +1,16 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually -%% @hidden +%% @doc +%% httpc-based implementation of {@link r3_hex_http} contract. +%% +%% Configuration keys: +%% +%% * `profile' - the name of the profile, defaults to `default'. See +%% {@link httpc:set_options/2} for more information on setting +%% options on profiles. +%% +%% * `http_options' - a list of HTTP options, defaults to `[]'. See +%% {@link httpc:request/5} for a list of available HTTP options. -module(r3_hex_http_httpc). -behaviour(r3_hex_http). @@ -10,32 +20,67 @@ %% API functions %%==================================================================== -request(Method, URI, ReqHeaders, Body, AdapterConfig) -> +request(Method, URI, ReqHeaders, Body, AdapterConfig) when is_binary(URI) -> Profile = maps:get(profile, AdapterConfig, default), + HTTPOptions = maps:get(http_options, AdapterConfig, []), + + HTTPS = + case URI of + <<"https", _/binary>> -> true; + _ -> false + end, + SSLOpts = proplists:get_value(ssl, HTTPOptions), + + if + HTTPS == true andalso SSLOpts == undefined -> + io:format( + "[r3_hex_http_httpc] using default ssl options which are insecure.~n" + "Configure your adapter with: " + "{r3_hex_http_httpc, #{http_options => [{ssl, SslOpts}]}}~n" + ); + true -> + ok + end, + Request = build_request(URI, ReqHeaders, Body), - case httpc:request(Method, Request, [], [{body_format, binary}], Profile) of + case httpc:request(Method, Request, HTTPOptions, [{body_format, binary}], Profile) of {ok, {{_, StatusCode, _}, RespHeaders, RespBody}} -> RespHeaders2 = load_headers(RespHeaders), {ok, {StatusCode, RespHeaders2, RespBody}}; - {error, Reason} -> {error, Reason} + {error, Reason} -> + {error, Reason} end. %%==================================================================== %% Internal functions %%==================================================================== +%% @private build_request(URI, ReqHeaders, Body) -> build_request2(binary_to_list(URI), dump_headers(ReqHeaders), Body). +%% @private build_request2(URI, ReqHeaders, undefined) -> {URI, ReqHeaders}; build_request2(URI, ReqHeaders, {ContentType, Body}) -> {URI, ReqHeaders, ContentType, Body}. +%% @private dump_headers(Map) -> - maps:fold(fun(K, V, Acc) -> - [{binary_to_list(K), binary_to_list(V)} | Acc] end, [], Map). + maps:fold( + fun(K, V, Acc) -> + [{binary_to_list(K), binary_to_list(V)} | Acc] + end, + [], + Map + ). +%% @private load_headers(List) -> - lists:foldl(fun({K, V}, Acc) -> - maps:put(list_to_binary(K), list_to_binary(V), Acc) end, #{}, List). + lists:foldl( + fun({K, V}, Acc) -> + maps:put(list_to_binary(K), list_to_binary(V), Acc) + end, + #{}, + List + ). diff --git a/apps/rebar/src/vendored/r3_hex_licenses.erl b/apps/rebar/src/vendored/r3_hex_licenses.erl new file mode 100644 index 000000000..d0c87bb44 --- /dev/null +++ b/apps/rebar/src/vendored/r3_hex_licenses.erl @@ -0,0 +1,471 @@ +%% Vendored from hex_core v0.10.0, do not edit manually + +%% @doc +%% Hex Licenses. +%% File generated by spdx.ex. Do not edit manually. + +-module(r3_hex_licenses). + +-export([valid/1]). + +valid(<<"0BSD">>) -> true; +valid(<<"AAL">>) -> true; +valid(<<"ADSL">>) -> true; +valid(<<"AFL-1.1">>) -> true; +valid(<<"AFL-1.2">>) -> true; +valid(<<"AFL-2.0">>) -> true; +valid(<<"AFL-2.1">>) -> true; +valid(<<"AFL-3.0">>) -> true; +valid(<<"AGPL-1.0">>) -> true; +valid(<<"AGPL-1.0-only">>) -> true; +valid(<<"AGPL-1.0-or-later">>) -> true; +valid(<<"AGPL-3.0">>) -> true; +valid(<<"AGPL-3.0-only">>) -> true; +valid(<<"AGPL-3.0-or-later">>) -> true; +valid(<<"AMDPLPA">>) -> true; +valid(<<"AML">>) -> true; +valid(<<"AMPAS">>) -> true; +valid(<<"ANTLR-PD">>) -> true; +valid(<<"ANTLR-PD-fallback">>) -> true; +valid(<<"APAFML">>) -> true; +valid(<<"APL-1.0">>) -> true; +valid(<<"APSL-1.0">>) -> true; +valid(<<"APSL-1.1">>) -> true; +valid(<<"APSL-1.2">>) -> true; +valid(<<"APSL-2.0">>) -> true; +valid(<<"Abstyles">>) -> true; +valid(<<"Adobe-2006">>) -> true; +valid(<<"Adobe-Glyph">>) -> true; +valid(<<"Afmparse">>) -> true; +valid(<<"Aladdin">>) -> true; +valid(<<"Apache-1.0">>) -> true; +valid(<<"Apache-1.1">>) -> true; +valid(<<"Apache-2.0">>) -> true; +valid(<<"Artistic-1.0">>) -> true; +valid(<<"Artistic-1.0-Perl">>) -> true; +valid(<<"Artistic-1.0-cl8">>) -> true; +valid(<<"Artistic-2.0">>) -> true; +valid(<<"BSD-1-Clause">>) -> true; +valid(<<"BSD-2-Clause">>) -> true; +valid(<<"BSD-2-Clause-FreeBSD">>) -> true; +valid(<<"BSD-2-Clause-NetBSD">>) -> true; +valid(<<"BSD-2-Clause-Patent">>) -> true; +valid(<<"BSD-2-Clause-Views">>) -> true; +valid(<<"BSD-3-Clause">>) -> true; +valid(<<"BSD-3-Clause-Attribution">>) -> true; +valid(<<"BSD-3-Clause-Clear">>) -> true; +valid(<<"BSD-3-Clause-LBNL">>) -> true; +valid(<<"BSD-3-Clause-Modification">>) -> true; +valid(<<"BSD-3-Clause-No-Military-License">>) -> true; +valid(<<"BSD-3-Clause-No-Nuclear-License">>) -> true; +valid(<<"BSD-3-Clause-No-Nuclear-License-2014">>) -> true; +valid(<<"BSD-3-Clause-No-Nuclear-Warranty">>) -> true; +valid(<<"BSD-3-Clause-Open-MPI">>) -> true; +valid(<<"BSD-4-Clause">>) -> true; +valid(<<"BSD-4-Clause-Shortened">>) -> true; +valid(<<"BSD-4-Clause-UC">>) -> true; +valid(<<"BSD-Protection">>) -> true; +valid(<<"BSD-Source-Code">>) -> true; +valid(<<"BSL-1.0">>) -> true; +valid(<<"BUSL-1.1">>) -> true; +valid(<<"Bahyph">>) -> true; +valid(<<"Barr">>) -> true; +valid(<<"Beerware">>) -> true; +valid(<<"BitTorrent-1.0">>) -> true; +valid(<<"BitTorrent-1.1">>) -> true; +valid(<<"BlueOak-1.0.0">>) -> true; +valid(<<"Borceux">>) -> true; +valid(<<"C-UDA-1.0">>) -> true; +valid(<<"CAL-1.0">>) -> true; +valid(<<"CAL-1.0-Combined-Work-Exception">>) -> true; +valid(<<"CATOSL-1.1">>) -> true; +valid(<<"CC-BY-1.0">>) -> true; +valid(<<"CC-BY-2.0">>) -> true; +valid(<<"CC-BY-2.5">>) -> true; +valid(<<"CC-BY-3.0">>) -> true; +valid(<<"CC-BY-3.0-AT">>) -> true; +valid(<<"CC-BY-3.0-US">>) -> true; +valid(<<"CC-BY-4.0">>) -> true; +valid(<<"CC-BY-NC-1.0">>) -> true; +valid(<<"CC-BY-NC-2.0">>) -> true; +valid(<<"CC-BY-NC-2.5">>) -> true; +valid(<<"CC-BY-NC-3.0">>) -> true; +valid(<<"CC-BY-NC-4.0">>) -> true; +valid(<<"CC-BY-NC-ND-1.0">>) -> true; +valid(<<"CC-BY-NC-ND-2.0">>) -> true; +valid(<<"CC-BY-NC-ND-2.5">>) -> true; +valid(<<"CC-BY-NC-ND-3.0">>) -> true; +valid(<<"CC-BY-NC-ND-3.0-IGO">>) -> true; +valid(<<"CC-BY-NC-ND-4.0">>) -> true; +valid(<<"CC-BY-NC-SA-1.0">>) -> true; +valid(<<"CC-BY-NC-SA-2.0">>) -> true; +valid(<<"CC-BY-NC-SA-2.5">>) -> true; +valid(<<"CC-BY-NC-SA-3.0">>) -> true; +valid(<<"CC-BY-NC-SA-4.0">>) -> true; +valid(<<"CC-BY-ND-1.0">>) -> true; +valid(<<"CC-BY-ND-2.0">>) -> true; +valid(<<"CC-BY-ND-2.5">>) -> true; +valid(<<"CC-BY-ND-3.0">>) -> true; +valid(<<"CC-BY-ND-4.0">>) -> true; +valid(<<"CC-BY-SA-1.0">>) -> true; +valid(<<"CC-BY-SA-2.0">>) -> true; +valid(<<"CC-BY-SA-2.0-UK">>) -> true; +valid(<<"CC-BY-SA-2.1-JP">>) -> true; +valid(<<"CC-BY-SA-2.5">>) -> true; +valid(<<"CC-BY-SA-3.0">>) -> true; +valid(<<"CC-BY-SA-3.0-AT">>) -> true; +valid(<<"CC-BY-SA-4.0">>) -> true; +valid(<<"CC-PDDC">>) -> true; +valid(<<"CC0-1.0">>) -> true; +valid(<<"CDDL-1.0">>) -> true; +valid(<<"CDDL-1.1">>) -> true; +valid(<<"CDL-1.0">>) -> true; +valid(<<"CDLA-Permissive-1.0">>) -> true; +valid(<<"CDLA-Sharing-1.0">>) -> true; +valid(<<"CECILL-1.0">>) -> true; +valid(<<"CECILL-1.1">>) -> true; +valid(<<"CECILL-2.0">>) -> true; +valid(<<"CECILL-2.1">>) -> true; +valid(<<"CECILL-B">>) -> true; +valid(<<"CECILL-C">>) -> true; +valid(<<"CERN-OHL-1.1">>) -> true; +valid(<<"CERN-OHL-1.2">>) -> true; +valid(<<"CERN-OHL-P-2.0">>) -> true; +valid(<<"CERN-OHL-S-2.0">>) -> true; +valid(<<"CERN-OHL-W-2.0">>) -> true; +valid(<<"CNRI-Jython">>) -> true; +valid(<<"CNRI-Python">>) -> true; +valid(<<"CNRI-Python-GPL-Compatible">>) -> true; +valid(<<"CPAL-1.0">>) -> true; +valid(<<"CPL-1.0">>) -> true; +valid(<<"CPOL-1.02">>) -> true; +valid(<<"CUA-OPL-1.0">>) -> true; +valid(<<"Caldera">>) -> true; +valid(<<"ClArtistic">>) -> true; +valid(<<"Condor-1.1">>) -> true; +valid(<<"Crossword">>) -> true; +valid(<<"CrystalStacker">>) -> true; +valid(<<"Cube">>) -> true; +valid(<<"D-FSL-1.0">>) -> true; +valid(<<"DOC">>) -> true; +valid(<<"DRL-1.0">>) -> true; +valid(<<"DSDP">>) -> true; +valid(<<"Dotseqn">>) -> true; +valid(<<"ECL-1.0">>) -> true; +valid(<<"ECL-2.0">>) -> true; +valid(<<"EFL-1.0">>) -> true; +valid(<<"EFL-2.0">>) -> true; +valid(<<"EPICS">>) -> true; +valid(<<"EPL-1.0">>) -> true; +valid(<<"EPL-2.0">>) -> true; +valid(<<"EUDatagrid">>) -> true; +valid(<<"EUPL-1.0">>) -> true; +valid(<<"EUPL-1.1">>) -> true; +valid(<<"EUPL-1.2">>) -> true; +valid(<<"Entessa">>) -> true; +valid(<<"ErlPL-1.1">>) -> true; +valid(<<"Eurosym">>) -> true; +valid(<<"FSFAP">>) -> true; +valid(<<"FSFUL">>) -> true; +valid(<<"FSFULLR">>) -> true; +valid(<<"FTL">>) -> true; +valid(<<"Fair">>) -> true; +valid(<<"Frameworx-1.0">>) -> true; +valid(<<"FreeBSD-DOC">>) -> true; +valid(<<"FreeImage">>) -> true; +valid(<<"GD">>) -> true; +valid(<<"GFDL-1.1">>) -> true; +valid(<<"GFDL-1.1-invariants-only">>) -> true; +valid(<<"GFDL-1.1-invariants-or-later">>) -> true; +valid(<<"GFDL-1.1-no-invariants-only">>) -> true; +valid(<<"GFDL-1.1-no-invariants-or-later">>) -> true; +valid(<<"GFDL-1.1-only">>) -> true; +valid(<<"GFDL-1.1-or-later">>) -> true; +valid(<<"GFDL-1.2">>) -> true; +valid(<<"GFDL-1.2-invariants-only">>) -> true; +valid(<<"GFDL-1.2-invariants-or-later">>) -> true; +valid(<<"GFDL-1.2-no-invariants-only">>) -> true; +valid(<<"GFDL-1.2-no-invariants-or-later">>) -> true; +valid(<<"GFDL-1.2-only">>) -> true; +valid(<<"GFDL-1.2-or-later">>) -> true; +valid(<<"GFDL-1.3">>) -> true; +valid(<<"GFDL-1.3-invariants-only">>) -> true; +valid(<<"GFDL-1.3-invariants-or-later">>) -> true; +valid(<<"GFDL-1.3-no-invariants-only">>) -> true; +valid(<<"GFDL-1.3-no-invariants-or-later">>) -> true; +valid(<<"GFDL-1.3-only">>) -> true; +valid(<<"GFDL-1.3-or-later">>) -> true; +valid(<<"GL2PS">>) -> true; +valid(<<"GLWTPL">>) -> true; +valid(<<"GPL-1.0">>) -> true; +valid(<<"GPL-1.0+">>) -> true; +valid(<<"GPL-1.0-only">>) -> true; +valid(<<"GPL-1.0-or-later">>) -> true; +valid(<<"GPL-2.0">>) -> true; +valid(<<"GPL-2.0+">>) -> true; +valid(<<"GPL-2.0-only">>) -> true; +valid(<<"GPL-2.0-or-later">>) -> true; +valid(<<"GPL-2.0-with-GCC-exception">>) -> true; +valid(<<"GPL-2.0-with-autoconf-exception">>) -> true; +valid(<<"GPL-2.0-with-bison-exception">>) -> true; +valid(<<"GPL-2.0-with-classpath-exception">>) -> true; +valid(<<"GPL-2.0-with-font-exception">>) -> true; +valid(<<"GPL-3.0">>) -> true; +valid(<<"GPL-3.0+">>) -> true; +valid(<<"GPL-3.0-only">>) -> true; +valid(<<"GPL-3.0-or-later">>) -> true; +valid(<<"GPL-3.0-with-GCC-exception">>) -> true; +valid(<<"GPL-3.0-with-autoconf-exception">>) -> true; +valid(<<"Giftware">>) -> true; +valid(<<"Glide">>) -> true; +valid(<<"Glulxe">>) -> true; +valid(<<"HPND">>) -> true; +valid(<<"HPND-sell-variant">>) -> true; +valid(<<"HTMLTIDY">>) -> true; +valid(<<"HaskellReport">>) -> true; +valid(<<"Hippocratic-2.1">>) -> true; +valid(<<"IBM-pibs">>) -> true; +valid(<<"ICU">>) -> true; +valid(<<"IJG">>) -> true; +valid(<<"IPA">>) -> true; +valid(<<"IPL-1.0">>) -> true; +valid(<<"ISC">>) -> true; +valid(<<"ImageMagick">>) -> true; +valid(<<"Imlib2">>) -> true; +valid(<<"Info-ZIP">>) -> true; +valid(<<"Intel">>) -> true; +valid(<<"Intel-ACPI">>) -> true; +valid(<<"Interbase-1.0">>) -> true; +valid(<<"JPNIC">>) -> true; +valid(<<"JSON">>) -> true; +valid(<<"JasPer-2.0">>) -> true; +valid(<<"LAL-1.2">>) -> true; +valid(<<"LAL-1.3">>) -> true; +valid(<<"LGPL-2.0">>) -> true; +valid(<<"LGPL-2.0+">>) -> true; +valid(<<"LGPL-2.0-only">>) -> true; +valid(<<"LGPL-2.0-or-later">>) -> true; +valid(<<"LGPL-2.1">>) -> true; +valid(<<"LGPL-2.1+">>) -> true; +valid(<<"LGPL-2.1-only">>) -> true; +valid(<<"LGPL-2.1-or-later">>) -> true; +valid(<<"LGPL-3.0">>) -> true; +valid(<<"LGPL-3.0+">>) -> true; +valid(<<"LGPL-3.0-only">>) -> true; +valid(<<"LGPL-3.0-or-later">>) -> true; +valid(<<"LGPLLR">>) -> true; +valid(<<"LPL-1.0">>) -> true; +valid(<<"LPL-1.02">>) -> true; +valid(<<"LPPL-1.0">>) -> true; +valid(<<"LPPL-1.1">>) -> true; +valid(<<"LPPL-1.2">>) -> true; +valid(<<"LPPL-1.3a">>) -> true; +valid(<<"LPPL-1.3c">>) -> true; +valid(<<"Latex2e">>) -> true; +valid(<<"Leptonica">>) -> true; +valid(<<"LiLiQ-P-1.1">>) -> true; +valid(<<"LiLiQ-R-1.1">>) -> true; +valid(<<"LiLiQ-Rplus-1.1">>) -> true; +valid(<<"Libpng">>) -> true; +valid(<<"Linux-OpenIB">>) -> true; +valid(<<"MIT">>) -> true; +valid(<<"MIT-0">>) -> true; +valid(<<"MIT-CMU">>) -> true; +valid(<<"MIT-Modern-Variant">>) -> true; +valid(<<"MIT-advertising">>) -> true; +valid(<<"MIT-enna">>) -> true; +valid(<<"MIT-feh">>) -> true; +valid(<<"MIT-open-group">>) -> true; +valid(<<"MITNFA">>) -> true; +valid(<<"MPL-1.0">>) -> true; +valid(<<"MPL-1.1">>) -> true; +valid(<<"MPL-2.0">>) -> true; +valid(<<"MPL-2.0-no-copyleft-exception">>) -> true; +valid(<<"MS-PL">>) -> true; +valid(<<"MS-RL">>) -> true; +valid(<<"MTLL">>) -> true; +valid(<<"MakeIndex">>) -> true; +valid(<<"MirOS">>) -> true; +valid(<<"Motosoto">>) -> true; +valid(<<"MulanPSL-1.0">>) -> true; +valid(<<"MulanPSL-2.0">>) -> true; +valid(<<"Multics">>) -> true; +valid(<<"Mup">>) -> true; +valid(<<"NAIST-2003">>) -> true; +valid(<<"NASA-1.3">>) -> true; +valid(<<"NBPL-1.0">>) -> true; +valid(<<"NCGL-UK-2.0">>) -> true; +valid(<<"NCSA">>) -> true; +valid(<<"NGPL">>) -> true; +valid(<<"NIST-PD">>) -> true; +valid(<<"NIST-PD-fallback">>) -> true; +valid(<<"NLOD-1.0">>) -> true; +valid(<<"NLPL">>) -> true; +valid(<<"NOSL">>) -> true; +valid(<<"NPL-1.0">>) -> true; +valid(<<"NPL-1.1">>) -> true; +valid(<<"NPOSL-3.0">>) -> true; +valid(<<"NRL">>) -> true; +valid(<<"NTP">>) -> true; +valid(<<"NTP-0">>) -> true; +valid(<<"Naumen">>) -> true; +valid(<<"Net-SNMP">>) -> true; +valid(<<"NetCDF">>) -> true; +valid(<<"Newsletr">>) -> true; +valid(<<"Nokia">>) -> true; +valid(<<"Noweb">>) -> true; +valid(<<"Nunit">>) -> true; +valid(<<"O-UDA-1.0">>) -> true; +valid(<<"OCCT-PL">>) -> true; +valid(<<"OCLC-2.0">>) -> true; +valid(<<"ODC-By-1.0">>) -> true; +valid(<<"ODbL-1.0">>) -> true; +valid(<<"OFL-1.0">>) -> true; +valid(<<"OFL-1.0-RFN">>) -> true; +valid(<<"OFL-1.0-no-RFN">>) -> true; +valid(<<"OFL-1.1">>) -> true; +valid(<<"OFL-1.1-RFN">>) -> true; +valid(<<"OFL-1.1-no-RFN">>) -> true; +valid(<<"OGC-1.0">>) -> true; +valid(<<"OGDL-Taiwan-1.0">>) -> true; +valid(<<"OGL-Canada-2.0">>) -> true; +valid(<<"OGL-UK-1.0">>) -> true; +valid(<<"OGL-UK-2.0">>) -> true; +valid(<<"OGL-UK-3.0">>) -> true; +valid(<<"OGTSL">>) -> true; +valid(<<"OLDAP-1.1">>) -> true; +valid(<<"OLDAP-1.2">>) -> true; +valid(<<"OLDAP-1.3">>) -> true; +valid(<<"OLDAP-1.4">>) -> true; +valid(<<"OLDAP-2.0">>) -> true; +valid(<<"OLDAP-2.0.1">>) -> true; +valid(<<"OLDAP-2.1">>) -> true; +valid(<<"OLDAP-2.2">>) -> true; +valid(<<"OLDAP-2.2.1">>) -> true; +valid(<<"OLDAP-2.2.2">>) -> true; +valid(<<"OLDAP-2.3">>) -> true; +valid(<<"OLDAP-2.4">>) -> true; +valid(<<"OLDAP-2.5">>) -> true; +valid(<<"OLDAP-2.6">>) -> true; +valid(<<"OLDAP-2.7">>) -> true; +valid(<<"OLDAP-2.8">>) -> true; +valid(<<"OML">>) -> true; +valid(<<"OPL-1.0">>) -> true; +valid(<<"OSET-PL-2.1">>) -> true; +valid(<<"OSL-1.0">>) -> true; +valid(<<"OSL-1.1">>) -> true; +valid(<<"OSL-2.0">>) -> true; +valid(<<"OSL-2.1">>) -> true; +valid(<<"OSL-3.0">>) -> true; +valid(<<"OpenSSL">>) -> true; +valid(<<"PDDL-1.0">>) -> true; +valid(<<"PHP-3.0">>) -> true; +valid(<<"PHP-3.01">>) -> true; +valid(<<"PSF-2.0">>) -> true; +valid(<<"Parity-6.0.0">>) -> true; +valid(<<"Parity-7.0.0">>) -> true; +valid(<<"Plexus">>) -> true; +valid(<<"PolyForm-Noncommercial-1.0.0">>) -> true; +valid(<<"PolyForm-Small-Business-1.0.0">>) -> true; +valid(<<"PostgreSQL">>) -> true; +valid(<<"Python-2.0">>) -> true; +valid(<<"QPL-1.0">>) -> true; +valid(<<"Qhull">>) -> true; +valid(<<"RHeCos-1.1">>) -> true; +valid(<<"RPL-1.1">>) -> true; +valid(<<"RPL-1.5">>) -> true; +valid(<<"RPSL-1.0">>) -> true; +valid(<<"RSA-MD">>) -> true; +valid(<<"RSCPL">>) -> true; +valid(<<"Rdisc">>) -> true; +valid(<<"Ruby">>) -> true; +valid(<<"SAX-PD">>) -> true; +valid(<<"SCEA">>) -> true; +valid(<<"SGI-B-1.0">>) -> true; +valid(<<"SGI-B-1.1">>) -> true; +valid(<<"SGI-B-2.0">>) -> true; +valid(<<"SHL-0.5">>) -> true; +valid(<<"SHL-0.51">>) -> true; +valid(<<"SISSL">>) -> true; +valid(<<"SISSL-1.2">>) -> true; +valid(<<"SMLNJ">>) -> true; +valid(<<"SMPPL">>) -> true; +valid(<<"SNIA">>) -> true; +valid(<<"SPL-1.0">>) -> true; +valid(<<"SSH-OpenSSH">>) -> true; +valid(<<"SSH-short">>) -> true; +valid(<<"SSPL-1.0">>) -> true; +valid(<<"SWL">>) -> true; +valid(<<"Saxpath">>) -> true; +valid(<<"Sendmail">>) -> true; +valid(<<"Sendmail-8.23">>) -> true; +valid(<<"SimPL-2.0">>) -> true; +valid(<<"Sleepycat">>) -> true; +valid(<<"Spencer-86">>) -> true; +valid(<<"Spencer-94">>) -> true; +valid(<<"Spencer-99">>) -> true; +valid(<<"StandardML-NJ">>) -> true; +valid(<<"SugarCRM-1.1.3">>) -> true; +valid(<<"TAPR-OHL-1.0">>) -> true; +valid(<<"TCL">>) -> true; +valid(<<"TCP-wrappers">>) -> true; +valid(<<"TMate">>) -> true; +valid(<<"TORQUE-1.1">>) -> true; +valid(<<"TOSL">>) -> true; +valid(<<"TU-Berlin-1.0">>) -> true; +valid(<<"TU-Berlin-2.0">>) -> true; +valid(<<"UCL-1.0">>) -> true; +valid(<<"UPL-1.0">>) -> true; +valid(<<"Unicode-DFS-2015">>) -> true; +valid(<<"Unicode-DFS-2016">>) -> true; +valid(<<"Unicode-TOU">>) -> true; +valid(<<"Unlicense">>) -> true; +valid(<<"VOSTROM">>) -> true; +valid(<<"VSL-1.0">>) -> true; +valid(<<"Vim">>) -> true; +valid(<<"W3C">>) -> true; +valid(<<"W3C-19980720">>) -> true; +valid(<<"W3C-20150513">>) -> true; +valid(<<"WTFPL">>) -> true; +valid(<<"Watcom-1.0">>) -> true; +valid(<<"Wsuipa">>) -> true; +valid(<<"X11">>) -> true; +valid(<<"XFree86-1.1">>) -> true; +valid(<<"XSkat">>) -> true; +valid(<<"Xerox">>) -> true; +valid(<<"Xnet">>) -> true; +valid(<<"YPL-1.0">>) -> true; +valid(<<"YPL-1.1">>) -> true; +valid(<<"ZPL-1.1">>) -> true; +valid(<<"ZPL-2.0">>) -> true; +valid(<<"ZPL-2.1">>) -> true; +valid(<<"Zed">>) -> true; +valid(<<"Zend-2.0">>) -> true; +valid(<<"Zimbra-1.3">>) -> true; +valid(<<"Zimbra-1.4">>) -> true; +valid(<<"Zlib">>) -> true; +valid(<<"blessing">>) -> true; +valid(<<"bzip2-1.0.5">>) -> true; +valid(<<"bzip2-1.0.6">>) -> true; +valid(<<"copyleft-next-0.3.0">>) -> true; +valid(<<"copyleft-next-0.3.1">>) -> true; +valid(<<"curl">>) -> true; +valid(<<"diffmark">>) -> true; +valid(<<"dvipdfm">>) -> true; +valid(<<"eCos-2.0">>) -> true; +valid(<<"eGenix">>) -> true; +valid(<<"etalab-2.0">>) -> true; +valid(<<"gSOAP-1.3b">>) -> true; +valid(<<"gnuplot">>) -> true; +valid(<<"iMatix">>) -> true; +valid(<<"libpng-2.0">>) -> true; +valid(<<"libselinux-1.0">>) -> true; +valid(<<"libtiff">>) -> true; +valid(<<"mpich2">>) -> true; +valid(<<"psfrag">>) -> true; +valid(<<"psutils">>) -> true; +valid(<<"wxWindows">>) -> true; +valid(<<"xinetd">>) -> true; +valid(<<"xpp">>) -> true; +valid(<<"zlib-acknowledgement">>) -> true; +valid(_) -> false. diff --git a/apps/rebar/src/vendored/r3_hex_pb_names.erl b/apps/rebar/src/vendored/r3_hex_pb_names.erl index 420058e89..ac46fe1b2 100644 --- a/apps/rebar/src/vendored/r3_hex_pb_names.erl +++ b/apps/rebar/src/vendored/r3_hex_pb_names.erl @@ -1,9 +1,10 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.10.0 +%% Generated by gpb_compile version 4.17.6 +%% Version source: file -module(r3_hex_pb_names). -export([encode_msg/2, encode_msg/3]). @@ -45,6 +46,7 @@ -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). %% enumerated types @@ -53,101 +55,105 @@ %% message types -type 'Names'() :: - #{packages => ['Package'()], % = 1 - repository := iodata() % = 2 + #{packages => ['Package'()], % = 1, repeated + repository => unicode:chardata() % = 2, required }. -type 'Package'() :: - #{name := iodata() % = 1 + #{name => unicode:chardata(), % = 1, required + updated_at => 'Timestamp'() % = 3, optional }. --export_type(['Names'/0, 'Package'/0]). +-type 'Timestamp'() :: + #{seconds => integer(), % = 1, required, 64 bits + nanos => integer() % = 2, required, 32 bits + }. + +-export_type(['Names'/0, 'Package'/0, 'Timestamp'/0]). +-type '$msg_name'() :: 'Names' | 'Package' | 'Timestamp'. +-type '$msg'() :: 'Names'() | 'Package'() | 'Timestamp'(). +-export_type(['$msg_name'/0, '$msg'/0]). --spec encode_msg('Names'() | 'Package'(), atom()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> - encode_msg(Msg, MsgName, []). +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). --spec encode_msg('Names'() | 'Package'(), atom(), list()) -> binary(). +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Names' -> - encode_msg_Names(id(Msg, TrUserData), TrUserData); - 'Package' -> - encode_msg_Package(id(Msg, TrUserData), TrUserData) + 'Names' -> encode_msg_Names(id(Msg, TrUserData), TrUserData); + 'Package' -> encode_msg_Package(id(Msg, TrUserData), TrUserData); + 'Timestamp' -> encode_msg_Timestamp(id(Msg, TrUserData), TrUserData) end. -encode_msg_Names(Msg, TrUserData) -> - encode_msg_Names(Msg, <<>>, TrUserData). +encode_msg_Names(Msg, TrUserData) -> encode_msg_Names(Msg, <<>>, TrUserData). -encode_msg_Names(#{repository := F2} = M, Bin, - TrUserData) -> +encode_msg_Names(#{repository := F2} = M, Bin, TrUserData) -> B1 = case M of - #{packages := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_Names_packages(TrF1, Bin, TrUserData) - end; - _ -> Bin - end, - begin - TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>, TrUserData) - end. + #{packages := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_Names_packages(TrF1, Bin, TrUserData) + end; + _ -> Bin + end, + begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <>, TrUserData) end. -encode_msg_Package(Msg, TrUserData) -> - encode_msg_Package(Msg, <<>>, TrUserData). +encode_msg_Package(Msg, TrUserData) -> encode_msg_Package(Msg, <<>>, TrUserData). -encode_msg_Package(#{name := F1}, Bin, TrUserData) -> - begin - TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>, TrUserData) +encode_msg_Package(#{name := F1} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <>, TrUserData) end, + case M of + #{updated_at := F2} -> begin TrF2 = id(F2, TrUserData), e_mfield_Package_updated_at(TrF2, <>, TrUserData) end; + _ -> B1 end. +encode_msg_Timestamp(Msg, TrUserData) -> encode_msg_Timestamp(Msg, <<>>, TrUserData). + + +encode_msg_Timestamp(#{seconds := F1, nanos := F2}, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_int64(TrF1, <>, TrUserData) end, + begin TrF2 = id(F2, TrUserData), e_type_int32(TrF2, <>, TrUserData) end. + e_mfield_Names_packages(Msg, Bin, TrUserData) -> SubBin = encode_msg_Package(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_field_Names_packages([Elem | Rest], Bin, - TrUserData) -> +e_field_Names_packages([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, - Bin3 = e_mfield_Names_packages(id(Elem, TrUserData), - Bin2, TrUserData), + Bin3 = e_mfield_Names_packages(id(Elem, TrUserData), Bin2, TrUserData), e_field_Names_packages(Rest, Bin3, TrUserData); e_field_Names_packages([], Bin, _TrUserData) -> Bin. +e_mfield_Package_updated_at(Msg, Bin, TrUserData) -> + SubBin = encode_msg_Timestamp(Msg, <<>>, TrUserData), + Bin2 = e_varint(byte_size(SubBin), Bin), + <>. + -compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> - e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> - e_varint(Value * -2 - 1, Bin). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> - <>; -e_type_bool(false, Bin, _TrUserData) -> - <>; +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. @@ -158,51 +164,61 @@ e_type_string(S, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) - when is_binary(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; -e_type_bytes(Bytes, Bin, _TrUserData) - when is_list(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> - <>. +e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> - <>. +e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> - <>; -e_type_float(infinity, Bin, _) -> - <>; -e_type_float('-infinity', Bin, _) -> - <>; -e_type_float(nan, Bin, _) -> - <>. +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> - <>; -e_type_double(infinity, Bin, _) -> - <>; -e_type_double('-infinity', Bin, _) -> - <>; -e_type_double(nan, Bin, _) -> - <>. +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). @@ -214,8 +230,7 @@ e_varint(N, Bin) -> e_varint(N bsr 7, Bin2). -decode_msg(Bin, MsgName) when is_binary(Bin) -> - decode_msg(Bin, MsgName, []). +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), @@ -235,230 +250,188 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) -> end. -endif. -decode_msg_2_doit('Names', Bin, TrUserData) -> - id(decode_msg_Names(Bin, TrUserData), TrUserData); -decode_msg_2_doit('Package', Bin, TrUserData) -> - id(decode_msg_Package(Bin, TrUserData), TrUserData). +decode_msg_2_doit('Names', Bin, TrUserData) -> id(decode_msg_Names(Bin, TrUserData), TrUserData); +decode_msg_2_doit('Package', Bin, TrUserData) -> id(decode_msg_Package(Bin, TrUserData), TrUserData); +decode_msg_2_doit('Timestamp', Bin, TrUserData) -> id(decode_msg_Timestamp(Bin, TrUserData), TrUserData). -decode_msg_Names(Bin, TrUserData) -> - dfp_read_field_def_Names(Bin, 0, 0, id([], TrUserData), - id('$undef', TrUserData), TrUserData). +decode_msg_Names(Bin, TrUserData) -> dfp_read_field_def_Names(Bin, 0, 0, 0, id([], TrUserData), id('$undef', TrUserData), TrUserData). -dfp_read_field_def_Names(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Names_packages(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Names(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Names_repository(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Names(<<>>, 0, 0, R1, F@_2, - TrUserData) -> +dfp_read_field_def_Names(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Names_packages(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Names(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Names_repository(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Names(<<>>, 0, 0, _, R1, F@_2, TrUserData) -> S1 = #{repository => F@_2}, if R1 == '$undef' -> S1; true -> S1#{packages => lists_reverse(R1, TrUserData)} end; -dfp_read_field_def_Names(Other, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_Names(Other, Z1, Z2, F@_1, F@_2, - TrUserData). - -dg_read_field_def_Names(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Names(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -dg_read_field_def_Names(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) -> +dfp_read_field_def_Names(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Names(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_Names(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Names(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_Names(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Names_packages(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 18 -> - d_field_Names_repository(Rest, 0, 0, F@_1, F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Names(Rest, 0, 0, F@_1, F@_2, TrUserData); - 1 -> skip_64_Names(Rest, 0, 0, F@_1, F@_2, TrUserData); - 2 -> - skip_length_delimited_Names(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 3 -> - skip_group_Names(Rest, Key bsr 3, 0, F@_1, F@_2, - TrUserData); - 5 -> skip_32_Names(Rest, 0, 0, F@_1, F@_2, TrUserData) - end + 10 -> d_field_Names_packages(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_Names_repository(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Names(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_Names(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_Names(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_Names(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_Names(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end end; -dg_read_field_def_Names(<<>>, 0, 0, R1, F@_2, - TrUserData) -> +dg_read_field_def_Names(<<>>, 0, 0, _, R1, F@_2, TrUserData) -> S1 = #{repository => F@_2}, if R1 == '$undef' -> S1; true -> S1#{packages => lists_reverse(R1, TrUserData)} end. -d_field_Names_packages(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Names_packages(Rest, N + 7, X bsl N + Acc, F@_1, - F@_2, TrUserData); -d_field_Names_packages(<<0:1, X:7, Rest/binary>>, N, - Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_Package(Bs, TrUserData), TrUserData), - Rest2} - end, - dfp_read_field_def_Names(RestF, 0, 0, - cons(NewFValue, Prev, TrUserData), F@_2, - TrUserData). - -d_field_Names_repository(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Names_repository(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -d_field_Names_repository(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Names(RestF, 0, 0, F@_1, NewFValue, - TrUserData). - -skip_varint_Names(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - skip_varint_Names(Rest, Z1, Z2, F@_1, F@_2, TrUserData); -skip_varint_Names(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_Names(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -skip_length_delimited_Names(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_Names(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -skip_length_delimited_Names(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> +d_field_Names_packages(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Names_packages(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Names_packages(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_Package(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Names(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), F@_2, TrUserData). + +d_field_Names_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Names_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Names_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Names(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_Names(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Names(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_Names(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Names(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_Names(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Names(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_Names(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Names(Rest2, 0, 0, F@_1, F@_2, - TrUserData). + dfp_read_field_def_Names(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). -skip_group_Names(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> +skip_group_Names(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Names(Rest, 0, Z2, F@_1, F@_2, - TrUserData). - -skip_32_Names(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dfp_read_field_def_Names(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -skip_64_Names(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dfp_read_field_def_Names(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -decode_msg_Package(Bin, TrUserData) -> - dfp_read_field_def_Package(Bin, 0, 0, - id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, - F@_1, TrUserData) -> - d_field_Package_name(Rest, Z1, Z2, F@_1, TrUserData); -dfp_read_field_def_Package(<<>>, 0, 0, F@_1, _) -> - #{name => F@_1}; -dfp_read_field_def_Package(Other, Z1, Z2, F@_1, - TrUserData) -> - dg_read_field_def_Package(Other, Z1, Z2, F@_1, - TrUserData). - -dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, - F@_1, TrUserData); -dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, TrUserData) -> + dfp_read_field_def_Names(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_Names(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Names(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_Names(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Names(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Package_name(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Package_updated_at(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Package(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{name => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{updated_at => F@_2} + end; +dfp_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Package_name(Rest, 0, 0, F@_1, TrUserData); - _ -> - case Key band 7 of - 0 -> skip_varint_Package(Rest, 0, 0, F@_1, TrUserData); - 1 -> skip_64_Package(Rest, 0, 0, F@_1, TrUserData); - 2 -> - skip_length_delimited_Package(Rest, 0, 0, F@_1, - TrUserData); - 3 -> - skip_group_Package(Rest, Key bsr 3, 0, F@_1, - TrUserData); - 5 -> skip_32_Package(Rest, 0, 0, F@_1, TrUserData) - end + 10 -> d_field_Package_name(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 26 -> d_field_Package_updated_at(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end end; -dg_read_field_def_Package(<<>>, 0, 0, F@_1, _) -> - #{name => F@_1}. - -d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, TrUserData) - when N < 57 -> - d_field_Package_name(Rest, N + 7, X bsl N + Acc, F@_1, - TrUserData); -d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, - _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, NewFValue, - TrUserData). - -skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, TrUserData) -> - skip_varint_Package(Rest, Z1, Z2, F@_1, TrUserData); -skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, - TrUserData). - -skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) - when N < 57 -> - skip_length_delimited_Package(Rest, N + 7, - X bsl N + Acc, F@_1, TrUserData); -skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, TrUserData) -> +dg_read_field_def_Package(<<>>, 0, 0, _, F@_1, F@_2, _) -> + S1 = #{name => F@_1}, + if F@_2 == '$undef' -> S1; + true -> S1#{updated_at => F@_2} + end. + +d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Package_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_Package_updated_at(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Package_updated_at(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Package_updated_at(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_Timestamp(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, + 0, + 0, + F, + F@_1, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_Timestamp(Prev, NewFValue, TrUserData) + end, + TrUserData). + +skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Package(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Package(Rest2, 0, 0, F@_1, - TrUserData). + dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). -skip_group_Package(Bin, FNum, Z2, F@_1, TrUserData) -> +skip_group_Package(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Package(Rest, 0, Z2, F@_1, - TrUserData). + dfp_read_field_def_Package(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). -skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, - TrUserData). +skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). -skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, - TrUserData). +skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_Timestamp(Bin, TrUserData) -> dfp_read_field_def_Timestamp(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_Timestamp(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Timestamp_seconds(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Timestamp(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Timestamp_nanos(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}; +dfp_read_field_def_Timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Timestamp(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_Timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_Timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> + Key = X bsl N + Acc, + case Key of + 8 -> d_field_Timestamp_seconds(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 16 -> d_field_Timestamp_nanos(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_Timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_Timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_Timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_Timestamp(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end + end; +dg_read_field_def_Timestamp(<<>>, 0, 0, _, F@_1, F@_2, _) -> #{seconds => F@_1, nanos => F@_2}. + +d_field_Timestamp_seconds(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Timestamp_seconds(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Timestamp_seconds(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):64/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_Timestamp(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_Timestamp_nanos(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Timestamp_nanos(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Timestamp_nanos(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_Timestamp(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_Timestamp(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_Timestamp(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_Timestamp(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Timestamp(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_Timestamp(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> + Length = X bsl N + Acc, + <<_:Length/binary, Rest2/binary>> = Rest, + dfp_read_field_def_Timestamp(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). + +skip_group_Timestamp(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> + {_, Rest} = read_group(Bin, FNum), + dfp_read_field_def_Timestamp(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_Timestamp(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_Timestamp(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Timestamp(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), @@ -518,127 +491,139 @@ read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> - merge_msgs(Prev, New, MsgName, []). +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Names' -> merge_msg_Names(Prev, New, TrUserData); - 'Package' -> merge_msg_Package(Prev, New, TrUserData) + 'Names' -> merge_msg_Names(Prev, New, TrUserData); + 'Package' -> merge_msg_Package(Prev, New, TrUserData); + 'Timestamp' -> merge_msg_Timestamp(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_Names/3}). -merge_msg_Names(#{} = PMsg, - #{repository := NFrepository} = NMsg, TrUserData) -> +merge_msg_Names(#{} = PMsg, #{repository := NFrepository} = NMsg, TrUserData) -> S1 = #{repository => NFrepository}, case {PMsg, NMsg} of - {#{packages := PFpackages}, - #{packages := NFpackages}} -> - S1#{packages => - 'erlang_++'(PFpackages, NFpackages, TrUserData)}; - {_, #{packages := NFpackages}} -> - S1#{packages => NFpackages}; - {#{packages := PFpackages}, _} -> - S1#{packages => PFpackages}; - {_, _} -> S1 + {#{packages := PFpackages}, #{packages := NFpackages}} -> S1#{packages => 'erlang_++'(PFpackages, NFpackages, TrUserData)}; + {_, #{packages := NFpackages}} -> S1#{packages => NFpackages}; + {#{packages := PFpackages}, _} -> S1#{packages => PFpackages}; + {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_Package/3}). -merge_msg_Package(#{}, #{name := NFname}, _) -> - #{name => NFname}. +merge_msg_Package(#{} = PMsg, #{name := NFname} = NMsg, TrUserData) -> + S1 = #{name => NFname}, + case {PMsg, NMsg} of + {#{updated_at := PFupdated_at}, #{updated_at := NFupdated_at}} -> S1#{updated_at => merge_msg_Timestamp(PFupdated_at, NFupdated_at, TrUserData)}; + {_, #{updated_at := NFupdated_at}} -> S1#{updated_at => NFupdated_at}; + {#{updated_at := PFupdated_at}, _} -> S1#{updated_at => PFupdated_at}; + {_, _} -> S1 + end. +-compile({nowarn_unused_function,merge_msg_Timestamp/3}). +merge_msg_Timestamp(#{}, #{seconds := NFseconds, nanos := NFnanos}, _) -> #{seconds => NFseconds, nanos => NFnanos}. -verify_msg(Msg, MsgName) when is_atom(MsgName) -> - verify_msg(Msg, MsgName, []). + +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Names' -> v_msg_Names(Msg, [MsgName], TrUserData); - 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) + 'Names' -> v_msg_Names(Msg, [MsgName], TrUserData); + 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); + 'Timestamp' -> v_msg_Timestamp(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_Names/3}). -dialyzer({nowarn_function,v_msg_Names/3}). -v_msg_Names(#{repository := F2} = M, Path, - TrUserData) -> +v_msg_Names(#{repository := F2} = M, Path, TrUserData) -> case M of - #{packages := F1} -> - if is_list(F1) -> - _ = [v_msg_Package(Elem, [packages | Path], TrUserData) - || Elem <- F1], - ok; - true -> - mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, - [packages | Path]) - end; - _ -> ok + #{packages := F1} -> + if is_list(F1) -> + _ = [v_msg_Package(Elem, [packages | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, [packages | Path]) + end; + _ -> ok end, v_type_string(F2, [repository | Path], TrUserData), lists:foreach(fun (packages) -> ok; - (repository) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (repository) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Names(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [repository] -- maps:keys(M), 'Names'}, - M, Path); -v_msg_Names(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Names'}, X, Path). +v_msg_Names(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [repository] -- maps:keys(M), 'Names'}, M, Path); +v_msg_Names(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Names'}, X, Path). -compile({nowarn_unused_function,v_msg_Package/3}). -dialyzer({nowarn_function,v_msg_Package/3}). v_msg_Package(#{name := F1} = M, Path, TrUserData) -> v_type_string(F1, [name | Path], TrUserData), + case M of + #{updated_at := F2} -> v_msg_Timestamp(F2, [updated_at | Path], TrUserData); + _ -> ok + end, lists:foreach(fun (name) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (updated_at) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Package(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, [name] -- maps:keys(M), - 'Package'}, - M, Path); -v_msg_Package(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Package'}, X, Path). +v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [name] -- maps:keys(M), 'Package'}, M, Path); +v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path). + +-compile({nowarn_unused_function,v_msg_Timestamp/3}). +-dialyzer({nowarn_function,v_msg_Timestamp/3}). +v_msg_Timestamp(#{seconds := F1, nanos := F2} = M, Path, TrUserData) -> + v_type_int64(F1, [seconds | Path], TrUserData), + v_type_int32(F2, [nanos | Path], TrUserData), + lists:foreach(fun (seconds) -> ok; + (nanos) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), + ok; +v_msg_Timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [seconds, nanos] -- maps:keys(M), 'Timestamp'}, M, Path); +v_msg_Timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Timestamp'}, X, Path). + +-compile({nowarn_unused_function,v_type_int32/3}). +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); +v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). + +-compile({nowarn_unused_function,v_type_int64/3}). +-dialyzer({nowarn_function,v_type_int64/3}). +v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path); +v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) - when is_list(S); is_binary(S) -> +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> - mk_type_error(bad_unicode_string, S, Path) + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch - error:badarg -> - mk_type_error(bad_unicode_string, S, Path) + error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; -v_type_string(X, Path, _TrUserData) -> - mk_type_error(bad_unicode_string, X, Path). +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), - erlang:error({gpb_type_error, - {Error, [{value, ValueSeen}, {path, Path2}]}}). + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> - list_to_atom(lists:append(lists:join(".", - lists:map(fun atom_to_list/1, - lists:reverse(PathR))))). +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). -compile({nowarn_unused_function,id/2}). @@ -666,24 +651,18 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. get_msg_defs() -> - [{{msg, 'Names'}, - [#{name => packages, fnum => 1, rnum => 2, - type => {msg, 'Package'}, occurrence => repeated, - opts => []}, - #{name => repository, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}]}, - {{msg, 'Package'}, - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => required, opts => []}]}]. + [{{msg, 'Names'}, [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}]}, + {{msg, 'Package'}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, #{name => updated_at, fnum => 3, rnum => 3, type => {msg, 'Timestamp'}, occurrence => optional, opts => []}]}, + {{msg, 'Timestamp'}, [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => required, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => required, opts => []}]}]. -get_msg_names() -> ['Names', 'Package']. +get_msg_names() -> ['Names', 'Package', 'Timestamp']. get_group_names() -> []. -get_msg_or_group_names() -> ['Names', 'Package']. +get_msg_or_group_names() -> ['Names', 'Package', 'Timestamp']. get_enum_names() -> []. @@ -691,25 +670,18 @@ get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> - erlang:error({no_such_enum, EnumName}). - - -find_msg_def('Names') -> - [#{name => packages, fnum => 1, rnum => 2, - type => {msg, 'Package'}, occurrence => repeated, - opts => []}, - #{name => repository, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}]; -find_msg_def('Package') -> - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => required, opts => []}]; +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). + + +find_msg_def('Names') -> [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}]; +find_msg_def('Package') -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, #{name => updated_at, fnum => 3, rnum => 3, type => {msg, 'Timestamp'}, occurrence => optional, opts => []}]; +find_msg_def('Timestamp') -> [#{name => seconds, fnum => 1, rnum => 2, type => int64, occurrence => required, opts => []}, #{name => nanos, fnum => 2, rnum => 3, type => int32, occurrence => required, opts => []}]; find_msg_def(_) -> error. @@ -717,13 +689,11 @@ find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). @@ -741,58 +711,53 @@ find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). -fetch_rpc_def(ServiceName, RpcName) -> - erlang:error({no_such_rpc, ServiceName, RpcName}). +fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). -fqbin_to_service_name(X) -> - error({gpb_error, {badservice, X}}). +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). -service_name_to_fqbin(X) -> - error({gpb_error, {badservice, X}}). +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). -fqbins_to_service_and_rpc_name(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). -service_and_rpc_name_to_fqbins(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"Names">>) -> 'Names'; fqbin_to_msg_name(<<"Package">>) -> 'Package'; +fqbin_to_msg_name(<<"Timestamp">>) -> 'Timestamp'; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin('Names') -> <<"Names">>; msg_name_to_fqbin('Package') -> <<"Package">>; +msg_name_to_fqbin('Timestamp') -> <<"Timestamp">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> - error({gpb_error, {badenum, E}}). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> - error({gpb_error, {badenum, E}}). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> undefined. @@ -822,58 +787,50 @@ get_all_source_basenames() -> ["r3_hex_pb_names.proto"]. get_all_proto_names() -> ["r3_hex_pb_names"]. -get_msg_containment("r3_hex_pb_names") -> - ['Names', 'Package']; -get_msg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_msg_containment("r3_hex_pb_names") -> ['Names', 'Package', 'Timestamp']; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("r3_hex_pb_names") -> undefined; -get_pkg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("r3_hex_pb_names") -> []; -get_service_containment(P) -> - error({gpb_error, {badproto, P}}). +get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("r3_hex_pb_names") -> []; -get_rpc_containment(P) -> - error({gpb_error, {badproto, P}}). +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("r3_hex_pb_names") -> []; -get_enum_containment(P) -> - error({gpb_error, {badproto, P}}). +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). -get_proto_by_msg_name_as_fqbin(<<"Names">>) -> - "r3_hex_pb_names"; -get_proto_by_msg_name_as_fqbin(<<"Package">>) -> - "r3_hex_pb_names"; -get_proto_by_msg_name_as_fqbin(E) -> - error({gpb_error, {badmsg, E}}). +get_proto_by_msg_name_as_fqbin(<<"Timestamp">>) -> "r3_hex_pb_names"; +get_proto_by_msg_name_as_fqbin(<<"Names">>) -> "r3_hex_pb_names"; +get_proto_by_msg_name_as_fqbin(<<"Package">>) -> "r3_hex_pb_names"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). -get_proto_by_service_name_as_fqbin(E) -> - error({gpb_error, {badservice, E}}). +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> - error({gpb_error, {badenum, E}}). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -spec get_protos_by_pkg_name_as_fqbin(_) -> no_return(). -get_protos_by_pkg_name_as_fqbin(E) -> - error({gpb_error, {badpkg, E}}). +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.10.0". + "4.17.6". gpb_version_as_list() -> - [4,10,0]. + [4,17,6]. + +gpb_version_source() -> + "file". diff --git a/apps/rebar/src/vendored/r3_hex_pb_package.erl b/apps/rebar/src/vendored/r3_hex_pb_package.erl index 7d3c72ad6..35043f5fd 100644 --- a/apps/rebar/src/vendored/r3_hex_pb_package.erl +++ b/apps/rebar/src/vendored/r3_hex_pb_package.erl @@ -1,9 +1,10 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.10.0 +%% Generated by gpb_compile version 4.17.6 +%% Version source: file -module(r3_hex_pb_package). -export([encode_msg/2, encode_msg/3]). @@ -46,6 +47,7 @@ -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). %% enumerated types @@ -54,180 +56,117 @@ %% message types -type 'Package'() :: - #{releases => ['Release'()], % = 1 - name := iodata(), % = 2 - repository := iodata() % = 3 + #{releases => ['Release'()], % = 1, repeated + name => unicode:chardata(), % = 2, required + repository => unicode:chardata() % = 3, required }. -type 'Release'() :: - #{version := iodata(), % = 1 - inner_checksum := iodata(), % = 2 - dependencies => ['Dependency'()], % = 3 - retired => 'RetirementStatus'(), % = 4 - outer_checksum => iodata() % = 5 + #{version => unicode:chardata(), % = 1, required + inner_checksum => iodata(), % = 2, required + dependencies => ['Dependency'()], % = 3, repeated + retired => 'RetirementStatus'(), % = 4, optional + outer_checksum => iodata() % = 5, optional }. -type 'RetirementStatus'() :: - #{reason := 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer(), % = 1, enum RetirementReason - message => iodata() % = 2 + #{reason => 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer(), % = 1, required, enum RetirementReason + message => unicode:chardata() % = 2, optional }. -type 'Dependency'() :: - #{package := iodata(), % = 1 - requirement := iodata(), % = 2 - optional => boolean() | 0 | 1, % = 3 - app => iodata(), % = 4 - repository => iodata() % = 5 + #{package => unicode:chardata(), % = 1, required + requirement => unicode:chardata(), % = 2, required + optional => boolean() | 0 | 1, % = 3, optional + app => unicode:chardata(), % = 4, optional + repository => unicode:chardata() % = 5, optional }. -export_type(['Package'/0, 'Release'/0, 'RetirementStatus'/0, 'Dependency'/0]). +-type '$msg_name'() :: 'Package' | 'Release' | 'RetirementStatus' | 'Dependency'. +-type '$msg'() :: 'Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(). +-export_type(['$msg_name'/0, '$msg'/0]). --spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> - encode_msg(Msg, MsgName, []). +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). --spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom(), list()) -> binary(). +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Package' -> - encode_msg_Package(id(Msg, TrUserData), TrUserData); - 'Release' -> - encode_msg_Release(id(Msg, TrUserData), TrUserData); - 'RetirementStatus' -> - encode_msg_RetirementStatus(id(Msg, TrUserData), - TrUserData); - 'Dependency' -> - encode_msg_Dependency(id(Msg, TrUserData), TrUserData) + 'Package' -> encode_msg_Package(id(Msg, TrUserData), TrUserData); + 'Release' -> encode_msg_Release(id(Msg, TrUserData), TrUserData); + 'RetirementStatus' -> encode_msg_RetirementStatus(id(Msg, TrUserData), TrUserData); + 'Dependency' -> encode_msg_Dependency(id(Msg, TrUserData), TrUserData) end. -encode_msg_Package(Msg, TrUserData) -> - encode_msg_Package(Msg, <<>>, TrUserData). +encode_msg_Package(Msg, TrUserData) -> encode_msg_Package(Msg, <<>>, TrUserData). -encode_msg_Package(#{name := F2, repository := F3} = M, - Bin, TrUserData) -> +encode_msg_Package(#{name := F2, repository := F3} = M, Bin, TrUserData) -> B1 = case M of - #{releases := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_Package_releases(TrF1, Bin, TrUserData) - end; - _ -> Bin - end, - B2 = begin - TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>, TrUserData) - end, - begin - TrF3 = id(F3, TrUserData), - e_type_string(TrF3, <>, TrUserData) - end. - -encode_msg_Release(Msg, TrUserData) -> - encode_msg_Release(Msg, <<>>, TrUserData). - - -encode_msg_Release(#{version := F1, - inner_checksum := F2} = - M, - Bin, TrUserData) -> - B1 = begin - TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>, TrUserData) - end, - B2 = begin - TrF2 = id(F2, TrUserData), - e_type_bytes(TrF2, <>, TrUserData) - end, + #{releases := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_Package_releases(TrF1, Bin, TrUserData) + end; + _ -> Bin + end, + B2 = begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <>, TrUserData) end, + begin TrF3 = id(F3, TrUserData), e_type_string(TrF3, <>, TrUserData) end. + +encode_msg_Release(Msg, TrUserData) -> encode_msg_Release(Msg, <<>>, TrUserData). + + +encode_msg_Release(#{version := F1, inner_checksum := F2} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <>, TrUserData) end, + B2 = begin TrF2 = id(F2, TrUserData), e_type_bytes(TrF2, <>, TrUserData) end, B3 = case M of - #{dependencies := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> - e_field_Release_dependencies(TrF3, B2, TrUserData) - end; - _ -> B2 - end, + #{dependencies := F3} -> + TrF3 = id(F3, TrUserData), + if TrF3 == [] -> B2; + true -> e_field_Release_dependencies(TrF3, B2, TrUserData) + end; + _ -> B2 + end, B4 = case M of - #{retired := F4} -> - begin - TrF4 = id(F4, TrUserData), - e_mfield_Release_retired(TrF4, <>, - TrUserData) - end; - _ -> B3 - end, + #{retired := F4} -> begin TrF4 = id(F4, TrUserData), e_mfield_Release_retired(TrF4, <>, TrUserData) end; + _ -> B3 + end, case M of - #{outer_checksum := F5} -> - begin - TrF5 = id(F5, TrUserData), - e_type_bytes(TrF5, <>, TrUserData) - end; - _ -> B4 + #{outer_checksum := F5} -> begin TrF5 = id(F5, TrUserData), e_type_bytes(TrF5, <>, TrUserData) end; + _ -> B4 end. -encode_msg_RetirementStatus(Msg, TrUserData) -> - encode_msg_RetirementStatus(Msg, <<>>, TrUserData). +encode_msg_RetirementStatus(Msg, TrUserData) -> encode_msg_RetirementStatus(Msg, <<>>, TrUserData). -encode_msg_RetirementStatus(#{reason := F1} = M, Bin, - TrUserData) -> - B1 = begin - TrF1 = id(F1, TrUserData), - e_enum_RetirementReason(TrF1, <>, - TrUserData) - end, +encode_msg_RetirementStatus(#{reason := F1} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_enum_RetirementReason(TrF1, <>, TrUserData) end, case M of - #{message := F2} -> - begin - TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>, TrUserData) - end; - _ -> B1 + #{message := F2} -> begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <>, TrUserData) end; + _ -> B1 end. -encode_msg_Dependency(Msg, TrUserData) -> - encode_msg_Dependency(Msg, <<>>, TrUserData). - - -encode_msg_Dependency(#{package := F1, - requirement := F2} = - M, - Bin, TrUserData) -> - B1 = begin - TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>, TrUserData) - end, - B2 = begin - TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>, TrUserData) - end, +encode_msg_Dependency(Msg, TrUserData) -> encode_msg_Dependency(Msg, <<>>, TrUserData). + + +encode_msg_Dependency(#{package := F1, requirement := F2} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <>, TrUserData) end, + B2 = begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <>, TrUserData) end, B3 = case M of - #{optional := F3} -> - begin - TrF3 = id(F3, TrUserData), - e_type_bool(TrF3, <>, TrUserData) - end; - _ -> B2 - end, + #{optional := F3} -> begin TrF3 = id(F3, TrUserData), e_type_bool(TrF3, <>, TrUserData) end; + _ -> B2 + end, B4 = case M of - #{app := F4} -> - begin - TrF4 = id(F4, TrUserData), - e_type_string(TrF4, <>, TrUserData) - end; - _ -> B3 - end, + #{app := F4} -> begin TrF4 = id(F4, TrUserData), e_type_string(TrF4, <>, TrUserData) end; + _ -> B3 + end, case M of - #{repository := F5} -> - begin - TrF5 = id(F5, TrUserData), - e_type_string(TrF5, <>, TrUserData) - end; - _ -> B4 + #{repository := F5} -> begin TrF5 = id(F5, TrUserData), e_type_string(TrF5, <>, TrUserData) end; + _ -> B4 end. e_mfield_Package_releases(Msg, Bin, TrUserData) -> @@ -235,11 +174,9 @@ e_mfield_Package_releases(Msg, Bin, TrUserData) -> Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_field_Package_releases([Elem | Rest], Bin, - TrUserData) -> +e_field_Package_releases([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, - Bin3 = e_mfield_Package_releases(id(Elem, TrUserData), - Bin2, TrUserData), + Bin3 = e_mfield_Package_releases(id(Elem, TrUserData), Bin2, TrUserData), e_field_Package_releases(Rest, Bin3, TrUserData); e_field_Package_releases([], Bin, _TrUserData) -> Bin. @@ -248,67 +185,43 @@ e_mfield_Release_dependencies(Msg, Bin, TrUserData) -> Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_field_Release_dependencies([Elem | Rest], Bin, - TrUserData) -> +e_field_Release_dependencies([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, - Bin3 = e_mfield_Release_dependencies(id(Elem, - TrUserData), - Bin2, TrUserData), + Bin3 = e_mfield_Release_dependencies(id(Elem, TrUserData), Bin2, TrUserData), e_field_Release_dependencies(Rest, Bin3, TrUserData); -e_field_Release_dependencies([], Bin, _TrUserData) -> - Bin. +e_field_Release_dependencies([], Bin, _TrUserData) -> Bin. e_mfield_Release_retired(Msg, Bin, TrUserData) -> - SubBin = encode_msg_RetirementStatus(Msg, <<>>, - TrUserData), + SubBin = encode_msg_RetirementStatus(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_enum_RetirementReason('RETIRED_OTHER', Bin, - _TrUserData) -> - <>; -e_enum_RetirementReason('RETIRED_INVALID', Bin, - _TrUserData) -> - <>; -e_enum_RetirementReason('RETIRED_SECURITY', Bin, - _TrUserData) -> - <>; -e_enum_RetirementReason('RETIRED_DEPRECATED', Bin, - _TrUserData) -> - <>; -e_enum_RetirementReason('RETIRED_RENAMED', Bin, - _TrUserData) -> - <>; -e_enum_RetirementReason(V, Bin, _TrUserData) -> - e_varint(V, Bin). +e_enum_RetirementReason('RETIRED_OTHER', Bin, _TrUserData) -> <>; +e_enum_RetirementReason('RETIRED_INVALID', Bin, _TrUserData) -> <>; +e_enum_RetirementReason('RETIRED_SECURITY', Bin, _TrUserData) -> <>; +e_enum_RetirementReason('RETIRED_DEPRECATED', Bin, _TrUserData) -> <>; +e_enum_RetirementReason('RETIRED_RENAMED', Bin, _TrUserData) -> <>; +e_enum_RetirementReason(V, Bin, _TrUserData) -> e_varint(V, Bin). -compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> - e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> - e_varint(Value * -2 - 1, Bin). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> - <>; -e_type_bool(false, Bin, _TrUserData) -> - <>; +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. @@ -319,51 +232,61 @@ e_type_string(S, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) - when is_binary(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; -e_type_bytes(Bytes, Bin, _TrUserData) - when is_list(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> - <>. +e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> - <>. +e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> - <>; -e_type_float(infinity, Bin, _) -> - <>; -e_type_float('-infinity', Bin, _) -> - <>; -e_type_float(nan, Bin, _) -> - <>. +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> - <>; -e_type_double(infinity, Bin, _) -> - <>; -e_type_double('-infinity', Bin, _) -> - <>; -e_type_double(nan, Bin, _) -> - <>. +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). @@ -375,8 +298,7 @@ e_varint(N, Bin) -> e_varint(N bsr 7, Bin2). -decode_msg(Bin, MsgName) when is_binary(Bin) -> - decode_msg(Bin, MsgName, []). +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), @@ -396,774 +318,332 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) -> end. -endif. -decode_msg_2_doit('Package', Bin, TrUserData) -> - id(decode_msg_Package(Bin, TrUserData), TrUserData); -decode_msg_2_doit('Release', Bin, TrUserData) -> - id(decode_msg_Release(Bin, TrUserData), TrUserData); -decode_msg_2_doit('RetirementStatus', Bin, - TrUserData) -> - id(decode_msg_RetirementStatus(Bin, TrUserData), - TrUserData); -decode_msg_2_doit('Dependency', Bin, TrUserData) -> - id(decode_msg_Dependency(Bin, TrUserData), TrUserData). - - - -decode_msg_Package(Bin, TrUserData) -> - dfp_read_field_def_Package(Bin, 0, 0, - id([], TrUserData), id('$undef', TrUserData), - id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_releases(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_name(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_repository(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData); -dfp_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3, - TrUserData) -> +decode_msg_2_doit('Package', Bin, TrUserData) -> id(decode_msg_Package(Bin, TrUserData), TrUserData); +decode_msg_2_doit('Release', Bin, TrUserData) -> id(decode_msg_Release(Bin, TrUserData), TrUserData); +decode_msg_2_doit('RetirementStatus', Bin, TrUserData) -> id(decode_msg_RetirementStatus(Bin, TrUserData), TrUserData); +decode_msg_2_doit('Dependency', Bin, TrUserData) -> id(decode_msg_Dependency(Bin, TrUserData), TrUserData). + + + +decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, 0, id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_releases(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_repository(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<>>, 0, 0, _, R1, F@_2, F@_3, TrUserData) -> S1 = #{name => F@_2, repository => F@_3}, if R1 == '$undef' -> S1; true -> S1#{releases => lists_reverse(R1, TrUserData)} end; -dfp_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData) -> - dg_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) -> +dfp_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Package_releases(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 18 -> - d_field_Package_name(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 26 -> - d_field_Package_repository(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 1 -> - skip_64_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 2 -> - skip_length_delimited_Package(Rest, 0, 0, F@_1, F@_2, - F@_3, TrUserData); - 3 -> - skip_group_Package(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, - TrUserData); - 5 -> - skip_32_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData) - end + 10 -> d_field_Package_releases(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_Package_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_field_Package_repository(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end end; -dg_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3, - TrUserData) -> +dg_read_field_def_Package(<<>>, 0, 0, _, R1, F@_2, F@_3, TrUserData) -> S1 = #{name => F@_2, repository => F@_3}, if R1 == '$undef' -> S1; true -> S1#{releases => lists_reverse(R1, TrUserData)} end. -d_field_Package_releases(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_releases(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -d_field_Package_releases(<<0:1, X:7, Rest/binary>>, N, - Acc, Prev, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_Release(Bs, TrUserData), TrUserData), - Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, - cons(NewFValue, Prev, TrUserData), F@_2, F@_3, - TrUserData). - -d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_name(Rest, N + 7, X bsl N + Acc, F@_1, - F@_2, F@_3, TrUserData); -d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, - F@_1, _, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, F@_1, NewFValue, - F@_3, TrUserData). - -d_field_Package_repository(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_repository(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -d_field_Package_repository(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, F@_1, F@_2, - NewFValue, TrUserData). - -skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_Package(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - skip_length_delimited_Package(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) -> +d_field_Package_releases(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_releases(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_releases(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_Release(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), F@_2, F@_3, TrUserData). + +d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). + +d_field_Package_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, F@_2, NewFValue, TrUserData). + +skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Package(Rest2, 0, 0, F@_1, F@_2, - F@_3, TrUserData). + dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). -skip_group_Package(Bin, FNum, Z2, F@_1, F@_2, F@_3, - TrUserData) -> +skip_group_Package(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Package(Rest, 0, Z2, F@_1, F@_2, - F@_3, TrUserData). - -skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -decode_msg_Release(Bin, TrUserData) -> - dfp_read_field_def_Release(Bin, 0, 0, - id('$undef', TrUserData), - id('$undef', TrUserData), id([], TrUserData), - id('$undef', TrUserData), - id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_Release(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Release_version(Rest, Z1, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); -dfp_read_field_def_Release(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Release_inner_checksum(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Release(<<26, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Release_dependencies(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Release(<<34, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Release_retired(Rest, Z1, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); -dfp_read_field_def_Release(<<42, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Release_outer_checksum(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1, - F@_4, F@_5, TrUserData) -> + dfp_read_field_def_Package(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). + +skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +decode_msg_Release(Bin, TrUserData) -> dfp_read_field_def_Release(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_Release(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_version(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Release(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_inner_checksum(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Release(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_dependencies(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Release(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Release(<<42, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Release_outer_checksum(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Release(<<>>, 0, 0, _, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) -> S1 = #{version => F@_1, inner_checksum => F@_2}, S2 = if R1 == '$undef' -> S1; - true -> - S1#{dependencies => lists_reverse(R1, TrUserData)} - end, + true -> S1#{dependencies => lists_reverse(R1, TrUserData)} + end, S3 = if F@_4 == '$undef' -> S2; - true -> S2#{retired => F@_4} - end, + true -> S2#{retired => F@_4} + end, if F@_5 == '$undef' -> S3; true -> S3#{outer_checksum => F@_5} end; -dfp_read_field_def_Release(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData) -> - dg_read_field_def_Release(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -dg_read_field_def_Release(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Release(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -dg_read_field_def_Release(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> +dfp_read_field_def_Release(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dg_read_field_def_Release(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +dg_read_field_def_Release(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 32 - 7 -> dg_read_field_def_Release(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dg_read_field_def_Release(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Release_version(Rest, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 18 -> - d_field_Release_inner_checksum(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 26 -> - d_field_Release_dependencies(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 34 -> - d_field_Release_retired(Rest, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 42 -> - d_field_Release_outer_checksum(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData); - 1 -> - skip_64_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData); - 2 -> - skip_length_delimited_Release(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 3 -> - skip_group_Release(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 5 -> - skip_32_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData) - end + 10 -> d_field_Release_version(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 18 -> d_field_Release_inner_checksum(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 26 -> d_field_Release_dependencies(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 34 -> d_field_Release_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 42 -> d_field_Release_outer_checksum(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 1 -> skip_64_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 2 -> skip_length_delimited_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 3 -> skip_group_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 5 -> skip_32_Release(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) + end end; -dg_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1, - F@_4, F@_5, TrUserData) -> +dg_read_field_def_Release(<<>>, 0, 0, _, F@_1, F@_2, R1, F@_4, F@_5, TrUserData) -> S1 = #{version => F@_1, inner_checksum => F@_2}, S2 = if R1 == '$undef' -> S1; - true -> - S1#{dependencies => lists_reverse(R1, TrUserData)} - end, + true -> S1#{dependencies => lists_reverse(R1, TrUserData)} + end, S3 = if F@_4 == '$undef' -> S2; - true -> S2#{retired => F@_4} - end, + true -> S2#{retired => F@_4} + end, if F@_5 == '$undef' -> S3; true -> S3#{outer_checksum => F@_5} end. -d_field_Release_version(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Release_version(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Release_version(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Release(RestF, 0, 0, NewFValue, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -d_field_Release_inner_checksum(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Release_inner_checksum(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData); -d_field_Release_inner_checksum(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Release(RestF, 0, 0, F@_1, NewFValue, - F@_3, F@_4, F@_5, TrUserData). - -d_field_Release_dependencies(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Release_dependencies(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Release_dependencies(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, Prev, F@_4, F@_5, - TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_Dependency(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2, - cons(NewFValue, Prev, TrUserData), F@_4, F@_5, - TrUserData). - -d_field_Release_retired(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Release_retired(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Release_retired(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, Prev, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_RetirementStatus(Bs, TrUserData), - TrUserData), - Rest2} - end, - dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2, - F@_3, - if Prev == '$undef' -> NewFValue; - true -> - merge_msg_RetirementStatus(Prev, - NewFValue, - TrUserData) - end, - F@_5, TrUserData). - -d_field_Release_outer_checksum(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Release_outer_checksum(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData); -d_field_Release_outer_checksum(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2, - F@_3, F@_4, NewFValue, TrUserData). - -skip_varint_Release(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - skip_varint_Release(Rest, Z1, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); -skip_varint_Release(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -skip_length_delimited_Release(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - skip_length_delimited_Release(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData); -skip_length_delimited_Release(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData) -> +d_field_Release_version(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_version(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Release_version(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Release(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData). + +d_field_Release_inner_checksum(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_inner_checksum(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Release_inner_checksum(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData). + +d_field_Release_dependencies(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_dependencies(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Release_dependencies(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_Dependency(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), F@_4, F@_5, TrUserData). + +d_field_Release_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Release_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, Prev, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_RetirementStatus(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Release(RestF, + 0, + 0, + F, + F@_1, + F@_2, + F@_3, + if Prev == '$undef' -> NewFValue; + true -> merge_msg_RetirementStatus(Prev, NewFValue, TrUserData) + end, + F@_5, + TrUserData). + +d_field_Release_outer_checksum(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Release_outer_checksum(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Release_outer_checksum(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Release(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData). + +skip_varint_Release(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> skip_varint_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +skip_varint_Release(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +skip_length_delimited_Release(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> skip_length_delimited_Release(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +skip_length_delimited_Release(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Release(Rest2, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). + dfp_read_field_def_Release(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). -skip_group_Release(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData) -> +skip_group_Release(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Release(Rest, 0, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -skip_32_Release(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -skip_64_Release(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -decode_msg_RetirementStatus(Bin, TrUserData) -> - dfp_read_field_def_RetirementStatus(Bin, 0, 0, - id('$undef', TrUserData), - id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_RetirementStatus(<<8, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_RetirementStatus_reason(Rest, Z1, Z2, F@_1, - F@_2, TrUserData); -dfp_read_field_def_RetirementStatus(<<18, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - d_field_RetirementStatus_message(Rest, Z1, Z2, F@_1, - F@_2, TrUserData); -dfp_read_field_def_RetirementStatus(<<>>, 0, 0, F@_1, - F@_2, _) -> + dfp_read_field_def_Release(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +skip_32_Release(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +skip_64_Release(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Release(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +decode_msg_RetirementStatus(Bin, TrUserData) -> dfp_read_field_def_RetirementStatus(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_RetirementStatus(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_RetirementStatus_reason(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_RetirementStatus(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_RetirementStatus_message(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_RetirementStatus(<<>>, 0, 0, _, F@_1, F@_2, _) -> S1 = #{reason => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{message => F@_2} end; -dfp_read_field_def_RetirementStatus(Other, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dg_read_field_def_RetirementStatus(Other, Z1, Z2, F@_1, - F@_2, TrUserData). - -dg_read_field_def_RetirementStatus(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_RetirementStatus(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, TrUserData); -dg_read_field_def_RetirementStatus(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> +dfp_read_field_def_RetirementStatus(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_RetirementStatus(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_RetirementStatus(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_RetirementStatus(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_RetirementStatus(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of - 8 -> - d_field_RetirementStatus_reason(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 18 -> - d_field_RetirementStatus_message(Rest, 0, 0, F@_1, F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_RetirementStatus(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 1 -> - skip_64_RetirementStatus(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 2 -> - skip_length_delimited_RetirementStatus(Rest, 0, 0, F@_1, - F@_2, TrUserData); - 3 -> - skip_group_RetirementStatus(Rest, Key bsr 3, 0, F@_1, - F@_2, TrUserData); - 5 -> - skip_32_RetirementStatus(Rest, 0, 0, F@_1, F@_2, - TrUserData) - end + 8 -> d_field_RetirementStatus_reason(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_RetirementStatus_message(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_RetirementStatus(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end end; -dg_read_field_def_RetirementStatus(<<>>, 0, 0, F@_1, - F@_2, _) -> +dg_read_field_def_RetirementStatus(<<>>, 0, 0, _, F@_1, F@_2, _) -> S1 = #{reason => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{message => F@_2} end. -d_field_RetirementStatus_reason(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_RetirementStatus_reason(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, TrUserData); -d_field_RetirementStatus_reason(<<0:1, X:7, - Rest/binary>>, - N, Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = {id(d_enum_RetirementReason(begin - <> = - <<(X bsl N + - Acc):32/unsigned-native>>, - id(Res, TrUserData) - end), - TrUserData), - Rest}, - dfp_read_field_def_RetirementStatus(RestF, 0, 0, - NewFValue, F@_2, TrUserData). - -d_field_RetirementStatus_message(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_RetirementStatus_message(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, TrUserData); -d_field_RetirementStatus_message(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_RetirementStatus(RestF, 0, 0, F@_1, - NewFValue, TrUserData). - -skip_varint_RetirementStatus(<<1:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - skip_varint_RetirementStatus(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -skip_varint_RetirementStatus(<<0:1, _:7, Rest/binary>>, - Z1, Z2, F@_1, F@_2, TrUserData) -> - dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1, - F@_2, TrUserData). - -skip_length_delimited_RetirementStatus(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_RetirementStatus(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, - TrUserData); -skip_length_delimited_RetirementStatus(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> +d_field_RetirementStatus_reason(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_RetirementStatus_reason(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_RetirementStatus_reason(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = {id(d_enum_RetirementReason(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, + dfp_read_field_def_RetirementStatus(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_RetirementStatus_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_RetirementStatus_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_RetirementStatus_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_RetirementStatus(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_RetirementStatus(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_RetirementStatus(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_RetirementStatus(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_RetirementStatus(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_RetirementStatus(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_RetirementStatus(Rest2, 0, 0, F@_1, - F@_2, TrUserData). + dfp_read_field_def_RetirementStatus(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). -skip_group_RetirementStatus(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> +skip_group_RetirementStatus(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_RetirementStatus(Rest, 0, Z2, F@_1, - F@_2, TrUserData). - -skip_32_RetirementStatus(<<_:32, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1, - F@_2, TrUserData). - -skip_64_RetirementStatus(<<_:64, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1, - F@_2, TrUserData). - -decode_msg_Dependency(Bin, TrUserData) -> - dfp_read_field_def_Dependency(Bin, 0, 0, - id('$undef', TrUserData), - id('$undef', TrUserData), - id('$undef', TrUserData), - id('$undef', TrUserData), - id('$undef', TrUserData), TrUserData). - -dfp_read_field_def_Dependency(<<10, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Dependency_package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Dependency(<<18, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Dependency_requirement(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Dependency(<<24, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Dependency_optional(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Dependency(<<34, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Dependency_app(Rest, Z1, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); -dfp_read_field_def_Dependency(<<42, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - d_field_Dependency_repository(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); -dfp_read_field_def_Dependency(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, _) -> + dfp_read_field_def_RetirementStatus(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_RetirementStatus(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_RetirementStatus(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_Dependency(Bin, TrUserData) -> dfp_read_field_def_Dependency(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). + +dfp_read_field_def_Dependency(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Dependency(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_requirement(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Dependency(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_optional(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Dependency(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_app(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Dependency(<<42, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> d_field_Dependency_repository(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dfp_read_field_def_Dependency(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, _) -> S1 = #{package => F@_1, requirement => F@_2}, S2 = if F@_3 == '$undef' -> S1; - true -> S1#{optional => F@_3} - end, + true -> S1#{optional => F@_3} + end, S3 = if F@_4 == '$undef' -> S2; - true -> S2#{app => F@_4} - end, + true -> S2#{app => F@_4} + end, if F@_5 == '$undef' -> S3; true -> S3#{repository => F@_5} end; -dfp_read_field_def_Dependency(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData) -> - dg_read_field_def_Dependency(Other, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -dg_read_field_def_Dependency(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Dependency(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -dg_read_field_def_Dependency(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData) -> +dfp_read_field_def_Dependency(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dg_read_field_def_Dependency(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +dg_read_field_def_Dependency(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 32 - 7 -> dg_read_field_def_Dependency(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +dg_read_field_def_Dependency(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Dependency_package(Rest, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 18 -> - d_field_Dependency_requirement(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 24 -> - d_field_Dependency_optional(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 34 -> - d_field_Dependency_app(Rest, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 42 -> - d_field_Dependency_repository(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); - 1 -> - skip_64_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData); - 2 -> - skip_length_delimited_Dependency(Rest, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 3 -> - skip_group_Dependency(Rest, Key bsr 3, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData); - 5 -> - skip_32_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData) - end + 10 -> d_field_Dependency_package(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 18 -> d_field_Dependency_requirement(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 24 -> d_field_Dependency_optional(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 34 -> d_field_Dependency_app(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 42 -> d_field_Dependency_repository(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 1 -> skip_64_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 2 -> skip_length_delimited_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 3 -> skip_group_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); + 5 -> skip_32_Dependency(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) + end end; -dg_read_field_def_Dependency(<<>>, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, _) -> +dg_read_field_def_Dependency(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, F@_5, _) -> S1 = #{package => F@_1, requirement => F@_2}, S2 = if F@_3 == '$undef' -> S1; - true -> S1#{optional => F@_3} - end, + true -> S1#{optional => F@_3} + end, S3 = if F@_4 == '$undef' -> S2; - true -> S2#{app => F@_4} - end, + true -> S2#{app => F@_4} + end, if F@_5 == '$undef' -> S3; true -> S3#{repository => F@_5} end. -d_field_Dependency_package(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Dependency_package(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Dependency_package(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Dependency(RestF, 0, 0, NewFValue, - F@_2, F@_3, F@_4, F@_5, TrUserData). - -d_field_Dependency_requirement(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Dependency_requirement(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData); -d_field_Dependency_requirement(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, _, F@_3, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, - NewFValue, F@_3, F@_4, F@_5, TrUserData). - -d_field_Dependency_optional(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Dependency_optional(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Dependency_optional(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, _, F@_4, F@_5, TrUserData) -> - {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, - TrUserData), - Rest}, - dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, - NewFValue, F@_4, F@_5, TrUserData). - -d_field_Dependency_app(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Dependency_app(Rest, N + 7, X bsl N + Acc, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData); -d_field_Dependency_app(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, _, F@_5, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, - F@_3, NewFValue, F@_5, TrUserData). - -d_field_Dependency_repository(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) - when N < 57 -> - d_field_Dependency_repository(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData); -d_field_Dependency_repository(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2, - F@_3, F@_4, NewFValue, TrUserData). - -skip_varint_Dependency(<<1:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - skip_varint_Dependency(Rest, Z1, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData); -skip_varint_Dependency(<<0:1, _:7, Rest/binary>>, Z1, - Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). - -skip_length_delimited_Dependency(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData) - when N < 57 -> - skip_length_delimited_Dependency(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, - F@_5, TrUserData); -skip_length_delimited_Dependency(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, - TrUserData) -> +d_field_Dependency_package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Dependency_package(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Dependency(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, F@_5, TrUserData). + +d_field_Dependency_requirement(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_requirement(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Dependency_requirement(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, F@_5, TrUserData). + +d_field_Dependency_optional(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_optional(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Dependency_optional(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, F@_5, TrUserData) -> + {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, + dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, F@_5, TrUserData). + +d_field_Dependency_app(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_app(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Dependency_app(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, F@_5, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, F@_5, TrUserData). + +d_field_Dependency_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> d_field_Dependency_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +d_field_Dependency_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Dependency(RestF, 0, 0, F, F@_1, F@_2, F@_3, F@_4, NewFValue, TrUserData). + +skip_varint_Dependency(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> skip_varint_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +skip_varint_Dependency(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). + +skip_length_delimited_Dependency(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) when N < 57 -> skip_length_delimited_Dependency(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData); +skip_length_delimited_Dependency(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Dependency(Rest2, 0, 0, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). + dfp_read_field_def_Dependency(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). -skip_group_Dependency(Bin, FNum, Z2, F@_1, F@_2, F@_3, - F@_4, F@_5, TrUserData) -> +skip_group_Dependency(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Dependency(Rest, 0, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). + dfp_read_field_def_Dependency(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). -skip_32_Dependency(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). +skip_32_Dependency(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). -skip_64_Dependency(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, F@_4, F@_5, TrUserData) -> - dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2, - F@_3, F@_4, F@_5, TrUserData). +skip_64_Dependency(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) -> dfp_read_field_def_Dependency(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData). d_enum_RetirementReason(0) -> 'RETIRED_OTHER'; d_enum_RetirementReason(1) -> 'RETIRED_INVALID'; @@ -1230,315 +710,203 @@ read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> - merge_msgs(Prev, New, MsgName, []). +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Package' -> merge_msg_Package(Prev, New, TrUserData); - 'Release' -> merge_msg_Release(Prev, New, TrUserData); - 'RetirementStatus' -> - merge_msg_RetirementStatus(Prev, New, TrUserData); - 'Dependency' -> - merge_msg_Dependency(Prev, New, TrUserData) + 'Package' -> merge_msg_Package(Prev, New, TrUserData); + 'Release' -> merge_msg_Release(Prev, New, TrUserData); + 'RetirementStatus' -> merge_msg_RetirementStatus(Prev, New, TrUserData); + 'Dependency' -> merge_msg_Dependency(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_Package/3}). -merge_msg_Package(#{} = PMsg, - #{name := NFname, repository := NFrepository} = NMsg, - TrUserData) -> +merge_msg_Package(#{} = PMsg, #{name := NFname, repository := NFrepository} = NMsg, TrUserData) -> S1 = #{name => NFname, repository => NFrepository}, case {PMsg, NMsg} of - {#{releases := PFreleases}, - #{releases := NFreleases}} -> - S1#{releases => - 'erlang_++'(PFreleases, NFreleases, TrUserData)}; - {_, #{releases := NFreleases}} -> - S1#{releases => NFreleases}; - {#{releases := PFreleases}, _} -> - S1#{releases => PFreleases}; - {_, _} -> S1 + {#{releases := PFreleases}, #{releases := NFreleases}} -> S1#{releases => 'erlang_++'(PFreleases, NFreleases, TrUserData)}; + {_, #{releases := NFreleases}} -> S1#{releases => NFreleases}; + {#{releases := PFreleases}, _} -> S1#{releases => PFreleases}; + {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_Release/3}). -merge_msg_Release(#{} = PMsg, - #{version := NFversion, - inner_checksum := NFinner_checksum} = - NMsg, - TrUserData) -> - S1 = #{version => NFversion, - inner_checksum => NFinner_checksum}, +merge_msg_Release(#{} = PMsg, #{version := NFversion, inner_checksum := NFinner_checksum} = NMsg, TrUserData) -> + S1 = #{version => NFversion, inner_checksum => NFinner_checksum}, S2 = case {PMsg, NMsg} of - {#{dependencies := PFdependencies}, - #{dependencies := NFdependencies}} -> - S1#{dependencies => - 'erlang_++'(PFdependencies, NFdependencies, - TrUserData)}; - {_, #{dependencies := NFdependencies}} -> - S1#{dependencies => NFdependencies}; - {#{dependencies := PFdependencies}, _} -> - S1#{dependencies => PFdependencies}; - {_, _} -> S1 - end, + {#{dependencies := PFdependencies}, #{dependencies := NFdependencies}} -> S1#{dependencies => 'erlang_++'(PFdependencies, NFdependencies, TrUserData)}; + {_, #{dependencies := NFdependencies}} -> S1#{dependencies => NFdependencies}; + {#{dependencies := PFdependencies}, _} -> S1#{dependencies => PFdependencies}; + {_, _} -> S1 + end, S3 = case {PMsg, NMsg} of - {#{retired := PFretired}, #{retired := NFretired}} -> - S2#{retired => - merge_msg_RetirementStatus(PFretired, NFretired, - TrUserData)}; - {_, #{retired := NFretired}} -> - S2#{retired => NFretired}; - {#{retired := PFretired}, _} -> - S2#{retired => PFretired}; - {_, _} -> S2 - end, + {#{retired := PFretired}, #{retired := NFretired}} -> S2#{retired => merge_msg_RetirementStatus(PFretired, NFretired, TrUserData)}; + {_, #{retired := NFretired}} -> S2#{retired => NFretired}; + {#{retired := PFretired}, _} -> S2#{retired => PFretired}; + {_, _} -> S2 + end, case {PMsg, NMsg} of - {_, #{outer_checksum := NFouter_checksum}} -> - S3#{outer_checksum => NFouter_checksum}; - {#{outer_checksum := PFouter_checksum}, _} -> - S3#{outer_checksum => PFouter_checksum}; - _ -> S3 + {_, #{outer_checksum := NFouter_checksum}} -> S3#{outer_checksum => NFouter_checksum}; + {#{outer_checksum := PFouter_checksum}, _} -> S3#{outer_checksum => PFouter_checksum}; + _ -> S3 end. -compile({nowarn_unused_function,merge_msg_RetirementStatus/3}). -merge_msg_RetirementStatus(#{} = PMsg, - #{reason := NFreason} = NMsg, _) -> +merge_msg_RetirementStatus(#{} = PMsg, #{reason := NFreason} = NMsg, _) -> S1 = #{reason => NFreason}, case {PMsg, NMsg} of - {_, #{message := NFmessage}} -> - S1#{message => NFmessage}; - {#{message := PFmessage}, _} -> - S1#{message => PFmessage}; - _ -> S1 + {_, #{message := NFmessage}} -> S1#{message => NFmessage}; + {#{message := PFmessage}, _} -> S1#{message => PFmessage}; + _ -> S1 end. -compile({nowarn_unused_function,merge_msg_Dependency/3}). -merge_msg_Dependency(#{} = PMsg, - #{package := NFpackage, requirement := NFrequirement} = - NMsg, - _) -> - S1 = #{package => NFpackage, - requirement => NFrequirement}, +merge_msg_Dependency(#{} = PMsg, #{package := NFpackage, requirement := NFrequirement} = NMsg, _) -> + S1 = #{package => NFpackage, requirement => NFrequirement}, S2 = case {PMsg, NMsg} of - {_, #{optional := NFoptional}} -> - S1#{optional => NFoptional}; - {#{optional := PFoptional}, _} -> - S1#{optional => PFoptional}; - _ -> S1 - end, + {_, #{optional := NFoptional}} -> S1#{optional => NFoptional}; + {#{optional := PFoptional}, _} -> S1#{optional => PFoptional}; + _ -> S1 + end, S3 = case {PMsg, NMsg} of - {_, #{app := NFapp}} -> S2#{app => NFapp}; - {#{app := PFapp}, _} -> S2#{app => PFapp}; - _ -> S2 - end, + {_, #{app := NFapp}} -> S2#{app => NFapp}; + {#{app := PFapp}, _} -> S2#{app => PFapp}; + _ -> S2 + end, case {PMsg, NMsg} of - {_, #{repository := NFrepository}} -> - S3#{repository => NFrepository}; - {#{repository := PFrepository}, _} -> - S3#{repository => PFrepository}; - _ -> S3 + {_, #{repository := NFrepository}} -> S3#{repository => NFrepository}; + {#{repository := PFrepository}, _} -> S3#{repository => PFrepository}; + _ -> S3 end. -verify_msg(Msg, MsgName) when is_atom(MsgName) -> - verify_msg(Msg, MsgName, []). +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); - 'Release' -> v_msg_Release(Msg, [MsgName], TrUserData); - 'RetirementStatus' -> - v_msg_RetirementStatus(Msg, [MsgName], TrUserData); - 'Dependency' -> - v_msg_Dependency(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) + 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); + 'Release' -> v_msg_Release(Msg, [MsgName], TrUserData); + 'RetirementStatus' -> v_msg_RetirementStatus(Msg, [MsgName], TrUserData); + 'Dependency' -> v_msg_Dependency(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_Package/3}). -dialyzer({nowarn_function,v_msg_Package/3}). -v_msg_Package(#{name := F2, repository := F3} = M, Path, - TrUserData) -> +v_msg_Package(#{name := F2, repository := F3} = M, Path, TrUserData) -> case M of - #{releases := F1} -> - if is_list(F1) -> - _ = [v_msg_Release(Elem, [releases | Path], TrUserData) - || Elem <- F1], - ok; - true -> - mk_type_error({invalid_list_of, {msg, 'Release'}}, F1, - [releases | Path]) - end; - _ -> ok + #{releases := F1} -> + if is_list(F1) -> + _ = [v_msg_Release(Elem, [releases | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, 'Release'}}, F1, [releases | Path]) + end; + _ -> ok end, v_type_string(F2, [name | Path], TrUserData), v_type_string(F3, [repository | Path], TrUserData), lists:foreach(fun (releases) -> ok; - (name) -> ok; - (repository) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (name) -> ok; + (repository) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Package(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [name, repository] -- maps:keys(M), 'Package'}, - M, Path); -v_msg_Package(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Package'}, X, Path). +v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [name, repository] -- maps:keys(M), 'Package'}, M, Path); +v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path). -compile({nowarn_unused_function,v_msg_Release/3}). -dialyzer({nowarn_function,v_msg_Release/3}). -v_msg_Release(#{version := F1, inner_checksum := F2} = - M, - Path, TrUserData) -> +v_msg_Release(#{version := F1, inner_checksum := F2} = M, Path, TrUserData) -> v_type_string(F1, [version | Path], TrUserData), v_type_bytes(F2, [inner_checksum | Path], TrUserData), case M of - #{dependencies := F3} -> - if is_list(F3) -> - _ = [v_msg_Dependency(Elem, [dependencies | Path], - TrUserData) - || Elem <- F3], - ok; - true -> - mk_type_error({invalid_list_of, {msg, 'Dependency'}}, - F3, [dependencies | Path]) - end; - _ -> ok + #{dependencies := F3} -> + if is_list(F3) -> + _ = [v_msg_Dependency(Elem, [dependencies | Path], TrUserData) || Elem <- F3], + ok; + true -> mk_type_error({invalid_list_of, {msg, 'Dependency'}}, F3, [dependencies | Path]) + end; + _ -> ok end, case M of - #{retired := F4} -> - v_msg_RetirementStatus(F4, [retired | Path], - TrUserData); - _ -> ok + #{retired := F4} -> v_msg_RetirementStatus(F4, [retired | Path], TrUserData); + _ -> ok end, case M of - #{outer_checksum := F5} -> - v_type_bytes(F5, [outer_checksum | Path], TrUserData); - _ -> ok + #{outer_checksum := F5} -> v_type_bytes(F5, [outer_checksum | Path], TrUserData); + _ -> ok end, lists:foreach(fun (version) -> ok; - (inner_checksum) -> ok; - (dependencies) -> ok; - (retired) -> ok; - (outer_checksum) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (inner_checksum) -> ok; + (dependencies) -> ok; + (retired) -> ok; + (outer_checksum) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Release(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [version, inner_checksum] -- maps:keys(M), 'Release'}, - M, Path); -v_msg_Release(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Release'}, X, Path). +v_msg_Release(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [version, inner_checksum] -- maps:keys(M), 'Release'}, M, Path); +v_msg_Release(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Release'}, X, Path). -compile({nowarn_unused_function,v_msg_RetirementStatus/3}). -dialyzer({nowarn_function,v_msg_RetirementStatus/3}). -v_msg_RetirementStatus(#{reason := F1} = M, Path, - TrUserData) -> - v_enum_RetirementReason(F1, [reason | Path], - TrUserData), +v_msg_RetirementStatus(#{reason := F1} = M, Path, TrUserData) -> + v_enum_RetirementReason(F1, [reason | Path], TrUserData), case M of - #{message := F2} -> - v_type_string(F2, [message | Path], TrUserData); - _ -> ok + #{message := F2} -> v_type_string(F2, [message | Path], TrUserData); + _ -> ok end, lists:foreach(fun (reason) -> ok; - (message) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (message) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_RetirementStatus(M, Path, _TrUserData) - when is_map(M) -> - mk_type_error({missing_fields, [reason] -- maps:keys(M), - 'RetirementStatus'}, - M, Path); -v_msg_RetirementStatus(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'RetirementStatus'}, X, - Path). +v_msg_RetirementStatus(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [reason] -- maps:keys(M), 'RetirementStatus'}, M, Path); +v_msg_RetirementStatus(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'RetirementStatus'}, X, Path). -compile({nowarn_unused_function,v_msg_Dependency/3}). -dialyzer({nowarn_function,v_msg_Dependency/3}). -v_msg_Dependency(#{package := F1, requirement := F2} = - M, - Path, TrUserData) -> +v_msg_Dependency(#{package := F1, requirement := F2} = M, Path, TrUserData) -> v_type_string(F1, [package | Path], TrUserData), v_type_string(F2, [requirement | Path], TrUserData), case M of - #{optional := F3} -> - v_type_bool(F3, [optional | Path], TrUserData); - _ -> ok + #{optional := F3} -> v_type_bool(F3, [optional | Path], TrUserData); + _ -> ok end, case M of - #{app := F4} -> - v_type_string(F4, [app | Path], TrUserData); - _ -> ok + #{app := F4} -> v_type_string(F4, [app | Path], TrUserData); + _ -> ok end, case M of - #{repository := F5} -> - v_type_string(F5, [repository | Path], TrUserData); - _ -> ok + #{repository := F5} -> v_type_string(F5, [repository | Path], TrUserData); + _ -> ok end, lists:foreach(fun (package) -> ok; - (requirement) -> ok; - (optional) -> ok; - (app) -> ok; - (repository) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (requirement) -> ok; + (optional) -> ok; + (app) -> ok; + (repository) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [package, requirement] -- maps:keys(M), 'Dependency'}, - M, Path); -v_msg_Dependency(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Dependency'}, X, Path). +v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [package, requirement] -- maps:keys(M), 'Dependency'}, M, Path); +v_msg_Dependency(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Dependency'}, X, Path). -compile({nowarn_unused_function,v_enum_RetirementReason/3}). -dialyzer({nowarn_function,v_enum_RetirementReason/3}). -v_enum_RetirementReason('RETIRED_OTHER', _Path, - _TrUserData) -> - ok; -v_enum_RetirementReason('RETIRED_INVALID', _Path, - _TrUserData) -> - ok; -v_enum_RetirementReason('RETIRED_SECURITY', _Path, - _TrUserData) -> - ok; -v_enum_RetirementReason('RETIRED_DEPRECATED', _Path, - _TrUserData) -> - ok; -v_enum_RetirementReason('RETIRED_RENAMED', _Path, - _TrUserData) -> - ok; -v_enum_RetirementReason(V, Path, TrUserData) - when is_integer(V) -> - v_type_sint32(V, Path, TrUserData); -v_enum_RetirementReason(X, Path, _TrUserData) -> - mk_type_error({invalid_enum, 'RetirementReason'}, X, - Path). - --compile({nowarn_unused_function,v_type_sint32/3}). --dialyzer({nowarn_function,v_type_sint32/3}). -v_type_sint32(N, _Path, _TrUserData) - when -2147483648 =< N, N =< 2147483647 -> - ok; -v_type_sint32(N, Path, _TrUserData) - when is_integer(N) -> - mk_type_error({value_out_of_range, sint32, signed, 32}, - N, Path); -v_type_sint32(X, Path, _TrUserData) -> - mk_type_error({bad_integer, sint32, signed, 32}, X, - Path). +v_enum_RetirementReason('RETIRED_OTHER', _Path, _TrUserData) -> ok; +v_enum_RetirementReason('RETIRED_INVALID', _Path, _TrUserData) -> ok; +v_enum_RetirementReason('RETIRED_SECURITY', _Path, _TrUserData) -> ok; +v_enum_RetirementReason('RETIRED_DEPRECATED', _Path, _TrUserData) -> ok; +v_enum_RetirementReason('RETIRED_RENAMED', _Path, _TrUserData) -> ok; +v_enum_RetirementReason(V, _Path, _TrUserData) when -2147483648 =< V, V =< 2147483647, is_integer(V) -> ok; +v_enum_RetirementReason(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'RetirementReason'}, X, Path). -compile({nowarn_unused_function,v_type_bool/3}). -dialyzer({nowarn_function,v_type_bool/3}). @@ -1546,48 +914,36 @@ v_type_bool(false, _Path, _TrUserData) -> ok; v_type_bool(true, _Path, _TrUserData) -> ok; v_type_bool(0, _Path, _TrUserData) -> ok; v_type_bool(1, _Path, _TrUserData) -> ok; -v_type_bool(X, Path, _TrUserData) -> - mk_type_error(bad_boolean_value, X, Path). +v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) - when is_list(S); is_binary(S) -> +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> - mk_type_error(bad_unicode_string, S, Path) + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch - error:badarg -> - mk_type_error(bad_unicode_string, S, Path) + error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; -v_type_string(X, Path, _TrUserData) -> - mk_type_error(bad_unicode_string, X, Path). +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> - ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> - ok; -v_type_bytes(X, Path, _TrUserData) -> - mk_type_error(bad_binary_value, X, Path). +v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; +v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), - erlang:error({gpb_type_error, - {Error, [{value, ValueSeen}, {path, Path2}]}}). + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> - list_to_atom(lists:append(lists:join(".", - lists:map(fun atom_to_list/1, - lists:reverse(PathR))))). +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). -compile({nowarn_unused_function,id/2}). @@ -1615,61 +971,33 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. get_msg_defs() -> - [{{enum, 'RetirementReason'}, - [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, - {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, - {'RETIRED_RENAMED', 4}]}, + [{{enum, 'RetirementReason'}, [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, {'RETIRED_RENAMED', 4}]}, {{msg, 'Package'}, - [#{name => releases, fnum => 1, rnum => 2, - type => {msg, 'Release'}, occurrence => repeated, - opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, - occurrence => required, opts => []}, - #{name => repository, fnum => 3, rnum => 4, - type => string, occurrence => required, opts => []}]}, + [#{name => releases, fnum => 1, rnum => 2, type => {msg, 'Release'}, occurrence => repeated, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}, + #{name => repository, fnum => 3, rnum => 4, type => string, occurrence => required, opts => []}]}, {{msg, 'Release'}, - [#{name => version, fnum => 1, rnum => 2, - type => string, occurrence => required, opts => []}, - #{name => inner_checksum, fnum => 2, rnum => 3, - type => bytes, occurrence => required, opts => []}, - #{name => dependencies, fnum => 3, rnum => 4, - type => {msg, 'Dependency'}, occurrence => repeated, - opts => []}, - #{name => retired, fnum => 4, rnum => 5, - type => {msg, 'RetirementStatus'}, - occurrence => optional, opts => []}, - #{name => outer_checksum, fnum => 5, rnum => 6, - type => bytes, occurrence => optional, opts => []}]}, - {{msg, 'RetirementStatus'}, - [#{name => reason, fnum => 1, rnum => 2, - type => {enum, 'RetirementReason'}, - occurrence => required, opts => []}, - #{name => message, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]}, + [#{name => version, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => inner_checksum, fnum => 2, rnum => 3, type => bytes, occurrence => required, opts => []}, + #{name => dependencies, fnum => 3, rnum => 4, type => {msg, 'Dependency'}, occurrence => repeated, opts => []}, + #{name => retired, fnum => 4, rnum => 5, type => {msg, 'RetirementStatus'}, occurrence => optional, opts => []}, + #{name => outer_checksum, fnum => 5, rnum => 6, type => bytes, occurrence => optional, opts => []}]}, + {{msg, 'RetirementStatus'}, [#{name => reason, fnum => 1, rnum => 2, type => {enum, 'RetirementReason'}, occurrence => required, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, {{msg, 'Dependency'}, - [#{name => package, fnum => 1, rnum => 2, - type => string, occurrence => required, opts => []}, - #{name => requirement, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}, - #{name => optional, fnum => 3, rnum => 4, type => bool, - occurrence => optional, opts => []}, - #{name => app, fnum => 4, rnum => 5, type => string, - occurrence => optional, opts => []}, - #{name => repository, fnum => 5, rnum => 6, - type => string, occurrence => optional, opts => []}]}]. + [#{name => package, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => requirement, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}, + #{name => optional, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}, + #{name => app, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}, + #{name => repository, fnum => 5, rnum => 6, type => string, occurrence => optional, opts => []}]}]. -get_msg_names() -> - ['Package', 'Release', 'RetirementStatus', - 'Dependency']. +get_msg_names() -> ['Package', 'Release', 'RetirementStatus', 'Dependency']. get_group_names() -> []. -get_msg_or_group_names() -> - ['Package', 'Release', 'RetirementStatus', - 'Dependency']. +get_msg_or_group_names() -> ['Package', 'Release', 'RetirementStatus', 'Dependency']. get_enum_names() -> ['RetirementReason']. @@ -1677,96 +1005,60 @@ get_enum_names() -> ['RetirementReason']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) end. fetch_enum_def(EnumName) -> case find_enum_def(EnumName) of - Es when is_list(Es) -> Es; - error -> erlang:error({no_such_enum, EnumName}) + Es when is_list(Es) -> Es; + error -> erlang:error({no_such_enum, EnumName}) end. find_msg_def('Package') -> - [#{name => releases, fnum => 1, rnum => 2, - type => {msg, 'Release'}, occurrence => repeated, - opts => []}, - #{name => name, fnum => 2, rnum => 3, type => string, - occurrence => required, opts => []}, - #{name => repository, fnum => 3, rnum => 4, - type => string, occurrence => required, opts => []}]; + [#{name => releases, fnum => 1, rnum => 2, type => {msg, 'Release'}, occurrence => repeated, opts => []}, + #{name => name, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}, + #{name => repository, fnum => 3, rnum => 4, type => string, occurrence => required, opts => []}]; find_msg_def('Release') -> - [#{name => version, fnum => 1, rnum => 2, - type => string, occurrence => required, opts => []}, - #{name => inner_checksum, fnum => 2, rnum => 3, - type => bytes, occurrence => required, opts => []}, - #{name => dependencies, fnum => 3, rnum => 4, - type => {msg, 'Dependency'}, occurrence => repeated, - opts => []}, - #{name => retired, fnum => 4, rnum => 5, - type => {msg, 'RetirementStatus'}, - occurrence => optional, opts => []}, - #{name => outer_checksum, fnum => 5, rnum => 6, - type => bytes, occurrence => optional, opts => []}]; -find_msg_def('RetirementStatus') -> - [#{name => reason, fnum => 1, rnum => 2, - type => {enum, 'RetirementReason'}, - occurrence => required, opts => []}, - #{name => message, fnum => 2, rnum => 3, type => string, - occurrence => optional, opts => []}]; + [#{name => version, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => inner_checksum, fnum => 2, rnum => 3, type => bytes, occurrence => required, opts => []}, + #{name => dependencies, fnum => 3, rnum => 4, type => {msg, 'Dependency'}, occurrence => repeated, opts => []}, + #{name => retired, fnum => 4, rnum => 5, type => {msg, 'RetirementStatus'}, occurrence => optional, opts => []}, + #{name => outer_checksum, fnum => 5, rnum => 6, type => bytes, occurrence => optional, opts => []}]; +find_msg_def('RetirementStatus') -> [#{name => reason, fnum => 1, rnum => 2, type => {enum, 'RetirementReason'}, occurrence => required, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def('Dependency') -> - [#{name => package, fnum => 1, rnum => 2, - type => string, occurrence => required, opts => []}, - #{name => requirement, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}, - #{name => optional, fnum => 3, rnum => 4, type => bool, - occurrence => optional, opts => []}, - #{name => app, fnum => 4, rnum => 5, type => string, - occurrence => optional, opts => []}, - #{name => repository, fnum => 5, rnum => 6, - type => string, occurrence => optional, opts => []}]; + [#{name => package, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => requirement, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}, + #{name => optional, fnum => 3, rnum => 4, type => bool, occurrence => optional, opts => []}, + #{name => app, fnum => 4, rnum => 5, type => string, occurrence => optional, opts => []}, + #{name => repository, fnum => 5, rnum => 6, type => string, occurrence => optional, opts => []}]; find_msg_def(_) -> error. -find_enum_def('RetirementReason') -> - [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, - {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, - {'RETIRED_RENAMED', 4}]; +find_enum_def('RetirementReason') -> [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1}, {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3}, {'RETIRED_RENAMED', 4}]; find_enum_def(_) -> error. -enum_symbol_by_value('RetirementReason', Value) -> - enum_symbol_by_value_RetirementReason(Value). +enum_symbol_by_value('RetirementReason', Value) -> enum_symbol_by_value_RetirementReason(Value). -enum_value_by_symbol('RetirementReason', Sym) -> - enum_value_by_symbol_RetirementReason(Sym). +enum_value_by_symbol('RetirementReason', Sym) -> enum_value_by_symbol_RetirementReason(Sym). -enum_symbol_by_value_RetirementReason(0) -> - 'RETIRED_OTHER'; -enum_symbol_by_value_RetirementReason(1) -> - 'RETIRED_INVALID'; -enum_symbol_by_value_RetirementReason(2) -> - 'RETIRED_SECURITY'; -enum_symbol_by_value_RetirementReason(3) -> - 'RETIRED_DEPRECATED'; -enum_symbol_by_value_RetirementReason(4) -> - 'RETIRED_RENAMED'. +enum_symbol_by_value_RetirementReason(0) -> 'RETIRED_OTHER'; +enum_symbol_by_value_RetirementReason(1) -> 'RETIRED_INVALID'; +enum_symbol_by_value_RetirementReason(2) -> 'RETIRED_SECURITY'; +enum_symbol_by_value_RetirementReason(3) -> 'RETIRED_DEPRECATED'; +enum_symbol_by_value_RetirementReason(4) -> 'RETIRED_RENAMED'. -enum_value_by_symbol_RetirementReason('RETIRED_OTHER') -> - 0; -enum_value_by_symbol_RetirementReason('RETIRED_INVALID') -> - 1; -enum_value_by_symbol_RetirementReason('RETIRED_SECURITY') -> - 2; -enum_value_by_symbol_RetirementReason('RETIRED_DEPRECATED') -> - 3; -enum_value_by_symbol_RetirementReason('RETIRED_RENAMED') -> - 4. +enum_value_by_symbol_RetirementReason('RETIRED_OTHER') -> 0; +enum_value_by_symbol_RetirementReason('RETIRED_INVALID') -> 1; +enum_value_by_symbol_RetirementReason('RETIRED_SECURITY') -> 2; +enum_value_by_symbol_RetirementReason('RETIRED_DEPRECATED') -> 3; +enum_value_by_symbol_RetirementReason('RETIRED_RENAMED') -> 4. get_service_names() -> []. @@ -1783,38 +1075,33 @@ find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). -fetch_rpc_def(ServiceName, RpcName) -> - erlang:error({no_such_rpc, ServiceName, RpcName}). +fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). -fqbin_to_service_name(X) -> - error({gpb_error, {badservice, X}}). +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). -service_name_to_fqbin(X) -> - error({gpb_error, {badservice, X}}). +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). -fqbins_to_service_and_rpc_name(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). -service_and_rpc_name_to_fqbins(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"Package">>) -> 'Package'; @@ -1832,13 +1119,11 @@ msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_enum_name(<<"RetirementReason">>) -> 'RetirementReason'; -fqbin_to_enum_name(E) -> - error({gpb_error, {badenum, E}}). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). enum_name_to_fqbin('RetirementReason') -> <<"RetirementReason">>; -enum_name_to_fqbin(E) -> - error({gpb_error, {badenum, E}}). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> undefined. @@ -1868,65 +1153,51 @@ get_all_source_basenames() -> ["r3_hex_pb_package.proto"]. get_all_proto_names() -> ["r3_hex_pb_package"]. -get_msg_containment("r3_hex_pb_package") -> - ['Dependency', 'Package', 'Release', - 'RetirementStatus']; -get_msg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_msg_containment("r3_hex_pb_package") -> ['Dependency', 'Package', 'Release', 'RetirementStatus']; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("r3_hex_pb_package") -> undefined; -get_pkg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("r3_hex_pb_package") -> []; -get_service_containment(P) -> - error({gpb_error, {badproto, P}}). +get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("r3_hex_pb_package") -> []; -get_rpc_containment(P) -> - error({gpb_error, {badproto, P}}). +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). -get_enum_containment("r3_hex_pb_package") -> - ['RetirementReason']; -get_enum_containment(P) -> - error({gpb_error, {badproto, P}}). +get_enum_containment("r3_hex_pb_package") -> ['RetirementReason']; +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). -get_proto_by_msg_name_as_fqbin(<<"RetirementStatus">>) -> - "r3_hex_pb_package"; -get_proto_by_msg_name_as_fqbin(<<"Release">>) -> - "r3_hex_pb_package"; -get_proto_by_msg_name_as_fqbin(<<"Package">>) -> - "r3_hex_pb_package"; -get_proto_by_msg_name_as_fqbin(<<"Dependency">>) -> - "r3_hex_pb_package"; -get_proto_by_msg_name_as_fqbin(E) -> - error({gpb_error, {badmsg, E}}). +get_proto_by_msg_name_as_fqbin(<<"RetirementStatus">>) -> "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Release">>) -> "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Package">>) -> "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(<<"Dependency">>) -> "r3_hex_pb_package"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). -get_proto_by_service_name_as_fqbin(E) -> - error({gpb_error, {badservice, E}}). +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -get_proto_by_enum_name_as_fqbin(<<"RetirementReason">>) -> - "r3_hex_pb_package"; -get_proto_by_enum_name_as_fqbin(E) -> - error({gpb_error, {badenum, E}}). +get_proto_by_enum_name_as_fqbin(<<"RetirementReason">>) -> "r3_hex_pb_package"; +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -spec get_protos_by_pkg_name_as_fqbin(_) -> no_return(). -get_protos_by_pkg_name_as_fqbin(E) -> - error({gpb_error, {badpkg, E}}). +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.10.0". + "4.17.6". gpb_version_as_list() -> - [4,10,0]. + [4,17,6]. + +gpb_version_source() -> + "file". diff --git a/apps/rebar/src/vendored/r3_hex_pb_signed.erl b/apps/rebar/src/vendored/r3_hex_pb_signed.erl index 87645c185..5944327c4 100644 --- a/apps/rebar/src/vendored/r3_hex_pb_signed.erl +++ b/apps/rebar/src/vendored/r3_hex_pb_signed.erl @@ -1,9 +1,10 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.10.0 +%% Generated by gpb_compile version 4.17.6 +%% Version source: file -module(r3_hex_pb_signed). -export([encode_msg/2, encode_msg/3]). @@ -45,6 +46,7 @@ -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). %% enumerated types @@ -53,72 +55,54 @@ %% message types -type 'Signed'() :: - #{payload := iodata(), % = 1 - signature => iodata() % = 2 + #{payload => iodata(), % = 1, required + signature => iodata() % = 2, optional }. -export_type(['Signed'/0]). +-type '$msg_name'() :: 'Signed'. +-type '$msg'() :: 'Signed'(). +-export_type(['$msg_name'/0, '$msg'/0]). --spec encode_msg('Signed'(), atom()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> - encode_msg(Msg, MsgName, []). +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). --spec encode_msg('Signed'(), atom(), list()) -> binary(). +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - 'Signed' -> - encode_msg_Signed(id(Msg, TrUserData), TrUserData) - end. + case MsgName of 'Signed' -> encode_msg_Signed(id(Msg, TrUserData), TrUserData) end. -encode_msg_Signed(Msg, TrUserData) -> - encode_msg_Signed(Msg, <<>>, TrUserData). +encode_msg_Signed(Msg, TrUserData) -> encode_msg_Signed(Msg, <<>>, TrUserData). -encode_msg_Signed(#{payload := F1} = M, Bin, - TrUserData) -> - B1 = begin - TrF1 = id(F1, TrUserData), - e_type_bytes(TrF1, <>, TrUserData) - end, +encode_msg_Signed(#{payload := F1} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_bytes(TrF1, <>, TrUserData) end, case M of - #{signature := F2} -> - begin - TrF2 = id(F2, TrUserData), - e_type_bytes(TrF2, <>, TrUserData) - end; - _ -> B1 + #{signature := F2} -> begin TrF2 = id(F2, TrUserData), e_type_bytes(TrF2, <>, TrUserData) end; + _ -> B1 end. -compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> - e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> - e_varint(Value * -2 - 1, Bin). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> - <>; -e_type_bool(false, Bin, _TrUserData) -> - <>; +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. @@ -129,51 +113,61 @@ e_type_string(S, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) - when is_binary(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; -e_type_bytes(Bytes, Bin, _TrUserData) - when is_list(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> - <>. +e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> - <>. +e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> - <>; -e_type_float(infinity, Bin, _) -> - <>; -e_type_float('-infinity', Bin, _) -> - <>; -e_type_float(nan, Bin, _) -> - <>. +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> - <>; -e_type_double(infinity, Bin, _) -> - <>; -e_type_double('-infinity', Bin, _) -> - <>; -e_type_double(nan, Bin, _) -> - <>. +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). @@ -185,8 +179,7 @@ e_varint(N, Bin) -> e_varint(N bsr 7, Bin2). -decode_msg(Bin, MsgName) when is_binary(Bin) -> - decode_msg(Bin, MsgName, []). +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), @@ -206,135 +199,68 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) -> end. -endif. -decode_msg_2_doit('Signed', Bin, TrUserData) -> - id(decode_msg_Signed(Bin, TrUserData), TrUserData). +decode_msg_2_doit('Signed', Bin, TrUserData) -> id(decode_msg_Signed(Bin, TrUserData), TrUserData). -decode_msg_Signed(Bin, TrUserData) -> - dfp_read_field_def_Signed(Bin, 0, 0, - id('$undef', TrUserData), - id('$undef', TrUserData), TrUserData). +decode_msg_Signed(Bin, TrUserData) -> dfp_read_field_def_Signed(Bin, 0, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). -dfp_read_field_def_Signed(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Signed_payload(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Signed(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Signed_signature(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Signed(<<>>, 0, 0, F@_1, F@_2, _) -> +dfp_read_field_def_Signed(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Signed_payload(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Signed(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Signed_signature(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Signed(<<>>, 0, 0, _, F@_1, F@_2, _) -> S1 = #{payload => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{signature => F@_2} end; -dfp_read_field_def_Signed(Other, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_Signed(Other, Z1, Z2, F@_1, F@_2, - TrUserData). - -dg_read_field_def_Signed(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Signed(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -dg_read_field_def_Signed(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) -> +dfp_read_field_def_Signed(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Signed(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_Signed(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Signed(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_Signed(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Signed_payload(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 18 -> - d_field_Signed_signature(Rest, 0, 0, F@_1, F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Signed(Rest, 0, 0, F@_1, F@_2, TrUserData); - 1 -> skip_64_Signed(Rest, 0, 0, F@_1, F@_2, TrUserData); - 2 -> - skip_length_delimited_Signed(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 3 -> - skip_group_Signed(Rest, Key bsr 3, 0, F@_1, F@_2, - TrUserData); - 5 -> skip_32_Signed(Rest, 0, 0, F@_1, F@_2, TrUserData) - end + 10 -> d_field_Signed_payload(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_Signed_signature(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_Signed(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end end; -dg_read_field_def_Signed(<<>>, 0, 0, F@_1, F@_2, _) -> +dg_read_field_def_Signed(<<>>, 0, 0, _, F@_1, F@_2, _) -> S1 = #{payload => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{signature => F@_2} end. -d_field_Signed_payload(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Signed_payload(Rest, N + 7, X bsl N + Acc, F@_1, - F@_2, TrUserData); -d_field_Signed_payload(<<0:1, X:7, Rest/binary>>, N, - Acc, _, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Signed(RestF, 0, 0, NewFValue, F@_2, - TrUserData). - -d_field_Signed_signature(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Signed_signature(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -d_field_Signed_signature(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Signed(RestF, 0, 0, F@_1, NewFValue, - TrUserData). - -skip_varint_Signed(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - skip_varint_Signed(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -skip_varint_Signed(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_Signed(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -skip_length_delimited_Signed(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_Signed(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -skip_length_delimited_Signed(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> +d_field_Signed_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Signed_payload(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Signed_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Signed(RestF, 0, 0, F, NewFValue, F@_2, TrUserData). + +d_field_Signed_signature(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Signed_signature(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Signed_signature(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Signed(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_Signed(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_Signed(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_Signed(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Signed(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_Signed(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Signed(Rest2, 0, 0, F@_1, F@_2, - TrUserData). + dfp_read_field_def_Signed(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). -skip_group_Signed(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> +skip_group_Signed(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Signed(Rest, 0, Z2, F@_1, F@_2, - TrUserData). + dfp_read_field_def_Signed(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). -skip_32_Signed(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_Signed(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). +skip_32_Signed(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). -skip_64_Signed(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_Signed(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). +skip_64_Signed(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Signed(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), @@ -394,36 +320,29 @@ read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> - merge_msgs(Prev, New, MsgName, []). +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), - case MsgName of - 'Signed' -> merge_msg_Signed(Prev, New, TrUserData) - end. + case MsgName of 'Signed' -> merge_msg_Signed(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_Signed/3}). -merge_msg_Signed(#{} = PMsg, - #{payload := NFpayload} = NMsg, _) -> +merge_msg_Signed(#{} = PMsg, #{payload := NFpayload} = NMsg, _) -> S1 = #{payload => NFpayload}, case {PMsg, NMsg} of - {_, #{signature := NFsignature}} -> - S1#{signature => NFsignature}; - {#{signature := PFsignature}, _} -> - S1#{signature => PFsignature}; - _ -> S1 + {_, #{signature := NFsignature}} -> S1#{signature => NFsignature}; + {#{signature := PFsignature}, _} -> S1#{signature => PFsignature}; + _ -> S1 end. -verify_msg(Msg, MsgName) when is_atom(MsgName) -> - verify_msg(Msg, MsgName, []). +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Signed' -> v_msg_Signed(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) + 'Signed' -> v_msg_Signed(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) end. @@ -432,48 +351,35 @@ verify_msg(Msg, MsgName, Opts) -> v_msg_Signed(#{payload := F1} = M, Path, TrUserData) -> v_type_bytes(F1, [payload | Path], TrUserData), case M of - #{signature := F2} -> - v_type_bytes(F2, [signature | Path], TrUserData); - _ -> ok + #{signature := F2} -> v_type_bytes(F2, [signature | Path], TrUserData); + _ -> ok end, lists:foreach(fun (payload) -> ok; - (signature) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (signature) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Signed(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [payload] -- maps:keys(M), 'Signed'}, - M, Path); -v_msg_Signed(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Signed'}, X, Path). +v_msg_Signed(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [payload] -- maps:keys(M), 'Signed'}, M, Path); +v_msg_Signed(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Signed'}, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). -v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> - ok; -v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> - ok; -v_type_bytes(X, Path, _TrUserData) -> - mk_type_error(bad_binary_value, X, Path). +v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; +v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; +v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), - erlang:error({gpb_type_error, - {Error, [{value, ValueSeen}, {path, Path2}]}}). + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> - list_to_atom(lists:append(lists:join(".", - lists:map(fun atom_to_list/1, - lists:reverse(PathR))))). +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). -compile({nowarn_unused_function,id/2}). @@ -500,12 +406,7 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. 'erlang_++'(A, B, _TrUserData) -> A ++ B. -get_msg_defs() -> - [{{msg, 'Signed'}, - [#{name => payload, fnum => 1, rnum => 2, type => bytes, - occurrence => required, opts => []}, - #{name => signature, fnum => 2, rnum => 3, - type => bytes, occurrence => optional, opts => []}]}]. +get_msg_defs() -> [{{msg, 'Signed'}, [#{name => payload, fnum => 1, rnum => 2, type => bytes, occurrence => required, opts => []}, #{name => signature, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]}]. get_msg_names() -> ['Signed']. @@ -522,21 +423,16 @@ get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> - erlang:error({no_such_enum, EnumName}). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). -find_msg_def('Signed') -> - [#{name => payload, fnum => 1, rnum => 2, type => bytes, - occurrence => required, opts => []}, - #{name => signature, fnum => 2, rnum => 3, - type => bytes, occurrence => optional, opts => []}]; +find_msg_def('Signed') -> [#{name => payload, fnum => 1, rnum => 2, type => bytes, occurrence => required, opts => []}, #{name => signature, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]; find_msg_def(_) -> error. @@ -544,13 +440,11 @@ find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). @@ -568,38 +462,33 @@ find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). -fetch_rpc_def(ServiceName, RpcName) -> - erlang:error({no_such_rpc, ServiceName, RpcName}). +fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). -fqbin_to_service_name(X) -> - error({gpb_error, {badservice, X}}). +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). -service_name_to_fqbin(X) -> - error({gpb_error, {badservice, X}}). +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). -fqbins_to_service_and_rpc_name(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). -service_and_rpc_name_to_fqbins(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"Signed">>) -> 'Signed'; @@ -611,13 +500,11 @@ msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> - error({gpb_error, {badenum, E}}). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> - error({gpb_error, {badenum, E}}). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> undefined. @@ -648,54 +535,47 @@ get_all_proto_names() -> ["r3_hex_pb_signed"]. get_msg_containment("r3_hex_pb_signed") -> ['Signed']; -get_msg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("r3_hex_pb_signed") -> undefined; -get_pkg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("r3_hex_pb_signed") -> []; -get_service_containment(P) -> - error({gpb_error, {badproto, P}}). +get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("r3_hex_pb_signed") -> []; -get_rpc_containment(P) -> - error({gpb_error, {badproto, P}}). +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("r3_hex_pb_signed") -> []; -get_enum_containment(P) -> - error({gpb_error, {badproto, P}}). +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). -get_proto_by_msg_name_as_fqbin(<<"Signed">>) -> - "r3_hex_pb_signed"; -get_proto_by_msg_name_as_fqbin(E) -> - error({gpb_error, {badmsg, E}}). +get_proto_by_msg_name_as_fqbin(<<"Signed">>) -> "r3_hex_pb_signed"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). -get_proto_by_service_name_as_fqbin(E) -> - error({gpb_error, {badservice, E}}). +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> - error({gpb_error, {badenum, E}}). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -spec get_protos_by_pkg_name_as_fqbin(_) -> no_return(). -get_protos_by_pkg_name_as_fqbin(E) -> - error({gpb_error, {badpkg, E}}). +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.10.0". + "4.17.6". gpb_version_as_list() -> - [4,10,0]. + [4,17,6]. + +gpb_version_source() -> + "file". diff --git a/apps/rebar/src/vendored/r3_hex_pb_versions.erl b/apps/rebar/src/vendored/r3_hex_pb_versions.erl index f86f02a30..9e36a7339 100644 --- a/apps/rebar/src/vendored/r3_hex_pb_versions.erl +++ b/apps/rebar/src/vendored/r3_hex_pb_versions.erl @@ -1,9 +1,10 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.10.0 +%% Generated by gpb_compile version 4.17.6 +%% Version source: file -module(r3_hex_pb_versions). -export([encode_msg/2, encode_msg/3]). @@ -45,6 +46,7 @@ -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). +-export([gpb_version_source/0]). %% enumerated types @@ -53,78 +55,68 @@ %% message types -type 'Versions'() :: - #{packages => ['Package'()], % = 1 - repository := iodata() % = 2 + #{packages => ['Package'()], % = 1, repeated + repository => unicode:chardata() % = 2, required }. -type 'Package'() :: - #{name := iodata(), % = 1 - versions => [iodata()], % = 2 - retired => [integer()] % = 3, 32 bits + #{name => unicode:chardata(), % = 1, required + versions => [unicode:chardata()], % = 2, repeated + retired => [integer()] % = 3, repeated, 32 bits }. -export_type(['Versions'/0, 'Package'/0]). +-type '$msg_name'() :: 'Versions' | 'Package'. +-type '$msg'() :: 'Versions'() | 'Package'(). +-export_type(['$msg_name'/0, '$msg'/0]). --spec encode_msg('Versions'() | 'Package'(), atom()) -> binary(). -encode_msg(Msg, MsgName) when is_atom(MsgName) -> - encode_msg(Msg, MsgName, []). +-spec encode_msg('$msg'(), '$msg_name'()) -> binary(). +encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). --spec encode_msg('Versions'() | 'Package'(), atom(), list()) -> binary(). +-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Versions' -> - encode_msg_Versions(id(Msg, TrUserData), TrUserData); - 'Package' -> - encode_msg_Package(id(Msg, TrUserData), TrUserData) + 'Versions' -> encode_msg_Versions(id(Msg, TrUserData), TrUserData); + 'Package' -> encode_msg_Package(id(Msg, TrUserData), TrUserData) end. -encode_msg_Versions(Msg, TrUserData) -> - encode_msg_Versions(Msg, <<>>, TrUserData). +encode_msg_Versions(Msg, TrUserData) -> encode_msg_Versions(Msg, <<>>, TrUserData). -encode_msg_Versions(#{repository := F2} = M, Bin, - TrUserData) -> +encode_msg_Versions(#{repository := F2} = M, Bin, TrUserData) -> B1 = case M of - #{packages := F1} -> - TrF1 = id(F1, TrUserData), - if TrF1 == [] -> Bin; - true -> e_field_Versions_packages(TrF1, Bin, TrUserData) - end; - _ -> Bin - end, - begin - TrF2 = id(F2, TrUserData), - e_type_string(TrF2, <>, TrUserData) - end. + #{packages := F1} -> + TrF1 = id(F1, TrUserData), + if TrF1 == [] -> Bin; + true -> e_field_Versions_packages(TrF1, Bin, TrUserData) + end; + _ -> Bin + end, + begin TrF2 = id(F2, TrUserData), e_type_string(TrF2, <>, TrUserData) end. -encode_msg_Package(Msg, TrUserData) -> - encode_msg_Package(Msg, <<>>, TrUserData). +encode_msg_Package(Msg, TrUserData) -> encode_msg_Package(Msg, <<>>, TrUserData). -encode_msg_Package(#{name := F1} = M, Bin, - TrUserData) -> - B1 = begin - TrF1 = id(F1, TrUserData), - e_type_string(TrF1, <>, TrUserData) - end, +encode_msg_Package(#{name := F1} = M, Bin, TrUserData) -> + B1 = begin TrF1 = id(F1, TrUserData), e_type_string(TrF1, <>, TrUserData) end, B2 = case M of - #{versions := F2} -> - TrF2 = id(F2, TrUserData), - if TrF2 == [] -> B1; - true -> e_field_Package_versions(TrF2, B1, TrUserData) - end; - _ -> B1 - end, + #{versions := F2} -> + TrF2 = id(F2, TrUserData), + if TrF2 == [] -> B1; + true -> e_field_Package_versions(TrF2, B1, TrUserData) + end; + _ -> B1 + end, case M of - #{retired := F3} -> - TrF3 = id(F3, TrUserData), - if TrF3 == [] -> B2; - true -> e_field_Package_retired(TrF3, B2, TrUserData) - end; - _ -> B2 + #{retired := F3} -> + TrF3 = id(F3, TrUserData), + if TrF3 == [] -> B2; + true -> e_field_Package_retired(TrF3, B2, TrUserData) + end; + _ -> B2 end. e_mfield_Versions_packages(Msg, Bin, TrUserData) -> @@ -132,65 +124,49 @@ e_mfield_Versions_packages(Msg, Bin, TrUserData) -> Bin2 = e_varint(byte_size(SubBin), Bin), <>. -e_field_Versions_packages([Elem | Rest], Bin, - TrUserData) -> +e_field_Versions_packages([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, - Bin3 = e_mfield_Versions_packages(id(Elem, TrUserData), - Bin2, TrUserData), + Bin3 = e_mfield_Versions_packages(id(Elem, TrUserData), Bin2, TrUserData), e_field_Versions_packages(Rest, Bin3, TrUserData); e_field_Versions_packages([], Bin, _TrUserData) -> Bin. -e_field_Package_versions([Elem | Rest], Bin, - TrUserData) -> +e_field_Package_versions([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, - Bin3 = e_type_string(id(Elem, TrUserData), Bin2, - TrUserData), + Bin3 = e_type_string(id(Elem, TrUserData), Bin2, TrUserData), e_field_Package_versions(Rest, Bin3, TrUserData); e_field_Package_versions([], Bin, _TrUserData) -> Bin. -e_field_Package_retired(Elems, Bin, TrUserData) - when Elems =/= [] -> - SubBin = e_pfield_Package_retired(Elems, <<>>, - TrUserData), +e_field_Package_retired(Elems, Bin, TrUserData) when Elems =/= [] -> + SubBin = e_pfield_Package_retired(Elems, <<>>, TrUserData), Bin2 = <>, Bin3 = e_varint(byte_size(SubBin), Bin2), <>; e_field_Package_retired([], Bin, _TrUserData) -> Bin. -e_pfield_Package_retired([Value | Rest], Bin, - TrUserData) -> - Bin2 = e_type_int32(id(Value, TrUserData), Bin, - TrUserData), +e_pfield_Package_retired([Value | Rest], Bin, TrUserData) -> + Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData), e_pfield_Package_retired(Rest, Bin2, TrUserData); e_pfield_Package_retired([], Bin, _TrUserData) -> Bin. -compile({nowarn_unused_function,e_type_sint/3}). -e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> - e_varint(Value * 2, Bin); -e_type_sint(Value, Bin, _TrUserData) -> - e_varint(Value * -2 - 1, Bin). +e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); +e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). -e_type_int32(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). -e_type_int64(Value, Bin, _TrUserData) - when 0 =< Value, Value =< 127 -> - <>; +e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). -e_type_bool(true, Bin, _TrUserData) -> - <>; -e_type_bool(false, Bin, _TrUserData) -> - <>; +e_type_bool(true, Bin, _TrUserData) -> <>; +e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. @@ -201,51 +177,61 @@ e_type_string(S, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_bytes/3}). -e_type_bytes(Bytes, Bin, _TrUserData) - when is_binary(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; -e_type_bytes(Bytes, Bin, _TrUserData) - when is_list(Bytes) -> +e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). -e_type_fixed32(Value, Bin, _TrUserData) -> - <>. +e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). -e_type_sfixed32(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). -e_type_fixed64(Value, Bin, _TrUserData) -> - <>. +e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). -e_type_sfixed64(Value, Bin, _TrUserData) -> - <>. +e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). -e_type_float(V, Bin, _) when is_number(V) -> - <>; -e_type_float(infinity, Bin, _) -> - <>; -e_type_float('-infinity', Bin, _) -> - <>; -e_type_float(nan, Bin, _) -> - <>. +e_type_float(V, Bin, _) when is_number(V) -> <>; +e_type_float(infinity, Bin, _) -> <>; +e_type_float('-infinity', Bin, _) -> <>; +e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). -e_type_double(V, Bin, _) when is_number(V) -> - <>; -e_type_double(infinity, Bin, _) -> - <>; -e_type_double('-infinity', Bin, _) -> - <>; -e_type_double(nan, Bin, _) -> - <>. +e_type_double(V, Bin, _) when is_number(V) -> <>; +e_type_double(infinity, Bin, _) -> <>; +e_type_double('-infinity', Bin, _) -> <>; +e_type_double(nan, Bin, _) -> <>. + +-compile({nowarn_unused_function,e_unknown_elems/2}). +e_unknown_elems([Elem | Rest], Bin) -> + BinR = case Elem of + {varint, FNum, N} -> + BinF = e_varint(FNum bsl 3, Bin), + e_varint(N, BinF); + {length_delimited, FNum, Data} -> + BinF = e_varint(FNum bsl 3 bor 2, Bin), + BinL = e_varint(byte_size(Data), BinF), + <>; + {group, FNum, GroupFields} -> + Bin1 = e_varint(FNum bsl 3 bor 3, Bin), + Bin2 = e_unknown_elems(GroupFields, Bin1), + e_varint(FNum bsl 3 bor 4, Bin2); + {fixed32, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 5, Bin), + <>; + {fixed64, FNum, V} -> + BinF = e_varint(FNum bsl 3 bor 1, Bin), + <> + end, + e_unknown_elems(Rest, BinR); +e_unknown_elems([], Bin) -> Bin. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). @@ -257,8 +243,7 @@ e_varint(N, Bin) -> e_varint(N bsr 7, Bin2). -decode_msg(Bin, MsgName) when is_binary(Bin) -> - decode_msg(Bin, MsgName, []). +decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), @@ -278,341 +263,142 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) -> end. -endif. -decode_msg_2_doit('Versions', Bin, TrUserData) -> - id(decode_msg_Versions(Bin, TrUserData), TrUserData); -decode_msg_2_doit('Package', Bin, TrUserData) -> - id(decode_msg_Package(Bin, TrUserData), TrUserData). +decode_msg_2_doit('Versions', Bin, TrUserData) -> id(decode_msg_Versions(Bin, TrUserData), TrUserData); +decode_msg_2_doit('Package', Bin, TrUserData) -> id(decode_msg_Package(Bin, TrUserData), TrUserData). -decode_msg_Versions(Bin, TrUserData) -> - dfp_read_field_def_Versions(Bin, 0, 0, - id([], TrUserData), id('$undef', TrUserData), - TrUserData). +decode_msg_Versions(Bin, TrUserData) -> dfp_read_field_def_Versions(Bin, 0, 0, 0, id([], TrUserData), id('$undef', TrUserData), TrUserData). -dfp_read_field_def_Versions(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Versions_packages(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Versions(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - d_field_Versions_repository(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -dfp_read_field_def_Versions(<<>>, 0, 0, R1, F@_2, - TrUserData) -> +dfp_read_field_def_Versions(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Versions_packages(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Versions(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_Versions_repository(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +dfp_read_field_def_Versions(<<>>, 0, 0, _, R1, F@_2, TrUserData) -> S1 = #{repository => F@_2}, if R1 == '$undef' -> S1; true -> S1#{packages => lists_reverse(R1, TrUserData)} end; -dfp_read_field_def_Versions(Other, Z1, Z2, F@_1, F@_2, - TrUserData) -> - dg_read_field_def_Versions(Other, Z1, Z2, F@_1, F@_2, - TrUserData). - -dg_read_field_def_Versions(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Versions(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -dg_read_field_def_Versions(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) -> +dfp_read_field_def_Versions(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_Versions(Other, Z1, Z2, F, F@_1, F@_2, TrUserData). + +dg_read_field_def_Versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_Versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +dg_read_field_def_Versions(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Versions_packages(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 18 -> - d_field_Versions_repository(Rest, 0, 0, F@_1, F@_2, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Versions(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 1 -> - skip_64_Versions(Rest, 0, 0, F@_1, F@_2, TrUserData); - 2 -> - skip_length_delimited_Versions(Rest, 0, 0, F@_1, F@_2, - TrUserData); - 3 -> - skip_group_Versions(Rest, Key bsr 3, 0, F@_1, F@_2, - TrUserData); - 5 -> - skip_32_Versions(Rest, 0, 0, F@_1, F@_2, TrUserData) - end + 10 -> d_field_Versions_packages(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + 18 -> d_field_Versions_repository(Rest, 0, 0, 0, F@_1, F@_2, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 1 -> skip_64_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 2 -> skip_length_delimited_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 3 -> skip_group_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData); + 5 -> skip_32_Versions(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData) + end end; -dg_read_field_def_Versions(<<>>, 0, 0, R1, F@_2, - TrUserData) -> +dg_read_field_def_Versions(<<>>, 0, 0, _, R1, F@_2, TrUserData) -> S1 = #{repository => F@_2}, if R1 == '$undef' -> S1; true -> S1#{packages => lists_reverse(R1, TrUserData)} end. -d_field_Versions_packages(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Versions_packages(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -d_field_Versions_packages(<<0:1, X:7, Rest/binary>>, N, - Acc, Prev, F@_2, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(decode_msg_Package(Bs, TrUserData), TrUserData), - Rest2} - end, - dfp_read_field_def_Versions(RestF, 0, 0, - cons(NewFValue, Prev, TrUserData), F@_2, - TrUserData). - -d_field_Versions_repository(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - d_field_Versions_repository(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, TrUserData); -d_field_Versions_repository(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, _, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Versions(RestF, 0, 0, F@_1, - NewFValue, TrUserData). - -skip_varint_Versions(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - skip_varint_Versions(Rest, Z1, Z2, F@_1, F@_2, - TrUserData); -skip_varint_Versions(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, TrUserData) -> - dfp_read_field_def_Versions(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -skip_length_delimited_Versions(<<1:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) - when N < 57 -> - skip_length_delimited_Versions(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, TrUserData); -skip_length_delimited_Versions(<<0:1, X:7, - Rest/binary>>, - N, Acc, F@_1, F@_2, TrUserData) -> +d_field_Versions_packages(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Versions_packages(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Versions_packages(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, F@_2, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_Package(Bs, TrUserData), TrUserData), Rest2} end, + dfp_read_field_def_Versions(RestF, 0, 0, F, cons(NewFValue, Prev, TrUserData), F@_2, TrUserData). + +d_field_Versions_repository(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_Versions_repository(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +d_field_Versions_repository(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Versions(RestF, 0, 0, F, F@_1, NewFValue, TrUserData). + +skip_varint_Versions(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData); +skip_varint_Versions(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_length_delimited_Versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_Versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData); +skip_length_delimited_Versions(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Versions(Rest2, 0, 0, F@_1, F@_2, - TrUserData). + dfp_read_field_def_Versions(Rest2, 0, 0, F, F@_1, F@_2, TrUserData). -skip_group_Versions(Bin, FNum, Z2, F@_1, F@_2, - TrUserData) -> +skip_group_Versions(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Versions(Rest, 0, Z2, F@_1, F@_2, - TrUserData). - -skip_32_Versions(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_Versions(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -skip_64_Versions(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, TrUserData) -> - dfp_read_field_def_Versions(Rest, Z1, Z2, F@_1, F@_2, - TrUserData). - -decode_msg_Package(Bin, TrUserData) -> - dfp_read_field_def_Package(Bin, 0, 0, - id('$undef', TrUserData), id([], TrUserData), - id([], TrUserData), TrUserData). - -dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_name(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_versions(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_pfield_Package_retired(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<24, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - d_field_Package_retired(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -dfp_read_field_def_Package(<<>>, 0, 0, F@_1, R1, R2, - TrUserData) -> - #{name => F@_1, - versions => lists_reverse(R1, TrUserData), - retired => lists_reverse(R2, TrUserData)}; -dfp_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData) -> - dg_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 32 - 7 -> - dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) -> + dfp_read_field_def_Versions(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData). + +skip_32_Versions(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +skip_64_Versions(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_Versions(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData). + +decode_msg_Package(Bin, TrUserData) -> dfp_read_field_def_Package(Bin, 0, 0, 0, id('$undef', TrUserData), id([], TrUserData), id([], TrUserData), TrUserData). + +dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_name(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_versions(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_pfield_Package_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_Package_retired(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +dfp_read_field_def_Package(<<>>, 0, 0, _, F@_1, R1, R2, TrUserData) -> #{name => F@_1, versions => lists_reverse(R1, TrUserData), retired => lists_reverse(R2, TrUserData)}; +dfp_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_Package(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of - 10 -> - d_field_Package_name(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 18 -> - d_field_Package_versions(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 26 -> - d_pfield_Package_retired(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 24 -> - d_field_Package_retired(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - _ -> - case Key band 7 of - 0 -> - skip_varint_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 1 -> - skip_64_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData); - 2 -> - skip_length_delimited_Package(Rest, 0, 0, F@_1, F@_2, - F@_3, TrUserData); - 3 -> - skip_group_Package(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, - TrUserData); - 5 -> - skip_32_Package(Rest, 0, 0, F@_1, F@_2, F@_3, - TrUserData) - end + 10 -> d_field_Package_name(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 18 -> d_field_Package_versions(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 26 -> d_pfield_Package_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + 24 -> d_field_Package_retired(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); + _ -> + case Key band 7 of + 0 -> skip_varint_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 1 -> skip_64_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 2 -> skip_length_delimited_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 3 -> skip_group_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData); + 5 -> skip_32_Package(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) + end end; -dg_read_field_def_Package(<<>>, 0, 0, F@_1, R1, R2, - TrUserData) -> - #{name => F@_1, - versions => lists_reverse(R1, TrUserData), - retired => lists_reverse(R2, TrUserData)}. - -d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, - F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_name(Rest, N + 7, X bsl N + Acc, F@_1, - F@_2, F@_3, TrUserData); -d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, - _, F@_2, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, NewFValue, F@_2, - F@_3, TrUserData). - -d_field_Package_versions(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_versions(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -d_field_Package_versions(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, Prev, F@_3, TrUserData) -> - {NewFValue, RestF} = begin - Len = X bsl N + Acc, - <> = Rest, - {id(binary:copy(Bytes), TrUserData), Rest2} - end, - dfp_read_field_def_Package(RestF, 0, 0, F@_1, - cons(NewFValue, Prev, TrUserData), F@_3, - TrUserData). - -d_field_Package_retired(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_field_Package_retired(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -d_field_Package_retired(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, Prev, TrUserData) -> - {NewFValue, RestF} = {begin - <> = <<(X bsl N + - Acc):32/unsigned-native>>, - id(Res, TrUserData) - end, - Rest}, - dfp_read_field_def_Package(RestF, 0, 0, F@_1, F@_2, - cons(NewFValue, Prev, TrUserData), TrUserData). - -d_pfield_Package_retired(<<1:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - d_pfield_Package_retired(Rest, N + 7, X bsl N + Acc, - F@_1, F@_2, F@_3, TrUserData); -d_pfield_Package_retired(<<0:1, X:7, Rest/binary>>, N, - Acc, F@_1, F@_2, E, TrUserData) -> +dg_read_field_def_Package(<<>>, 0, 0, _, F@_1, R1, R2, TrUserData) -> #{name => F@_1, versions => lists_reverse(R1, TrUserData), retired => lists_reverse(R2, TrUserData)}. + +d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_name(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). + +d_field_Package_versions(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_versions(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_versions(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, F@_3, TrUserData) -> + {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, + dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, cons(NewFValue, Prev, TrUserData), F@_3, TrUserData). + +d_field_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_Package_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_field_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, Prev, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + dfp_read_field_def_Package(RestF, 0, 0, F, F@_1, F@_2, cons(NewFValue, Prev, TrUserData), TrUserData). + +d_pfield_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_pfield_Package_retired(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +d_pfield_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, E, TrUserData) -> Len = X bsl N + Acc, <> = Rest, - NewSeq = d_packed_field_Package_retired(PackedBytes, 0, - 0, E, TrUserData), - dfp_read_field_def_Package(Rest2, 0, 0, F@_1, F@_2, - NewSeq, TrUserData). - -d_packed_field_Package_retired(<<1:1, X:7, - Rest/binary>>, - N, Acc, AccSeq, TrUserData) - when N < 57 -> - d_packed_field_Package_retired(Rest, N + 7, - X bsl N + Acc, AccSeq, TrUserData); -d_packed_field_Package_retired(<<0:1, X:7, - Rest/binary>>, - N, Acc, AccSeq, TrUserData) -> - {NewFValue, RestF} = {begin - <> = <<(X bsl N + - Acc):32/unsigned-native>>, - id(Res, TrUserData) - end, - Rest}, - d_packed_field_Package_retired(RestF, 0, 0, - [NewFValue | AccSeq], TrUserData); -d_packed_field_Package_retired(<<>>, 0, 0, AccSeq, _) -> - AccSeq. - -skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - skip_varint_Package(Rest, Z1, Z2, F@_1, F@_2, F@_3, - TrUserData); -skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, - F@_1, F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). - -skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) - when N < 57 -> - skip_length_delimited_Package(Rest, N + 7, - X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); -skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, - N, Acc, F@_1, F@_2, F@_3, TrUserData) -> + NewSeq = d_packed_field_Package_retired(PackedBytes, 0, 0, F, E, TrUserData), + dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, NewSeq, TrUserData). + +d_packed_field_Package_retired(<<1:1, X:7, Rest/binary>>, N, Acc, F, AccSeq, TrUserData) when N < 57 -> d_packed_field_Package_retired(Rest, N + 7, X bsl N + Acc, F, AccSeq, TrUserData); +d_packed_field_Package_retired(<<0:1, X:7, Rest/binary>>, N, Acc, F, AccSeq, TrUserData) -> + {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, + d_packed_field_Package_retired(RestF, 0, 0, F, [NewFValue | AccSeq], TrUserData); +d_packed_field_Package_retired(<<>>, 0, 0, _, AccSeq, _) -> AccSeq. + +skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); +skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). + +skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_Package(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); +skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, - dfp_read_field_def_Package(Rest2, 0, 0, F@_1, F@_2, - F@_3, TrUserData). + dfp_read_field_def_Package(Rest2, 0, 0, F, F@_1, F@_2, F@_3, TrUserData). -skip_group_Package(Bin, FNum, Z2, F@_1, F@_2, F@_3, - TrUserData) -> +skip_group_Package(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), - dfp_read_field_def_Package(Rest, 0, Z2, F@_1, F@_2, - F@_3, TrUserData). + dfp_read_field_def_Package(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, TrUserData). -skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). +skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). -skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F@_1, - F@_2, F@_3, TrUserData) -> - dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2, - F@_3, TrUserData). +skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_Package(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), @@ -672,188 +458,135 @@ read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). -merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> - merge_msgs(Prev, New, MsgName, []). +merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Versions' -> merge_msg_Versions(Prev, New, TrUserData); - 'Package' -> merge_msg_Package(Prev, New, TrUserData) + 'Versions' -> merge_msg_Versions(Prev, New, TrUserData); + 'Package' -> merge_msg_Package(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_Versions/3}). -merge_msg_Versions(#{} = PMsg, - #{repository := NFrepository} = NMsg, TrUserData) -> +merge_msg_Versions(#{} = PMsg, #{repository := NFrepository} = NMsg, TrUserData) -> S1 = #{repository => NFrepository}, case {PMsg, NMsg} of - {#{packages := PFpackages}, - #{packages := NFpackages}} -> - S1#{packages => - 'erlang_++'(PFpackages, NFpackages, TrUserData)}; - {_, #{packages := NFpackages}} -> - S1#{packages => NFpackages}; - {#{packages := PFpackages}, _} -> - S1#{packages => PFpackages}; - {_, _} -> S1 + {#{packages := PFpackages}, #{packages := NFpackages}} -> S1#{packages => 'erlang_++'(PFpackages, NFpackages, TrUserData)}; + {_, #{packages := NFpackages}} -> S1#{packages => NFpackages}; + {#{packages := PFpackages}, _} -> S1#{packages => PFpackages}; + {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_Package/3}). -merge_msg_Package(#{} = PMsg, #{name := NFname} = NMsg, - TrUserData) -> +merge_msg_Package(#{} = PMsg, #{name := NFname} = NMsg, TrUserData) -> S1 = #{name => NFname}, S2 = case {PMsg, NMsg} of - {#{versions := PFversions}, - #{versions := NFversions}} -> - S1#{versions => - 'erlang_++'(PFversions, NFversions, TrUserData)}; - {_, #{versions := NFversions}} -> - S1#{versions => NFversions}; - {#{versions := PFversions}, _} -> - S1#{versions => PFversions}; - {_, _} -> S1 - end, + {#{versions := PFversions}, #{versions := NFversions}} -> S1#{versions => 'erlang_++'(PFversions, NFversions, TrUserData)}; + {_, #{versions := NFversions}} -> S1#{versions => NFversions}; + {#{versions := PFversions}, _} -> S1#{versions => PFversions}; + {_, _} -> S1 + end, case {PMsg, NMsg} of - {#{retired := PFretired}, #{retired := NFretired}} -> - S2#{retired => - 'erlang_++'(PFretired, NFretired, TrUserData)}; - {_, #{retired := NFretired}} -> - S2#{retired => NFretired}; - {#{retired := PFretired}, _} -> - S2#{retired => PFretired}; - {_, _} -> S2 + {#{retired := PFretired}, #{retired := NFretired}} -> S2#{retired => 'erlang_++'(PFretired, NFretired, TrUserData)}; + {_, #{retired := NFretired}} -> S2#{retired => NFretired}; + {#{retired := PFretired}, _} -> S2#{retired => PFretired}; + {_, _} -> S2 end. -verify_msg(Msg, MsgName) when is_atom(MsgName) -> - verify_msg(Msg, MsgName, []). +verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of - 'Versions' -> - v_msg_Versions(Msg, [MsgName], TrUserData); - 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); - _ -> mk_type_error(not_a_known_message, Msg, []) + 'Versions' -> v_msg_Versions(Msg, [MsgName], TrUserData); + 'Package' -> v_msg_Package(Msg, [MsgName], TrUserData); + _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_Versions/3}). -dialyzer({nowarn_function,v_msg_Versions/3}). -v_msg_Versions(#{repository := F2} = M, Path, - TrUserData) -> +v_msg_Versions(#{repository := F2} = M, Path, TrUserData) -> case M of - #{packages := F1} -> - if is_list(F1) -> - _ = [v_msg_Package(Elem, [packages | Path], TrUserData) - || Elem <- F1], - ok; - true -> - mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, - [packages | Path]) - end; - _ -> ok + #{packages := F1} -> + if is_list(F1) -> + _ = [v_msg_Package(Elem, [packages | Path], TrUserData) || Elem <- F1], + ok; + true -> mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, [packages | Path]) + end; + _ -> ok end, v_type_string(F2, [repository | Path], TrUserData), lists:foreach(fun (packages) -> ok; - (repository) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (repository) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Versions(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, - [repository] -- maps:keys(M), 'Versions'}, - M, Path); -v_msg_Versions(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Versions'}, X, Path). +v_msg_Versions(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [repository] -- maps:keys(M), 'Versions'}, M, Path); +v_msg_Versions(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Versions'}, X, Path). -compile({nowarn_unused_function,v_msg_Package/3}). -dialyzer({nowarn_function,v_msg_Package/3}). v_msg_Package(#{name := F1} = M, Path, TrUserData) -> v_type_string(F1, [name | Path], TrUserData), case M of - #{versions := F2} -> - if is_list(F2) -> - _ = [v_type_string(Elem, [versions | Path], TrUserData) - || Elem <- F2], - ok; - true -> - mk_type_error({invalid_list_of, string}, F2, - [versions | Path]) - end; - _ -> ok + #{versions := F2} -> + if is_list(F2) -> + _ = [v_type_string(Elem, [versions | Path], TrUserData) || Elem <- F2], + ok; + true -> mk_type_error({invalid_list_of, string}, F2, [versions | Path]) + end; + _ -> ok end, case M of - #{retired := F3} -> - if is_list(F3) -> - _ = [v_type_int32(Elem, [retired | Path], TrUserData) - || Elem <- F3], - ok; - true -> - mk_type_error({invalid_list_of, int32}, F3, - [retired | Path]) - end; - _ -> ok + #{retired := F3} -> + if is_list(F3) -> + _ = [v_type_int32(Elem, [retired | Path], TrUserData) || Elem <- F3], + ok; + true -> mk_type_error({invalid_list_of, int32}, F3, [retired | Path]) + end; + _ -> ok end, lists:foreach(fun (name) -> ok; - (versions) -> ok; - (retired) -> ok; - (OtherKey) -> - mk_type_error({extraneous_key, OtherKey}, M, Path) - end, - maps:keys(M)), + (versions) -> ok; + (retired) -> ok; + (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) + end, + maps:keys(M)), ok; -v_msg_Package(M, Path, _TrUserData) when is_map(M) -> - mk_type_error({missing_fields, [name] -- maps:keys(M), - 'Package'}, - M, Path); -v_msg_Package(X, Path, _TrUserData) -> - mk_type_error({expected_msg, 'Package'}, X, Path). +v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [name] -- maps:keys(M), 'Package'}, M, Path); +v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) - when -2147483648 =< N, N =< 2147483647 -> - ok; -v_type_int32(N, Path, _TrUserData) when is_integer(N) -> - mk_type_error({value_out_of_range, int32, signed, 32}, - N, Path); -v_type_int32(X, Path, _TrUserData) -> - mk_type_error({bad_integer, int32, signed, 32}, X, - Path). +v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); +v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). -v_type_string(S, Path, _TrUserData) - when is_list(S); is_binary(S) -> +v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of - B when is_binary(B) -> ok; - {error, _, _} -> - mk_type_error(bad_unicode_string, S, Path) + B when is_binary(B) -> ok; + {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch - error:badarg -> - mk_type_error(bad_unicode_string, S, Path) + error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; -v_type_string(X, Path, _TrUserData) -> - mk_type_error(bad_unicode_string, X, Path). +v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), - erlang:error({gpb_type_error, - {Error, [{value, ValueSeen}, {path, Path2}]}}). + erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> - list_to_atom(lists:append(lists:join(".", - lists:map(fun atom_to_list/1, - lists:reverse(PathR))))). +prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))). -compile({nowarn_unused_function,id/2}). @@ -881,19 +614,11 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. get_msg_defs() -> - [{{msg, 'Versions'}, - [#{name => packages, fnum => 1, rnum => 2, - type => {msg, 'Package'}, occurrence => repeated, - opts => []}, - #{name => repository, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}]}, + [{{msg, 'Versions'}, [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}]}, {{msg, 'Package'}, - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => required, opts => []}, - #{name => versions, fnum => 2, rnum => 3, - type => string, occurrence => repeated, opts => []}, - #{name => retired, fnum => 3, rnum => 4, type => int32, - occurrence => repeated, opts => [packed]}]}]. + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => versions, fnum => 2, rnum => 3, type => string, occurrence => repeated, opts => []}, + #{name => retired, fnum => 3, rnum => 4, type => int32, occurrence => repeated, opts => [packed]}]}]. get_msg_names() -> ['Versions', 'Package']. @@ -910,29 +635,20 @@ get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of - Fs when is_list(Fs) -> Fs; - error -> erlang:error({no_such_msg, MsgName}) + Fs when is_list(Fs) -> Fs; + error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). -fetch_enum_def(EnumName) -> - erlang:error({no_such_enum, EnumName}). +fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). -find_msg_def('Versions') -> - [#{name => packages, fnum => 1, rnum => 2, - type => {msg, 'Package'}, occurrence => repeated, - opts => []}, - #{name => repository, fnum => 2, rnum => 3, - type => string, occurrence => required, opts => []}]; +find_msg_def('Versions') -> [#{name => packages, fnum => 1, rnum => 2, type => {msg, 'Package'}, occurrence => repeated, opts => []}, #{name => repository, fnum => 2, rnum => 3, type => string, occurrence => required, opts => []}]; find_msg_def('Package') -> - [#{name => name, fnum => 1, rnum => 2, type => string, - occurrence => required, opts => []}, - #{name => versions, fnum => 2, rnum => 3, - type => string, occurrence => repeated, opts => []}, - #{name => retired, fnum => 3, rnum => 4, type => int32, - occurrence => repeated, opts => [packed]}]; + [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => required, opts => []}, + #{name => versions, fnum => 2, rnum => 3, type => string, occurrence => repeated, opts => []}, + #{name => retired, fnum => 3, rnum => 4, type => int32, occurrence => repeated, opts => [packed]}]; find_msg_def(_) -> error. @@ -940,13 +656,11 @@ find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). -enum_symbol_by_value(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). -enum_value_by_symbol(E, V) -> - erlang:error({no_enum_defs, E, V}). +enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). @@ -964,38 +678,33 @@ find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). -fetch_rpc_def(ServiceName, RpcName) -> - erlang:error({no_such_rpc, ServiceName, RpcName}). +fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). -fqbin_to_service_name(X) -> - error({gpb_error, {badservice, X}}). +fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). -service_name_to_fqbin(X) -> - error({gpb_error, {badservice, X}}). +service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). -fqbins_to_service_and_rpc_name(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). -service_and_rpc_name_to_fqbins(S, R) -> - error({gpb_error, {badservice_or_rpc, {S, R}}}). +service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"Versions">>) -> 'Versions'; @@ -1009,13 +718,11 @@ msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec fqbin_to_enum_name(_) -> no_return(). -fqbin_to_enum_name(E) -> - error({gpb_error, {badenum, E}}). +fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec enum_name_to_fqbin(_) -> no_return(). -enum_name_to_fqbin(E) -> - error({gpb_error, {badenum, E}}). +enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> undefined. @@ -1045,58 +752,49 @@ get_all_source_basenames() -> ["r3_hex_pb_versions.proto"]. get_all_proto_names() -> ["r3_hex_pb_versions"]. -get_msg_containment("r3_hex_pb_versions") -> - ['Package', 'Versions']; -get_msg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_msg_containment("r3_hex_pb_versions") -> ['Package', 'Versions']; +get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("r3_hex_pb_versions") -> undefined; -get_pkg_containment(P) -> - error({gpb_error, {badproto, P}}). +get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("r3_hex_pb_versions") -> []; -get_service_containment(P) -> - error({gpb_error, {badproto, P}}). +get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("r3_hex_pb_versions") -> []; -get_rpc_containment(P) -> - error({gpb_error, {badproto, P}}). +get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("r3_hex_pb_versions") -> []; -get_enum_containment(P) -> - error({gpb_error, {badproto, P}}). +get_enum_containment(P) -> error({gpb_error, {badproto, P}}). -get_proto_by_msg_name_as_fqbin(<<"Versions">>) -> - "r3_hex_pb_versions"; -get_proto_by_msg_name_as_fqbin(<<"Package">>) -> - "r3_hex_pb_versions"; -get_proto_by_msg_name_as_fqbin(E) -> - error({gpb_error, {badmsg, E}}). +get_proto_by_msg_name_as_fqbin(<<"Versions">>) -> "r3_hex_pb_versions"; +get_proto_by_msg_name_as_fqbin(<<"Package">>) -> "r3_hex_pb_versions"; +get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). -get_proto_by_service_name_as_fqbin(E) -> - error({gpb_error, {badservice, E}}). +get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). -get_proto_by_enum_name_as_fqbin(E) -> - error({gpb_error, {badenum, E}}). +get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). -spec get_protos_by_pkg_name_as_fqbin(_) -> no_return(). -get_protos_by_pkg_name_as_fqbin(E) -> - error({gpb_error, {badpkg, E}}). +get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.10.0". + "4.17.6". gpb_version_as_list() -> - [4,10,0]. + [4,17,6]. + +gpb_version_source() -> + "file". diff --git a/apps/rebar/src/vendored/r3_hex_registry.erl b/apps/rebar/src/vendored/r3_hex_registry.erl index 6c5ae3c99..8ab40b6ad 100644 --- a/apps/rebar/src/vendored/r3_hex_registry.erl +++ b/apps/rebar/src/vendored/r3_hex_registry.erl @@ -1,13 +1,21 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Functions for encoding and decoding Hex registries. -module(r3_hex_registry). -export([ encode_names/1, decode_names/2, + build_names/2, + unpack_names/3, encode_versions/1, decode_versions/2, + build_versions/2, + unpack_versions/3, encode_package/1, decode_package/3, + build_package/2, + unpack_package/4, sign_protobuf/2, decode_signed/1, decode_and_verify_signed/2, @@ -24,75 +32,102 @@ %%==================================================================== %% @doc -%% Encode Names message. +%% Builds names resource. +build_names(Names, PrivateKey) -> + Payload = encode_names(Names), + zlib:gzip(sign_protobuf(Payload, PrivateKey)). + +%% @doc +%% Unpacks names resource. +unpack_names(Payload, Repository, PublicKey) -> + case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of + {ok, Names} -> decode_names(Names, Repository); + Other -> Other + end. + +%% @private encode_names(Names) -> r3_hex_pb_names:encode_msg(Names, 'Names'). -%% @doc -%% Decode message created with encode_names/1. +%% @private decode_names(Payload, no_verify) -> - #{packages := Packages} = r3_hex_pb_names:decode_msg(Payload, 'Names'), - {ok, Packages}; - + {ok, r3_hex_pb_names:decode_msg(Payload, 'Names')}; decode_names(Payload, Repository) -> case r3_hex_pb_names:decode_msg(Payload, 'Names') of - #{repository := Repository, packages := Packages} -> - {ok, Packages}; + #{repository := Repository, packages := _Packages} = Result -> + {ok, Result}; _ -> {error, unverified} end. %% @doc -%% Encode Versions message. +%% Builds versions resource. +build_versions(Versions, PrivateKey) -> + Payload = encode_versions(Versions), + zlib:gzip(sign_protobuf(Payload, PrivateKey)). + +%% @doc +%% Unpacks versions resource. +unpack_versions(Payload, Repository, PublicKey) -> + case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of + {ok, Versions} -> decode_versions(Versions, Repository); + Other -> Other + end. + +%% @private encode_versions(Versions) -> r3_hex_pb_versions:encode_msg(Versions, 'Versions'). -%% @doc -%% Decode message created with encode_versions/1. +%% @private decode_versions(Payload, no_verify) -> - #{packages := Packages} = r3_hex_pb_versions:decode_msg(Payload, 'Versions'), - {ok, Packages}; - + {ok, r3_hex_pb_versions:decode_msg(Payload, 'Versions')}; decode_versions(Payload, Repository) -> case r3_hex_pb_versions:decode_msg(Payload, 'Versions') of - #{repository := Repository, packages := Packages} -> - {ok, Packages}; + #{repository := Repository, packages := _Packages} = Result -> + {ok, Result}; _ -> {error, unverified} end. %% @doc -%% Encode Package message. +%% Builds package resource. +build_package(Package, PrivateKey) -> + Payload = encode_package(Package), + zlib:gzip(sign_protobuf(Payload, PrivateKey)). + +%% @doc +%% Unpacks package resource. +unpack_package(Payload, Repository, Name, PublicKey) -> + case decode_and_verify_signed(zlib:gunzip(Payload), PublicKey) of + {ok, Package} -> decode_package(Package, Repository, Name); + Other -> Other + end. + +%% @private encode_package(Package) -> r3_hex_pb_package:encode_msg(Package, 'Package'). -%% @doc -%% Decode message created with encode_package/1. +%% @private decode_package(Payload, no_verify, no_verify) -> - #{releases := Releases} = r3_hex_pb_package:decode_msg(Payload, 'Package'), - {ok, Releases}; - + {ok, r3_hex_pb_package:decode_msg(Payload, 'Package')}; decode_package(Payload, Repository, Package) -> case r3_hex_pb_package:decode_msg(Payload, 'Package') of - #{repository := Repository, name := Package, releases := Releases} -> - {ok, Releases}; + #{repository := Repository, name := Package, releases := _Releases} = Result -> + {ok, Result}; _ -> {error, unverified} end. -%% @doc -%% Encode Signed message. +%% @private sign_protobuf(Payload, PrivateKey) -> Signature = sign(Payload, PrivateKey), r3_hex_pb_signed:encode_msg(#{payload => Payload, signature => Signature}, 'Signed'). -%% @doc -%% Decode message created with sign_protobuf/2 without verification. +%% @private decode_signed(Signed) -> r3_hex_pb_signed:decode_msg(Signed, 'Signed'). -%% @doc -%% Decode message created with sign_protobuf/2 and verify it against public key. +%% @private -spec decode_and_verify_signed(binary(), public_key()) -> {ok, binary()} | {error, term()}. decode_and_verify_signed(Signed, PublicKey) -> #{payload := Payload, signature := Signature} = decode_signed(Signed), @@ -102,15 +137,13 @@ decode_and_verify_signed(Signed, PublicKey) -> {error, Reason} -> {error, Reason} end. -%% @doc -%% Signs binary with given private key. +%% @private -spec sign(binary(), private_key()) -> binary(). sign(Binary, PrivateKey) -> {ok, RSAPrivateKey} = key(PrivateKey), public_key:sign(Binary, sha512, RSAPrivateKey). -%% @doc -%% Verifies binary against signature and a public key. +%% @private -spec verify(binary(), binary(), public_key()) -> boolean() | {error, term()}. verify(Binary, Signature, PublicKey) -> case key(PublicKey) of @@ -122,6 +155,7 @@ verify(Binary, Signature, PublicKey) -> %% Internal functions %%==================================================================== +%% @private key(#'RSAPublicKey'{} = Key) -> {ok, Key}; key(#'RSAPrivateKey'{} = Key) -> diff --git a/apps/rebar/src/vendored/r3_hex_repo.erl b/apps/rebar/src/vendored/r3_hex_repo.erl index 50c7b11fc..c6b8add26 100644 --- a/apps/rebar/src/vendored/r3_hex_repo.erl +++ b/apps/rebar/src/vendored/r3_hex_repo.erl @@ -1,11 +1,15 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Repo API. -module(r3_hex_repo). -export([ get_names/1, get_versions/1, get_package/2, - get_tarball/3 + get_tarball/3, + get_docs/3, + get_public_key/1 ]). %%==================================================================== @@ -27,12 +31,8 @@ %% ''' %% @end get_names(Config) when is_map(Config) -> - Verify = maps:get(repo_verify_origin, Config, true), Decoder = fun(Data) -> - case Verify of - true -> r3_hex_registry:decode_names(Data, repo_name(Config)); - false -> r3_hex_registry:decode_names(Data, no_verify) - end + r3_hex_registry:decode_names(Data, verify_repo(Config)) end, get_protobuf(Config, <<"names">>, Decoder). @@ -53,12 +53,8 @@ get_names(Config) when is_map(Config) -> %% ''' %% @end get_versions(Config) when is_map(Config) -> - Verify = maps:get(repo_verify_origin, Config, true), Decoder = fun(Data) -> - case Verify of - true -> r3_hex_registry:decode_versions(Data, repo_name(Config)); - false -> r3_hex_registry:decode_versions(Data, no_verify) - end + r3_hex_registry:decode_versions(Data, verify_repo(Config)) end, get_protobuf(Config, <<"versions">>, Decoder). @@ -104,7 +100,46 @@ get_tarball(Config, Name, Version) -> case get(Config, tarball_url(Config, Name, Version), ReqHeaders) of {ok, {200, RespHeaders, Tarball}} -> {ok, {200, RespHeaders, Tarball}}; + Other -> + Other + end. + +%% @doc +%% Gets docs tarball from the repository. +%% +%% Examples: +%% +%% ``` +%% > {ok, {200, _, Docs}} = r3_hex_repo:get_docs(r3_hex_core:default_config(), <<"package1">>, <<"1.0.0">>), +%% > r3_hex_tarball:unpack_docs(Docs, memory) +%% {ok, [{"index.html", <<"">>}, ...]} +%% ''' +get_docs(Config, Name, Version) -> + ReqHeaders = make_headers(Config), + case get(Config, docs_url(Config, Name, Version), ReqHeaders) of + {ok, {200, RespHeaders, Docs}} -> + {ok, {200, RespHeaders, Docs}}; + Other -> + Other + end. + +%% @doc +%% Gets the public key from the repository. +%% +%% Examples: +%% +%% ``` +%% > r3_hex_repo:get_public_key(r3_hex_core:default_config()) +%% {ok, {200, _, PublicKey}} +%% ''' +get_public_key(Config) -> + ReqHeaders = make_headers(Config), + URI = build_url(Config, <<"public_key">>), + + case get(Config, URI, ReqHeaders) of + {ok, {200, RespHeaders, PublicKey}} -> + {ok, {200, RespHeaders, PublicKey}}; Other -> Other end. @@ -113,9 +148,11 @@ get_tarball(Config, Name, Version) -> %% Internal functions %%==================================================================== +%% @private get(Config, URI, Headers) -> r3_hex_http:request(Config, get, URI, Headers, undefined). +%% @private get_protobuf(Config, Path, Decoder) -> PublicKey = maps:get(repo_public_key, Config), ReqHeaders = make_headers(Config), @@ -126,15 +163,14 @@ get_protobuf(Config, Path, Decoder) -> case decode(Signed, PublicKey, Decoder, Config) of {ok, Decoded} -> {ok, {200, RespHeaders, Decoded}}; - {error, _} = Error -> Error end; - Other -> Other end. +%% @private decode(Signed, PublicKey, Decoder, Config) -> Verify = maps:get(repo_verify, Config, true), @@ -151,13 +187,28 @@ decode(Signed, PublicKey, Decoder, Config) -> Decoder(Payload) end. +%% @private +verify_repo(Config) -> + case maps:get(repo_verify_origin, Config, true) of + true -> repo_name(Config); + false -> no_verify + end. + +%% @private repo_name(#{repo_organization := Name}) when is_binary(Name) -> Name; repo_name(#{repo_name := Name}) when is_binary(Name) -> Name. +%% @private tarball_url(Config, Name, Version) -> Filename = tarball_filename(Name, Version), build_url(Config, <<"tarballs/", Filename/binary>>). +%% @private +docs_url(Config, Name, Version) -> + Filename = docs_filename(Name, Version), + build_url(Config, <<"docs/", Filename/binary>>). + +%% @private build_url(#{repo_url := URI, repo_organization := Org}, Path) when is_binary(Org) -> <>; build_url(#{repo_url := URI, repo_organization := undefined}, Path) -> @@ -165,12 +216,22 @@ build_url(#{repo_url := URI, repo_organization := undefined}, Path) -> build_url(Config, Path) -> build_url(Config#{repo_organization => undefined}, Path). +%% @private tarball_filename(Name, Version) -> <>. +%% @private +docs_filename(Name, Version) -> + <>. + +%% @private make_headers(Config) -> maps:fold(fun set_header/3, #{}, Config). -set_header(http_etag, ETag, Headers) when is_binary(ETag) -> maps:put(<<"if-none-match">>, ETag, Headers); -set_header(repo_key, Token, Headers) when is_binary(Token) -> maps:put(<<"authorization">>, Token, Headers); -set_header(_, _, Headers) -> Headers. +%% @private +set_header(http_etag, ETag, Headers) when is_binary(ETag) -> + maps:put(<<"if-none-match">>, ETag, Headers); +set_header(repo_key, Token, Headers) when is_binary(Token) -> + maps:put(<<"authorization">>, Token, Headers); +set_header(_, _, Headers) -> + Headers. diff --git a/apps/rebar/src/vendored/r3_hex_tarball.erl b/apps/rebar/src/vendored/r3_hex_tarball.erl index 7663f6a52..baf01fb41 100644 --- a/apps/rebar/src/vendored/r3_hex_tarball.erl +++ b/apps/rebar/src/vendored/r3_hex_tarball.erl @@ -1,8 +1,16 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually +%% @doc +%% Functions for creating and unpacking Hex tarballs. -module(r3_hex_tarball). --export([create/2, create/3, create_docs/1, create_docs/2, unpack/2, unpack/3, - unpack_docs/2, unpack_docs/3, format_checksum/1, format_error/1]). +-export([ + create/2, create/3, + create_docs/1, create_docs/2, + unpack/2, unpack/3, + unpack_docs/2, unpack_docs/3, + format_checksum/1, + format_error/1 +]). -ifdef(TEST). -export([do_decode_metadata/1, gzip/1, normalize_requirements/1]). -endif. @@ -44,8 +52,13 @@ %% inner_checksum => <<178,12,...>>}} %% ''' %% @end --spec create(metadata(), files(), r3_hex_core:config()) -> {ok, #{tarball => tarball(), outer_checksum => checksum(), - inner_checksum => tarball()}} | {error, term()}. +-spec create(metadata(), files(), r3_hex_core:config()) -> + {ok, #{ + tarball => tarball(), + outer_checksum => checksum(), + inner_checksum => tarball() + }} + | {error, term()}. create(Metadata, Files, Config) -> MetadataBinary = encode_metadata(Metadata), ContentsTarball = create_memory_tarball(Files), @@ -56,10 +69,10 @@ create(Metadata, Files, Config) -> TarballMaxUncompressedSize = maps:get(tarball_max_uncompressed_size, Config), OuterFiles = [ - {"VERSION", ?VERSION}, - {"CHECKSUM", InnerChecksumBase16}, - {"metadata.config", MetadataBinary}, - {"contents.tar.gz", ContentsTarballCompressed} + {"VERSION", ?VERSION}, + {"CHECKSUM", InnerChecksumBase16}, + {"metadata.config", MetadataBinary}, + {"contents.tar.gz", ContentsTarballCompressed} ], Tarball = create_memory_tarball(OuterFiles), @@ -68,18 +81,23 @@ create(Metadata, Files, Config) -> UncompressedSize = byte_size(ContentsTarball), case {(byte_size(Tarball) > TarballMaxSize), (UncompressedSize > TarballMaxUncompressedSize)} of - {_, true} -> + {_, true} -> {error, {tarball, {too_big_uncompressed, TarballMaxUncompressedSize}}}; - {true, _} -> {error, {tarball, {too_big_compressed, TarballMaxSize}}}; - {false, false} -> - {ok, #{tarball => Tarball, outer_checksum => OuterChecksum, inner_checksum => InnerChecksum}} + {ok, #{ + tarball => Tarball, outer_checksum => OuterChecksum, inner_checksum => InnerChecksum + }} end. --spec create(metadata(), files()) -> {ok, #{tarball => tarball(), outer_checksum => checksum(), - inner_checksum => tarball()}} | {error, term()}. +-spec create(metadata(), files()) -> + {ok, #{ + tarball => tarball(), + outer_checksum => checksum(), + inner_checksum => tarball() + }} + | {error, term()}. create(Metadata, Files) -> create(Metadata, Files, r3_hex_core:default_config()). @@ -95,17 +113,20 @@ create(Metadata, Files) -> %% ''' %% @end -spec create_docs(files(), r3_hex_core:config()) -> {ok, tarball()} | {error, term()}. -create_docs(Files, #{tarball_max_size := TarballMaxSize, tarball_max_uncompressed_size := TarballMaxUncompressedSize}) -> +create_docs(Files, #{ + tarball_max_size := TarballMaxSize, tarball_max_uncompressed_size := TarballMaxUncompressedSize +}) -> UncompressedTarball = create_memory_tarball(Files), UncompressedSize = byte_size(UncompressedTarball), Tarball = gzip(UncompressedTarball), Size = byte_size(Tarball), - case(Size > TarballMaxSize) or (UncompressedSize > TarballMaxUncompressedSize) of - true -> - {error, {tarball, too_big}}; - - false -> + case {(Size > TarballMaxSize), (UncompressedSize > TarballMaxUncompressedSize)} of + {_, true} -> + {error, {tarball, {too_big_uncompressed, TarballMaxUncompressedSize}}}; + {true, _} -> + {error, {tarball, {too_big_compressed, TarballMaxSize}}}; + {false, false} -> {ok, Tarball} end. @@ -117,7 +138,7 @@ create_docs(Files) -> %% Unpacks a package tarball. %% %% Remember to verify the outer tarball checksum against the registry checksum -%% returned from `r3_hex_repo:get_package(Config, Package)`. +%% returned from `r3_hex_repo:get_package(Config, Package)'. %% %% Examples: %% @@ -131,39 +152,57 @@ create_docs(Files) -> %% {ok,#{outer_checksum => <<...>>, %% metadata => #{<<"name">> => <<"foo">>, ...}}} %% ''' --spec unpack(tarball(), memory, r3_hex_core:config()) -> - {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), - metadata => metadata(), contents => contents()}} | - {error, term()}; - (tarball(), filename(), r3_hex_core:config()) -> - {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), - metadata => metadata()}} | - {error, term()}. -unpack(Tarball, _, #{tarball_max_size := TarballMaxSize}) when byte_size(Tarball) > TarballMaxSize -> +-spec unpack + (tarball(), memory, r3_hex_core:config()) -> + {ok, #{ + outer_checksum => checksum(), + inner_checksum => checksum(), + metadata => metadata(), + contents => contents() + }} + | {error, term()}; + (tarball(), filename(), r3_hex_core:config()) -> + {ok, #{ + outer_checksum => checksum(), + inner_checksum => checksum(), + metadata => metadata() + }} + | {error, term()}. +unpack(Tarball, _, #{tarball_max_size := TarballMaxSize}) when + byte_size(Tarball) > TarballMaxSize +-> {error, {tarball, too_big}}; - unpack(Tarball, Output, _Config) -> case r3_hex_erl_tar:extract({binary, Tarball}, [memory]) of {ok, []} -> {error, {tarball, empty}}; - {ok, FileList} -> OuterChecksum = crypto:hash(sha256, Tarball), do_unpack(maps:from_list(FileList), OuterChecksum, Output); - {error, Reason} -> {error, {tarball, Reason}} end. - --spec unpack(tarball(), memory) -> - {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), - metadata => metadata(), contents => contents()}} | - {error, term()}; - (tarball(), filename()) -> - {ok, #{outer_checksum => checksum(), inner_checksum => checksum(), - metadata => metadata()}} | - {error, term()}. +%% @doc +%% Unpacks a package tarball. +%% +%% @see unpack/3 +-spec unpack + (tarball(), memory) -> + {ok, #{ + outer_checksum => checksum(), + inner_checksum => checksum(), + metadata => metadata(), + contents => contents() + }} + | {error, term()}; + (tarball(), filename()) -> + {ok, #{ + outer_checksum => checksum(), + inner_checksum => checksum(), + metadata => metadata() + }} + | {error, term()}. unpack(Tarball, Output) -> unpack(Tarball, Output, r3_hex_core:default_config()). @@ -179,16 +218,19 @@ unpack(Tarball, Output) -> %% > r3_hex_tarball:unpack_docs(Tarball, "path/to/unpack"). %% ok %% ''' --spec unpack_docs(tarball(), memory, r3_hex_core:config()) -> {ok, contents()} | {error, term()}; - (tarball(), filename(), r3_hex_core:config()) -> ok | {error, term()}. -unpack_docs(Tarball, _, #{tarball_max_size := TarballMaxSize}) when byte_size(Tarball) > TarballMaxSize -> +-spec unpack_docs + (tarball(), memory, r3_hex_core:config()) -> {ok, contents()} | {error, term()}; + (tarball(), filename(), r3_hex_core:config()) -> ok | {error, term()}. +unpack_docs(Tarball, _, #{tarball_max_size := TarballMaxSize}) when + byte_size(Tarball) > TarballMaxSize +-> {error, {tarball, too_big}}; - unpack_docs(Tarball, Output, _Config) -> unpack_tarball(Tarball, Output). --spec unpack_docs(tarball(), memory) -> {ok, contents()} | {error, term()}; - (tarball(), filename()) -> ok | {error, term()}. +-spec unpack_docs + (tarball(), memory) -> {ok, contents()} | {error, term()}; + (tarball(), filename()) -> ok | {error, term()}. unpack_docs(Tarball, Output) -> unpack_docs(Tarball, Output, r3_hex_core:default_config()). @@ -201,50 +243,64 @@ format_checksum(Checksum) -> %% @doc %% Converts an error reason term to a human-readable error message string. -spec format_error(term()) -> string(). -format_error({tarball, empty}) -> "empty tarball"; -format_error({tarball, {too_big_uncompressed, Size}}) -> +format_error({tarball, empty}) -> + "empty tarball"; +format_error({tarball, {too_big_uncompressed, Size}}) -> io_lib:format("package exceeds max uncompressed size ~w ~s", [format_byte_size(Size), "MB"]); -format_error({tarball, {too_big_compressed, Size}}) -> - io_lib:format("package exceeds max compressed size ~w ~s", [format_byte_size(Size), "MB"]); - -format_error({tarball, {missing_files, Files}}) -> io_lib:format("missing files: ~p", [Files]); -format_error({tarball, {bad_version, Vsn}}) -> io_lib:format("unsupported version: ~p", [Vsn]); -format_error({tarball, invalid_checksum}) -> "invalid tarball checksum"; -format_error({tarball, Reason}) -> "tarball error, " ++ r3_hex_erl_tar:format_error(Reason); -format_error({inner_tarball, Reason}) -> "inner tarball error, " ++ r3_hex_erl_tar:format_error(Reason); -format_error({metadata, invalid_terms}) -> "error reading package metadata: invalid terms"; -format_error({metadata, not_key_value}) -> "error reading package metadata: not in key-value format"; -format_error({metadata, Reason}) -> "error reading package metadata" ++ r3_safe_erl_term:format_error(Reason); - +format_error({tarball, {too_big_compressed, Size}}) -> + io_lib:format("package exceeds max compressed size ~w ~s", [format_byte_size(Size), "MB"]); +format_error({tarball, {missing_files, Files}}) -> + io_lib:format("missing files: ~p", [Files]); +format_error({tarball, {bad_version, Vsn}}) -> + io_lib:format("unsupported version: ~p", [Vsn]); +format_error({tarball, invalid_checksum}) -> + "invalid tarball checksum"; +format_error({tarball, Reason}) -> + "tarball error, " ++ r3_hex_erl_tar:format_error(Reason); +format_error({inner_tarball, Reason}) -> + "inner tarball error, " ++ r3_hex_erl_tar:format_error(Reason); +format_error({metadata, invalid_terms}) -> + "error reading package metadata: invalid terms"; +format_error({metadata, not_key_value}) -> + "error reading package metadata: not in key-value format"; +format_error({metadata, Reason}) -> + "error reading package metadata" ++ r3_safe_erl_term:format_error(Reason); format_error({checksum_mismatch, ExpectedChecksum, ActualChecksum}) -> io_lib:format( "tarball checksum mismatch~n~n" ++ - "Expected (base16-encoded): ~s~n" ++ - "Actual (base16-encoded): ~s", - [encode_base16(ExpectedChecksum), encode_base16(ActualChecksum)]). + "Expected (base16-encoded): ~s~n" ++ + "Actual (base16-encoded): ~s", + [encode_base16(ExpectedChecksum), encode_base16(ActualChecksum)] + ). -format_byte_size(Size) -> +format_byte_size(Size) -> Size / 1000000. %%==================================================================== %% Internal functions %%==================================================================== +%% @private inner_checksum(Version, MetadataBinary, ContentsBinary) -> Blob = <>, crypto:hash(sha256, Blob). +%% @private checksum(ContentsBinary) when is_binary(ContentsBinary) -> crypto:hash(sha256, ContentsBinary). +%% @private encode_metadata(Meta) -> Data = lists:map( fun(MetaPair) -> String = io_lib_pretty:print(binarify(MetaPair), [{encoding, utf8}]), unicode:characters_to_binary([String, ".\n"]) - end, maps:to_list(Meta)), + end, + maps:to_list(Meta) + ), iolist_to_binary(Data). +%% @private do_unpack(Files, OuterChecksum, Output) -> State = #{ inner_checksum => undefined, @@ -260,53 +316,69 @@ do_unpack(Files, OuterChecksum, Output) -> State4 = decode_metadata(State3), finish_unpack(State4). +%% @private finish_unpack({error, _} = Error) -> Error; -finish_unpack(#{metadata := Metadata, files := Files, inner_checksum := InnerChecksum, outer_checksum := OuterChecksum, output := Output}) -> +finish_unpack(#{ + metadata := Metadata, + files := Files, + inner_checksum := InnerChecksum, + outer_checksum := OuterChecksum, + output := Output +}) -> _ = maps:get("VERSION", Files), ContentsBinary = maps:get("contents.tar.gz", Files), case Output of - memory -> ok; - _ -> filelib:ensure_dir(filename:join(Output, "*")) + memory -> ok; + _ -> filelib:ensure_dir(filename:join(Output, "*")) end, case unpack_tarball(ContentsBinary, Output) of ok -> copy_metadata_config(Output, maps:get("metadata.config", Files)), - {ok, #{inner_checksum => InnerChecksum, outer_checksum => OuterChecksum, metadata => Metadata}}; - + {ok, #{ + inner_checksum => InnerChecksum, + outer_checksum => OuterChecksum, + metadata => Metadata + }}; {ok, Contents} -> - {ok, #{inner_checksum => InnerChecksum, outer_checksum => OuterChecksum, metadata => Metadata, contents => Contents}}; - + {ok, #{ + inner_checksum => InnerChecksum, + outer_checksum => OuterChecksum, + metadata => Metadata, + contents => Contents + }}; {error, Reason} -> {error, {inner_tarball, Reason}} end. +%% @private copy_metadata_config(Output, MetadataBinary) -> ok = file:write_file(filename:join(Output, "hex_metadata.config"), MetadataBinary). +%% @private check_files(#{files := Files} = State) -> RequiredFiles = ["VERSION", "CHECKSUM", "metadata.config", "contents.tar.gz"], case diff_keys(Files, RequiredFiles, []) of ok -> State; - {error, {missing_keys, Keys}} -> {error, {tarball, {missing_files, Keys}}} end. +%% @private check_version({error, _} = Error) -> Error; check_version(#{files := Files} = State) -> case maps:get("VERSION", Files) of <<"3">> -> State; - Version -> {error, {tarball, {bad_version, Version}}} end. +%% @private % Note: This checksum is deprecated check_inner_checksum({error, _} = Error) -> Error; @@ -322,14 +394,13 @@ check_inner_checksum(#{files := Files} = State) -> if byte_size(ExpectedChecksum) /= 32 -> {error, {tarball, invalid_inner_checksum}}; - ExpectedChecksum == ActualChecksum -> maps:put(inner_checksum, ExpectedChecksum, State); - true -> {error, {tarball, {inner_checksum_mismatch, ExpectedChecksum, ActualChecksum}}} end. +%% @private decode_metadata({error, _} = Error) -> Error; decode_metadata(#{files := #{"metadata.config" := Binary}} = State) when is_binary(Binary) -> @@ -338,6 +409,7 @@ decode_metadata(#{files := #{"metadata.config" := Binary}} = State) when is_bina Other -> Other end. +%% @private do_decode_metadata(Binary) when is_binary(Binary) -> {ok, String} = characters_to_list(Binary), @@ -349,15 +421,14 @@ do_decode_metadata(Binary) when is_binary(Binary) -> catch error:function_clause -> {error, {metadata, invalid_terms}}; - error:badarg -> {error, {metadata, not_key_value}} end; - {error, {_Line, r3_safe_erl_term, Reason}, _Line2} -> {error, {metadata, Reason}} end. +%% @private characters_to_list(Binary) -> case unicode:characters_to_list(Binary) of List when is_list(List) -> @@ -369,34 +440,44 @@ characters_to_list(Binary) -> end end. +%% @private normalize_metadata(Metadata1) -> Metadata2 = maybe_update_with(<<"requirements">>, fun normalize_requirements/1, Metadata1), Metadata3 = maybe_update_with(<<"links">>, fun try_into_map/1, Metadata2), Metadata4 = maybe_update_with(<<"extra">>, fun try_into_map/1, Metadata3), guess_build_tools(Metadata4). +%% @private normalize_requirements(Requirements) -> case is_list(Requirements) andalso (Requirements /= []) andalso is_list(hd(Requirements)) of true -> maps:from_list(lists:map(fun normalize_legacy_requirement/1, Requirements)); - false -> try_into_map(fun normalize_normal_requirement/1, Requirements) end. +%% @private normalize_normal_requirement({Name, Requirement}) -> {Name, try_into_map(Requirement)}. +%% @private normalize_legacy_requirement(Requirement) -> Map = maps:from_list(Requirement), Name = maps:get(<<"name">>, Map), {Name, maps:without([<<"name">>], Map)}. +%% @private guess_build_tools(#{<<"build_tools">> := BuildTools} = Metadata) when is_list(BuildTools) -> Metadata; guess_build_tools(#{<<"files">> := Filenames} = Metadata) -> - BaseFiles = [Filename || Filename <- Filenames, filename:dirname(binary_to_list(Filename)) == "."], - BuildTools = lists:usort([Tool || {Filename, Tool} <- ?BUILD_TOOL_FILES, lists:member(Filename, BaseFiles)]), + BaseFiles = [ + Filename + || Filename <- Filenames, filename:dirname(binary_to_list(Filename)) == "." + ], + BuildTools = lists:usort([ + Tool + || {Filename, Tool} <- ?BUILD_TOOL_FILES, lists:member(Filename, BaseFiles) + ]), Metadata#{<<"build_tools">> => BuildTools}; guess_build_tools(Metadata) -> Metadata. @@ -405,24 +486,30 @@ guess_build_tools(Metadata) -> %% Tar Helpers %%==================================================================== +%% @private unpack_tarball(ContentsBinary, memory) -> r3_hex_erl_tar:extract({binary, ContentsBinary}, [memory, compressed]); unpack_tarball(ContentsBinary, Output) -> filelib:ensure_dir(filename:join(Output, "*")), case r3_hex_erl_tar:extract({binary, ContentsBinary}, [{cwd, Output}, compressed]) of ok -> - [try_updating_mtime(filename:join(Output, Path)) || Path <- filelib:wildcard("**", Output)], + [ + try_updating_mtime(filename:join(Output, Path)) + || Path <- filelib:wildcard("**", Output) + ], ok; Other -> Other end. +%% @private %% let it silently fail for bad symlinks try_updating_mtime(Path) -> Time = calendar:universal_time(), - _ = file:write_file_info(Path, #file_info{mtime=Time}, [{time, universal}]), + _ = file:write_file_info(Path, #file_info{mtime = Time}, [{time, universal}]), ok. +%% @private create_memory_tarball(Files) -> Path = tmp_path(), {ok, Tar} = r3_hex_erl_tar:open(Path, [write]), @@ -436,12 +523,15 @@ create_memory_tarball(Files) -> ok = file:delete(Path), Tarball. +%% @private tmp_path() -> "tmp_" ++ binary_to_list(encode_base16(crypto:strong_rand_bytes(32))). +%% @private add_files(Tar, Files) when is_list(Files) -> lists:map(fun(File) -> add_file(Tar, File) end, Files). +%% @private add_file(Tar, {Filename, Contents}) when is_list(Filename) and is_binary(Contents) -> ok = r3_hex_erl_tar:add(Tar, Contents, Filename, tar_opts()); add_file(Tar, Filename) when is_list(Filename) -> @@ -456,7 +546,6 @@ add_file(Tar, {Filename, AbsFilename}) when is_list(Filename), is_list(AbsFilena case file:list_dir(AbsFilename) of {ok, []} -> r3_hex_erl_tar:add(Tar, {Filename, AbsFilename}, tar_opts()); - {ok, _} -> ok end; @@ -466,12 +555,14 @@ add_file(Tar, {Filename, AbsFilename}) when is_list(Filename), is_list(AbsFilena ok = r3_hex_erl_tar:add(Tar, Contents, Filename, Mode, tar_opts()) end. +%% @private tar_opts() -> NixEpoch = calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}), Y2kEpoch = calendar:datetime_to_gregorian_seconds({{2000, 1, 1}, {0, 0, 0}}), Epoch = Y2kEpoch - NixEpoch, [{atime, Epoch}, {mtime, Epoch}, {ctime, Epoch}, {uid, 0}, {gid, 0}]. +%% @private %% Reproducible gzip by not setting mtime and OS %% %% From https://tools.ietf.org/html/rfc1952 @@ -495,6 +586,7 @@ gzip(Uncompressed) -> Trailer = <>, iolist_to_binary([Header, Compressed, Trailer]). +%% @private gzip_no_header(Uncompressed) -> Zstream = zlib:open(), @@ -511,6 +603,7 @@ gzip_no_header(Uncompressed) -> %% Helpers %%==================================================================== +%% @private binarify(Binary) when is_binary(Binary) -> Binary; binarify(Number) when is_number(Number) -> Number; binarify(Atom) when Atom == undefined orelse is_boolean(Atom) -> Atom; @@ -520,9 +613,10 @@ binarify(List) when is_list(List) -> binarify({Key, Value}) -> {binarify(Key), binarify(Value)}; binarify(Map) when is_map(Map) -> - List = maps:to_list(Map), - lists:map(fun({K, V}) -> binarify({K, V}) end, List). + List = maps:to_list(Map), + lists:map(fun({K, V}) -> binarify({K, V}) end, List). +%% @private diff_keys(Map, RequiredKeys, OptionalKeys) -> Keys = maps:keys(Map), MissingKeys = RequiredKeys -- Keys, @@ -531,7 +625,6 @@ diff_keys(Map, RequiredKeys, OptionalKeys) -> case {MissingKeys, UnknownKeys} of {[], []} -> ok; - % Server should validate this but clients should not % {_, [_ | _]} -> % {error, {unknown_keys, UnknownKeys}}; @@ -540,21 +633,28 @@ diff_keys(Map, RequiredKeys, OptionalKeys) -> {error, {missing_keys, MissingKeys}} end. +%% @private maybe_update_with(Key, Fun, Map) -> case maps:find(Key, Map) of {ok, Value} -> maps:put(Key, Fun(Value), Map); error -> Map end. +%% @private try_into_map(List) -> try_into_map(fun(X) -> X end, List). +%% @private try_into_map(Fun, Input) -> - case is_list(Input) andalso lists:all(fun(E) -> is_tuple(E) andalso (tuple_size(E) == 2) end, Input) of + case + is_list(Input) andalso + lists:all(fun(E) -> is_tuple(E) andalso (tuple_size(E) == 2) end, Input) + of true -> maps:from_list(lists:map(Fun, Input)); false -> Input end. +%% @private encode_base16(Binary) -> <> = Binary, String = string:to_upper(lists:flatten(io_lib:format("~64.16.0b", [X]))), @@ -563,9 +663,11 @@ encode_base16(Binary) -> %% Based on https://github.com/goj/base16/blob/master/src/base16.erl %% (C) 2012, Erlang Solutions Ltd. +%% @private decode_base16(Base16) -> - << <<(unhex(H) bsl 4 + unhex(L))>> || <> <= Base16 >>. + <<<<(unhex(H) bsl 4 + unhex(L))>> || <> <= Base16>>. +%% @private unhex(D) when $0 =< D andalso D =< $9 -> D - $0; unhex(D) when $a =< D andalso D =< $f -> diff --git a/apps/rebar/src/vendored/r3_safe_erl_term.xrl b/apps/rebar/src/vendored/r3_safe_erl_term.xrl index 7ee78a7d0..c53877fd5 100644 --- a/apps/rebar/src/vendored/r3_safe_erl_term.xrl +++ b/apps/rebar/src/vendored/r3_safe_erl_term.xrl @@ -1,4 +1,4 @@ -%% Vendored from hex_core v0.7.1, do not edit manually +%% Vendored from hex_core v0.10.0, do not edit manually %%% Author : Robert Virding %%% Purpose : Token definitions for Erlang.