diff options
Diffstat (limited to 'lib/asn1')
-rw-r--r-- | lib/asn1/src/asn1ct_constructed_per.erl | 46 | ||||
-rw-r--r-- | lib/asn1/src/asn1ct_imm.erl | 5 |
2 files changed, 29 insertions, 22 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl index ad6a534933..b29a7b3048 100644 --- a/lib/asn1/src/asn1ct_constructed_per.erl +++ b/lib/asn1/src/asn1ct_constructed_per.erl @@ -1117,14 +1117,24 @@ gen_dec_components_call(Erule, TopType, CompList, DecInfObj, 1, []), [Init|Cs]. -gen_dec_get_extension(_Erule) -> - fun(St) -> - emit(["{Extensions,",{next,bytes},"} = "]), - emit(["?RT_PER:getextension(Ext,", - {curr,bytes},")"]), - asn1ct_name:new(bytes), - St - end. +gen_dec_get_extension(Erule) -> + Imm0 = asn1ct_imm:per_dec_extension_map(is_aligned(Erule)), + E = fun(Imm, St) -> + emit([nl,"%% Extensions", + nl, + "{Extensions,",{next,bytes},"} = ", + "case Ext of",nl, + "0 -> {<<>>,",{curr,bytes},"};",nl, + "1 ->",nl]), + BytesVar = asn1ct_gen:mk_var(asn1ct_name:curr(bytes)), + {Dst,DstBuf} = asn1ct_imm:dec_slim_cg(Imm, BytesVar), + emit([com,nl, + "{",Dst,",",DstBuf,"}",nl, + "end"]), + asn1ct_name:new(bytes), + St + end, + {imm,Imm0,E}. gen_dec_comp_calls([C|Cs], Erule, TopType, OptTable, DecInfObj, Ext, NumberOfOptionals, Tpos, Acc) -> @@ -1204,10 +1214,10 @@ gen_dec_comp_call(Comp, Erule, TopType, Tpos, OptTable, DecInfObj, end, OptOrDef = - case {Ext,Prop,is_optimized(Erule)} of - {noext,mandatory,_} -> + case {Ext,Prop} of + {noext,mandatory} -> ignore; - {noext,_,_} -> %% OPTIONAL or DEFAULT + {noext,_} -> %% OPTIONAL or DEFAULT OptPos = get_optionality_pos(TextPos, OptTable), Element = io_lib:format("Opt band (1 bsl ~w)", [NumberOfOptionals - OptPos]), @@ -1216,18 +1226,10 @@ gen_dec_comp_call(Comp, Erule, TopType, Tpos, OptTable, DecInfObj, emit([" _Opt",TextPos," when _Opt",TextPos," > 0 ->"]), St end; - {_,_,false} -> %% extension element, not bitstring - fun(St) -> - emit(["case Extensions of",nl]), - emit([" _ when size(Extensions) >= ",Pos, - ",element(",Pos,",Extensions) == 1 ->",nl]), - St - end; - _ -> + {{ext,_,_},_} -> %Extension fun(St) -> - emit(["case Extensions of",nl]), - emit([" <<_:",Pos-1,",1:1,_/bitstring>> " - "when bit_size(Extensions) >= ",Pos," ->",nl]), + emit(["case Extensions of",nl, + " <<_:",Pos-1,",1:1,_/bitstring>> ->",nl]), St end end, diff --git a/lib/asn1/src/asn1ct_imm.erl b/lib/asn1/src/asn1ct_imm.erl index 0969dec272..34bb0b8714 100644 --- a/lib/asn1/src/asn1ct_imm.erl +++ b/lib/asn1/src/asn1ct_imm.erl @@ -19,6 +19,7 @@ %% -module(asn1ct_imm). -export([per_dec_boolean/0,per_dec_enumerated/2,per_dec_enumerated/3, + per_dec_extension_map/1, per_dec_integer/2,per_dec_length/3,per_dec_named_integer/3, per_dec_octet_string/2,per_dec_open_type/1]). -export([optimize_alignment/1,optimize_alignment/2, @@ -70,6 +71,10 @@ per_dec_enumerated(BaseNamedList, NamedListExt0, Aligned) -> Ext = {map,per_dec_normally_small_number(Aligned),NamedListExt}, bit_case(Base, Ext). +per_dec_extension_map(Aligned) -> + Len = {add,per_dec_normally_small_number(Aligned),1}, + {get_bits,Len,[1,bitstring]}. + per_dec_integer(Constraint0, Aligned) -> Constraint = effective_constraint(integer, Constraint0), per_dec_integer_1(Constraint, Aligned). |