diff options
author | Lukas Larsson <[email protected]> | 2011-07-21 11:11:47 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-08-01 17:29:46 +0200 |
commit | e09729b33b2d4967686239c313e6020579032851 (patch) | |
tree | c7ace44abab19ce729c194d0f6533c19f433e579 /lib/asn1/src/asn1rt_ber_bin_v2.erl | |
parent | d13531f6efb62f69bd9002efeca32f0f9f6fc4e3 (diff) | |
download | otp-e09729b33b2d4967686239c313e6020579032851.tar.gz otp-e09729b33b2d4967686239c313e6020579032851.tar.bz2 otp-e09729b33b2d4967686239c313e6020579032851.zip |
Update code genaration to call nif/erlang depending on what is configured
Diffstat (limited to 'lib/asn1/src/asn1rt_ber_bin_v2.erl')
-rw-r--r-- | lib/asn1/src/asn1rt_ber_bin_v2.erl | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl index 16b7556d72..bef2216091 100644 --- a/lib/asn1/src/asn1rt_ber_bin_v2.erl +++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl @@ -21,7 +21,7 @@ %% encoding / decoding of BER --export([decode/1, decode/2, match_tags/2, encode/1]). +-export([decode/1, decode/2, match_tags/2, encode/1, encode/2]). -export([fixoptionals/2, cindex/3, list_to_record/2, encode_tag_val/1, @@ -50,7 +50,8 @@ -export([encode_open_type/1,encode_open_type/2, decode_open_type/2,decode_open_type/3, - decode_open_type_as_binary/2]). + decode_open_type_as_binary/2, + decode_open_type_as_binary/3]). -export([decode_primitive_incomplete/2,decode_selective/2]). @@ -128,20 +129,23 @@ % encode(Tlv) -> % encode_constructed(Tlv). -encode(Tlv) when is_binary(Tlv) -> - Tlv; -encode([Tlv]) -> - encode(Tlv); encode(Tlv) -> + encode(Tlv,erlang). + +encode(Tlv,_) when is_binary(Tlv) -> + Tlv; +encode([Tlv],Method) -> + encode(Tlv,Method); +encode(Tlv, nif) -> case is_nif_loadable() of true -> asn1rt_nif:encode_ber_tlv(Tlv); false -> encode_erl(Tlv) - end. + end; +encode(Tlv, _) -> + encode_erl(Tlv). -encode_erl([Tlv]) -> - encode_erl(Tlv); encode_erl({TlvTag,TlvVal}) when is_list(TlvVal) -> %% constructed form of value encode_tlv(TlvTag,TlvVal,?CONSTRUCTED); @@ -800,12 +804,14 @@ decode_open_type(Tlv, TagIn, Method) -> end. -decode_open_type_as_binary(Tlv,TagIn)-> +decode_open_type_as_binary(Tlv, TagIn) -> + decode_open_type_as_binary(Tlv, TagIn, erlang). +decode_open_type_as_binary(Tlv,TagIn, Method)-> case match_tags(Tlv,TagIn) of V when is_binary(V) -> V; - [Tlv2] -> encode(Tlv2); - Tlv2 -> encode(Tlv2) + [Tlv2] -> encode(Tlv2, Method); + Tlv2 -> encode(Tlv2, Method) end. %%=============================================================================== |