Commit 6f9060f8 authored by Lev Walkin's avatar Lev Walkin

PER extensibility support for CHOICE types

parent 7c87eef2
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <asn_internal.h> #include <asn_internal.h>
#include <constr_CHOICE.h> #include <constr_CHOICE.h>
#include <per_opentype.h>
/* /*
* Number of bytes left for this structure. * Number of bytes left for this structure.
...@@ -871,8 +872,6 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -871,8 +872,6 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
value += specs->ext_start; value += specs->ext_start;
if(value >= td->elements_count) if(value >= td->elements_count)
_ASN_DECODE_FAILED; _ASN_DECODE_FAILED;
ASN_DEBUG("NOT IMPLEMENTED YET");
_ASN_DECODE_FAILED;
} }
/* Adjust if canonical order is different from natural order */ /* Adjust if canonical order is different from natural order */
...@@ -892,11 +891,17 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -892,11 +891,17 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
} }
ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name); ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, if(ct && ct->range_bits >= 0) {
rv = elm->type->uper_decoder(opt_codec_ctx, elm->type,
elm->per_constraints, memb_ptr2, pd);
} else {
rv = uper_open_type_get(opt_codec_ctx, elm->type,
elm->per_constraints, memb_ptr2, pd); elm->per_constraints, memb_ptr2, pd);
}
if(rv.code != RC_OK) if(rv.code != RC_OK)
ASN_DEBUG("Failed to decode %s in %s (CHOICE)", ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
elm->name, td->name); elm->name, td->name, rv.code);
return rv; return rv;
} }
...@@ -951,18 +956,6 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, ...@@ -951,18 +956,6 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
if(per_put_few_bits(po, 0, 1)) if(per_put_few_bits(po, 0, 1))
_ASN_ENCODE_FAILED; _ASN_ENCODE_FAILED;
if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, present, ct->range_bits))
_ASN_ENCODE_FAILED;
} else {
if(specs->ext_start == -1)
_ASN_ENCODE_FAILED;
if(uper_put_nsnnwn(po, present - specs->ext_start))
_ASN_ENCODE_FAILED;
ASN_DEBUG("NOT IMPLEMENTED YET");
_ASN_ENCODE_FAILED;
}
elm = &td->elements[present]; elm = &td->elements[present];
if(elm->flags & ATF_POINTER) { if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */ /* Member is a pointer to another structure */
...@@ -972,8 +965,24 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, ...@@ -972,8 +965,24 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
memb_ptr = (char *)sptr + elm->memb_offset; memb_ptr = (char *)sptr + elm->memb_offset;
} }
return elm->type->uper_encoder(elm->type, elm->per_constraints, if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, present, ct->range_bits))
_ASN_ENCODE_FAILED;
return elm->type->uper_encoder(elm->type, elm->per_constraints,
memb_ptr, po); memb_ptr, po);
} else {
asn_enc_rval_t rval;
if(specs->ext_start == -1)
_ASN_ENCODE_FAILED;
if(uper_put_nsnnwn(po, present - specs->ext_start))
_ASN_ENCODE_FAILED;
if(uper_open_type_put(elm->type, elm->per_constraints,
memb_ptr, po))
_ASN_ENCODE_FAILED;
rval.encoded = 0;
_ASN_ENCODED_OK(rval);
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment