aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-11-21 20:08:25 +0100
committerHans Nilsson <[email protected]>2017-11-21 20:08:25 +0100
commit93365f0ed71323e4e5475dd7c68d18ab2a83f7e5 (patch)
tree87eeafd5b2c2778715d4a0fc35a3b78af92a6d7f /lib/asn1/src/asn1ct_gen.erl
parent1a2a36794f1913b5a813c133bdfb9eea74d0a386 (diff)
downloadotp-93365f0ed71323e4e5475dd7c68d18ab2a83f7e5.tar.gz
otp-93365f0ed71323e4e5475dd7c68d18ab2a83f7e5.tar.bz2
otp-93365f0ed71323e4e5475dd7c68d18ab2a83f7e5.zip
asn1: Further adjustments on generated code
Diffstat (limited to 'lib/asn1/src/asn1ct_gen.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen.erl37
1 files changed, 22 insertions, 15 deletions
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index bd50a1ee18..da9f6ac559 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -752,8 +752,8 @@ pgen_dispatcher(Gen, Types) ->
emit(["decode(Type, ",Data,") ->",nl]),
case NoOkWrapper of
- false -> emit(["try",nl," case",nl," begin",nl]);
- true -> emit(["case",nl," begin"])
+ false -> emit(["try",nl]);
+ true -> ok
end,
DecWrap =
@@ -769,22 +769,29 @@ pgen_dispatcher(Gen, Types) ->
"Data"
end,
- emit([" decode_disp(Type, ",DecWrap,")",nl," end of",nl]),
- case Gen of
- #gen{erule=ber} ->
- emit([" Result ->",nl]);
- #gen{erule=per} ->
- emit([" {Result,Rest} ->",nl])
- end,
- case ReturnRest of
- false -> result_line(NoOkWrapper, ["Result"]);
- true -> result_line(NoOkWrapper, ["Result","Rest"])
+ DecodeDisp = ["decode_disp(Type, ",DecWrap,")"],
+ case {Gen,ReturnRest} of
+ {#gen{erule=ber},true} ->
+ emit([" Result = ",DecodeDisp,",",nl]),
+ result_line(NoOkWrapper, ["Result","Rest"]);
+ {#gen{erule=ber},false} ->
+ emit([" Result = ",DecodeDisp,",",nl]),
+ result_line(NoOkWrapper, ["Result"]);
+
+
+ {#gen{erule=per},true} ->
+ emit([" {Result,Rest} = ",DecodeDisp,",",nl]),
+ result_line(NoOkWrapper, ["Result","Rest"]);
+ {#gen{erule=per},false} ->
+ emit([" {Result,_Rest} = ",DecodeDisp,",",nl]),
+ result_line(NoOkWrapper, ["Result"])
end,
+
case NoOkWrapper of
false ->
- emit([nl," end",nl,try_catch(),nl,nl]);
+ emit([nl,try_catch(),nl,nl]);
true ->
- emit([nl,"end.",nl,nl])
+ emit([".",nl,nl])
end,
%% REST of MODULE
@@ -795,7 +802,7 @@ pgen_dispatcher(Gen, Types) ->
gen_dispatcher(Types, "decode_disp", "dec_").
result_line(NoOkWrapper, Items) ->
- S = [" "|case NoOkWrapper of
+ S = [" "|case NoOkWrapper of
false -> result_line_1(["ok"|Items]);
true -> result_line_1(Items)
end],