aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/src')
-rw-r--r--lib/asn1/src/asn1ct.erl3
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl13
-rw-r--r--lib/asn1/src/asn1ct_gen.erl8
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl11
-rw-r--r--lib/asn1/src/asn1ct_gen_per_rt2ct.erl11
-rw-r--r--lib/asn1/src/asn1rt_per_bin_rt2ct.erl11
6 files changed, 43 insertions, 14 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index a167d27f82..112f32dd52 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -1082,7 +1082,8 @@ get_runtime_mod(Options) ->
ber_bin_v2 -> ["asn1rt_ber_bin_v2.erl"];
uper_bin -> ["asn1rt_uper_bin.erl"]
end,
- RtMod1++["asn1rt_check.erl","asn1rt_driver_handler.erl","asn1rt.erl"].
+ RtMod1++["asn1rt_check.erl","asn1rt_driver_handler.erl","asn1rt_nif.erl",
+ "asn1rt.erl"].
erl_compile(OutFile,Options) ->
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index b7c481547f..a1c852b846 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -935,6 +935,8 @@ gen_enc_line(Erule,TopType, Cname, Type, [], Pos,DynamicEnc,Ext) ->
gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) ->
Ctgenmod = list_to_atom(lists:concat(["asn1ct_gen_",per,
asn1ct_gen:rt2ct_suffix()])),
+ Nif = lists:member(nif,get(encoding_options)) andalso
+ lists:member(optimize,get(encoding_options)),
Atype =
case Type of
#type{def=#'ObjectClassFieldType'{type=InnerType}} ->
@@ -958,7 +960,9 @@ gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) ->
{Name,RestFieldNames} when is_atom(Name) ->
emit({"?RT_PER:encode_open_type([],?RT_PER:complete(",nl}),
emit({" ",Fun,"(",{asis,Name},", ",
- Element,", ",{asis,RestFieldNames},")))"});
+ Element,", ",{asis,RestFieldNames},")",
+ [",nif" || Nif == true],
+ "))"});
Other ->
throw({asn1,{'internal error',Other}})
end
@@ -969,7 +973,9 @@ gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) ->
emit({"?RT_PER:encode_open_type([],"
"?RT_PER:complete(",nl}),
emit({" ",Fun,"(",{asis,PrimFieldName1},
- ", ",Element,", ",{asis,PFNList},")))"})
+ ", ",Element,", ",{asis,PFNList},")",
+ [",nif" || Nif == true],
+ "))"})
end;
_ ->
CurrMod = get(currmod),
@@ -1020,7 +1026,8 @@ gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) ->
end,
case Ext of
{ext,_Ep2,_} ->
- emit(["))"]);
+ emit([[",nif" || Nif == true],
+ "))"]);
_ -> true
end.
gen_dec_components_call(Erule,TopType,{Root1,ExtList,Root2},MaybeComma,DecInfObj,Ext,NumberOfOptionals) ->
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index e49829d82f..e7f59c3d3c 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -936,15 +936,19 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
emit(["encoding_rule() ->",nl]),
emit([" ",{asis,Erules},".",nl,nl]),
NoFinalPadding = lists:member(no_final_padding,get(encoding_options)),
+ Nif = lists:member(nif,get(encoding_options)) andalso
+ lists:member(optimize,get(encoding_options)),
Call = case Erules of
per -> "?RT_PER:complete(encode_disp(Type,Data))";
- per_bin -> "?RT_PER:complete(encode_disp(Type,Data))";
+ per_bin -> ["?RT_PER:complete(encode_disp(Type,Data)",
+ [",nif" || Nif == true],")"];
ber -> "encode_disp(Type,Data)";
ber_bin -> "encode_disp(Type,Data)";
ber_bin_v2 -> "encode_disp(Type,Data)";
uper_bin when NoFinalPadding == true ->
"?RT_PER:complete_NFP(encode_disp(Type,Data))";
- uper_bin -> "?RT_PER:complete(encode_disp(Type,Data))"
+ uper_bin -> ["?RT_PER:complete(encode_disp(Type,Data)",
+ [",nif" || Nif == true],")"]
end,
EncWrap = case Erules of
ber -> "wrap_encode(Bytes)";
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 8313cf1b60..becd536967 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -232,13 +232,18 @@ gen_encode_prim(Erules,D,DoTag,Value) when is_record(D,type) ->
emit(["?RT_PER:encode_open_type(", {asis,Constraint}, ",",
Value, ")"]);
'ASN1_OPEN_TYPE' ->
+ Nif = lists:member(nif,get(encoding_options)) andalso
+ lists:member(optimize,get(encoding_options)),
NewValue = case Constraint of
[#'Externaltypereference'{type=Tname}] ->
io_lib:format(
- "?RT_PER:complete(enc_~s(~s))",[Tname,Value]);
+ "?RT_PER:complete(enc_~s(~s)"++
+ [",nif" || Nif == true]++")",[Tname,Value]);
[#type{def=#'Externaltypereference'{type=Tname}}] ->
io_lib:format(
- "?RT_PER:complete(enc_~s(~s))",[Tname,Value]);
+ "?RT_PER:complete(enc_~s(~s)"++
+ [",nif" || Nif == true]++")",
+ [Tname,Value]);
_ -> Value
end,
emit(["?RT_PER:encode_open_type(", {asis,Constraint}, ",",
diff --git a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
index 4f4fcfafc3..417a47849f 100644
--- a/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
+++ b/lib/asn1/src/asn1ct_gen_per_rt2ct.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -224,13 +224,18 @@ gen_encode_prim(Erules,D,DoTag,Value) when is_record(D,type) ->
emit(["?RT_PER:encode_open_type(", {asis,Constraint}, ",",
Value, ")"]);
'ASN1_OPEN_TYPE' ->
+ Nif = lists:member(nif,get(encoding_options)) andalso
+ lists:member(optimize,get(encoding_options)),
NewValue = case Constraint of
[#'Externaltypereference'{type=Tname}] ->
io_lib:format(
- "?RT_PER:complete(enc_~s(~s))",[Tname,Value]);
+ "?RT_PER:complete(enc_~s(~s)"++
+ [",nif" || Nif == true]++")",[Tname,Value]);
[#type{def=#'Externaltypereference'{type=Tname}}] ->
io_lib:format(
- "?RT_PER:complete(enc_~s(~s))",[Tname,Value]);
+ "?RT_PER:complete(enc_~s(~s)"++
+ [",nif" || Nif == true]++")",
+ [Tname,Value]);
_ -> Value
end,
emit(["?RT_PER:encode_open_type(", {asis,Constraint}, ",",
diff --git a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
index f4aecf9322..307b0aa5f1 100644
--- a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
+++ b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
@@ -39,7 +39,7 @@
encode_object_identifier/1, decode_object_identifier/1,
encode_real/1, decode_real/1,
encode_relative_oid/1, decode_relative_oid/1,
- complete/1]).
+ complete/1, complete/2]).
-export([encode_open_type/2, decode_open_type/2]).
@@ -1742,6 +1742,8 @@ complete(L) ->
{Acc,Bacc} ->
[Acc|complete_bytes(Bacc)]
end.
+complete(L,_) ->
+ complete(L).
% this function builds the ugly form of lists [E1|E2] to avoid having to reverse it at the end.
@@ -1842,6 +1844,9 @@ complete(L) ->
%% asn1-1.6.9
complete(L) ->
+ complete(L, driver).
+
+complete(L,driver) ->
case catch control(?COMPLETE_ENCODE,L) of
Bin when is_binary(Bin) ->
Bin;
@@ -1856,7 +1861,9 @@ complete(L) ->
Err ->
Err
end
- end.
+ end;
+complete(L,nif) ->
+ asn1rt_nif:encode_per_complete(L).
handle_error([],_)->