aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
AgeCommit message (Collapse)Author
2017-05-04Update copyright yearRaimo Niskanen
2017-03-14Clean up commentsBjörn Gustavsson
* Remove out-commented code * Fix obvious typos and bad grammar * Adhere to the conventions for when to use "%" and "%%".
2017-03-14Clean up use of asn1ct_gen:emit/1Björn Gustavsson
Stop up using asn1ct_gen:emit/1 with a tuple instead of a list. Also remove the remaining uses of asn1ct_gen:demit/1.
2017-03-14Remove the 'debug' optionBjörn Gustavsson
The debug option no longer serves any useful purpose.
2017-03-14Only generate needed single quotes around function namesBjörn Gustavsson
That will make code slightly easier to read.
2017-03-14asn1ct_gen_ber_bin_v2: Remove unused codeBjörn Gustavsson
The code is not covered. The code is also not present in the PER backend. Here is a somewhat more formal proof that the code cannot be reached: asn1ct_gen_ber_bin_v2:gen_encode_user/3 calls asn1ct_gen:gen_encode_constructed/4 where Typename is a list of one element. asn1ct_gen:gen_encode_constructed/4 will call asn1ct_gen_ber_bin_v2:gen_encode/3 via asn1ct_gen:gen_types/4. Note that if InnerType in asn1ct_gen:gen_encode_constructed/4 is 'SEQUENCE OF' or 'SET OF', Typename will be extended to a list with two elements. If InnerType in asn1ct_gen:gen_encode_constructed/4 is 'SET', 'SEQUENCE', or 'CHOICE', then asn1ct_gen_ber_bin_v2:gen_encode/3 will be called with the last argument being a #'ComponentType'{}. asn1ct_gen_ber_bin_v2:gen_encode/3 will in that cause extend Typename before calling itself recursively. Therefore, Typename is always a list with at least two elements when the removed code is called.
2017-02-06Teach the ASN.1 compiler the 'maps' optionBjörn Gustavsson
When the 'maps' option is given, the SEQUENCE and SET types are represented as maps instead of as records. Optional and default values must be not be given as asn1_NOVALUE or asn1_DEFAULT in a map passed to the M:encode/2 function; they must be omitted from the map. Similarly, when decoding missing values will be omitted from the map. No .hrl files will be generated when the 'maps' options is used. That means values in an ASN.1 module must be retrieved by calling the appropriate function in generated module. Since we one day hope to get rid of the options 'compact_bit_string', 'legacy_bit_string', and 'legacy_erlang_types', we will not allow them to be combined with the 'maps' option.
2016-03-15update copyright-yearHenrik Nord
2015-06-18Change license text to APLv2Bruce Yinhe
2015-01-12BER: Fix ENUMERATED with negative valuesBjörn Gustavsson
The ASN.1 compiler would go into an infinite loop if a value in an ENUMERATED was negative.
2015-01-12Clean up error reporting for duplicate tagsDan Gudmundsson
Split the test case duplicate_tags/1 into two parts. Do the error checking test in error_SUITE. Keep the SeqOptional2 specification and compile it from the per/1 and ber_other/1 test cases (for coverage).
2015-01-12asn1: Fix BER generation for non optional and extended object setsDan Gudmundsson
Object sets with extension mark and without optional fields was not generated properly. It needs the default [enc|dec]_xxx function clause for the open type but no other clauses.
2014-06-05BER: Eliminate dialyzer warnings for specialized decode functionsBjörn Gustavsson
2014-06-05BER: Eliminate dialyzer warning for encoding of BIT STRINGsBjörn Gustavsson
2014-06-05BER: Optimize encoding of ENUMERATEDBjörn Gustavsson
This will also eliminate a dialyzer warning.
2014-05-06BER: Optimize decoding of ENUMERATEDBjörn Gustavsson
2014-05-06BER: Suppress dialyzer warnings for encode_bit_string/4Björn Gustavsson
We don't want to touch the code used for encoding BIT STRINGs when 'legacy_erl_types' is active, since it will be removed within two or three major releases. But we do want to suppress the dialyzer warnings in the meantime. The easiest way is to call encode_bit_string/4 with unknown types from an exported function that is never actually called like this: -export(['dialyzer-suppressions'/0]). 'dialyzer-suppressions'(Arg) -> {A,B,C,D} = Arg, encode_bit_string(A, B, C, D), ok.
2014-04-29BER: Inline testing of constraints when decodingBjörn Gustavsson
Calling library routines for validation of constraints may cause dialyzer warnings if some type of constraints handled by the library routine are not used in a specific ASN.1 module. To avoid those warnings (and slightly speed up the decoding), inline the constraint checking.
2014-04-16Refactor gen_dec_prim/3 to facilitate future optimizationsBjörn Gustavsson
2014-04-16Remove unused arguments for asn1ct_gen_ber_bin_v2:gen_dec_prim()Björn Gustavsson
Make the source code a little bit cleaner.
2014-01-24Fix open typesBjörn Gustavsson
2014-01-24Fix OCTET STRINGBjörn Gustavsson
2014-01-24Fix BIT STRINGBjörn Gustavsson
2013-08-30Clean up checking of objectsBjörn Gustavsson
2013-08-30Remove broken support for multiple UNIQUEBjörn Gustavsson
According to the ASN.1 standard, having multiple UNIQUE in class is allowed. For example: C ::= CLASS { &id1 INTEGER UNIQUE, &id2 INTEGER UNIQUE } In practice, no one uses multiple UNIQUE. The ASN.1 compiler will crash if a class with multiple UNIQUE is used, but the backends have half-hearted support for multiple UNIQUE in that they generate helper functions similar to: getenc_OBJECT_SET(id1, 42) -> fun enc_XXX/3; ... Since we have no plans to implement support for multiple UNIQUE (no one seems to have missed it), simplify the helper functions like this: getenc_OBJECT_SET(42) -> fun enc_XXX/3; ...
2013-08-30Refactor encoding of REALBjörn Gustavsson
To facilitate optimizing PER encoding using an intermediate format, we must change asn1rtt_real_common:encode_real/1 so that it only returns the encoded binary.
2013-05-31asn1ct_check: Don't pass on #'ObjectClassFieldType'{} with fixed typeBjörn Gustavsson
Simplify the backends by letting asn1ct_check replacing a with the actual type.
2013-05-31BER: Fix handling of a constructed default value for a classBjörn Gustavsson
2013-05-31Eliminate handling of #pobjectdef{} from the backendsBjörn Gustavsson
asn1ct_check does not pass #pobjectdef{} records on to the backends (all the original #pobjectdef{} records have been instantiated and changed to #objectdef{} records).
2013-05-31Eliminate clauses that can never matchBjörn Gustavsson
Dialyzer issued two new warnings when the 'catch' was removed in the previous commit.
2013-05-31BER: Don't generate functions that are never usedBjörn Gustavsson
2013-05-31BER: Remove special case handling of certain string typesBjörn Gustavsson
ObjectDescriptor, UTCTime, and GeneralizedTime are not special and can be handled in the same way as all other restricted string types.
2013-05-31BER: Optimize handling of constraints for INTEGERsBjörn Gustavsson
This slight optimization will also eliminate some Dialyzer warnings.
2013-05-31Get rid of 'ANY' in the backendsBjörn Gustavsson
asn1ct_check has translated all occurrences of 'ANY' to 'ASN1_OPEN_TYPE'.
2013-05-31Normalize SIZE constraints to simplify backendsBjörn Gustavsson
2013-05-31Eliminate general use of #typereference{}Björn Gustavsson
The record #typereference{} is only used internally within the asn1ct_parser2 module (the parser translates it to an #'Externaltypereference{} record).
2013-05-31Eliminate duplicated code in gen_inlined_{dec,enc}_funs()Björn Gustavsson
2013-05-31Remove unused function pgen/4 in all backendsBjörn Gustavsson
2013-05-31Remove unnecessary code duplication in gen_objset_{dec,enc}()Björn Gustavsson
2013-05-31asn1ct_name: Remove unused functionsBjörn Gustavsson
asn1ct_name:delete/1 is used from asn1ct_gen_ber_bin_v2:add_removed_bytes/1, but that function is not used.
2013-02-16Eliminate use of obsolete size/1 in generated codeBjörn Gustavsson
It is recommended to use byte_size/1 or tuple_size/1 instead of size/1.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-23By default, encode BIT STRING to bitstringsBjörn Gustavsson
Add the option 'legacy_bit_string' to decode to the old list format.
2013-01-22BER run-time: Refactor decoding of string data typesBjörn Gustavsson
In the BER run-time code (asn1rtt_ber), there is a general function for decoding a string: decode_restricted_string(Tlv, Range, StringType, TagsIn) But the StringType argument is not important. It is only used internally in asn1rtt_ber to distinguish universal strings and BMP strings from other strings. By slightly refactoring the string decoding code, we can eliminate the StringType argument and a subsequent run-time test on the string type. That will slightly reduce code size, slightly increase speed, and eliminate Dialyzer warnings.
2013-01-22Refactor decoding of BIT STRINGsBjörn Gustavsson
Refactor decoding of BIT STRINGs so that the run-time code does not spend testing conditions that are known already at compile-time (which wastes time and produces unnecessary Dialyzer warnings). There are three ways to decode BIT STRINGs: 1) To a list of bit names (and {bit,Position} for unnamed positions) if the BIT STRING type has any bit names. 2a) To a list of ones and zeros if there are no named bits, and the compact_bit_string option was NOT given. 2b) To a {Unused,Bin} tuple if there are no named bits compact_bit_string option WAS given. Structure the decoding functions in the same way.
2013-01-22Add run-time library templates and use themBjörn Gustavsson
The template modules (asn1rtt_*.erl) are based on the existing run-time modules, but with some simplifications and improvements, for example: The run-time functions for BER encoding took a Constraint argument which was not used. It has been eliminated, along with the unused StringType argument for the encode_restricted_string function. The Range argument for decode_enumerated() has been dropped since it was not used.
2012-12-19Remove support for the {Typename,Value} notation in encodingBjörn Gustavsson
Support for the notation was removed in 6ef8cbdaaaa1c30a7dc462063.
2012-11-23Remove obsolete back-ends and simplify the optionsBjörn Gustavsson
It is time to clean up the mess of back-ends. Remove all the obsolete back-ends and simplify the options used to select them. New Option Old Equivalent ---------- -------------- ber ber_bin,optimize,nif per per,optimize,nif uper uper_bin The old options will still be recognized and translated to the new options, but will also print a warning. That implies that deprecated features that only are implemented in the old 'ber' back-end will no longer work (e.g. the {Typename,Value} notation). Also make the return type for the generated encode/2 function consistent. It used to be a binary for per and uper, and an iolist for ber. Always make it a binary.
2012-11-22Remove the obsolete and deprecated 'keyed_list' optionBjörn Gustavsson
The 'keyed_list' was only supported for the 'ber' and 'ber_bin' backends and has been undocumented for a long time. Also remove the note in the documentation about the feature.
2012-05-17Fix typo error in selected decode functionArtem Teslenko