Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorng committed Oct 18, 2023
1 parent 50f0233 commit 3aad219
Showing 1 changed file with 24 additions and 49 deletions.
73 changes: 24 additions & 49 deletions lib/asn1/src/asn1ct.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1593,14 +1593,24 @@ exclusive_dec_command([#'ComponentType'{name=Name,typespec=TS,
TagCommand = get_tag_command(TS, ?MANDATORY, Prop),
exclusive_dec_command(Comps,TNL,[TagCommand|Acc])
end;
exclusive_dec_command({'CHOICE',[#'ComponentType'{name=C1,
typespec=TS,
prop=Prop}|Comps]},
[{C1,Directive}|Rest], Acc) ->
mandatory = Prop, %Assertion.
exclusive_dec_command({'CHOICE',[_|_]=Cs}, TNL, Acc) ->
exclusive_dec_choice_comps(Cs, TNL, Acc);
exclusive_dec_command({'CHOICE',{Cs1,Cs2}}, TNL, Acc)
when is_list(Cs1), is_list(Cs2) ->
exclusive_dec_choice_comps(Cs1 ++ Cs2, TNL, Acc);
exclusive_dec_command(#'Externaltypereference'{module=M,type=Name},
TNL, Acc) ->
#type{def=Def} = get_referenced_type(M,Name),
exclusive_dec_command(get_components(Def), TNL, Acc);
exclusive_dec_command(_, TNL, _) ->
throw({error,{"unexpected error when creating partial "
"decode command",TNL}}).

exclusive_dec_choice_comps([#'ComponentType'{name=C,typespec=TS}|Comps],
[{C,Directive}|Rest], Acc) ->
case Directive of
List when is_list(List) ->
TagCommand = get_tag_command(TS, ?ALTERNATIVE, Prop),
TagCommand = get_tag_command(TS, ?ALTERNATIVE, mandatory),
CompAcc =
exclusive_dec_command(get_components(TS#type.def), List, []),
NewAcc = case TagCommand of
Expand All @@ -1609,53 +1619,18 @@ exclusive_dec_command({'CHOICE',[#'ComponentType'{name=C1,
end,
exclusive_dec_command({'CHOICE',Comps}, Rest, NewAcc);
undecoded ->
TagCommand = get_tag_command(TS, ?ALTERNATIVE_UNDECODED, Prop),
TagCommand = get_tag_command(TS, ?ALTERNATIVE_UNDECODED, mandatory),
exclusive_dec_command({'CHOICE',Comps}, Rest, [TagCommand|Acc]);
parts ->
TagCommand = get_tag_command(TS, ?ALTERNATIVE_PARTS, Prop),
TagCommand = get_tag_command(TS, ?ALTERNATIVE_PARTS, mandatory),
exclusive_dec_command({'CHOICE',Comps}, Rest, [TagCommand|Acc])
end;
exclusive_dec_command({'CHOICE',[#'ComponentType'{typespec=TS,
prop=Prop}|Comps]},
TNL, Acc) ->
TagCommand = get_tag_command(TS, ?ALTERNATIVE, Prop),
exclusive_dec_command({'CHOICE',Comps}, TNL, [TagCommand|Acc]);
exclusive_dec_command({'CHOICE',{Cs1,Cs2}},TNL,Acc)
when is_list(Cs1), is_list(Cs2) ->
exclusive_dec_command({'CHOICE',Cs1 ++ Cs2}, TNL, Acc);
exclusive_dec_command(#'Externaltypereference'{module=M,type=Name},
TNL, Acc) ->
#type{def=Def} = get_referenced_type(M,Name),
exclusive_dec_command(get_components(Def), TNL, Acc);
exclusive_dec_command(_, TNL, _) ->
throw({error,{"unexpected error when creating partial "
"decode command",TNL}}).

%% exclusive_dec_choice_comps([#'ComponentType'{name=C,typespec=TS}|Comps],
%% [{C,Directive}|Rest], Acc) ->
%% case Directive of
%% List when is_list(List) ->
%% TagCommand = get_tag_command(TS, ?ALTERNATIVE, mandatory),
%% CompAcc =
%% exclusive_dec_command(get_components(TS#type.def), List, []),
%% NewAcc = case TagCommand of
%% [Command,Tag] when is_atom(Command) ->
%% [[Command,Tag,CompAcc]|Acc]
%% end,
%% exclusive_dec_command({'CHOICE',Comps}, Rest, NewAcc);
%% undecoded ->
%% TagCommand = get_tag_command(TS, ?ALTERNATIVE_UNDECODED, mandatory),
%% exclusive_dec_command({'CHOICE',Comps}, Rest, [TagCommand|Acc]);
%% parts ->
%% TagCommand = get_tag_command(TS, ?ALTERNATIVE_PARTS, mandatory),
%% exclusive_dec_command({'CHOICE',Comps}, Rest, [TagCommand|Acc])
%% end;
%% exclusive_dec_choice_comps([#'ComponentType'{typespec=TS}|Cs],
%% TNL, Acc) ->
%% TagCommand = get_tag_command(TS, ?ALTERNATIVE, mandatory),
%% exclusive_dec_choice_comps(Cs, TNL, [TagCommand|Acc]);
%% exclusive_dec_choice_comps([], _TNL, Acc) ->
%% lists:reverse(Acc).
exclusive_dec_choice_comps([#'ComponentType'{typespec=TS}|Cs],
TNL, Acc) ->
TagCommand = get_tag_command(TS, ?ALTERNATIVE, mandatory),
exclusive_dec_choice_comps(Cs, TNL, [TagCommand|Acc]);
exclusive_dec_choice_comps(_, [], Acc) ->
lists:reverse(Acc).

partial_inc_dec_toptype([T|_]) when is_atom(T) ->
T;
Expand Down

0 comments on commit 3aad219

Please sign in to comment.