aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-07-10 07:52:37 +0200
committerBjörn Gustavsson <[email protected]>2013-08-30 10:13:18 +0200
commita9a6646832b6ea67ecc8350f1e1df995a5b9ae74 (patch)
tree250e5a48f7176e9c209a419c4bf757d0a2ca8be3 /lib/asn1
parent4c10999bf32603e81b597cbc3e43e7dbe4d94a04 (diff)
downloadotp-a9a6646832b6ea67ecc8350f1e1df995a5b9ae74.tar.gz
otp-a9a6646832b6ea67ecc8350f1e1df995a5b9ae74.tar.bz2
otp-a9a6646832b6ea67ecc8350f1e1df995a5b9ae74.zip
PER,UPER: Get rid of unused 'telltype' argument in decoding functions
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl8
-rw-r--r--lib/asn1/src/asn1ct_gen.erl9
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl36
3 files changed, 30 insertions, 23 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index 77e46a2798..92f087cc4d 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -635,7 +635,7 @@ gen_decode_sof_components(Erule,Typename,SeqOrSetOf,Cont) ->
{constructed,bif} ->
NewTypename = [Constructed_Suffix|Typename],
emit({"'dec_",asn1ct_gen:list2name(NewTypename),
- "'(Bytes, telltype",ObjFun,"),",nl});
+ "'(Bytes",ObjFun,"),",nl});
#'Externaltypereference'{}=Etype ->
asn1ct_gen_per:gen_dec_external(Etype, "Bytes"),
emit([com,nl]);
@@ -644,7 +644,7 @@ gen_decode_sof_components(Erule,Typename,SeqOrSetOf,Cont) ->
"Bytes"),
emit({com,nl});
_ ->
- emit({"'dec_",Conttype,"'(Bytes,telltype),",nl})
+ emit({"'dec_",Conttype,"'(Bytes),",nl})
end,
emit({indent(3),"'dec_",asn1ct_gen:list2name(Typename),
"_components'(Num-1, Remain",ObjFun,", [Term|Acc]).",nl}).
@@ -1425,12 +1425,12 @@ gen_dec_line_other(Erule, Atype, TopType, Comp) ->
[{objfun,_}|_R] ->
fun(BytesVar) ->
emit({"'dec_",asn1ct_gen:list2name(NewTypename),
- "'(",BytesVar,", telltype, ObjFun)"})
+ "'(",BytesVar,", ObjFun)"})
end;
_ ->
fun(BytesVar) ->
emit({"'dec_",asn1ct_gen:list2name(NewTypename),
- "'(",BytesVar,", telltype)"})
+ "'(",BytesVar,")"})
end
end
end.
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index 68da80c585..fa05aacb95 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -798,7 +798,12 @@ pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) ->
gen_exports1(Types,"enc_",1)
end,
emit({"-export([",nl}),
- gen_exports1(Types,"dec_",2)
+ case Erules of
+ ber ->
+ gen_exports1(Types, "dec_", 2);
+ _ ->
+ gen_exports1(Types, "dec_", 1)
+ end
end,
case [X || {n2n,X} <- get(encoding_options)] of
[] -> ok;
@@ -1007,7 +1012,7 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
gen_partial_inc_dispatcher();
_PerOrPer_bin ->
gen_dispatcher(Types,"encode_disp","enc_",""),
- gen_dispatcher(Types,"decode_disp","dec_",",mandatory")
+ gen_dispatcher(Types,"decode_disp","dec_","")
end,
emit([nl]),
emit({nl,nl}).
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 588e03f432..3973664227 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -255,6 +255,8 @@ enc_ext_and_val(uper, E, F, Args) ->
Bs = list_to_bitstring([apply(asn1ct_eval_uper, F, Args)]),
<<E:1,Bs/bitstring>>.
+dec_func(Tname) ->
+ list_to_atom(lists:concat(["dec_",Tname])).
%% Object code generating for encoding and decoding
%% ------------------------------------------------
@@ -539,15 +541,15 @@ gen_decode_field_call(Erules, ObjName, FieldName, Bytes, Type) ->
[];
{constructed,bif} ->
emit({" 'dec_",ObjName,'_',FieldName,
- "'(",Bytes,",telltype)"}),
+ "'(",Bytes,")"}),
%% [Type#typedef{name=list_to_atom(lists:concat([ObjName,'_',FieldName]))}];
[Type#typedef{name=[FieldName,ObjName]}];
{ExtMod,TypeName} ->
emit({" '",ExtMod,"':'dec_",TypeName,
- "'(",Bytes,", telltype)"}),
+ "'(",Bytes,")"}),
[];
TypeName ->
- emit({" 'dec_",TypeName,"'(",Bytes,", telltype)"}),
+ emit({" 'dec_",TypeName,"'(",Bytes,")"}),
[]
end.
@@ -555,8 +557,8 @@ gen_decode_default_call(Erules, ClassName, FieldName, Bytes, Type) ->
InnerType = asn1ct_gen:get_inner(Type#type.def),
case asn1ct_gen:type(InnerType) of
{constructed,bif} ->
- emit([" 'dec_",ClassName,'_',FieldName,"'(",Bytes,", telltype)"]),
-%% [#typedef{name=list_to_atom(lists:concat([ClassName,'_',FieldName])),
+ DecFunc = dec_func(lists:concat([ClassName,'_',FieldName])),
+ emit([" ",{asis,DecFunc},"(",Bytes,")"]),
[#typedef{name=[FieldName,ClassName],
typespec=Type}];
{primitive,bif} ->
@@ -876,11 +878,11 @@ emit_inner_of_decfun(Erule, #typedef{name={ExtName,Name},typespec=Type},
asn1ct_gen:list2name(InternalDefFunName),"'(Val)"}),
1;
_ ->
- emit({indent(12),"'",ExtName,"':'dec_",Name,"'(Val, telltype)"}),
+ emit({indent(12),"'",ExtName,"':'dec_",Name,"'(Val)"}),
0
end;
emit_inner_of_decfun(_Erule, #typedef{name=Name}, _) ->
- emit({indent(12),"'dec_",Name,"'(Val, telltype)"}),
+ emit({indent(12),"'dec_",Name,"'(Val)"}),
0;
emit_inner_of_decfun(Erule, #type{}=Type, _) ->
CurrMod = get(currmod),
@@ -910,12 +912,11 @@ gen_internal_funcs(Erules,[TypeDef|Rest]) ->
%% DECODING *****************************
%%***************************************
-gen_decode(Erules,Type) when is_record(Type,typedef) ->
- D = Type,
- emit({nl,nl}),
- emit({"'dec_",Type#typedef.name,"'(Bytes,_) ->",nl}),
+gen_decode(Erules, #typedef{}=Type) ->
+ DecFunc = dec_func(Type#typedef.name),
+ emit([nl,nl,{asis,DecFunc},"(Bytes) ->",nl]),
dbdec(Type#typedef.name),
- gen_decode_user(Erules,D).
+ gen_decode_user(Erules, Type).
gen_decode(Erules,Tname,#'ComponentType'{name=Cname,typespec=Type}) ->
NewTname = [Cname|Tname],
@@ -932,8 +933,9 @@ gen_decode(Erules,Typename,Type) when is_record(Type,type) ->
_ ->
""
end,
- emit({nl,"'dec_",asn1ct_gen:list2name(Typename),
- "'(Bytes,_",ObjFun,") ->",nl}),
+ emit([nl,
+ {asis,dec_func(asn1ct_gen:list2name(Typename))},
+ "(Bytes",ObjFun,") ->",nl]),
dbdec(Typename),
asn1ct_gen:gen_decode_constructed(Erules,Typename,InnerType,Type);
_ ->
@@ -970,8 +972,8 @@ gen_dec_external(Ext, BytesVar) ->
#'Externaltypereference'{module=Mod,type=Type} = Ext,
emit([case CurrMod of
Mod -> [];
- _ -> ["'",Mod,"':"]
- end,"'dec_",Type,"'(",BytesVar,",telltype)"]).
+ _ -> [{asis,Mod},":"]
+ end,{asis,dec_func(Type)},"(",BytesVar,")"]).
gen_dec_imm(Erule, #type{def=Name,constraint=C}) ->
Aligned = case Erule of
@@ -1158,7 +1160,7 @@ imm_dec_open_type_1(Type, Aligned) ->
asn1ct_name:new(tmpval),
emit(["begin",nl,
"{",{curr,tmpval},",_} = ",
- "dec_",Type,"(",OpenType,", mandatory),",nl,
+ {asis,dec_func(Type)},"(",OpenType,"),",nl,
"{",{curr,tmpval},com,Buf,"}",nl,
"end"])
end,