aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
AgeCommit message (Collapse)Author
2013-09-27Teach the ASN.1 compiler the no_ok_wrapper optionBjörn Gustavsson
Add the no_ok_wrapper option so that the generated M:encode/2 and M:decode/2 functions will not wrap a successful return value in an {ok,...} tuple. Errors will cause exceptions. Eliminating the wrapping tuple allows simpler nesting of calls.
2013-09-27Optimize the generated decode/2 functionBjörn Gustavsson
Use 'try' instead of 'catch', and don't match anything that cannot actually be returned from the generated encoding code.
2013-09-18asn1ct_gen: Clean up process dictionary after generatingBjörn Gustavsson
Cleanliness.
2013-09-18asn1ct_parser2: Clean the process dictionary after parsingBjörn Gustavsson
Apart from cleanliness, the test suite runs many tests cases in parallel, so it never hurts to reduce the memory pressure.
2013-09-03asn1ct_constucted_per: Directly call asn1ct_gen_perBjörn Gustavsson
2013-09-03Clean up handling of .asn1db filesBjörn Gustavsson
There is (differenct) code for reading .asn1db files both in asn1ct and asn1_db. Consolidate the reading into one routine in asn1db. Another problem is that the encoding rule that the .asn1db file was created for is not in the .asn1db, but only in the generated Erlang module. It is much easier and safer to put the encoding rule in the .asn1db file itself. We will also put the version number of the asn1 application into the file, to ensure that we don't use an old .asn1db file that could potentially be incompatible.
2013-09-03PER, UPER: Fix encoding/decoding of open types greater than 16KBjörn Gustavsson
2013-09-03PER, UPER: Optimize table constraintsBjörn Gustavsson
The generated code for table constraints has several problems: * For each object set, a function for getting an encoding or decoding fun is generated, regardless of whether it is actually used. In many specifications, the object set actually used is the union of several other object sets. That means that the code can become a lot bulkier than it would need to be. * The funs are not necessary. The funs just add to the code bloat and generate more unnecessary garbage at run-time. Also, one of the arguments of the fun is the name of the field in the class which is known at compile-time, and the fun for decoding has unused arguments. How to fix the problems: At each call site where an open type should be encoded/decoded, call a specific generated function specialized for the actual object set and the name of the field in the class. When generating the specialized functions, make sure that we re-use a previously generated function if possible.
2013-08-30PER, UPER: Optimize encoding using an intermediate formatBjörn Gustavsson
There are some minor incompatibilities for BIT STRING: {bit,Position} is now only only supported for a named BIT STRING type. Values longer than the maximum size for the BIT STRING type would be truncated silently - they now cause an exception.
2013-08-30Refactor decoding of components of SEQUENCE OF / SET OFBjörn Gustavsson
As a preparation for rewriting handling of table constraints, we must make sure that code for decoding a SEQUENCE OF / SET OF can be be contained in a single clause of a function; thus, we must not output the helper function for decoding of each component directly following the code that follows it. Use asn1ct_func:call_gen/3 to delay outputting the helper function.
2013-08-30PER,UPER: Get rid of unused 'telltype' argument in decoding functionsBjörn Gustavsson
2013-08-30Optimize the generated encode/2 functionBjörn Gustavsson
Use 'try' instead of 'catch', and don't match anything that cannot actually be returned from the generated encoding code.
2013-08-30UPER: Optimize complete/1Björn Gustavsson
2013-08-30Clean up checking of objectsBjörn Gustavsson
2013-08-30BER: Handle multiple optional SEQUENCE fields with table constraintsBjörn Gustavsson
2013-08-30PER/UPER: Fix encoding of an object set with multiple inlined constructsBjörn Gustavsson
Also extend the test suite with more tests of inlined constructs in object sets.
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-30Clean up handling of extension addition groupsBjörn Gustavsson
Break out the code to a separate function to make it more readable. Also avoid hard-coding the name of the value to use as "Val1" as it may not be true in the future. Instead of using a list comprenhension like this: case [X || X <- [element(5, Val),element(6, Val)], X =/= asn1_NOVALUE] of [] -> ...; _ -> ... end use an orelse chain: case element(5, Val) =/= asn1_NOVALUE orelse element(5, Val) =/= asn1_NOVALUE of false -> ...; true -> ... end
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-08-30Teach asn1ct_func to dynamically generate run-time functionsBjörn Gustavsson
2013-08-28asn1ct_constructed_per: Simplify gen_enc_line() and friendsBjörn Gustavsson
The first clause of gen_enc_line() allows us to pass in [] as the value for Element; if we modify the only caller that passes [] to pass an actual expression we can remove the first clause. Furthermore, since the Pos argument was only used by the first clause, we can remove the Pos argument. We can also remove the first clause in gen_enc_component_optional(), since the code in its body is exactly the same as in the following clause.
2013-08-28Remove code for handling an object/object set reference in SEQUENCEBjörn Gustavsson
An field in a class that references an object or object set is not allowed to be referenced directly from within a SEQUENCE.
2013-08-26Encode SEQUENCE OF / SET OF using a list comprehensionBjörn Gustavsson
Using a list comprehension will simplify both the code generator and the generated code. Also, if there is an ObjFun argument in the host function, the BEAM compiler will make sure it is only passed to the generated list comprehension function if it is actually used.
2013-08-26asn1ct_imm: Break out the rule for string alignmentBjörn Gustavsson
Break out the the rules for determining whether a string should be in aligned so that it can be reused for encoding.
2013-06-12Update copyright yearsBjörn-Egil Dahlberg
2013-06-10Merge branch 'bjorn/asn1/not-small-bugs/OTP-11153' into maintBjörn Gustavsson
* bjorn/asn1/not-small-bugs/OTP-11153: PER/UPER: Correct decoding of SEQUENCEs with more than 64 extensions testConstraints: Improve tests of semi-constrained INTEGERs Test ENUMERATED with many extended values UPER: Correct encoding of ENUMERATED with more than 63 extended values Add asn1_test_lib:hex_to_bin/1
2013-06-08PER/UPER: Correct decoding of SEQUENCEs with more than 64 extensionsBjörn Gustavsson
2013-06-07PER, UPER: Fix record name mismatch between HRL file and decoding codeBjörn Gustavsson
When a SEQUENCE was defined inline inside extension addition group like this: InlinedSeq ::= SEQUENCE { ..., [[ s SEQUENCE { a INTEGER, b BOOLEAN } ]] } the decoding code would return the contents of the SEQUENCE in a record named 'InlinedSeq_ExtAddGroup1_s', while the record definition in the generated HRL file would be 'InlinedSeq_s'. Since there is no reason to use the longer record name (no risk for ambiguity), correct the name in the decoding code.
2013-06-07UPER: Correct encoding of ENUMERATED with more than 63 extended valuesBjörn Gustavsson
2013-05-31asn1ct_check: Eliminate useless Per argument from complist_as_tuple()Björn Gustavsson
The Per argument is no longer used; it is only passed around.
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-31asn1ct_gen_per: Remove useless renewal of 'enumval'Björn Gustavsson
Since fbcb7fe589edbfe79d10d7fe01be8a9f77926b89, the 'enumval' variable is no longer used.
2013-05-31Fix encoding of semi-constrained, extensible INTEGERsBjörn Gustavsson
Given: Semi ::= INTEGER (Lb..MAX, ...) where Lb is an arbitrary integer, attempting to encode an integer less than Lb would cause the encoder to enter an infinite loop.
2013-05-31PER/UPER: Fix decoding of semi-constrained INTEGERsBjörn Gustavsson
A semi-constrained INTEGER with a non-zero lower bound would be incorrectly decoded. This bug was introduced in R16.
2013-05-31BER: Fix handling of a constructed default value for a classBjörn Gustavsson
2013-05-31PER: Generate code for deep table constraints at compile-timeBjörn Gustavsson
For the PER backends, generate code for accessing deep table constraints at compile-time in the same way as is done for BER. While at it, remove the complicated indentation code. Also modernize the test suite and add a test for a deeper nested constraint.
2013-05-31Normalize data representation for table constraintsBjörn Gustavsson
The name of the referenced object set name in #simpletableattributes{} would when used by INSTANCE OF be an atom, but in all other cases be a {Module,ObjectSetName} tuple. Simplify the code by always using the latter format.
2013-05-31asn1ct: Simplify check_value/2Björn Gustavsson
Most types don't have any validation functions that does anything useful, so it is sufficient to call normalize_value/4 for them.
2013-05-31Clean up checking of values for ENUMERATEDsBjörn Gustavsson
Unify the code for checking an enumeration value named in a DEFAULT and in an ENUMERATED value. There is no need to handle those cases differently. That also will also make sure that the following works: E ::= ENUMERATED { x, ..., y } e E ::= x (Extensible ENUMERATEDs were not handled when defining values.) Always generate an error when an unknown enumeration value is given (used in a DEFAULT, a message would be printed, but the compilation would succeed). Also make sure that we always include the line number for the incorrect enumeration. Write a new test case and remove the extremely rudimentary value_bad_enum_test/1 test case.
2013-05-31Introduce a new mechanism for structured error handlingBjörn Gustavsson
2013-05-31asn1_db: Make dbput/3 and dbsave/2 asynchronousBjörn Gustavsson
Those functions have no reason to be synchronous since they don't have a useful return value.
2013-05-31asn1_db: Remove unused functionsBjörn Gustavsson
Also replace unused code with assertions. While at it, also let reply/2 return 'ok' to silence Dialyzer warnings for unmatched returns.
2013-05-31asn1ct_check: Clean up checkc/3Björn Gustavsson
2013-05-31asn1ct_check: Clean up checkp/3Björn Gustavsson
2013-05-31asn1ct_check: Clean up checkv/3Björn Gustavsson
2013-05-31asn1ct_check: Introduce check_fold/3 and clean up checkt/3Björn Gustavsson
Capture the common pattern of checking a list of named ASN.1 items in a check_fold/3 function. Clean up checkt/3 using it, replacing the old-style catch with a try..catch.
2013-05-31asn1ct: Refactor running of compiler passesBjörn Gustavsson
As a preparation for future clean up of the error handling, we will need to take control on how how asn1ct runs the different compiler passes.
2013-05-31asn1ct_constructed_per: Remove dead code for handling of ENUMERATEDBjörn Gustavsson
An ENUMERATED is always represented as a two-tuple, never as three-tuple.
2013-05-31PER/UPER: Eliminate gen_encode_prim_wrapper() and DoTag argumentBjörn Gustavsson
asn1ct_constructed_per:gen_encode_prim_wrapper() no longer serves any useful purpose, as it is easier to call asn1ct_per:gen_encode_prim() directly. Also, the DoTag argument for asn1ct_per:gen_encode_prim() is never actually used, so it can be eliminated at the same time.
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).