aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per.erl
diff options
context:
space:
mode:
authorKenneth Lundin <[email protected]>2010-09-10 12:09:00 +0200
committerKenneth Lundin <[email protected]>2010-09-10 12:09:00 +0200
commit357860d3b5def55eba80523c0be83ee4ebcab12c (patch)
treece7ecf49f15053bd9aafd460e6201a7d6d44e33a /lib/asn1/src/asn1ct_gen_per.erl
parent1470138027905c4adfd87d805457a40b39c2bdc6 (diff)
parent210fbb984619e6a6bb1122b7a6f72f54fb72effb (diff)
downloadotp-357860d3b5def55eba80523c0be83ee4ebcab12c.tar.gz
otp-357860d3b5def55eba80523c0be83ee4ebcab12c.tar.bz2
otp-357860d3b5def55eba80523c0be83ee4ebcab12c.zip
Merge branch 'kenneth/asn1/nested_extaddgroup/OTP-8797' into dev
* kenneth/asn1/nested_extaddgroup/OTP-8797: Add support for ExtensionAdditionGroup notation in nested types as well Conflicts: lib/asn1/test/test_undecoded_rest.erl
Diffstat (limited to 'lib/asn1/src/asn1ct_gen_per.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 23fb392d60..8313cf1b60 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -31,6 +31,7 @@
-export([gen_encode/2, gen_encode/3]).
-export([is_already_generated/2,more_genfields/1,get_class_fields/1,
get_object_field/2]).
+-export([extaddgroup2sequence/1]).
-import(asn1ct_gen, [emit/1,demit/1]).
@@ -1393,3 +1394,25 @@ get_object_field(Name,ObjectFields) ->
false -> false
end.
+
+%% For PER the ExtensionAdditionGroup notation has significance for the encoding and decoding
+%% the components within the ExtensionAdditionGroup is treated in a similar way as if they
+%% have been specified within a SEQUENCE, therefore we construct a fake sequence type here
+%% so that we can generate code for it
+extaddgroup2sequence(ExtList) ->
+ extaddgroup2sequence(ExtList,[]).
+
+extaddgroup2sequence([{'ExtensionAdditionGroup',Number0}|T],Acc) ->
+ Number = case Number0 of undefined -> 1; _ -> Number0 end,
+ {ExtGroupComps,['ExtensionAdditionGroupEnd'|T2]} =
+ lists:splitwith(fun(Elem) -> is_record(Elem,'ComponentType') end,T),
+ extaddgroup2sequence(T2,[#'ComponentType'{
+ name='ExtAddGroup',
+ typespec=#type{def=#'SEQUENCE'{
+ extaddgroup=Number,
+ components=ExtGroupComps}},
+ prop='OPTIONAL'}|Acc]);
+extaddgroup2sequence([C|T],Acc) ->
+ extaddgroup2sequence(T,[C|Acc]);
+extaddgroup2sequence([],Acc) ->
+ lists:reverse(Acc).