aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2007-06-29 01:45:03 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2007-06-29 01:45:03 +0000
commit0de7baa9f2607d6decf493317005a781c7f4f1da (patch)
treeb283763704f88b9fb35c06c4923f1f763c7664d1
parent147206dfdab46c4abc4eb800cb25285ac1679cad (diff)
PER extensibility support for CHOICE types
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1354 59561ff5-6e30-0410-9f3c-9617f08c8826
-rw-r--r--skeletons/constr_CHOICE.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index 912febeb..a9eb7194 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -5,6 +5,7 @@
*/
#include <asn_internal.h>
#include <constr_CHOICE.h>
+#include <per_opentype.h>
/*
* 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,
value += specs->ext_start;
if(value >= td->elements_count)
_ASN_DECODE_FAILED;
- ASN_DEBUG("NOT IMPLEMENTED YET");
- _ASN_DECODE_FAILED;
}
/* 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,
}
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);
+ }
+
if(rv.code != RC_OK)
- ASN_DEBUG("Failed to decode %s in %s (CHOICE)",
- elm->name, td->name);
+ ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
+ elm->name, td->name, rv.code);
return rv;
}
@@ -951,18 +956,6 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
if(per_put_few_bits(po, 0, 1))
_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];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
@@ -972,8 +965,24 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
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);
+ } 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);
+ }
}