From a93c925b58d627b87618f583e3f45de9c785ddb9 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Tue, 11 Jun 2024 11:27:45 -0400 Subject: [PATCH] Bump gpb deps (#146) --- .github/workflows/main.yml | 6 ++-- rebar.config | 4 +-- src/hex_pb_names.erl | 53 +++++++++++++++++++++++++++-------- src/hex_pb_package.erl | 57 ++++++++++++++++++++++++++++++-------- src/hex_pb_signed.erl | 33 ++++++++++++++++------ src/hex_pb_versions.erl | 43 +++++++++++++++++++++------- 6 files changed, 150 insertions(+), 46 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c050c3..b726b1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,9 @@ jobs: - erlang: master rebar3: 3.22.1 + - erlang: 26 + rebar3: 3.21.0 + - erlang: 25 rebar3: 3.18.0 @@ -31,9 +34,6 @@ jobs: - erlang: 21 rebar3: 3.15.1 - - - erlang: 20 - rebar3: 3.15.1 steps: - uses: actions/checkout@v3 diff --git a/rebar.config b/rebar.config index 1ee293c..ae03520 100644 --- a/rebar.config +++ b/rebar.config @@ -33,10 +33,10 @@ {profiles, [ {dev, [ {deps, [ - {gpb, "4.17.6"} + {gpb, "4.21.1"} ]}, {plugins, [ - {rebar3_gpb_plugin, "2.20.1"} + {rebar3_gpb_plugin, "2.23.1"} ]}, {overrides, [ {del, rebar3_gpb_plugin, [ diff --git a/src/hex_pb_names.erl b/src/hex_pb_names.erl index d117361..a9891e0 100644 --- a/src/hex_pb_names.erl +++ b/src/hex_pb_names.erl @@ -1,7 +1,8 @@ %% -*- coding: utf-8 -*- +%% % this file is @generated %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.17.6 +%% Generated by gpb_compile version 4.21.1 %% Version source: file -module(hex_pb_names). @@ -72,9 +73,15 @@ -type '$msg'() :: 'Names'() | 'Package'() | 'Timestamp'(). -export_type(['$msg_name'/0, '$msg'/0]). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. -spec encode_msg('$msg'(), '$msg_name'()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. -spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), @@ -237,14 +244,21 @@ decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. @@ -536,11 +550,12 @@ verify_msg(Msg, MsgName, Opts) -> -compile({nowarn_unused_function,v_msg_Names/3}). +-dialyzer({nowarn_function,v_msg_Names/3}). 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], + _ = [v_submsg_Package(Elem, [packages | Path], TrUserData) || Elem <- F1], ok; true -> mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, [packages | Path]) end; @@ -556,11 +571,16 @@ v_msg_Names(#{repository := F2} = M, Path, TrUserData) -> 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_submsg_Package/3}). +-dialyzer({nowarn_function,v_submsg_Package/3}). +v_submsg_Package(Msg, Path, TrUserData) -> v_msg_Package(Msg, Path, TrUserData). + -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); + #{updated_at := F2} -> v_submsg_Timestamp(F2, [updated_at | Path], TrUserData); _ -> ok end, lists:foreach(fun (name) -> ok; @@ -572,7 +592,12 @@ v_msg_Package(#{name := F1} = M, Path, TrUserData) -> 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_submsg_Timestamp/3}). +-dialyzer({nowarn_function,v_submsg_Timestamp/3}). +v_submsg_Timestamp(Msg, Path, TrUserData) -> v_msg_Timestamp(Msg, Path, TrUserData). + -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), @@ -586,16 +611,19 @@ v_msg_Timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_f v_msg_Timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Timestamp'}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when is_integer(N), -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}). -v_type_int64(N, _Path, _TrUserData) when -9223372036854775808 =< N, N =< 9223372036854775807 -> ok; +-dialyzer({nowarn_function,v_type_int64/3}). +v_type_int64(N, _Path, _TrUserData) when is_integer(N), -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) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; @@ -613,8 +641,9 @@ mk_type_error(Error, ValueSeen, Path) -> -compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> string: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}). @@ -818,10 +847,10 @@ get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.17.6". + "4.21.1". gpb_version_as_list() -> - [4,17,6]. + [4,21,1]. gpb_version_source() -> "file". diff --git a/src/hex_pb_package.erl b/src/hex_pb_package.erl index f6871a5..4a8516f 100644 --- a/src/hex_pb_package.erl +++ b/src/hex_pb_package.erl @@ -1,7 +1,8 @@ %% -*- coding: utf-8 -*- +%% % this file is @generated %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.17.6 +%% Generated by gpb_compile version 4.21.1 %% Version source: file -module(hex_pb_package). @@ -85,9 +86,15 @@ -type '$msg'() :: 'Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(). -export_type(['$msg_name'/0, '$msg'/0]). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. -spec encode_msg('$msg'(), '$msg_name'()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. -spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), @@ -305,14 +312,21 @@ decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. @@ -793,11 +807,12 @@ verify_msg(Msg, MsgName, Opts) -> -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) -> case M of #{releases := F1} -> if is_list(F1) -> - _ = [v_msg_Release(Elem, [releases | Path], TrUserData) || Elem <- F1], + _ = [v_submsg_Release(Elem, [releases | Path], TrUserData) || Elem <- F1], ok; true -> mk_type_error({invalid_list_of, {msg, 'Release'}}, F1, [releases | Path]) end; @@ -815,21 +830,26 @@ v_msg_Package(#{name := F2, repository := F3} = M, Path, TrUserData) -> 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_submsg_Release/3}). +-dialyzer({nowarn_function,v_submsg_Release/3}). +v_submsg_Release(Msg, Path, TrUserData) -> v_msg_Release(Msg, Path, TrUserData). + -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_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], + _ = [v_submsg_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); + #{retired := F4} -> v_submsg_RetirementStatus(F4, [retired | Path], TrUserData); _ -> ok end, case M of @@ -848,7 +868,12 @@ v_msg_Release(#{version := F1, inner_checksum := F2} = M, Path, TrUserData) -> 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_submsg_RetirementStatus/3}). +-dialyzer({nowarn_function,v_submsg_RetirementStatus/3}). +v_submsg_RetirementStatus(Msg, Path, TrUserData) -> v_msg_RetirementStatus(Msg, Path, TrUserData). + -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), case M of @@ -864,7 +889,12 @@ v_msg_RetirementStatus(#{reason := F1} = M, Path, TrUserData) -> 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_submsg_Dependency/3}). +-dialyzer({nowarn_function,v_submsg_Dependency/3}). +v_submsg_Dependency(Msg, Path, TrUserData) -> v_msg_Dependency(Msg, Path, TrUserData). + -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_type_string(F1, [package | Path], TrUserData), v_type_string(F2, [requirement | Path], TrUserData), @@ -893,6 +923,7 @@ v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_ 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; @@ -902,6 +933,7 @@ v_enum_RetirementReason(V, _Path, _TrUserData) when -2147483648 =< V, V =< 21474 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}). v_type_bool(false, _Path, _TrUserData) -> ok; v_type_bool(true, _Path, _TrUserData) -> ok; v_type_bool(0, _Path, _TrUserData) -> ok; @@ -909,6 +941,7 @@ v_type_bool(1, _Path, _TrUserData) -> ok; 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) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; @@ -919,6 +952,7 @@ v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> 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). @@ -931,8 +965,9 @@ mk_type_error(Error, ValueSeen, Path) -> -compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> string: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}). @@ -1183,10 +1218,10 @@ get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.17.6". + "4.21.1". gpb_version_as_list() -> - [4,17,6]. + [4,21,1]. gpb_version_source() -> "file". diff --git a/src/hex_pb_signed.erl b/src/hex_pb_signed.erl index 1b42d3e..8258f2a 100644 --- a/src/hex_pb_signed.erl +++ b/src/hex_pb_signed.erl @@ -1,7 +1,8 @@ %% -*- coding: utf-8 -*- +%% % this file is @generated %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.17.6 +%% Generated by gpb_compile version 4.21.1 %% Version source: file -module(hex_pb_signed). @@ -62,9 +63,15 @@ -type '$msg'() :: 'Signed'(). -export_type(['$msg_name'/0, '$msg'/0]). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. -spec encode_msg('$msg'(), '$msg_name'()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. -spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), @@ -186,14 +193,21 @@ decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. @@ -345,6 +359,7 @@ verify_msg(Msg, MsgName, Opts) -> -compile({nowarn_unused_function,v_msg_Signed/3}). +-dialyzer({nowarn_function,v_msg_Signed/3}). v_msg_Signed(#{payload := F1} = M, Path, TrUserData) -> v_type_bytes(F1, [payload | Path], TrUserData), case M of @@ -361,6 +376,7 @@ v_msg_Signed(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fiel 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). @@ -373,8 +389,9 @@ mk_type_error(Error, ValueSeen, Path) -> -compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> string: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}). @@ -567,10 +584,10 @@ get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.17.6". + "4.21.1". gpb_version_as_list() -> - [4,17,6]. + [4,21,1]. gpb_version_source() -> "file". diff --git a/src/hex_pb_versions.erl b/src/hex_pb_versions.erl index 9466a88..0bade1b 100644 --- a/src/hex_pb_versions.erl +++ b/src/hex_pb_versions.erl @@ -1,7 +1,8 @@ %% -*- coding: utf-8 -*- +%% % this file is @generated %% @private %% Automatically generated, do not edit -%% Generated by gpb_compile version 4.17.6 +%% Generated by gpb_compile version 4.21.1 %% Version source: file -module(hex_pb_versions). @@ -68,9 +69,15 @@ -type '$msg'() :: 'Versions'() | 'Package'(). -export_type(['$msg_name'/0, '$msg'/0]). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/2}). +-endif. -spec encode_msg('$msg'(), '$msg_name'()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). +-if(?OTP_RELEASE >= 24). +-dialyzer({no_underspecs, encode_msg/3}). +-endif. -spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts), @@ -250,14 +257,21 @@ decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason:StackTrace -> + erlang:raise(error, Reason, StackTrace); + Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) - catch Class:Reason -> - StackTrace = erlang:get_stacktrace(), - error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) + catch + error:{gpb_error,_}=Reason -> + erlang:raise(error, Reason, + erlang:get_stacktrace()); + Class:Reason -> + StackTrace = erlang:get_stacktrace(), + error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. @@ -504,11 +518,12 @@ verify_msg(Msg, MsgName, Opts) -> -compile({nowarn_unused_function,v_msg_Versions/3}). +-dialyzer({nowarn_function,v_msg_Versions/3}). 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], + _ = [v_submsg_Package(Elem, [packages | Path], TrUserData) || Elem <- F1], ok; true -> mk_type_error({invalid_list_of, {msg, 'Package'}}, F1, [packages | Path]) end; @@ -524,7 +539,12 @@ v_msg_Versions(#{repository := F2} = M, Path, TrUserData) -> 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_submsg_Package/3}). +-dialyzer({nowarn_function,v_submsg_Package/3}). +v_submsg_Package(Msg, Path, TrUserData) -> v_msg_Package(Msg, Path, TrUserData). + -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 @@ -556,11 +576,13 @@ v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fie v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; +-dialyzer({nowarn_function,v_type_int32/3}). +v_type_int32(N, _Path, _TrUserData) when is_integer(N), -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) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; @@ -578,8 +600,9 @@ mk_type_error(Error, ValueSeen, Path) -> -compile({nowarn_unused_function,prettify_path/1}). +-dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; -prettify_path(PathR) -> string: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}). @@ -784,10 +807,10 @@ get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). gpb_version_as_string() -> - "4.17.6". + "4.21.1". gpb_version_as_list() -> - [4,17,6]. + [4,21,1]. gpb_version_source() -> "file".