%% Generated by the Erlang ASN.1 PER (unaligned) compiler. Version: 5.4.3 %% Purpose: Encoding and decoding of the types in GajumaruSerialization. -module('GajumaruSerialization'). -moduledoc false. -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -dialyzer(no_match). -include("GajumaruSerialization.hrl"). -asn1_info([{vsn,'5.4.3'}, {module,'GajumaruSerialization'}, {options,[uper,{outdir,"asn1_uper"},{i,"."},{i,"asn1_uper"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_GajumaruData/1, enc_Content/1, enc_TemplateFields/1, enc_TemplateField/1, enc_Value/1, enc_KeyValue/1, enc_Id/1, enc_Account/1, enc_SignedTx/1, enc_ContractCode/1, enc_ContractV1/1, enc_ContractV2/1, enc_ContractV3/1, enc_TypeInfoV1/1, enc_TypeInfoV3/1 ]). -export([ dec_GajumaruData/1, dec_Content/1, dec_TemplateFields/1, dec_TemplateField/1, dec_Value/1, dec_KeyValue/1, dec_Id/1, dec_Account/1, dec_SignedTx/1, dec_ContractCode/1, dec_ContractV1/1, dec_ContractV2/1, dec_ContractV3/1, dec_TypeInfoV1/1, dec_TypeInfoV3/1 ]). -export([info/0]). -export([encode/2,decode/2]). encoding_rule() -> uper. maps() -> false. bit_string_format() -> bitstring. legacy_erlang_types() -> false. encode(Type, Data) -> try complete(encode_disp(Type, Data)) of Bytes -> {ok,Bytes} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. decode(Type, Data) -> try {Result,_Rest} = decode_disp(Type, Data), {ok,Result} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. encode_disp('GajumaruData', Data) -> enc_GajumaruData(Data); encode_disp('Content', Data) -> enc_Content(Data); encode_disp('TemplateFields', Data) -> enc_TemplateFields(Data); encode_disp('TemplateField', Data) -> enc_TemplateField(Data); encode_disp('Value', Data) -> enc_Value(Data); encode_disp('KeyValue', Data) -> enc_KeyValue(Data); encode_disp('Id', Data) -> enc_Id(Data); encode_disp('Account', Data) -> enc_Account(Data); encode_disp('SignedTx', Data) -> enc_SignedTx(Data); encode_disp('ContractCode', Data) -> enc_ContractCode(Data); encode_disp('ContractV1', Data) -> enc_ContractV1(Data); encode_disp('ContractV2', Data) -> enc_ContractV2(Data); encode_disp('ContractV3', Data) -> enc_ContractV3(Data); encode_disp('TypeInfoV1', Data) -> enc_TypeInfoV1(Data); encode_disp('TypeInfoV3', Data) -> enc_TypeInfoV3(Data); encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('GajumaruData', Data) -> dec_GajumaruData(Data); decode_disp('Content', Data) -> dec_Content(Data); decode_disp('TemplateFields', Data) -> dec_TemplateFields(Data); decode_disp('TemplateField', Data) -> dec_TemplateField(Data); decode_disp('Value', Data) -> dec_Value(Data); decode_disp('KeyValue', Data) -> dec_KeyValue(Data); decode_disp('Id', Data) -> dec_Id(Data); decode_disp('Account', Data) -> dec_Account(Data); decode_disp('SignedTx', Data) -> dec_SignedTx(Data); decode_disp('ContractCode', Data) -> dec_ContractCode(Data); decode_disp('ContractV1', Data) -> dec_ContractV1(Data); decode_disp('ContractV2', Data) -> dec_ContractV2(Data); decode_disp('ContractV3', Data) -> dec_ContractV3(Data); decode_disp('TypeInfoV1', Data) -> dec_TypeInfoV1(Data); decode_disp('TypeInfoV3', Data) -> dec_TypeInfoV3(Data); decode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). info() -> case ?MODULE:module_info(attributes) of Attributes when is_list(Attributes) -> case lists:keyfind(asn1_info, 1, Attributes) of {_,Info} when is_list(Info) -> Info; _ -> [] end; _ -> [] end. enc_GajumaruData(Val) -> [begin %% attribute tag(1) with type INTEGER Enc1@element = element(2, Val), encode_unconstrained_number(Enc1@element) end, begin %% attribute vsn(2) with type INTEGER Enc3@element = element(3, Val), encode_unconstrained_number(Enc3@element) end|begin %% attribute content(3) with type Content Enc5@element = element(4, Val), enc_Content(Enc5@element) end]. dec_GajumaruData(Bytes) -> %% attribute tag(1) with type INTEGER {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@Buf4/bitstring>> when V1@V3 =/= 0 -> {V1@V3,V1@Buf4}; <<1:1,0:1,V1@V4:14,V1@Buf5/bitstring>> when V1@V4 =/= 0 -> {V1@V4,V1@Buf5}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> when V1@V4 =/= 0 -> V1@Mul6 = V1@V4 * 16384, {V1@Mul6,V1@Buf5} end, <> = V1@Buf1, {V1@V7,V1@Buf8} end, %% attribute vsn(2) with type INTEGER {Term2,Bytes2} = begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@Buf4/bitstring>> when V2@V3 =/= 0 -> {V2@V3,V2@Buf4}; <<1:1,0:1,V2@V4:14,V2@Buf5/bitstring>> when V2@V4 =/= 0 -> {V2@V4,V2@Buf5}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> when V2@V4 =/= 0 -> V2@Mul6 = V2@V4 * 16384, {V2@Mul6,V2@Buf5} end, <> = V2@Buf1, {V2@V7,V2@Buf8} end, %% attribute content(3) with type Content {Term3,Bytes3} = dec_Content(Bytes2), Res1 = {'GajumaruData',Term1,Term2,Term3}, {Res1,Bytes3}. enc_Content(Val) -> {ChoiceTag,ChoiceVal} = Val, if ChoiceTag =:= templateFields -> [<<0:2>>|enc_TemplateFields(ChoiceVal)]; ChoiceTag =:= account -> [<<1:2>>|enc_Account(ChoiceVal)]; ChoiceTag =:= signedTx -> [<<2:2>>|enc_SignedTx(ChoiceVal)]; ChoiceTag =:= contract -> [<<3:2>>|enc_ContractCode(ChoiceVal)] end. dec_Content(Bytes) -> {Choice,Bytes1} = begin <> = Bytes, {V1@V0,V1@Buf1} end, case Choice of 0 -> {Val,NewBytes} = begin dec_TemplateFields(Bytes1) end, {{templateFields,Val},NewBytes}; 1 -> {Val,NewBytes} = begin dec_Account(Bytes1) end, {{account,Val},NewBytes}; 2 -> {Val,NewBytes} = begin dec_SignedTx(Bytes1) end, {{signedTx,Val},NewBytes}; 3 -> {Val,NewBytes} = begin dec_ContractCode(Bytes1) end, {{contract,Val},NewBytes} end. enc_TemplateFields(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_TemplateField(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_TemplateField(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_TemplateField(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. dec_TemplateFields(Bytes) -> dec_components1(Bytes, []). enc_TemplateField(Val) -> [begin Enc1@element = element(2, Val), if Enc1@element =:= asn1_NOVALUE -> <<0:1>>; true -> <<1:1>> end end, begin %% attribute name(1) with type IA5String Enc2@element = element(2, Val), if Enc2@element =:= asn1_NOVALUE -> []; true -> begin Enc3@len = length(Enc2@element), Enc3@bin = encode_chars(Enc2@element, 7), if Enc3@len < 128 -> [Enc3@len|Enc3@bin]; Enc3@len < 16384 -> [<<2:2,Enc3@len:14>>|Enc3@bin]; true -> encode_fragmented(Enc3@bin, 7) end end end end|begin %% attribute value(2) with type Value Enc5@element = element(3, Val), enc_Value(Enc5@element) end]. dec_TemplateField(Bytes) -> {Opt,Bytes1} = begin <> = Bytes, {V1@V0,V1@Buf1} end, %% attribute name(1) with type IA5String {Term1,Bytes2} = case Opt band 1 of 1 -> begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:7,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:7,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 7), {V2@V6,V2@Buf7} end, {V2@V8,V2@Buf9} = {decode_chars(V2@V0, 7),V2@Buf1}, {V2@V8,V2@Buf9} end; 0 -> {asn1_NOVALUE,Bytes1} end, %% attribute value(2) with type Value {Term2,Bytes3} = dec_Value(Bytes2), Res1 = {'TemplateField',Term1,Term2}, {Res1,Bytes3}. enc_Value(Val) -> {ChoiceTag,ChoiceVal} = Val, if ChoiceTag =:= intValue -> [<<0:3>>|encode_unconstrained_number(ChoiceVal)]; ChoiceTag =:= boolValue -> if ChoiceVal =:= false -> <<1:3,0:1>>; ChoiceVal =:= true -> <<1:3,1:1>>; true -> exit({error,{asn1,{illegal_boolean,ChoiceVal}}}) end; ChoiceTag =:= binaryValue -> [<<2:3>>|begin Enc6@len = byte_size(ChoiceVal), if Enc6@len < 128 -> [Enc6@len|ChoiceVal]; Enc6@len < 16384 -> [<<2:2,Enc6@len:14>>|ChoiceVal]; true -> encode_fragmented(ChoiceVal, 8) end end]; ChoiceTag =:= idValue -> [<<3:3>>|enc_Id(ChoiceVal)]; ChoiceTag =:= listValue -> [<<4:3>>|enc_Value_listValue(ChoiceVal)]; ChoiceTag =:= tupleValue -> [<<5:3>>|enc_Value_tupleValue(ChoiceVal)]; ChoiceTag =:= mapValue -> [<<6:3>>|enc_Value_mapValue(ChoiceVal)] end. enc_Value_listValue(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_Value(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_Value(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_Value(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. enc_Value_tupleValue(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_Value(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_Value(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_Value(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. enc_Value_mapValue(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_KeyValue(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_KeyValue(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_KeyValue(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. dec_Value(Bytes) -> {Choice,Bytes1} = begin <> = Bytes, {V1@V0,V1@Buf1} end, case Choice of 0 -> {Val,NewBytes} = begin begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@Buf4/bitstring>> when V2@V3 =/= 0 -> {V2@V3,V2@Buf4}; <<1:1,0:1,V2@V4:14,V2@Buf5/bitstring>> when V2@V4 =/= 0 -> {V2@V4,V2@Buf5}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> when V2@V4 =/= 0 -> V2@Mul6 = V2@V4 * 16384, {V2@Mul6,V2@Buf5} end, <> = V2@Buf1, {V2@V7,V2@Buf8} end end, {{intValue,Val},NewBytes}; 1 -> {Val,NewBytes} = begin begin <> = Bytes1, V3@Int2 = case V3@V0 of 0 -> false; 1 -> true end, {V3@Int2,V3@Buf1} end end, {{boolValue,Val},NewBytes}; 2 -> {Val,NewBytes} = begin begin {V4@V0,V4@Buf1} = case Bytes1 of <<0:1,V4@V3:7,V4@V5:V4@V3/binary-unit:8,V4@Buf6/bitstring>> -> {V4@V5,V4@Buf6}; <<1:1,0:1,V4@V4:14,V4@V6:V4@V4/binary-unit:8,V4@Buf7/bitstring>> -> {V4@V6,V4@Buf7}; <<1:1,1:1,V4@V4:6,V4@Buf5/bitstring>> -> {V4@V6,V4@Buf7} = decode_fragmented(V4@V4, V4@Buf5, 8), {V4@V6,V4@Buf7} end, V4@Conv8 = binary:copy(V4@V0), {V4@Conv8,V4@Buf1} end end, {{binaryValue,Val},NewBytes}; 3 -> {Val,NewBytes} = begin dec_Id(Bytes1) end, {{idValue,Val},NewBytes}; 4 -> {Val,NewBytes} = begin dec_Value_listValue(Bytes1) end, {{listValue,Val},NewBytes}; 5 -> {Val,NewBytes} = begin dec_Value_tupleValue(Bytes1) end, {{tupleValue,Val},NewBytes}; 6 -> {Val,NewBytes} = begin dec_Value_mapValue(Bytes1) end, {{mapValue,Val},NewBytes} end. dec_Value_listValue(Bytes) -> dec_components2(Bytes, []). dec_Value_tupleValue(Bytes) -> dec_components3(Bytes, []). dec_Value_mapValue(Bytes) -> dec_components4(Bytes, []). enc_KeyValue(Val) -> [begin %% attribute key(1) with type Value Enc1@element = element(2, Val), enc_Value(Enc1@element) end|begin %% attribute val(2) with type Value Enc2@element = element(3, Val), enc_Value(Enc2@element) end]. dec_KeyValue(Bytes) -> %% attribute key(1) with type Value {Term1,Bytes1} = dec_Value(Bytes), %% attribute val(2) with type Value {Term2,Bytes2} = dec_Value(Bytes1), Res1 = {'KeyValue',Term1,Term2}, {Res1,Bytes2}. enc_Id(Val) -> [begin %% attribute type(1) with type INTEGER Enc1@element = element(2, Val), if Enc1@element bsr 8 =:= 0 -> Enc1@element; true -> exit({error,{asn1,{illegal_integer,Enc1@element}}}) end end|begin %% attribute value(2) with type OCTET STRING Enc3@element = element(3, Val), Enc4@len = byte_size(Enc3@element), if Enc4@len =:= 32 -> Enc3@element end end]. dec_Id(Bytes) -> %% attribute type(1) with type INTEGER {Term1,Bytes1} = begin <> = Bytes, {V1@V0,V1@Buf1} end, %% attribute value(2) with type OCTET STRING {Term2,Bytes2} = begin <> = Bytes1, V2@Conv2 = binary:copy(V2@V0), {V2@Conv2,V2@Buf1} end, Res1 = {'Id',Term1,Term2}, {Res1,Bytes2}. enc_Account(Val) -> [begin %% attribute foo(1) with type INTEGER Enc1@element = element(2, Val), encode_unconstrained_number(Enc1@element) end|begin %% attribute bar(2) with type OCTET STRING Enc3@element = element(3, Val), Enc4@len = byte_size(Enc3@element), if Enc4@len < 128 -> [Enc4@len|Enc3@element]; Enc4@len < 16384 -> [<<2:2,Enc4@len:14>>|Enc3@element]; true -> encode_fragmented(Enc3@element, 8) end end]. dec_Account(Bytes) -> %% attribute foo(1) with type INTEGER {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@Buf4/bitstring>> when V1@V3 =/= 0 -> {V1@V3,V1@Buf4}; <<1:1,0:1,V1@V4:14,V1@Buf5/bitstring>> when V1@V4 =/= 0 -> {V1@V4,V1@Buf5}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> when V1@V4 =/= 0 -> V1@Mul6 = V1@V4 * 16384, {V1@Mul6,V1@Buf5} end, <> = V1@Buf1, {V1@V7,V1@Buf8} end, %% attribute bar(2) with type OCTET STRING {Term2,Bytes2} = begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, Res1 = {'Account',Term1,Term2}, {Res1,Bytes2}. enc_SignedTx(Val) -> [begin %% attribute signatures(1) with type SEQUENCE OF Enc1@element = element(2, Val), enc_SignedTx_signatures(Enc1@element) end|begin %% attribute transaction(2) with type OCTET STRING Enc2@element = element(3, Val), Enc3@len = byte_size(Enc2@element), if Enc3@len < 128 -> [Enc3@len|Enc2@element]; Enc3@len < 16384 -> [<<2:2,Enc3@len:14>>|Enc2@element]; true -> encode_fragmented(Enc2@element, 8) end end]. enc_SignedTx_signatures(Val) -> Enc2@len = length(Val), if Enc2@len < 128 -> [Enc2@len|[begin Enc1@len = byte_size(Comp), if Enc1@len < 128 -> [Enc1@len|Comp]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|Comp]; true -> encode_fragmented(Comp, 8) end end || Comp <- Val]]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|[begin Enc1@len = byte_size(Comp), if Enc1@len < 128 -> [Enc1@len|Comp]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|Comp]; true -> encode_fragmented(Comp, 8) end end || Comp <- Val]]; true -> begin Enc2@fn = fun(Comp) -> begin Enc1@len = byte_size(Comp), if Enc1@len < 128 -> [Enc1@len|Comp]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|Comp]; true -> encode_fragmented(Comp, 8) end end end, encode_fragmented_sof(Enc2@fn, Val, Enc2@len) end end. dec_SignedTx(Bytes) -> %% attribute signatures(1) with type SEQUENCE OF {Term1,Bytes1} = dec_SignedTx_signatures(Bytes), %% attribute transaction(2) with type OCTET STRING {Term2,Bytes2} = begin {V1@V0,V1@Buf1} = case Bytes1 of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, Res1 = {'SignedTx',Term1,Term2}, {Res1,Bytes2}. dec_SignedTx_signatures(Bytes) -> dec_components5(Bytes, []). enc_ContractCode(Val) -> {ChoiceTag,ChoiceVal} = Val, if ChoiceTag =:= v1 -> [<<0:2>>|enc_ContractV1(ChoiceVal)]; ChoiceTag =:= v2 -> [<<1:2>>|enc_ContractV2(ChoiceVal)]; ChoiceTag =:= v3 -> [<<2:2>>|enc_ContractV3(ChoiceVal)] end. dec_ContractCode(Bytes) -> {Choice,Bytes1} = begin <> = Bytes, {V1@V0,V1@Buf1} end, case Choice of 0 -> {Val,NewBytes} = begin dec_ContractV1(Bytes1) end, {{v1,Val},NewBytes}; 1 -> {Val,NewBytes} = begin dec_ContractV2(Bytes1) end, {{v2,Val},NewBytes}; 2 -> {Val,NewBytes} = begin dec_ContractV3(Bytes1) end, {{v3,Val},NewBytes} end. enc_ContractV1(Val) -> [begin %% attribute sourceHash(1) with type OCTET STRING Enc1@element = element(2, Val), Enc2@len = byte_size(Enc1@element), if Enc2@len < 128 -> [Enc2@len|Enc1@element]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|Enc1@element]; true -> encode_fragmented(Enc1@element, 8) end end, begin %% attribute typeInfo(2) with type SEQUENCE OF Enc3@element = element(3, Val), enc_ContractV1_typeInfo(Enc3@element) end|begin %% attribute byteCode(3) with type OCTET STRING Enc4@element = element(4, Val), Enc5@len = byte_size(Enc4@element), if Enc5@len < 128 -> [Enc5@len|Enc4@element]; Enc5@len < 16384 -> [<<2:2,Enc5@len:14>>|Enc4@element]; true -> encode_fragmented(Enc4@element, 8) end end]. enc_ContractV1_typeInfo(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_TypeInfoV1(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_TypeInfoV1(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_TypeInfoV1(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. dec_ContractV1(Bytes) -> %% attribute sourceHash(1) with type OCTET STRING {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, %% attribute typeInfo(2) with type SEQUENCE OF {Term2,Bytes2} = dec_ContractV1_typeInfo(Bytes1), %% attribute byteCode(3) with type OCTET STRING {Term3,Bytes3} = begin {V2@V0,V2@Buf1} = case Bytes2 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, Res1 = {'ContractV1',Term1,Term2,Term3}, {Res1,Bytes3}. dec_ContractV1_typeInfo(Bytes) -> dec_components6(Bytes, []). enc_ContractV2(Val) -> [begin %% attribute sourceHash(1) with type OCTET STRING Enc1@element = element(2, Val), Enc2@len = byte_size(Enc1@element), if Enc2@len < 128 -> [Enc2@len|Enc1@element]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|Enc1@element]; true -> encode_fragmented(Enc1@element, 8) end end, begin %% attribute typeInfo(2) with type SEQUENCE OF Enc3@element = element(3, Val), enc_ContractV2_typeInfo(Enc3@element) end, begin %% attribute byteCode(3) with type OCTET STRING Enc4@element = element(4, Val), Enc5@len = byte_size(Enc4@element), if Enc5@len < 128 -> [Enc5@len|Enc4@element]; Enc5@len < 16384 -> [<<2:2,Enc5@len:14>>|Enc4@element]; true -> encode_fragmented(Enc4@element, 8) end end|begin %% attribute compilerVersion(4) with type OCTET STRING Enc6@element = element(5, Val), Enc7@len = byte_size(Enc6@element), if Enc7@len < 128 -> [Enc7@len|Enc6@element]; Enc7@len < 16384 -> [<<2:2,Enc7@len:14>>|Enc6@element]; true -> encode_fragmented(Enc6@element, 8) end end]. enc_ContractV2_typeInfo(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_TypeInfoV1(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_TypeInfoV1(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_TypeInfoV1(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. dec_ContractV2(Bytes) -> %% attribute sourceHash(1) with type OCTET STRING {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, %% attribute typeInfo(2) with type SEQUENCE OF {Term2,Bytes2} = dec_ContractV2_typeInfo(Bytes1), %% attribute byteCode(3) with type OCTET STRING {Term3,Bytes3} = begin {V2@V0,V2@Buf1} = case Bytes2 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, %% attribute compilerVersion(4) with type OCTET STRING {Term4,Bytes4} = begin {V3@V0,V3@Buf1} = case Bytes3 of <<0:1,V3@V3:7,V3@V5:V3@V3/binary-unit:8,V3@Buf6/bitstring>> -> {V3@V5,V3@Buf6}; <<1:1,0:1,V3@V4:14,V3@V6:V3@V4/binary-unit:8,V3@Buf7/bitstring>> -> {V3@V6,V3@Buf7}; <<1:1,1:1,V3@V4:6,V3@Buf5/bitstring>> -> {V3@V6,V3@Buf7} = decode_fragmented(V3@V4, V3@Buf5, 8), {V3@V6,V3@Buf7} end, V3@Conv8 = binary:copy(V3@V0), {V3@Conv8,V3@Buf1} end, Res1 = {'ContractV2',Term1,Term2,Term3,Term4}, {Res1,Bytes4}. dec_ContractV2_typeInfo(Bytes) -> dec_components7(Bytes, []). enc_ContractV3(Val) -> [begin %% attribute sourceHash(1) with type OCTET STRING Enc1@element = element(2, Val), Enc2@len = byte_size(Enc1@element), if Enc2@len < 128 -> [Enc2@len|Enc1@element]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|Enc1@element]; true -> encode_fragmented(Enc1@element, 8) end end, begin %% attribute typeInfo(2) with type SEQUENCE OF Enc3@element = element(3, Val), enc_ContractV3_typeInfo(Enc3@element) end, begin %% attribute byteCode(3) with type OCTET STRING Enc4@element = element(4, Val), Enc5@len = byte_size(Enc4@element), if Enc5@len < 128 -> [Enc5@len|Enc4@element]; Enc5@len < 16384 -> [<<2:2,Enc5@len:14>>|Enc4@element]; true -> encode_fragmented(Enc4@element, 8) end end, begin %% attribute compilerVersion(4) with type OCTET STRING Enc6@element = element(5, Val), Enc7@len = byte_size(Enc6@element), if Enc7@len < 128 -> [Enc7@len|Enc6@element]; Enc7@len < 16384 -> [<<2:2,Enc7@len:14>>|Enc6@element]; true -> encode_fragmented(Enc6@element, 8) end end|begin %% attribute payable(5) with type BOOLEAN Enc8@element = element(6, Val), if Enc8@element =:= false -> <<0:1>>; Enc8@element =:= true -> <<1:1>>; true -> exit({error,{asn1,{illegal_boolean,Enc8@element}}}) end end]. enc_ContractV3_typeInfo(Val) -> Enc1@len = length(Val), if Enc1@len < 128 -> [Enc1@len|[enc_TypeInfoV3(Comp) || Comp <- Val]]; Enc1@len < 16384 -> [<<2:2,Enc1@len:14>>|[enc_TypeInfoV3(Comp) || Comp <- Val]]; true -> begin Enc1@fn = fun(Comp) -> enc_TypeInfoV3(Comp) end, encode_fragmented_sof(Enc1@fn, Val, Enc1@len) end end. dec_ContractV3(Bytes) -> %% attribute sourceHash(1) with type OCTET STRING {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, %% attribute typeInfo(2) with type SEQUENCE OF {Term2,Bytes2} = dec_ContractV3_typeInfo(Bytes1), %% attribute byteCode(3) with type OCTET STRING {Term3,Bytes3} = begin {V2@V0,V2@Buf1} = case Bytes2 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, %% attribute compilerVersion(4) with type OCTET STRING {Term4,Bytes4} = begin {V3@V0,V3@Buf1} = case Bytes3 of <<0:1,V3@V3:7,V3@V5:V3@V3/binary-unit:8,V3@Buf6/bitstring>> -> {V3@V5,V3@Buf6}; <<1:1,0:1,V3@V4:14,V3@V6:V3@V4/binary-unit:8,V3@Buf7/bitstring>> -> {V3@V6,V3@Buf7}; <<1:1,1:1,V3@V4:6,V3@Buf5/bitstring>> -> {V3@V6,V3@Buf7} = decode_fragmented(V3@V4, V3@Buf5, 8), {V3@V6,V3@Buf7} end, V3@Conv8 = binary:copy(V3@V0), {V3@Conv8,V3@Buf1} end, %% attribute payable(5) with type BOOLEAN {Term5,Bytes5} = begin <> = Bytes4, V4@Int2 = case V4@V0 of 0 -> false; 1 -> true end, {V4@Int2,V4@Buf1} end, Res1 = {'ContractV3',Term1,Term2,Term3,Term4,Term5}, {Res1,Bytes5}. dec_ContractV3_typeInfo(Bytes) -> dec_components8(Bytes, []). enc_TypeInfoV1(Val) -> [begin %% attribute typeHash(1) with type OCTET STRING Enc1@element = element(2, Val), Enc2@len = byte_size(Enc1@element), if Enc2@len < 128 -> [Enc2@len|Enc1@element]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|Enc1@element]; true -> encode_fragmented(Enc1@element, 8) end end, begin %% attribute name(2) with type OCTET STRING Enc3@element = element(3, Val), Enc4@len = byte_size(Enc3@element), if Enc4@len < 128 -> [Enc4@len|Enc3@element]; Enc4@len < 16384 -> [<<2:2,Enc4@len:14>>|Enc3@element]; true -> encode_fragmented(Enc3@element, 8) end end, begin %% attribute argType(3) with type OCTET STRING Enc5@element = element(4, Val), Enc6@len = byte_size(Enc5@element), if Enc6@len < 128 -> [Enc6@len|Enc5@element]; Enc6@len < 16384 -> [<<2:2,Enc6@len:14>>|Enc5@element]; true -> encode_fragmented(Enc5@element, 8) end end|begin %% attribute outType(4) with type OCTET STRING Enc7@element = element(5, Val), Enc8@len = byte_size(Enc7@element), if Enc8@len < 128 -> [Enc8@len|Enc7@element]; Enc8@len < 16384 -> [<<2:2,Enc8@len:14>>|Enc7@element]; true -> encode_fragmented(Enc7@element, 8) end end]. dec_TypeInfoV1(Bytes) -> %% attribute typeHash(1) with type OCTET STRING {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, %% attribute name(2) with type OCTET STRING {Term2,Bytes2} = begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, %% attribute argType(3) with type OCTET STRING {Term3,Bytes3} = begin {V3@V0,V3@Buf1} = case Bytes2 of <<0:1,V3@V3:7,V3@V5:V3@V3/binary-unit:8,V3@Buf6/bitstring>> -> {V3@V5,V3@Buf6}; <<1:1,0:1,V3@V4:14,V3@V6:V3@V4/binary-unit:8,V3@Buf7/bitstring>> -> {V3@V6,V3@Buf7}; <<1:1,1:1,V3@V4:6,V3@Buf5/bitstring>> -> {V3@V6,V3@Buf7} = decode_fragmented(V3@V4, V3@Buf5, 8), {V3@V6,V3@Buf7} end, V3@Conv8 = binary:copy(V3@V0), {V3@Conv8,V3@Buf1} end, %% attribute outType(4) with type OCTET STRING {Term4,Bytes4} = begin {V4@V0,V4@Buf1} = case Bytes3 of <<0:1,V4@V3:7,V4@V5:V4@V3/binary-unit:8,V4@Buf6/bitstring>> -> {V4@V5,V4@Buf6}; <<1:1,0:1,V4@V4:14,V4@V6:V4@V4/binary-unit:8,V4@Buf7/bitstring>> -> {V4@V6,V4@Buf7}; <<1:1,1:1,V4@V4:6,V4@Buf5/bitstring>> -> {V4@V6,V4@Buf7} = decode_fragmented(V4@V4, V4@Buf5, 8), {V4@V6,V4@Buf7} end, V4@Conv8 = binary:copy(V4@V0), {V4@Conv8,V4@Buf1} end, Res1 = {'TypeInfoV1',Term1,Term2,Term3,Term4}, {Res1,Bytes4}. enc_TypeInfoV3(Val) -> [begin %% attribute typeHash(1) with type OCTET STRING Enc1@element = element(2, Val), Enc2@len = byte_size(Enc1@element), if Enc2@len < 128 -> [Enc2@len|Enc1@element]; Enc2@len < 16384 -> [<<2:2,Enc2@len:14>>|Enc1@element]; true -> encode_fragmented(Enc1@element, 8) end end, begin %% attribute name(2) with type OCTET STRING Enc3@element = element(3, Val), Enc4@len = byte_size(Enc3@element), if Enc4@len < 128 -> [Enc4@len|Enc3@element]; Enc4@len < 16384 -> [<<2:2,Enc4@len:14>>|Enc3@element]; true -> encode_fragmented(Enc3@element, 8) end end, begin %% attribute payable(3) with type BOOLEAN Enc5@element = element(4, Val), if Enc5@element =:= false -> <<0:1>>; Enc5@element =:= true -> <<1:1>>; true -> exit({error,{asn1,{illegal_boolean,Enc5@element}}}) end end, begin %% attribute argType(4) with type OCTET STRING Enc7@element = element(5, Val), Enc8@len = byte_size(Enc7@element), if Enc8@len < 128 -> [Enc8@len|Enc7@element]; Enc8@len < 16384 -> [<<2:2,Enc8@len:14>>|Enc7@element]; true -> encode_fragmented(Enc7@element, 8) end end|begin %% attribute outType(5) with type OCTET STRING Enc9@element = element(6, Val), Enc10@len = byte_size(Enc9@element), if Enc10@len < 128 -> [Enc10@len|Enc9@element]; Enc10@len < 16384 -> [<<2:2,Enc10@len:14>>|Enc9@element]; true -> encode_fragmented(Enc9@element, 8) end end]. dec_TypeInfoV3(Bytes) -> %% attribute typeHash(1) with type OCTET STRING {Term1,Bytes1} = begin {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@V5:V1@V3/binary-unit:8,V1@Buf6/bitstring>> -> {V1@V5,V1@Buf6}; <<1:1,0:1,V1@V4:14,V1@V6:V1@V4/binary-unit:8,V1@Buf7/bitstring>> -> {V1@V6,V1@Buf7}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> {V1@V6,V1@Buf7} = decode_fragmented(V1@V4, V1@Buf5, 8), {V1@V6,V1@Buf7} end, V1@Conv8 = binary:copy(V1@V0), {V1@Conv8,V1@Buf1} end, %% attribute name(2) with type OCTET STRING {Term2,Bytes2} = begin {V2@V0,V2@Buf1} = case Bytes1 of <<0:1,V2@V3:7,V2@V5:V2@V3/binary-unit:8,V2@Buf6/bitstring>> -> {V2@V5,V2@Buf6}; <<1:1,0:1,V2@V4:14,V2@V6:V2@V4/binary-unit:8,V2@Buf7/bitstring>> -> {V2@V6,V2@Buf7}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> {V2@V6,V2@Buf7} = decode_fragmented(V2@V4, V2@Buf5, 8), {V2@V6,V2@Buf7} end, V2@Conv8 = binary:copy(V2@V0), {V2@Conv8,V2@Buf1} end, %% attribute payable(3) with type BOOLEAN {Term3,Bytes3} = begin <> = Bytes2, V3@Int2 = case V3@V0 of 0 -> false; 1 -> true end, {V3@Int2,V3@Buf1} end, %% attribute argType(4) with type OCTET STRING {Term4,Bytes4} = begin {V4@V0,V4@Buf1} = case Bytes3 of <<0:1,V4@V3:7,V4@V5:V4@V3/binary-unit:8,V4@Buf6/bitstring>> -> {V4@V5,V4@Buf6}; <<1:1,0:1,V4@V4:14,V4@V6:V4@V4/binary-unit:8,V4@Buf7/bitstring>> -> {V4@V6,V4@Buf7}; <<1:1,1:1,V4@V4:6,V4@Buf5/bitstring>> -> {V4@V6,V4@Buf7} = decode_fragmented(V4@V4, V4@Buf5, 8), {V4@V6,V4@Buf7} end, V4@Conv8 = binary:copy(V4@V0), {V4@Conv8,V4@Buf1} end, %% attribute outType(5) with type OCTET STRING {Term5,Bytes5} = begin {V5@V0,V5@Buf1} = case Bytes4 of <<0:1,V5@V3:7,V5@V5:V5@V3/binary-unit:8,V5@Buf6/bitstring>> -> {V5@V5,V5@Buf6}; <<1:1,0:1,V5@V4:14,V5@V6:V5@V4/binary-unit:8,V5@Buf7/bitstring>> -> {V5@V6,V5@Buf7}; <<1:1,1:1,V5@V4:6,V5@Buf5/bitstring>> -> {V5@V6,V5@Buf7} = decode_fragmented(V5@V4, V5@Buf5, 8), {V5@V6,V5@Buf7} end, V5@Conv8 = binary:copy(V5@V0), {V5@Conv8,V5@Buf1} end, Res1 = {'TypeInfoV3',Term1,Term2,Term3,Term4,Term5}, {Res1,Bytes5}. %%% %%% Run-time functions. %%% 'dialyzer-suppressions'(Arg) -> _ = complete(element(1, Arg)), ok. dec_components1(Bytes, Acc) -> %% Length with constraint no {V1@V0,V1@Buf1} = case Bytes of <<0:1,V1@V3:7,V1@Buf4/bitstring>> -> {V1@V3,V1@Buf4}; <<1:1,0:1,V1@V4:14,V1@Buf5/bitstring>> -> {V1@V4,V1@Buf5}; <<1:1,1:1,V1@V4:6,V1@Buf5/bitstring>> -> V1@Mul6 = V1@V4 * 16384, {V1@Mul6,V1@Buf5} end, {Acc1,Buf1} = dec_fragment9(V1@V0, V1@Buf1, Acc), if V1@V0 >= 16384 -> dec_components1(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components2(Bytes, Acc) -> %% Length with constraint no {V2@V0,V2@Buf1} = case Bytes of <<0:1,V2@V3:7,V2@Buf4/bitstring>> -> {V2@V3,V2@Buf4}; <<1:1,0:1,V2@V4:14,V2@Buf5/bitstring>> -> {V2@V4,V2@Buf5}; <<1:1,1:1,V2@V4:6,V2@Buf5/bitstring>> -> V2@Mul6 = V2@V4 * 16384, {V2@Mul6,V2@Buf5} end, {Acc1,Buf1} = dec_fragment10(V2@V0, V2@Buf1, Acc), if V2@V0 >= 16384 -> dec_components2(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components3(Bytes, Acc) -> %% Length with constraint no {V3@V0,V3@Buf1} = case Bytes of <<0:1,V3@V3:7,V3@Buf4/bitstring>> -> {V3@V3,V3@Buf4}; <<1:1,0:1,V3@V4:14,V3@Buf5/bitstring>> -> {V3@V4,V3@Buf5}; <<1:1,1:1,V3@V4:6,V3@Buf5/bitstring>> -> V3@Mul6 = V3@V4 * 16384, {V3@Mul6,V3@Buf5} end, {Acc1,Buf1} = dec_fragment11(V3@V0, V3@Buf1, Acc), if V3@V0 >= 16384 -> dec_components3(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components4(Bytes, Acc) -> %% Length with constraint no {V4@V0,V4@Buf1} = case Bytes of <<0:1,V4@V3:7,V4@Buf4/bitstring>> -> {V4@V3,V4@Buf4}; <<1:1,0:1,V4@V4:14,V4@Buf5/bitstring>> -> {V4@V4,V4@Buf5}; <<1:1,1:1,V4@V4:6,V4@Buf5/bitstring>> -> V4@Mul6 = V4@V4 * 16384, {V4@Mul6,V4@Buf5} end, {Acc1,Buf1} = dec_fragment12(V4@V0, V4@Buf1, Acc), if V4@V0 >= 16384 -> dec_components4(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components5(Bytes, Acc) -> %% Length with constraint no {V5@V0,V5@Buf1} = case Bytes of <<0:1,V5@V3:7,V5@Buf4/bitstring>> -> {V5@V3,V5@Buf4}; <<1:1,0:1,V5@V4:14,V5@Buf5/bitstring>> -> {V5@V4,V5@Buf5}; <<1:1,1:1,V5@V4:6,V5@Buf5/bitstring>> -> V5@Mul6 = V5@V4 * 16384, {V5@Mul6,V5@Buf5} end, {Acc1,Buf1} = dec_fragment13(V5@V0, V5@Buf1, Acc), if V5@V0 >= 16384 -> dec_components5(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components6(Bytes, Acc) -> %% Length with constraint no {V6@V0,V6@Buf1} = case Bytes of <<0:1,V6@V3:7,V6@Buf4/bitstring>> -> {V6@V3,V6@Buf4}; <<1:1,0:1,V6@V4:14,V6@Buf5/bitstring>> -> {V6@V4,V6@Buf5}; <<1:1,1:1,V6@V4:6,V6@Buf5/bitstring>> -> V6@Mul6 = V6@V4 * 16384, {V6@Mul6,V6@Buf5} end, {Acc1,Buf1} = dec_fragment14(V6@V0, V6@Buf1, Acc), if V6@V0 >= 16384 -> dec_components6(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components7(Bytes, Acc) -> %% Length with constraint no {V7@V0,V7@Buf1} = case Bytes of <<0:1,V7@V3:7,V7@Buf4/bitstring>> -> {V7@V3,V7@Buf4}; <<1:1,0:1,V7@V4:14,V7@Buf5/bitstring>> -> {V7@V4,V7@Buf5}; <<1:1,1:1,V7@V4:6,V7@Buf5/bitstring>> -> V7@Mul6 = V7@V4 * 16384, {V7@Mul6,V7@Buf5} end, {Acc1,Buf1} = dec_fragment15(V7@V0, V7@Buf1, Acc), if V7@V0 >= 16384 -> dec_components7(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_components8(Bytes, Acc) -> %% Length with constraint no {V8@V0,V8@Buf1} = case Bytes of <<0:1,V8@V3:7,V8@Buf4/bitstring>> -> {V8@V3,V8@Buf4}; <<1:1,0:1,V8@V4:14,V8@Buf5/bitstring>> -> {V8@V4,V8@Buf5}; <<1:1,1:1,V8@V4:6,V8@Buf5/bitstring>> -> V8@Mul6 = V8@V4 * 16384, {V8@Mul6,V8@Buf5} end, {Acc1,Buf1} = dec_fragment16(V8@V0, V8@Buf1, Acc), if V8@V0 >= 16384 -> dec_components8(Buf1, Acc1); true -> {lists:reverse(Acc1),Buf1} end. dec_fragment10(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment10(Num, Bytes, Acc) -> {Term,Remain} = dec_Value(Bytes), dec_fragment10(Num-1, Remain, [Term|Acc]). dec_fragment11(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment11(Num, Bytes, Acc) -> {Term,Remain} = dec_Value(Bytes), dec_fragment11(Num-1, Remain, [Term|Acc]). dec_fragment12(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment12(Num, Bytes, Acc) -> {Term,Remain} = dec_KeyValue(Bytes), dec_fragment12(Num-1, Remain, [Term|Acc]). dec_fragment13(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment13(Num, Bytes, Acc) -> {Term,Remain} = begin {V9@V0,V9@Buf1} = case Bytes of <<0:1,V9@V3:7,V9@V5:V9@V3/binary-unit:8,V9@Buf6/bitstring>> -> {V9@V5,V9@Buf6}; <<1:1,0:1,V9@V4:14,V9@V6:V9@V4/binary-unit:8,V9@Buf7/bitstring>> -> {V9@V6,V9@Buf7}; <<1:1,1:1,V9@V4:6,V9@Buf5/bitstring>> -> {V9@V6,V9@Buf7} = decode_fragmented(V9@V4, V9@Buf5, 8), {V9@V6,V9@Buf7} end, V9@Conv8 = binary:copy(V9@V0), {V9@Conv8,V9@Buf1} end, dec_fragment13(Num-1, Remain, [Term|Acc]). dec_fragment14(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment14(Num, Bytes, Acc) -> {Term,Remain} = dec_TypeInfoV1(Bytes), dec_fragment14(Num-1, Remain, [Term|Acc]). dec_fragment15(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment15(Num, Bytes, Acc) -> {Term,Remain} = dec_TypeInfoV1(Bytes), dec_fragment15(Num-1, Remain, [Term|Acc]). dec_fragment16(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment16(Num, Bytes, Acc) -> {Term,Remain} = dec_TypeInfoV3(Bytes), dec_fragment16(Num-1, Remain, [Term|Acc]). dec_fragment9(0, Bytes, Acc) -> {Acc,Bytes}; dec_fragment9(Num, Bytes, Acc) -> {Term,Remain} = dec_TemplateField(Bytes), dec_fragment9(Num-1, Remain, [Term|Acc]). complete(InList) when is_list(InList) -> case list_to_bitstring(InList) of <<>> -> <<0>>; Res -> Sz = bit_size(Res), case Sz band 7 of 0 -> Res; Bits -> <> end end; complete(Bin) when is_binary(Bin) -> case Bin of <<>> -> <<0>>; _ -> Bin end; complete(InList) when is_bitstring(InList) -> Sz = bit_size(InList), PadLen = 8 - Sz band 7, <>. decode_chars(Val, N) -> [ C || <> <= Val ]. decode_fragmented(SegSz0, Buf0, Unit) -> SegSz = SegSz0 * Unit * 16384, <> = Buf0, decode_fragmented_1(Buf, Unit, Res). decode_fragmented_1(<<0:1,N:7,Buf0/bitstring>>, Unit, Res) -> Sz = N * Unit, <> = Buf0, {<>, Buf}; decode_fragmented_1(<<1:1,0:1,N:14,Buf0/bitstring>>, Unit, Res) -> Sz = N * Unit, <> = Buf0, {<>, Buf}; decode_fragmented_1(<<1:1,1:1,SegSz0:6,Buf0/bitstring>>, Unit, Res0) -> SegSz = SegSz0 * Unit * 16384, <> = Buf0, Res = <>, decode_fragmented_1(Buf, Unit, Res). encode_chars(Val, NumBits) -> << <> || C <- Val >>. encode_components(Cs, _Encoder, 0, Acc) -> {Cs, lists:reverse(Acc)}; encode_components([C | Cs], Encoder, Size, Acc) -> B = Encoder(C), encode_components(Cs, Encoder, Size - 1, [B | Acc]). encode_fragmented(Bin, Unit) -> encode_fragmented_1(Bin, Unit, 4). encode_fragmented_1(Bin, Unit, N) -> SegSz = Unit * N * 16384, case Bin of <> -> [<<3:2,N:6>>, B | encode_fragmented_1(T, Unit, N)]; _ when N > 1 -> encode_fragmented_1(Bin, Unit, N - 1); _ -> case bit_size(Bin) div Unit of Len when Len < 128 -> [Len, Bin]; Len when Len < 16384 -> [<<2:2,Len:14>>, Bin] end end. encode_fragmented_sof(Fun, Comps, Len) -> encode_fragmented_sof_1(Fun, Comps, Len, 4). encode_fragmented_sof_1(Encoder, Comps0, Len0, N) -> SegSz = N * 16384, if Len0 >= SegSz -> {Comps, B} = encode_components(Comps0, Encoder, SegSz, []), Len = Len0 - SegSz, [<<3:2,N:6>>, B | encode_fragmented_sof_1(Encoder, Comps, Len, N)]; N > 1 -> encode_fragmented_sof_1(Encoder, Comps0, Len0, N - 1); Len0 < 128 -> {[], B} = encode_components(Comps0, Encoder, Len0, []), [Len0 | B]; Len0 < 16384 -> {[], B} = encode_components(Comps0, Encoder, Len0, []), [<<2:2,Len0:14>> | B] end. encode_unconstrained_number(Val) when not is_integer(Val) -> exit({error, {asn1, {illegal_integer, Val}}}); encode_unconstrained_number(Val) when Val >= 0 -> if Val < 128 -> [1, Val]; Val < 256 -> [<<2,0>>, Val]; true -> case binary:encode_unsigned(Val) of <<0:1,_/bitstring>> = Bin -> case byte_size(Bin) of Sz when Sz < 128 -> [Sz, Bin]; Sz when Sz < 16384 -> [<<2:2,Sz:14>>, Bin] end; <<1:1,_/bitstring>> = Bin -> case byte_size(Bin) + 1 of Sz when Sz < 128 -> [Sz, 0, Bin]; Sz when Sz < 16384 -> [<<2:2,Sz:14,0:8>>, Bin] end end end; encode_unconstrained_number(Val) -> Oct = enint(Val, []), Len = length(Oct), if Len < 128 -> [Len | Oct]; Len < 16384 -> [<<2:2,Len:14>> | Oct] end. enint(-1, [B1 | T]) when B1 > 127 -> [B1 | T]; enint(N, Acc) -> enint(N bsr 8, [N band 255 | Acc]).