aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-01-20 14:49:56 +0100
committerBjörn Gustavsson <[email protected]>2014-01-24 16:24:55 +0100
commitbd9e8cf011ee6c1391c134287f0fe877e51c54b8 (patch)
tree52b952143cc0b854de371bdc2116a05a9a90e53e /lib/asn1
parent1658a7fdd1dfa08a4fa2b9c94fb2d07799e15b20 (diff)
downloadotp-bd9e8cf011ee6c1391c134287f0fe877e51c54b8.tar.gz
otp-bd9e8cf011ee6c1391c134287f0fe877e51c54b8.tar.bz2
otp-bd9e8cf011ee6c1391c134287f0fe877e51c54b8.zip
Add legacy_erlang_types
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct.erl29
-rw-r--r--lib/asn1/src/asn1ct_gen.erl7
2 files changed, 33 insertions, 3 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index f2e9606ccb..531a4935fe 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -40,7 +40,7 @@
maybe_rename_function/3,current_sindex/0,
set_current_sindex/1,maybe_saved_sindex/2,
parse_and_save/2,verbose/3,warning/3,warning/4,error/3]).
--export([get_bit_string_format/0]).
+-export([get_bit_string_format/0,use_legacy_types/0]).
-include("asn1_records.hrl").
-include_lib("stdlib/include/erl_compile.hrl").
@@ -841,6 +841,7 @@ delete_double_of_symbol1([],Acc) ->
generate({M,GenTOrV}, OutFile, EncodingRule, Options) ->
debug_on(Options),
setup_bit_string_format(Options),
+ setup_legacy_erlang_types(Options),
put(encoding_options,Options),
asn1ct_table:new(check_functions),
@@ -869,6 +870,31 @@ generate({M,GenTOrV}, OutFile, EncodingRule, Options) ->
asn1ct_table:delete(check_functions),
Result.
+setup_legacy_erlang_types(Opts) ->
+ F = case lists:member(legacy_erlang_types, Opts) of
+ false ->
+ case get_bit_string_format() of
+ bitstring ->
+ false;
+ compact ->
+ legacy_forced_info(compact_bit_string),
+ true;
+ legacy ->
+ legacy_forced_info(legacy_bit_string),
+ true
+ end;
+ true ->
+ true
+ end,
+ put(use_legacy_erlang_types, F).
+
+legacy_forced_info(Opt) ->
+ io:format("Info: The option 'legacy_erlang_types' "
+ "is implied by the '~s' option.\n", [Opt]).
+
+use_legacy_types() ->
+ get(use_legacy_erlang_types).
+
setup_bit_string_format(Opts) ->
Format = case {lists:member(compact_bit_string, Opts),
lists:member(legacy_bit_string, Opts)} of
@@ -1075,6 +1101,7 @@ remove_asn_flags(Options) ->
X /= optimize,
X /= compact_bit_string,
X /= legacy_bit_string,
+ X /= legacy_erlang_types,
X /= debug,
X /= asn1config,
X /= record_name_prefix].
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index 37b33194d0..71d870b4ce 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -790,7 +790,8 @@ gen_decode_constructed(Erules,Typename,InnerType,D) when is_record(D,typedef) ->
pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) ->
- emit(["-export([encoding_rule/0,bit_string_format/0]).",nl]),
+ emit(["-export([encoding_rule/0,bit_string_format/0,"
+ " legacy_erlang_types/0]).",nl]),
case Types of
[] -> ok;
_ ->
@@ -1022,7 +1023,9 @@ gen_info_functions(Erules) ->
emit(["encoding_rule() -> ",
{asis,Erules},".",nl,nl,
"bit_string_format() -> ",
- {asis,asn1ct:get_bit_string_format()},".",nl,nl]).
+ {asis,asn1ct:get_bit_string_format()},".",nl,nl,
+ "legacy_erlang_types() -> ",
+ {asis,asn1ct:use_legacy_types()},".",nl,nl]).
gen_decode_partial_incomplete(ber) ->
case {asn1ct:read_config_data(partial_incomplete_decode),