refactored parameterization support

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1102 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2006-03-21 03:40:38 +00:00
parent b9667769cc
commit 0c6d3810a1
51 changed files with 5372 additions and 5194 deletions

View File

@ -1,10 +1,11 @@
0.9.21: 2006-Mar-14
0.9.21: 2006-Mar-20
* skeletons/standard-modules directory is now used for standard types.
* Fixed class field access problem (Test case 98)
(Severity: medim; Security impact: none)
* Refactored Information Object Classes parsing.
* Refactored Parameterization support.
0.9.20: 2006-Mar-06

View File

@ -85,9 +85,8 @@ static int emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode
} while(0)
/* MKID_safe() without checking for reserved keywords */
#define MKID(id) ((id)?asn1c_make_identifier(0, (id), 0):"Member")
#define MKID_safe(id) ((id)?asn1c_make_identifier(AMI_CHECK_RESERVED, \
(id), 0):"Member")
#define MKID(expr) (asn1c_make_identifier(0, expr, 0))
#define MKID_safe(expr) (asn1c_make_identifier(AMI_CHECK_RESERVED, expr, 0))
int
asn1c_lang_C_type_REAL(arg_t *arg) {
@ -140,7 +139,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
case A1TC_UNIVERVAL:
OUT("\t");
out_name_chain(arg, ONC_noflags);
OUT("_%s", MKID(v->Identifier));
OUT("_%s", MKID(v));
OUT("\t= %" PRIdASN "%s\n",
v->value->value.v_integer,
(eidx+1 < el_count) ? "," : "");
@ -178,7 +177,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
REDIR(OT_STAT_DEFS);
OUT("static asn_INTEGER_enum_map_t asn_MAP_%s_value2enum_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byValue);
for(eidx = 0; eidx < el_count; eidx++) {
v2e[eidx].idx = eidx;
@ -192,7 +191,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("};\n");
OUT("static unsigned int asn_MAP_%s_enum2value_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byName);
for(eidx = 0; eidx < el_count; eidx++) {
OUT("\t%d%s\t/* %s(%" PRIdASN ") */\n",
@ -205,15 +204,15 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("};\n");
OUT("static asn_INTEGER_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENT(+1);
OUT("asn_MAP_%s_value2enum_%d,\t"
"/* \"tag\" => N; sorted by tag */\n",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
OUT("asn_MAP_%s_enum2value_%d,\t"
"/* N => \"tag\"; sorted by N */\n",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
OUT("%d,\t/* Number of elements in the maps */\n",
el_count);
@ -255,7 +254,7 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
}
OUT("\t");
out_name_chain(arg, ONC_noflags);
OUT("_%s", MKID(v->Identifier));
OUT("_%s", MKID(v));
OUT("\t= %" PRIdASN "%s\n",
v->value->value.v_integer,
(eidx < el_count) ? "," : "");
@ -283,7 +282,7 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
OUT(" {\n");
} else {
OUT("typedef struct %s {\n",
MKID_safe(expr->Identifier));
MKID_safe(expr));
}
TQ_FOR(v, &(expr->members), next) {
@ -299,8 +298,8 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
OUT("} %s%s%s", (expr->marker.flags & EM_INDIRECT)?"*":"",
expr->_anonymous_type ? "" :
arg->embed
? MKID_safe(expr->Identifier)
: MKID(expr->Identifier),
? MKID_safe(expr)
: MKID(expr),
arg->embed ? "" : "_t");
return asn1c_lang_C_type_SEQUENCE_def(arg);
@ -344,7 +343,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
if(emit_members_PER_constraints(arg))
return -1;
OUT("static asn_TYPE_member_t asn_MBR_%s_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
elements = 0;
roms_count = 0;
@ -369,7 +368,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
int comma = 0;
comp_mode = 0;
OUT("static int asn_MAP_%s_oms_%d[] = {",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
TQ_FOR(v, &(expr->members), next) {
if(v->expr_type == A1TC_EXTENSIBLE) {
@ -426,7 +425,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
emit_tag2member_map(arg, tag2el, tag2el_count, 0);
OUT("static asn_SEQUENCE_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENT(+1);
OUT("sizeof(struct ");
out_name_chain(arg, ONC_avoid_keywords); OUT("),\n");
@ -435,7 +434,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
if(tag2el_count) {
OUT("asn_MAP_%s_tag2el_%d,\n",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
OUT("%d,\t/* Count of tags in the map */\n", tag2el_count);
} else {
@ -444,7 +443,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
}
if(roms_count + aoms_count) {
OUT("asn_MAP_%s_oms_%d,\t/* Optional members */\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
OUT("%d, %d,\t/* Root/Additions */\n", roms_count, aoms_count);
} else {
OUT("0, 0, 0,\t/* Optional elements (not needed) */\n");
@ -492,7 +491,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
INDENTED(
out_name_chain(arg, ONC_noflags);
OUT("_PR_");
id = MKID(v->Identifier);
id = MKID(v);
OUT("%s,\t/* Member %s is present */\n",
id, id)
);
@ -508,7 +507,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
OUT(" {\n");
} else {
OUT("typedef struct %s {\n",
MKID_safe(expr->Identifier));
MKID_safe(expr));
}
TQ_FOR(v, &(expr->members), next) {
@ -521,7 +520,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
}
INDENTED(
id = MKID(expr->Identifier);
id = MKID(expr);
OUT("\n");
OUT("/* Presence bitmask: ASN_SET_ISPRESENT(p%s, %s_PR_x) */\n",
id, id);
@ -531,7 +530,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
PCTX_DEF;
OUT("} %s%s%s", (expr->marker.flags & EM_INDIRECT)?"*":"",
expr->_anonymous_type ? "" : MKID_safe(expr->Identifier),
expr->_anonymous_type ? "" : MKID_safe(expr),
arg->embed ? "" : "_t");
return asn1c_lang_C_type_SET_def(arg);
@ -584,7 +583,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
if(emit_members_PER_constraints(arg))
return -1;
OUT("static asn_TYPE_member_t asn_MBR_%s_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
elements = 0;
INDENTED(TQ_FOR(v, &(expr->members), next) {
@ -616,8 +615,8 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
* Emit a map of mandatory elements.
*/
OUT("static uint8_t asn_MAP_%s_mmap_%d",
MKID(expr->Identifier), expr->_type_unique_index);
p = MKID_safe(expr->Identifier);
MKID(expr), expr->_type_unique_index);
p = MKID_safe(expr);
OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements);
OUT(" = {\n");
INDENTED(
@ -644,7 +643,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
OUT("};\n");
OUT("static asn_SET_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENTED(
OUT("sizeof(struct ");
out_name_chain(arg, ONC_avoid_keywords);
@ -655,7 +654,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
OUT("offsetof(struct ");
out_name_chain(arg, ONC_avoid_keywords);
OUT(", _presence_map),\n");
p = MKID(expr->Identifier);
p = MKID(expr);
OUT("asn_MAP_%s_tag2el_%d,\n", p, expr->_type_unique_index);
OUT("%d,\t/* Count of tags in the map */\n", tag2el_count);
if(tag2el_cxer)
@ -696,7 +695,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
out_name_chain(arg, ONC_avoid_keywords);
OUT(" {\n");
} else {
OUT("typedef struct %s {\n", MKID_safe(expr->Identifier));
OUT("typedef struct %s {\n", MKID_safe(expr));
}
INDENT(+1);
@ -728,7 +727,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
if(0)
tmp_memb.Identifier = strdup(
asn1c_make_identifier(0,
expr->Identifier, "Member", 0));
expr, "Member", 0));
assert(tmp_memb.Identifier);
}
tmp.default_cb(&tmp);
@ -749,7 +748,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
PCTX_DEF;
OUT("} %s%s%s", (expr->marker.flags & EM_INDIRECT)?"*":"",
expr->_anonymous_type ? "" : MKID_safe(expr->Identifier),
expr->_anonymous_type ? "" : MKID_safe(expr),
arg->embed ? "" : "_t");
/*
@ -786,7 +785,7 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
if(emit_members_PER_constraints(arg))
return -1;
OUT("static asn_TYPE_member_t asn_MBR_%s_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENT(+1);
v = TQ_FIRST(&(expr->members));
if(!v->Identifier) {
@ -806,7 +805,7 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
tv_mode = emit_tags_vectors(arg, expr, &tags_count, &all_tags_count);
OUT("static asn_SET_OF_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENTED(
OUT("sizeof(struct ");
out_name_chain(arg, ONC_avoid_keywords);
@ -857,7 +856,7 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
}
out_name_chain(arg, ONC_noflags);
OUT("_PR_");
id = MKID(v->Identifier);
id = MKID(v);
OUT("%s,\n", id, id);
}
);
@ -868,7 +867,7 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
if(arg->embed) {
OUT("struct "); out_name_chain(arg, ONC_avoid_keywords); OUT(" {\n");
} else {
OUT("typedef struct %s {\n", MKID_safe(expr->Identifier));
OUT("typedef struct %s {\n", MKID_safe(expr));
}
INDENTED(
@ -891,8 +890,8 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
OUT("} %s%s%s", (expr->marker.flags & EM_INDIRECT)?"*":"",
expr->_anonymous_type ? "" :
arg->embed
? MKID_safe(expr->Identifier)
: MKID(expr->Identifier),
? MKID_safe(expr)
: MKID(expr),
arg->embed ? "" : "_t");
return asn1c_lang_C_type_CHOICE_def(arg);
@ -932,7 +931,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
if(emit_members_PER_constraints(arg))
return -1;
OUT("static asn_TYPE_member_t asn_MBR_%s_%d[] = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
elements = 0;
INDENTED(TQ_FOR(v, &(expr->members), next) {
@ -952,7 +951,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
cmap = compute_canonical_members_order(arg, elements);
if(cmap) {
OUT("static int asn_MAP_%s_cmap_%d[] = {",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
for(i = 0; i < elements; i++) {
if(i) OUT(",");
@ -980,7 +979,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
emit_tag2member_map(arg, tag2el, tag2el_count, 0);
OUT("static asn_CHOICE_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENTED(
OUT("sizeof(struct ");
out_name_chain(arg, ONC_avoid_keywords);
@ -995,11 +994,11 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
out_name_chain(arg, ONC_avoid_keywords);
OUT(" *)0)->present),\n");
OUT("asn_MAP_%s_tag2el_%d,\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
OUT("%d,\t/* Count of tags in the map */\n", tag2el_count);
if(C99_MODE) OUT(".canonical_order = ");
if(cmap) OUT("asn_MAP_%s_cmap_%d,\t/* Canonically sorted */\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
else OUT("0,\n");
if(C99_MODE) OUT(".ext_start = ");
OUT("%d\t/* Extensions start */\n",
@ -1029,7 +1028,7 @@ asn1c_lang_C_type_REFERENCE(arg_t *arg) {
int ret;
extract = asn1f_class_access_ex(arg->asn, arg->expr->module,
arg->expr, ref);
arg->expr, arg->expr->rhs_pspecs, ref);
if(extract == NULL)
return -1;
@ -1092,7 +1091,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("%s", asn1c_type_name(arg, arg->expr, tnfmt));
if(!expr->_anonymous_type) {
OUT("%s", (expr->marker.flags&EM_INDIRECT)?"\t*":"\t ");
OUT("%s", MKID_safe(expr->Identifier));
OUT("%s", MKID_safe(expr));
if((expr->marker.flags & (EM_DEFAULT & ~EM_INDIRECT))
== (EM_DEFAULT & ~EM_INDIRECT))
OUT("\t/* DEFAULT %s */",
@ -1112,7 +1111,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
asn1c_type_name(arg, arg->expr, TNF_CTYPE));
OUT("%s%s_t",
(expr->marker.flags & EM_INDIRECT)?"*":" ",
MKID(expr->Identifier));
MKID(expr));
}
if((expr->expr_type == ASN_BASIC_ENUMERATED)
@ -1141,7 +1140,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
type_name = asn1c_type_name(arg, expr, TNF_SAFE);
OUT("/* This type is equivalent to %s */\n", type_name);
if(HIDE_INNER_DEFS) OUT("/* ");
OUT("#define\tasn_DEF_%s\t", MKID(expr->Identifier));
OUT("#define\tasn_DEF_%s\t", MKID(expr));
type_name = asn1c_type_name(arg, expr, TNF_SAFE);
OUT("asn_DEF_%s", type_name);
if(HIDE_INNER_DEFS)
@ -1170,7 +1169,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
* Constraint checking.
*/
if(!(arg->flags & A1C_NO_CONSTRAINTS)) {
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("int\n");
OUT("%s", p);
@ -1208,7 +1207,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT(" */\n");
OUT("static void\n");
OUT("%s_%d_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {\n",
MKID(expr->Identifier), expr->_type_unique_index);
MKID(expr), expr->_type_unique_index);
INDENT(+1);
{
asn1p_expr_t *terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
@ -1248,7 +1247,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("void\n");
OUT("%s", p);
@ -1263,7 +1262,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("int\n");
OUT("%s", p);
@ -1278,7 +1277,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_dec_rval_t\n");
OUT("%s", p);
@ -1293,7 +1292,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_enc_rval_t\n");
OUT("%s", p);
@ -1309,7 +1308,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_dec_rval_t\n");
OUT("%s", p);
@ -1324,7 +1323,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("}\n");
OUT("\n");
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_enc_rval_t\n");
OUT("%s", p);
@ -1341,7 +1340,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("\n");
if(arg->flags & A1C_GEN_PER) {
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_dec_rval_t\n");
OUT("%s", p);
@ -1359,7 +1358,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
REDIR(OT_FUNC_DECLS);
p = MKID(expr->Identifier);
p = MKID(expr);
if(HIDE_INNER_DEFS) {
OUT("/* extern asn_TYPE_descriptor_t asn_DEF_%s_%d;"
"\t// (Use -fall-defs-global to expose) */\n",
@ -1620,7 +1619,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char *
if(!tag2el_count) return 0; /* No top level tags */
OUT("static asn_TYPE_tag2member_t asn_MAP_%s_tag2el%s_%d[] = {\n",
MKID(expr->Identifier), opt_modifier?opt_modifier:"",
MKID(expr), opt_modifier?opt_modifier:"",
expr->_type_unique_index);
for(i = 0; i < tag2el_count; i++) {
OUT(" { ");
@ -1685,7 +1684,7 @@ emit_tags_vectors(arg_t *arg, asn1p_expr_t *expr, int *tags_count_r, int *all_ta
#define EMIT_TAGS_TABLE(name, tags, tags_count) do { \
OUT("static ber_tlv_tag_t asn_DEF_%s%s_tags_%d[] = {\n",\
MKID(expr->Identifier), name, \
MKID(expr), name, \
expr->_type_unique_index); \
INDENT(+1); \
/* Print the array of collected tags */ \
@ -1917,7 +1916,7 @@ emit_members_PER_constraints(arg_t *arg) {
|| v->expr_type == ASN_CONSTR_CHOICE) {
OUT("static asn_per_constraints_t "
"asn_PER_memb_%s_constr_%d = {\n",
MKID(v->Identifier), v->_type_unique_index);
MKID(v), v->_type_unique_index);
if(emit_single_member_PER_constraints(arg, v))
return -1;
OUT("};\n");
@ -2027,7 +2026,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
OUT(", ");
if(arg->expr->expr_type == ASN_CONSTR_CHOICE
&& (!UNNAMED_UNIONS)) OUT("choice.");
OUT("%s),\n", MKID_safe(expr->Identifier));
OUT("%s),\n", MKID_safe(expr));
}
INDENT(+1);
if(C99_MODE) OUT(".tag = ");
@ -2060,7 +2059,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
if(C99_MODE) OUT(".type = ");
OUT("&asn_DEF_");
if(complex_contents) {
OUT("%s", MKID(expr->Identifier));
OUT("%s", MKID(expr));
if(!(arg->flags & A1C_ALL_DEFS_GLOBAL))
OUT("_%d", expr->_type_unique_index);
} else {
@ -2072,7 +2071,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
if(arg->flags & A1C_NO_CONSTRAINTS) {
OUT("0,\t/* No check because of -fno-constraints */\n");
} else {
char *id = MKID(expr->Identifier);
char *id = MKID(expr);
if(expr->_anonymous_type
&& !strcmp(expr->Identifier, "Member"))
id = asn1c_type_name(arg, expr, TNF_SAFE);
@ -2088,7 +2087,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|| expr->expr_type == ASN_BASIC_ENUMERATED
|| expr->expr_type == ASN_CONSTR_CHOICE) {
OUT("&asn_PER_memb_%s_constr_%d,\n",
MKID(expr->Identifier),
MKID(expr),
expr->_type_unique_index);
} else {
OUT("0,\t/* No PER visible constraints */\n");
@ -2124,7 +2123,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
if(expr->_anonymous_type && !strcmp(expr->Identifier, "Member"))
p = asn1c_type_name(arg, expr, TNF_SAFE);
else
p = MKID(expr->Identifier);
p = MKID(expr);
OUT("static int\n");
OUT("memb_%s_constraint_%d(asn_TYPE_descriptor_t *td, const void *sptr,\n", p, arg->expr->_type_unique_index);
INDENT(+1);
@ -2150,7 +2149,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
static int
emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_count, int all_tags_count, int elements_count, enum etd_spec spec) {
int using_type_name = 0;
char *p = MKID(expr->Identifier);
char *p = MKID(expr);
if((arg->flags & A1C_GEN_PER)
&& (expr->constraints
@ -2174,7 +2173,9 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
if(expr->_anonymous_type) {
p = ASN_EXPR_TYPE2STR(expr->expr_type);
OUT("\"%s\",\n", p?p:"");
OUT("\"%s\",\n", MKID(p?p:""));
OUT("\"%s\",\n",
p ? asn1c_make_identifier(AMI_CHECK_RESERVED,
0, p, 0) : "");
} else {
OUT("\"%s\",\n", expr->Identifier);
OUT("\"%s\",\n", expr->Identifier);
@ -2184,7 +2185,7 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
using_type_name = 1;
p = asn1c_type_name(arg, arg->expr, TNF_SAFE);
} else {
p = MKID(expr->Identifier);
p = MKID(expr);
}
#define FUNCREF(foo) do { \
@ -2212,7 +2213,7 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
OUT("0,\t/* Use generic outmost tag fetcher */\n");
}
p = MKID(expr->Identifier);
p = MKID(expr);
if(tags_count) {
OUT("asn_DEF_%s_tags_%d,\n",
p, expr->_type_unique_index);
@ -2341,9 +2342,9 @@ out_name_chain(arg_t *arg, enum onc_flags onc_flags) {
}
if(onc_flags & ONC_avoid_keywords)
id = MKID_safe(expr->Identifier);
id = MKID_safe(expr);
else
id = MKID(expr->Identifier);
id = MKID(expr);
OUT("%s", id);
return 0;

View File

@ -33,27 +33,40 @@ reserved_keyword(const char *str) {
* Convert unsafe characters to underscores.
*/
char *
asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
static char *storage;
static int storage_size;
int nodelimiter = 0;
va_list ap;
char *str;
char *nextstr;
char *first = 0;
char *second = 0;
size_t size;
char *p;
if(arg1 == NULL)
return NULL;
if(expr) {
/*
* Estimate the necessary storage size
*/
if(expr->Identifier == NULL)
return "Member";
size = strlen(expr->Identifier);
if(expr->spec_index != -1) {
static char buf[32];
second = buf;
size += 1 + snprintf(buf, sizeof buf, "%dP%d",
expr->_lineno, expr->spec_index);
}
} else {
size = -1;
}
/*
* Estimate the necessary storage size
*/
size = strlen(arg1);
va_start(ap, arg1);
va_start(ap, expr);
while((str = va_arg(ap, char *)))
size += 1 + strlen(str);
va_end(ap);
if(size == -1) return NULL;
/*
* Make sure we have this amount of storage.
@ -72,12 +85,23 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
/*
* Fill-in the storage.
*/
va_start(ap, arg1);
str = arg1;
va_start(ap, expr);
p = storage;
for(str = arg1; str; str = nextstr) {
nextstr = "";
for(p = storage, str = 0; str || nextstr; str = nextstr) {
int subst_made = 0;
nextstr = va_arg(ap, char *);
nextstr = second ? second : va_arg(ap, char *);
if(str == 0) {
if(expr) {
str = expr->Identifier;
first = str;
second = 0;
} else {
first = nextstr;
continue;
}
}
if(str[0] == ' ' && str[1] == '\0') {
*p++ = ' ';
@ -85,7 +109,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
continue;
}
if(str != arg1 && !nodelimiter)
if(str != first && !nodelimiter)
*p++ = '_'; /* Delimiter between tokens */
nodelimiter = 0;
@ -94,7 +118,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
* with C/C++ language keywords.
*/
if((flags & AMI_CHECK_RESERVED)
&& str == arg1 && !nextstr && reserved_keyword(str)) {
&& str == first && !nextstr && reserved_keyword(str)) {
*p++ = toupper(*str++);
/* Fall through */
}
@ -123,7 +147,9 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
char *
asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
asn1p_expr_t *exprid = 0;
asn1p_expr_t *top_parent;
asn1p_expr_t *terminal;
char *typename;
/* Rewind to the topmost parent expression */
@ -145,15 +171,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
* Resolve it and use instead.
*/
tmp.expr = asn1f_class_access_ex(arg->asn,
arg->expr->module, arg->expr, expr->reference);
arg->expr->module, arg->expr, expr->rhs_pspecs, expr->reference);
if(!tmp.expr) return NULL;
return asn1c_type_name(&tmp, tmp.expr, _format);
}
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
if(_format == TNF_RSAFE) {
asn1p_expr_t *terminal;
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
if(terminal && terminal->expr_type & ASN_CONSTR_MASK) {
typename = terminal->Identifier;
}
@ -165,29 +191,17 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
* switch to a recursion-safe type naming
* ("struct foo" instead of "foo_t").
*/
asn1p_expr_t *terminal;
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
if(terminal && terminal == top_parent) {
_format = TNF_RSAFE;
}
}
break;
#if 0
case ASN_CONSTR_SEQUENCE_OF:
case ASN_CONSTR_SET_OF:
if(expr->Identifier) {
typename = expr->Identifier;
} else {
asn1p_expr_t *child;
child = TQ_FIRST(&(expr->members));
typename = asn1c_type_name(arg, child, _format);
if(typename)
return typename;
_format = TNF_SAFE;
typename = child->Identifier;
if(terminal && terminal->spec_index != -1) {
exprid = terminal;
typename = 0;
}
break;
#endif
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
case ASN_BASIC_REAL:
@ -229,13 +243,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
switch(_format) {
case TNF_UNMODIFIED:
case TNF_INCLUDE:
return asn1c_make_identifier(AMI_MASK_ONLY_SPACES, typename, 0);
return asn1c_make_identifier(AMI_MASK_ONLY_SPACES,
0, exprid ? exprid->Identifier : typename, 0);
case TNF_SAFE:
return asn1c_make_identifier(0, typename, 0);
return asn1c_make_identifier(0, exprid, typename, 0);
case TNF_CTYPE: /* C type */
return asn1c_make_identifier(0, typename, "t", 0);
return asn1c_make_identifier(0, exprid,
exprid?"t":typename, exprid?0:"t", 0);
case TNF_RSAFE: /* Recursion-safe type */
return asn1c_make_identifier(AMI_CHECK_RESERVED,
return asn1c_make_identifier(AMI_CHECK_RESERVED, 0,
"struct", " ", typename, 0);
}

View File

@ -10,7 +10,7 @@ enum ami_flags_e {
AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */
};
char *asn1c_make_identifier(enum ami_flags_e, char *arg1, ...);
char *asn1c_make_identifier(enum ami_flags_e, asn1p_expr_t *expr, ...);
/*
* Return the type name of the specified expression.

View File

@ -102,8 +102,7 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
int saved_target = arg->target->target; \
REDIR(OT_FUNC_DECLS); \
OUT_NOINDENT("extern asn_TYPE_descriptor_t " \
"asn_DEF_%s;\n", \
MKID(expr->Identifier)); \
"asn_DEF_%s;\n", MKID(expr)); \
REDIR(saved_target); \
} while(0)

View File

@ -215,7 +215,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **a
generate_preamble(arg, fp_c, argc, optc, argv);
generate_preamble(arg, fp_h, argc, optc, argv);
header_id = asn1c_make_identifier(0, expr->Identifier, NULL);
header_id = asn1c_make_identifier(0, expr, NULL);
fprintf(fp_h,
"#ifndef\t_%s_H_\n"
"#define\t_%s_H_\n"
@ -477,8 +477,7 @@ generate_pdu_collection_file(arg_t *arg) {
continue;
fprintf(fp, "extern struct asn_TYPE_descriptor_s "
"asn_DEF_%s;\n",
asn1c_make_identifier(0, arg->expr->Identifier,
NULL));
asn1c_make_identifier(0, arg->expr, NULL));
}
}
@ -496,8 +495,7 @@ generate_pdu_collection_file(arg_t *arg) {
arg->expr->module->ModuleName,
arg->expr->module->source_file_name);
fprintf(fp, "\t&asn_DEF_%s,\t\n",
asn1c_make_identifier(0, arg->expr->Identifier,
NULL));
asn1c_make_identifier(0, arg->expr, NULL));
}
}

View File

@ -43,7 +43,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
ret = asn1c_compile_expr(arg);
if(ret) {
FATAL("Cannot compile %s (%x:%x) at line %d",
FATAL("Cannot compile \"%s\" (%x:%x) at line %d",
arg->expr->Identifier,
arg->expr->expr_type,
arg->expr->meta_type,
@ -82,10 +82,26 @@ asn1c_compile_expr(arg_t *arg) {
expr->Identifier,
expr->_lineno);
ret = type_cb(arg);
if(arg->target->destination[OT_TYPE_DECLS].indent_level == 0)
OUT(";\n");
if(expr->lhs_params && expr->spec_index == -1) {
int i;
ret = 0;
DEBUG("Parameterized type %s at line %d: %s (%d)",
expr->Identifier, expr->_lineno,
expr->specializations.pspecs_count
? "compiling" : "unused, skipping");
for(i = 0; i<expr->specializations.pspecs_count; i++) {
arg->expr = expr->specializations
.pspec[i].my_clone;
ret = asn1c_compile_expr(arg);
if(ret) break;
}
arg->expr = expr; /* Restore */
} else {
ret = type_cb(arg);
if(arg->target->destination[OT_TYPE_DECLS]
.indent_level == 0)
OUT(";\n");
}
} else {
ret = -1;
/*
@ -94,7 +110,6 @@ asn1c_compile_expr(arg_t *arg) {
* certain expressions need not to be compiled at all.
*/
switch(expr->meta_type) {
case AMT_PARAMTYPE:
case AMT_OBJECT:
case AMT_OBJECTCLASS:
case AMT_OBJECTFIELD:

View File

@ -15,6 +15,7 @@ static int asn1f_resolve_constraints(arg_t *arg); /* For subtype constraints */
static int asn1f_check_constraints(arg_t *arg); /* For subtype constraints */
static int asn1f_check_duplicate(arg_t *arg);
static int asn1f_apply_unique_index(arg_t *arg);
static int phase_1_1(arg_t *arg, int prm2);
arg_t a1f_replace_me_with_proper_interface_arg;
@ -179,71 +180,21 @@ asn1f_fix_module__phase_1(arg_t *arg) {
*/
TQ_FOR(expr, &(arg->mod->members), next) {
arg->expr = expr;
/* Check whether this type is a duplicate */
ret = asn1f_check_duplicate(arg);
ret = phase_1_1(arg, 0);
RET2RVAL(ret, rvalue);
if(expr->meta_type == AMT_PARAMTYPE)
/* Do not process the parametrized type just yet */
continue;
DEBUG("=== Now processing \"%s\" (%d/0x%x) at line %d ===",
expr->Identifier, expr->meta_type, expr->expr_type,
expr->_lineno);
assert(expr->meta_type != AMT_INVALID);
/*
* 2.1 Pre-process simple types (ENUMERATED, INTEGER, etc).
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_simple);
RET2RVAL(ret, rvalue);
/*
* 2.5.4
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_types);
RET2RVAL(ret, rvalue);
/*
* Fix tagging of top-level types.
*/
ret = asn1f_fix_constr_tag(arg, 1);
RET2RVAL(ret, rvalue);
/*
* 2.[234] Process SEQUENCE/SET/CHOICE types.
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_constructed);
RET2RVAL(ret, rvalue);
/*
* 2.5.5
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_values);
RET2RVAL(ret, rvalue);
/*
* Parse class objects and fill up the object class with data.
*/
ret = asn1f_parse_class_object(arg);
RET2RVAL(ret, rvalue);
/*
* Resolve references in constraints.
*/
ret = asn1f_recurse_expr(arg, asn1f_resolve_constraints);
RET2RVAL(ret, rvalue);
/*
* 6. INTEGER value processed at 2.5.4.
*/
/*
* Make sure everybody's behaving well.
*/
assert(arg->expr == expr);
}
TQ_FOR(expr, &(arg->mod->members), next) {
arg->expr = expr;
ret = phase_1_1(arg, 1);
RET2RVAL(ret, rvalue);
assert(arg->expr == expr);
}
/*
* 5. Automatic tagging
@ -295,16 +246,9 @@ asn1f_fix_module__phase_2(arg_t *arg) {
int rvalue = 0;
int ret;
TQ_FOR(expr, &(arg->mod->members), next) {
}
TQ_FOR(expr, &(arg->mod->members), next) {
arg->expr = expr;
if(expr->meta_type == AMT_PARAMTYPE)
/* Do not process the parametrized types here */
continue;
/*
* Dereference DEFAULT values.
*/
@ -330,6 +274,88 @@ asn1f_fix_module__phase_2(arg_t *arg) {
return rvalue;
}
static int
phase_1_1(arg_t *arg, int prm2) {
asn1p_expr_t *expr = arg->expr;
int rvalue = 0;
int ret;
if(expr->lhs_params && expr->spec_index == -1) {
int i;
if(!prm2)
/* Do not process the parameterized type just yet */
return 0;
for(i = 0; i < expr->specializations.pspecs_count; i++) {
arg->expr = expr->specializations.pspec[i].my_clone;
ret = phase_1_1(arg, 0);
RET2RVAL(ret, rvalue);
}
arg->expr = expr; /* revert */
return rvalue;
} else if(prm2) {
return 0; /* Already done! */
}
/* Check whether this type is a duplicate */
if(!expr->lhs_params) {
ret = asn1f_check_duplicate(arg);
RET2RVAL(ret, rvalue);
}
DEBUG("=== Now processing \"%s\" (%d/0x%x) at line %d ===",
expr->Identifier, expr->meta_type, expr->expr_type,
expr->_lineno);
assert(expr->meta_type != AMT_INVALID);
/*
* 2.1 Pre-process simple types (ENUMERATED, INTEGER, etc).
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_simple);
RET2RVAL(ret, rvalue);
/*
* 2.5.4
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_types);
RET2RVAL(ret, rvalue);
/*
* Fix tagging of top-level types.
*/
ret = asn1f_fix_constr_tag(arg, 1);
RET2RVAL(ret, rvalue);
/*
* 2.[234] Process SEQUENCE/SET/CHOICE types.
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_constructed);
RET2RVAL(ret, rvalue);
/*
* 2.5.5
*/
ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_values);
RET2RVAL(ret, rvalue);
/*
* Parse class objects and fill up the object class with data.
*/
ret = asn1f_parse_class_object(arg);
RET2RVAL(ret, rvalue);
/*
* Resolve references in constraints.
*/
ret = asn1f_recurse_expr(arg, asn1f_resolve_constraints);
RET2RVAL(ret, rvalue);
/*
* 6. INTEGER value processed at 2.5.4.
*/
return rvalue;
}
static int
asn1f_fix_simple(arg_t *arg) {
int rvalue = 0;

View File

@ -1,7 +1,7 @@
#include "asn1fix_internal.h"
asn1p_expr_t *
asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, asn1p_ref_t *ref) {
asn1p_expr_t *ioclass;
asn1p_expr_t *classfield;
asn1p_expr_t *expr;
@ -20,14 +20,16 @@ asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
tmpref = *ref;
tmpref.comp_count = 1;
ioclass = asn1f_lookup_symbol(arg, mod, &tmpref);
ioclass = asn1f_lookup_symbol(arg, mod, rhs_pspecs, &tmpref);
if(ioclass == NULL) {
errno = ESRCH;
return NULL;
}
if(ioclass->expr_type == A1TC_REFERENCE) {
ioclass = asn1f_lookup_symbol(arg,
ioclass->module, ioclass->reference);
ioclass->module,
ioclass->rhs_pspecs,
ioclass->reference);
if(ioclass == NULL) {
errno = ESRCH;
return NULL;

View File

@ -4,12 +4,6 @@
/*
* Fetch the element from the class-related stuff (thing) by its reference.
*/
asn1p_expr_t *asn1f_class_access(arg_t *, asn1p_module_t *mod, asn1p_ref_t *);
/*
* Externally accessible version of above function.
*/
asn1p_expr_t *asn1f_class_access2(asn1p_t *asn, asn1p_module_t *mod,
asn1p_expr_t *expr, asn1p_ref_t *);
asn1p_expr_t *asn1f_class_access(arg_t *, asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, asn1p_ref_t *);
#endif /* _ASN1FIX_CLASS_H_ */

View File

@ -471,7 +471,8 @@ _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) {
DEBUG(" %s is a type reference", a->Identifier);
a = asn1f_lookup_symbol(arg, a->module, a->reference);
a = asn1f_lookup_symbol(arg,
a->module, a->rhs_pspecs, a->reference);
if(!a) return 0; /* Already FATAL()'ed somewhere else */
WITH_MODULE(a->module, ret = _asn1f_compare_tags(arg, a, b));
return ret;

View File

@ -30,7 +30,7 @@ asn1constraint_pullup(arg_t *arg) {
asn1p_expr_t *parent_expr;
assert(ref);
parent_expr = asn1f_lookup_symbol(arg, expr->module, ref);
parent_expr = asn1f_lookup_symbol(arg, expr->module, expr->rhs_pspecs, ref);
if(!parent_expr) {
if(errno != EEXIST) {
DEBUG("\tWhile fetching parent constraints: "
@ -259,6 +259,7 @@ constraint_type_resolve(arg_t *arg, asn1p_constraint_t *ct) {
assert(ct->containedSubtype->type == ATV_REFERENCED);
rtype = asn1f_lookup_symbol(arg, arg->expr->module,
arg->expr->rhs_pspecs,
ct->containedSubtype->value.reference);
if(!rtype) {
FATAL("Cannot find type \"%s\" in constraints at line %d",

View File

@ -206,7 +206,7 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_row_s *row, struct asn1p_i
asn1p_ref_add_component(ref, p, RLT_UNKNOWN);
assert(ref);
expr = asn1f_lookup_symbol(arg, arg->mod, ref);
expr = asn1f_lookup_symbol(arg, arg->mod, arg->expr->rhs_pspecs, ref);
if(!expr) {
FATAL("Cannot find %s referenced by %s at line %d",
p, arg->expr->Identifier,

View File

@ -6,9 +6,6 @@ asn1f_fix_dereference_types(arg_t *arg) {
asn1p_expr_t *type_expr;
int r_value = 0;
if(expr->expr_type == A1TC_PARAMETRIZED)
return asn1f_fix_parametrized_assignment(arg);
if(expr->expr_type != A1TC_REFERENCE
|| expr->meta_type != AMT_TYPEREF) {
//assert(expr->reference == 0);

View File

@ -20,13 +20,14 @@ asn1f_lookup_symbol_ex(
arg.debug = a1f_replace_me_with_proper_interface_arg.debug;
return asn1f_lookup_symbol(&arg, expr->module, ref);
return asn1f_lookup_symbol(&arg, expr->module, expr->rhs_pspecs, ref);
}
asn1p_expr_t *
asn1f_class_access_ex(asn1p_t *asn,
asn1p_module_t *mod,
asn1p_expr_t *expr,
asn1p_expr_t *rhs_pspecs,
asn1p_ref_t *ref) {
arg_t arg;
@ -38,7 +39,7 @@ asn1f_class_access_ex(asn1p_t *asn,
arg.eh = a1f_replace_me_with_proper_interface_arg.eh;
arg.debug = a1f_replace_me_with_proper_interface_arg.debug;
return asn1f_class_access(&arg, mod, ref);
return asn1f_class_access(&arg, mod, rhs_pspecs, ref);
}
asn1p_expr_t *

View File

@ -25,7 +25,7 @@ asn1p_expr_t *asn1f_lookup_symbol_ex(
* Exportable version of an asn1f_class_access().
*/
asn1p_expr_t *asn1f_class_access_ex(asn1p_t *asn, asn1p_module_t *mod,
asn1p_expr_t *expr, asn1p_ref_t *);
asn1p_expr_t *expr, asn1p_expr_t *rhs_rspecs, asn1p_ref_t *);
/*
* Exportable version of asn1f_find_terminal_type().

View File

@ -143,7 +143,8 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type)
* Then, it is a reference. For a reference, try to resolve type
* and try again.
*/
next_expr = asn1f_lookup_symbol(arg, expr->module, expr->reference);
next_expr = asn1f_lookup_symbol(arg, expr->module,
expr->rhs_pspecs, expr->reference);
if(next_expr == NULL) {
errno = ESRCH;
return -1;

View File

@ -62,7 +62,7 @@ typedef struct arg_s {
#include "asn1fix_constr.h" /* Constructed types */
#include "asn1fix_class.h" /* CLASS support */
#include "asn1fix_cws.h" /* CLASS WITH SYNTAX support */
#include "asn1fix_param.h" /* Parametrization */
#include "asn1fix_param.h" /* Parameterization */
#include "asn1fix_retrieve.h" /* Data retrieval */
#include "asn1fix_enum.h" /* Process ENUMERATED */
#include "asn1fix_integer.h" /* Process INTEGER */

View File

@ -196,6 +196,17 @@ asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) {
assert(expr);
if(expr->lhs_params && expr->spec_index == -1) {
int i;
for(i = 0; i < expr->specializations.pspecs_count; i++) {
arg->expr = expr->specializations.pspec[i].my_clone;
ret = asn1f_recurse_expr(arg, callback);
RET2RVAL(ret, rvalue);
}
arg->expr = expr; /* revert */
return rvalue;
}
/*
* Invoke the callback at this very level.
*/

View File

@ -1,306 +1,217 @@
#include "asn1fix_internal.h"
static int asn1f_parametrize(arg_t *arg, asn1p_expr_t *ex, asn1p_expr_t *ptype);
static int asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs);
static int asn1f_param_process_constraints(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs);
typedef struct resolver_arg {
asn1p_expr_t *(*resolver)(asn1p_expr_t *, void *arg);
arg_t *arg;
asn1p_expr_t *original_expr;
asn1p_paramlist_t *lhs_params;
asn1p_expr_t *rhs_pspecs;
} resolver_arg_t;
static asn1p_expr_t *_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs);
static int _process_constraints(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_t *ptype, asn1p_expr_t *actargs);
static asn1p_expr_t *resolve_expr(asn1p_expr_t *, void *resolver_arg);
static int compare_specializations(arg_t *, asn1p_expr_t *a, asn1p_expr_t *b);
static asn1p_expr_t *find_target_specialization_byref(resolver_arg_t *rarg, asn1p_ref_t *ref);
static asn1p_expr_t *find_target_specialization_bystr(resolver_arg_t *rarg, char *str);
int
asn1f_fix_parametrized_assignment(arg_t *arg) {
asn1p_expr_t *expr = arg->expr;
asn1p_expr_t *ptype;
assert(expr->expr_type == A1TC_PARAMETRIZED);
assert(expr->reference);
DEBUG("(\"%s\" ::= \"%s\" { %s }) for line %d",
expr->Identifier,
asn1f_printable_reference(expr->reference),
asn1f_printable_value(expr->value),
expr->_lineno);
/*
* Find the corresponding parametrized type definition.
*/
DEBUG("Looking for parametrized type definition \"%s\"",
asn1f_printable_reference(expr->reference));
ptype = asn1f_lookup_symbol(arg, expr->module, expr->reference);
if(ptype == NULL) {
DEBUG("%s: missing parametrized type declaration",
asn1f_printable_reference(expr->reference));
return -1;
}
/*
* Check that the number of arguments which are expected by
* the parametrized type declaration is consistent with the
* number of arguments supplied by the parametrized assignment.
*/
if(asn1f_count_children(expr) != ptype->params->params_count) {
FATAL("Number of actual arguments %d in %s at line %d "
"is not equal to number of expected arguments "
"%d in %s at line %d",
asn1f_count_children(expr),
asn1f_printable_reference(expr->reference),
expr->_lineno,
ptype->params->params_count,
ptype->Identifier,
ptype->_lineno
);
return -1;
}
/*
* Perform an expansion of a parametrized assignment.
*/
return asn1f_parametrize(arg, expr, ptype);
}
#define SUBSTITUTE(to, from) do { \
asn1p_expr_t tmp, *__v; \
if((to)->tag.tag_class \
&& (from)->tag.tag_class) { \
FATAL("Layered tagging in parametrization " \
"is not yet supported, " \
"contact asn1c author for assistance " \
"with line %d", (to)->_lineno); \
return -1; \
} \
/* This code shall not be invoked too early */ \
assert((to)->combined_constraints == NULL); \
assert((from)->combined_constraints == NULL); \
/* Copy stuff, and merge some parameters */ \
tmp = *(to); \
*(to) = *(from); \
TQ_MOVE(&(to)->members, &(from)->members); \
*(from) = tmp; \
(to)->next = tmp.next; \
(to)->parent_expr = tmp.parent_expr; \
assert((to)->marker.flags == EM_NOMARK); \
(to)->marker = tmp.marker; \
if(tmp.tag.tag_class) \
(to)->tag = tmp.tag; \
if(tmp.constraints) { \
if((to)->constraints) { \
asn1p_constraint_t *ct; \
ct = asn1p_constraint_new( \
(to)->constraints->_lineno); \
ct->type = ACT_CA_SET; \
asn1p_constraint_insert(ct, \
(to)->constraints); \
asn1p_constraint_insert(ct, \
tmp.constraints); \
(to)->constraints = ct; \
} else { \
(to)->constraints = tmp.constraints; \
} \
} \
(from)->constraints = 0; \
(from)->marker.default_value = 0; \
memset(&((from)->next), 0, sizeof((from)->next)); \
memset(&((from)->members), 0, sizeof((from)->members)); \
asn1p_expr_free(from); \
TQ_FOR(__v, &((to)->members), next) { \
assert(__v->parent_expr == (from)); \
__v->parent_expr = (to); \
} \
} while(0)
static int
asn1f_parametrize(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype) {
asn1p_expr_t *nex;
asn1p_expr_t *
asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_pspecs) {
resolver_arg_t rarg; /* resolver argument */
asn1p_expr_t *exc; /* expr clone */
asn1p_expr_t *rpc; /* rhs_pspecs clone */
asn1p_expr_t *target;
void *p;
int ret;
struct asn1p_pspec_s *pspec;
int npspecs;
int i;
DEBUG("asn1f_parametrize(%s <= %s)",
expr->Identifier, ptype->Identifier);
assert(rhs_pspecs);
assert(expr->lhs_params);
assert(expr->parent_expr == 0);
DEBUG("Forking parameterization at %d for %s (%d alr)",
rhs_pspecs->_lineno, expr->Identifier,
expr->specializations.pspecs_count);
/*
* The algorithm goes like that:
* 1. Replace the expression's type with parametrized type.
* 2. For every child in the parametrized type, import it
* as a child of the expression, replacing all occurences of
* symbols which are defined as parametrized type arguments
* with the actual values.
* 3. Don't forget to parametrize the subtype constraints.
* Find if this exact specialization has been used already.
*/
nex = asn1p_expr_clone(ptype, 0);
if(nex == NULL) return -1;
/*
* Cleanup the new expression so there is no ptype-related
* stuff hanging around.
*/
if(expr->Identifier) {
p = strdup(expr->Identifier);
if(p) {
free(nex->Identifier);
nex->Identifier = p;
} else {
asn1p_expr_free(nex);
return -1;
for(npspecs = 0;
npspecs < expr->specializations.pspecs_count;
npspecs++) {
if(compare_specializations(arg, rhs_pspecs,
expr->specializations.pspec[npspecs].rhs_pspecs) == 0) {
DEBUG("Reused parameterization for %s",
expr->Identifier);
return expr->specializations.pspec[npspecs].my_clone;
}
}
asn1p_paramlist_free(nex->params);
nex->params = NULL;
nex->meta_type = expr->meta_type;
ret = asn1f_param_process_recursive(arg, nex, ptype, expr);
if(ret != 0) {
asn1p_expr_free(nex);
return ret;
rarg.resolver = resolve_expr;
rarg.arg = arg;
rarg.original_expr = expr;
rarg.lhs_params = expr->lhs_params;
rarg.rhs_pspecs = rhs_pspecs;
exc = asn1p_expr_clone_with_resolver(expr, resolve_expr, &rarg);
rpc = asn1p_expr_clone(rhs_pspecs, 0);
assert(exc && rpc);
/*
* Create a new specialization.
*/
npspecs = expr->specializations.pspecs_count;
p = realloc(expr->specializations.pspec,
(npspecs + 1) * sizeof(expr->specializations.pspec[0]));
assert(p);
expr->specializations.pspec = p;
pspec = &expr->specializations.pspec[npspecs];
memset(pspec, 0, sizeof *pspec);
pspec->rhs_pspecs = rpc;
pspec->my_clone = exc;
exc->spec_index = npspecs;
/* Update LHS->RHS specialization in target */
target = TQ_FIRST(&rpc->members);
for(i = 0; i < exc->lhs_params->params_count;
i++, target = TQ_NEXT(target, next)) {
if(!target) { target = (void *)0xdeadbeef; break; }
assert(exc->lhs_params->params[i].into_expr == 0);
exc->lhs_params->params[i].into_expr = target;
}
if(target) {
asn1p_expr_free(exc);
asn1p_expr_free(rpc);
FATAL("Parameterization of %s failed: "
"parameters number mismatch", expr->Identifier);
errno = EPERM;
return NULL;
}
SUBSTITUTE(expr, nex);
DEBUG("Forked new parameterization for %s", expr->Identifier);
return ret;
/* Commit */
expr->specializations.pspecs_count = npspecs + 1;
return exc;
}
static int
asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs) {
asn1p_expr_t *child;
compare_specializations(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) {
asn1p_expr_t *ac = TQ_FIRST(&a->members);
asn1p_expr_t *bc = TQ_FIRST(&b->members);
for(;ac && bc; ac = TQ_NEXT(ac, next), bc = TQ_NEXT(bc, next)) {
retry:
if(ac == bc) continue;
if(ac->meta_type != bc->meta_type) break;
if(ac->expr_type != bc->expr_type) break;
TQ_FOR(child, &(expr->members), next) {
asn1p_expr_t *ra;
asn1p_expr_t *ne; /* new expression (clone) */
if(!ac->reference && !bc->reference)
continue;
if(asn1f_param_process_constraints(arg, child, ptype, actargs))
return -1;
ra = _referenced_argument(child->reference, ptype, actargs);
if(ra) {
DEBUG("Substituting parameter for %s %s at line %d",
child->Identifier,
asn1f_printable_reference(child->reference),
child->_lineno
);
assert(child->meta_type == AMT_TYPEREF);
assert(child->expr_type == A1TC_REFERENCE);
ne = asn1p_expr_clone(ra, 0);
if(ne == NULL) return -1;
assert(ne->Identifier == 0);
ne->Identifier = strdup(child->Identifier);
if(ne->Identifier == 0) {
asn1p_expr_free(ne);
return -1;
}
SUBSTITUTE(child, ne);
if(ac->reference) {
ac = asn1f_lookup_symbol(arg,
ac->module, ac->rhs_pspecs, ac->reference);
if(!ac) break;
}
if(bc->reference) {
bc = asn1f_lookup_symbol(arg,
bc->module, bc->rhs_pspecs, bc->reference);
if(!bc) break;
}
goto retry;
}
if(ac || bc)
/* Specializations do not match: different size option sets */
return -1;
return 0;
}
/*
* Check that the given ref looks like an argument of a parametrized type.
*/
static asn1p_expr_t *
_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs) {
asn1p_expr_t *aa;
int i;
resolve_expr(asn1p_expr_t *expr_to_resolve, void *resolver_arg) {
resolver_arg_t *rarg = resolver_arg;
arg_t *arg = rarg->arg;
asn1p_expr_t *expr;
asn1p_expr_t *nex;
if(ref == NULL || ref->comp_count != 1)
DEBUG("Resolving %s (meta %d)",
expr_to_resolve->Identifier, expr_to_resolve->meta_type);
if(expr_to_resolve->meta_type == AMT_TYPEREF) {
expr = find_target_specialization_byref(rarg,
expr_to_resolve->reference);
if(!expr) return NULL;
} else if(expr_to_resolve->meta_type == AMT_VALUE) {
assert(expr_to_resolve->value);
expr = find_target_specialization_bystr(rarg,
expr_to_resolve->Identifier);
if(!expr) return NULL;
} else {
errno = ESRCH;
return NULL;
}
aa = TQ_FIRST(&(actargs->members));
for(i = 0; i < ptype->params->params_count;
i++, aa = TQ_NEXT(aa, next)) {
if(strcmp(ref->components[0].name,
ptype->params->params[i].argument) == 0)
return aa;
DEBUG("Found target %s", expr->Identifier);
if(expr->meta_type == AMT_TYPE
|| expr->meta_type == AMT_VALUE) {
DEBUG("Target is a simple type %s",
ASN_EXPR_TYPE2STR(expr->expr_type));
nex = asn1p_expr_clone(expr, 0);
free(nex->Identifier);
nex->Identifier = expr_to_resolve->Identifier
? strdup(expr_to_resolve->Identifier) : 0;
return nex;
} else {
FATAL("Feature not implemented for %s",
rarg->original_expr->Identifier);
errno = EPERM;
return NULL;
}
return NULL;
}
/*
* Search for parameters inside constraints.
*/
static int
asn1f_param_process_constraints(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs) {
asn1p_constraint_t *cts;
int ret;
static asn1p_expr_t *
find_target_specialization_byref(resolver_arg_t *rarg, asn1p_ref_t *ref) {
char *refstr;
if(!expr->constraints) return 0;
cts = asn1p_constraint_clone(expr->constraints);
assert(cts);
ret = _process_constraints(arg, cts, ptype, actargs);
if(ret == 1) {
asn1p_constraint_free(expr->constraints);
expr->constraints = cts;
ret = 0;
} else {
asn1p_constraint_free(cts);
if(!ref || ref->comp_count != 1) {
errno = ESRCH;
return NULL;
}
return ret;
refstr = ref->components[0].name; /* T */
return find_target_specialization_bystr(rarg, refstr);
}
static int
_process_constraints(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_t *ptype, asn1p_expr_t *actargs) {
asn1p_value_t *values[3];
int rvalue = 0;
size_t i;
static asn1p_expr_t *
find_target_specialization_bystr(resolver_arg_t *rarg, char *refstr) {
arg_t *arg = rarg->arg;
asn1p_expr_t *target;
int i;
values[0] = ct->value;
values[1] = ct->range_start;
values[2] = ct->range_stop;
target = TQ_FIRST(&rarg->rhs_pspecs->members);
for(i = 0; i < rarg->lhs_params->params_count;
i++, target = TQ_NEXT(target, next)) {
struct asn1p_param_s *param = &rarg->lhs_params->params[i];
if(!target) break;
for(i = 0; i < sizeof(values)/sizeof(values[0]); i++) {
asn1p_value_t *v = values[i];
asn1p_expr_t *ra;
asn1p_ref_t *ref;
char *str;
if(strcmp(param->argument, refstr))
continue;
if(!v || v->type != ATV_REFERENCED) continue;
ref = v->value.reference;
ra = _referenced_argument(ref, ptype, actargs);
if(!ra) continue;
DEBUG("_process_constraints(%s), ra=%s",
asn1f_printable_reference(ref), ra->Identifier);
if(ra->expr_type == A1TC_PARAMETRIZED) {
DEBUG("Double %s", "parametrization");
}
assert(ra->Identifier);
str = strdup(ra->Identifier);
if(!str) return -1;
assert(ref->comp_count == 1);
ref = asn1p_ref_new(ref->_lineno);
if(!ref) { free(str); return -1; }
if(asn1p_ref_add_component(ref, str, 0)) {
free(str);
return -1;
}
asn1p_ref_free(v->value.reference);
v->value.reference = ref;
rvalue = 1;
return target;
}
if(i != rarg->lhs_params->params_count) {
FATAL("Parameterization of %s failed: "
"parameters number mismatch",
rarg->original_expr->Identifier);
errno = EPERM;
return NULL;
}
/* Process the rest of constraints recursively */
for(i = 0; i < ct->el_count; i++) {
int ret = _process_constraints(arg, ct->elements[i],
ptype, actargs);
if(ret == -1)
rvalue = -1;
else if(ret == 1 && rvalue != -1)
rvalue = 1;
}
return rvalue;
errno = ESRCH;
return NULL;
}

View File

@ -1,6 +1,6 @@
#ifndef _ASN1FIX_PARAMETRIZATION_H_
#define _ASN1FIX_PARAMETRIZATION_H_
#ifndef _ASN1FIX_PARAMETERIZATION_H_
#define _ASN1FIX_PARAMETERIZATION_H_
int asn1f_fix_parametrized_assignment(arg_t *arg);
asn1p_expr_t *asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_pspecs);
#endif /* _ASN1FIX_PARAMETRIZATION_H_ */
#endif /* _ASN1FIX_PARAMETERIZATION_H_ */

View File

@ -146,7 +146,7 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) {
}
static asn1p_expr_t *
asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int recursion_depth) {
asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, asn1p_ref_t *ref, int recursion_depth) {
asn1p_expr_t *ref_tc; /* Referenced tc */
asn1p_module_t *imports_from;
char *modulename;
@ -193,7 +193,7 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int
* This is a reference to a CLASS-related stuff.
* Employ a separate function for that.
*/
extract = asn1f_class_access(arg, mod, ref);
extract = asn1f_class_access(arg, mod, rhs_pspecs, ref);
return extract;
} else {
@ -255,7 +255,8 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int
assert(tmpref.comp_count > 0);
}
expr = asn1f_lookup_symbol_impl(arg, imports_from, &tmpref, recursion_depth);
expr = asn1f_lookup_symbol_impl(arg, imports_from,
rhs_pspecs, &tmpref, recursion_depth);
if(!expr && !(arg->expr->_mark & TM_BROKEN)
&& !(imports_from->_tags & MT_STANDARD_MODULE)) {
arg->expr->_mark |= TM_BROKEN;
@ -285,9 +286,38 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int
if(strcmp(ref_tc->Identifier, identifier) == 0)
break;
}
if(ref_tc)
return ref_tc;
if(ref_tc) {
if(rhs_pspecs && !ref_tc->lhs_params) {
FATAL("Parameterized type %s expected "
"for %s at line %d",
ref_tc->Identifier,
asn1f_printable_reference(ref),
ref->_lineno);
errno = EPERM;
return NULL;
}
if(!rhs_pspecs && ref_tc->lhs_params) {
FATAL("Type %s expects specialization "
"from %s at line %d",
ref_tc->Identifier,
asn1f_printable_reference(ref),
ref->_lineno);
errno = EPERM;
return NULL;
}
if(rhs_pspecs && ref_tc->lhs_params) {
/* Specialize the target */
ref_tc = asn1f_parameterization_fork(arg,
ref_tc, rhs_pspecs);
}
return ref_tc;
}
/*
* Not found in the current module.
* Search in our default standard module.
*/
{
/* Search inside standard module */
static asn1p_oid_t *uioc_oid;
@ -335,8 +365,9 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int
asn1p_expr_t *
asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
return asn1f_lookup_symbol_impl(arg, mod, ref, 0);
asn1f_lookup_symbol(arg_t *arg,
asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, asn1p_ref_t *ref) {
return asn1f_lookup_symbol_impl(arg, mod, rhs_pspecs, ref, 0);
}
asn1p_expr_t *
@ -397,7 +428,7 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, enum ftt_what what) {
/*
* Lookup inside the default module and its IMPORTS section.
*/
tc = asn1f_lookup_symbol(arg, expr->module, ref);
tc = asn1f_lookup_symbol(arg, expr->module, expr->rhs_pspecs, ref);
if(tc == NULL) {
DEBUG("\tSymbol \"%s\" not found: %s",
asn1f_printable_reference(ref),

View File

@ -39,6 +39,7 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg,
*/
asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg,
asn1p_module_t *mod,
asn1p_expr_t *rhs_pspecs,
asn1p_ref_t *ref);
/*

View File

@ -66,7 +66,7 @@ asn1f_fetch_tags_impl(arg_t *arg, struct asn1p_type_tag_s **tags, int count, int
if(expr->meta_type == AMT_TYPEREF) {
asn1p_expr_t *nexpr;
DEBUG("Following the reference %s", expr->Identifier);
nexpr = asn1f_lookup_symbol(arg, expr->module, expr->reference);
nexpr = asn1f_lookup_symbol(arg, expr->module, expr->rhs_pspecs, expr->reference);
if(nexpr == NULL) {
if(errno != EEXIST) /* -fknown-extern-type */
return -1;

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
@ -45,14 +46,20 @@ asn1p_constraint_free(asn1p_constraint_t *ct) {
asn1p_constraint_t *
asn1p_constraint_clone(asn1p_constraint_t *src) {
return asn1p_constraint_clone_with_resolver(src, 0, 0);
}
asn1p_constraint_t *
asn1p_constraint_clone_with_resolver(asn1p_constraint_t *src,
asn1p_value_t *(*vr)(asn1p_value_t *, void *varg), void *varg) {
asn1p_constraint_t *clone;
#define CLONE(field, func) do { if(src->field) { \
clone->field = func(src->field); \
if(clone->field == NULL) { \
asn1p_constraint_free(clone); \
return NULL; \
} \
#define CLONE(field, func) do { if(src->field) { \
clone->field = func(src->field, vr, varg); \
if(clone->field == NULL) { \
asn1p_constraint_free(clone); \
return NULL; \
} \
} } while(0)
clone = asn1p_constraint_new(src->_lineno);
@ -61,14 +68,14 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
clone->type = src->type;
clone->presence = src->presence;
CLONE(containedSubtype, asn1p_value_clone);
CLONE(value, asn1p_value_clone);
CLONE(range_start, asn1p_value_clone);
CLONE(range_stop, asn1p_value_clone);
CLONE(containedSubtype, asn1p_value_clone_with_resolver);
CLONE(value, asn1p_value_clone_with_resolver);
CLONE(range_start, asn1p_value_clone_with_resolver);
CLONE(range_stop, asn1p_value_clone_with_resolver);
for(i = 0; i < src->el_count; i++) {
asn1p_constraint_t *t;
t = asn1p_constraint_clone(src->elements[i]);
t = asn1p_constraint_clone_with_resolver(src->elements[i], vr, varg);
if(!t) {
asn1p_constraint_free(clone);
return NULL;
@ -86,32 +93,55 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
return clone;
}
/*
* Make sure there's enough space to add an element.
*/
static int
asn1p_constraint_make_memory(asn1p_constraint_t *ct) {
if(ct->el_count == ct->el_size) {
unsigned int newsize = ct->el_size ? ct->el_size << 2 : 4;
void *p;
p = realloc(ct->elements, newsize * sizeof(ct->elements[0]));
if(p) {
ct->elements = p;
ct->el_size = newsize;
} else {
return -1;
}
}
return 0;
}
int
asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) {
assert(into);
assert(what);
/*
* Make sure there's enough space to add an element.
*/
if(into->el_count == into->el_size) {
unsigned int newsize = into->el_size?into->el_size<<2:4;
void *p;
p = realloc(into->elements,
newsize * sizeof(into->elements[0]));
if(p) {
into->elements = p;
into->el_size = newsize;
} else {
return -1;
}
}
if(asn1p_constraint_make_memory(into))
return -1;
into->elements[into->el_count++] = what;
return 0;
}
int
asn1p_constraint_prepend(asn1p_constraint_t *before, asn1p_constraint_t *what) {
assert(before);
assert(what);
if(asn1p_constraint_make_memory(before))
return -1;
memmove(&before->elements[1], &before->elements[0],
before->el_count * sizeof(before->elements[0]));
before->elements[0] = what;
before->el_count++;
return 0;
}
char *
asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {

View File

@ -76,10 +76,14 @@ void asn1p_constraint_free(asn1p_constraint_t *);
* Clone the constraint and all its children.
*/
asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone);
asn1p_constraint_t *asn1p_constraint_clone_with_resolver(
asn1p_constraint_t *source_to_clone,
asn1p_value_t *(*resolver)(asn1p_value_t *, void *), void *);
/*
* Insert additional element into the element array of a (to) constraint.
*/
int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what);
int asn1p_constraint_prepend(asn1p_constraint_t *before, asn1p_constraint_t *what);
#endif /* ASN1_PARSER_CONSTRAINT_H */

View File

@ -6,6 +6,9 @@
#include "asn1parser.h"
static asn1p_expr_t *asn1p_expr_clone_impl(asn1p_expr_t *expr, int skip_extensions, asn1p_expr_t *(*)(asn1p_expr_t *, void *), void *);
static asn1p_value_t *value_resolver(asn1p_value_t *, void *arg);
/*
* Construct a new empty types collection.
*/
@ -16,6 +19,7 @@ asn1p_expr_new(int _lineno) {
expr = calloc(1, sizeof *expr);
if(expr) {
TQ_INIT(&(expr->members));
expr->spec_index = -1;
expr->_lineno = _lineno;
}
@ -24,21 +28,62 @@ asn1p_expr_new(int _lineno) {
asn1p_expr_t *
asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
asn1p_expr_t *clone;
return asn1p_expr_clone_impl(expr, skip_extensions, 0, 0);
}
asn1p_expr_t *
asn1p_expr_clone_with_resolver(asn1p_expr_t *expr, asn1p_expr_t *(*r)(asn1p_expr_t *, void *), void *rarg) {
return asn1p_expr_clone_impl(expr, 0, r, rarg);
}
static asn1p_expr_t *
asn1p_expr_clone_impl(asn1p_expr_t *expr, int skip_extensions, asn1p_expr_t *(*r)(asn1p_expr_t *, void *), void *rarg) {
asn1p_value_t *(*vr)(asn1p_value_t *, void *) = 0;
asn1p_expr_t *clone = 0;
asn1p_expr_t *tcmemb; /* Child of tc */
int hit_ext = 0;
clone = asn1p_expr_new(expr->_lineno);
if(clone == NULL) return NULL;
#define CLCOPY(field) do { clone->field = expr->field; } while(0)
#define CLCLONE(field, func) do { if(expr->field) { \
clone->field = func(expr->field); \
if(clone->field == NULL) { \
asn1p_expr_free(clone); \
return NULL; \
} \
#define CLCLONE(field, func) do { if(expr->field) { \
clone->field = func(expr->field); \
if(clone->field == NULL) { \
asn1p_expr_free(clone); \
return NULL; \
} \
} } while(0)
#define CLVRCLONE(field, func) do { if(expr->field) { \
clone->field = func(expr->field, vr, rarg); \
if(clone->field == NULL) { \
asn1p_expr_free(clone); \
return NULL; \
} \
} } while(0)
if(r) {
vr = value_resolver;
clone = r(expr, rarg);
if(clone) {
/* Merge constraints */
if(expr->constraints) {
asn1p_constraint_t *tmpct = asn1p_constraint_clone_with_resolver(expr->constraints, vr, rarg);
if(clone->constraints) {
if(asn1p_constraint_insert(clone->constraints, tmpct)) {
asn1p_constraint_free(tmpct);
asn1p_expr_free(clone);
return NULL;
}
} else {
clone->constraints = tmpct;
}
}
assert(expr->combined_constraints == 0);
return clone;
} else if(errno != ESRCH) {
return NULL; /* Hard error */
}
}
if(!clone) clone = asn1p_expr_new(expr->_lineno);
if(!clone) return NULL;
/*
* Copy simple fields.
@ -58,10 +103,10 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
*/
CLCLONE(Identifier, strdup);
CLCLONE(reference, asn1p_ref_clone);
CLCLONE(constraints, asn1p_constraint_clone);
CLCLONE(combined_constraints, asn1p_constraint_clone);
CLCLONE(params, asn1p_paramlist_clone);
CLCLONE(value, asn1p_value_clone);
CLVRCLONE(constraints, asn1p_constraint_clone_with_resolver);
CLVRCLONE(combined_constraints, asn1p_constraint_clone_with_resolver);
CLCLONE(lhs_params, asn1p_paramlist_clone);
CLVRCLONE(value, asn1p_value_clone_with_resolver);
CLCLONE(marker.default_value, asn1p_value_clone);
CLCLONE(with_syntax, asn1p_wsyntx_clone);
@ -78,7 +123,7 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
}
if(hit_ext == 1) continue; /* Skip between ...'s */
cmemb = asn1p_expr_clone(tcmemb, skip_extensions);
cmemb = asn1p_expr_clone_impl(tcmemb, skip_extensions, r, rarg);
if(cmemb == NULL) {
asn1p_expr_free(clone);
return NULL;
@ -89,6 +134,48 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
return clone;
}
static asn1p_value_t *
value_resolver(asn1p_value_t *value, void *rarg) {
asn1p_value_t *cval;
asn1p_expr_t *tmpexpr;
asn1p_expr_t *target;
asn1p_ref_t *ref;
struct {
asn1p_expr_t *(*expr_resolve)(asn1p_expr_t *, void *arg);
} *varg = rarg;
if(!value || value->type != ATV_REFERENCED) {
errno = ESRCH;
return NULL;
}
ref = value->value.reference;
tmpexpr = asn1p_expr_new(ref->_lineno);
tmpexpr->meta_type = AMT_TYPEREF;
tmpexpr->expr_type = A1TC_REFERENCE;
tmpexpr->reference = ref;
target = varg->expr_resolve(tmpexpr, rarg);
tmpexpr->reference = 0;
asn1p_expr_free(tmpexpr);
if(!target)
return NULL; /* errno's are compatible */
if(!target->value) {
fprintf(stderr,
"FATAL: Parameterization did not resolve value reference "
"at line %d", ref->_lineno);
asn1p_expr_free(target);
errno = EPERM;
return NULL;
}
cval = asn1p_value_clone(target->value);
asn1p_expr_free(target);
return cval;
}
/*
* Add expression as a member of another.
*/
@ -125,8 +212,8 @@ asn1p_expr_free(asn1p_expr_t *expr) {
asn1p_constraint_free(expr->constraints);
if(expr->combined_constraints)
asn1p_constraint_free(expr->combined_constraints);
if(expr->params)
asn1p_paramlist_free(expr->params);
if(expr->lhs_params)
asn1p_paramlist_free(expr->lhs_params);
if(expr->value)
asn1p_value_free(expr->value);
if(expr->marker.default_value)

View File

@ -11,7 +11,6 @@ typedef enum asn1p_expr_meta {
AMT_INVALID,
AMT_TYPE, /* Type1 ::= INTEGER */
AMT_TYPEREF, /* Type2 ::= Type1 */
AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */
AMT_VALUE, /* value1 Type1 ::= 1 */
AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */
AMT_OBJECT, /* object CLASS ::= {...} */
@ -35,7 +34,6 @@ typedef enum asn1p_expr_type {
A1TC_OPAQUE, /* Opaque data encoded as a bitvector */
A1TC_EXTENSIBLE, /* An extension marker "..." */
A1TC_COMPONENTS_OF, /* COMPONENTS OF clause */
A1TC_PARAMETRIZED, /* A parametrized type declaration */
A1TC_VALUESET, /* Value set definition */
A1TC_CLASSDEF, /* Information Object Class */
A1TC_INSTANCE, /* Instance of Object Class */
@ -148,10 +146,27 @@ typedef struct asn1p_expr_s {
asn1p_constraint_t *combined_constraints;
/*
* A list of parameters for parametrized type declaration
* (AMT_PARAMTYPE).
* Left hand side parameters for parametrized type declaration
* Type{Param1, Param2} ::= SEQUENCE { a Param1, b Param2 }
*/
asn1p_paramlist_t *params;
asn1p_paramlist_t *lhs_params;
/*
* Right hand type specialization.
* Type2 ::= Type{Param1}
*/
struct asn1p_expr_s *rhs_pspecs; /* ->members */
/*
* If lhs_params is defined, this structure represents all possible
* specializations of the parent expression.
*/
struct {
struct asn1p_pspec_s {
struct asn1p_expr_s *rhs_pspecs;
struct asn1p_expr_s *my_clone;
} *pspec;
int pspecs_count; /* Number of specializations */
} specializations;
int spec_index; /* -1, or 0-based specialization index in the parent */
/*
* The actual value (DefinedValue or inlined value).
@ -258,6 +273,9 @@ typedef struct asn1p_expr_s {
*/
asn1p_expr_t *asn1p_expr_new(int _lineno);
asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *, int skip_extensions);
asn1p_expr_t *asn1p_expr_clone_with_resolver(asn1p_expr_t *,
asn1p_expr_t *(*resolver)(asn1p_expr_t *to_resolve, void *resolver_arg),
void *resolver_arg);
void asn1p_expr_add(asn1p_expr_t *to, asn1p_expr_t *what);
void asn1p_expr_free(asn1p_expr_t *expr);

View File

@ -28,7 +28,7 @@
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
@ -41,9 +41,7 @@
#ifdef __cplusplus
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
@ -83,7 +81,6 @@
#define YY_PROTO(proto) ()
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
@ -1887,7 +1884,7 @@ static asn1c_integer_t _lex_atoi(const char *ptr);
/* Newline */
/* White-space */
#line 1891 "asn1p_l.c"
#line 1888 "asn1p_l.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -1987,20 +1984,9 @@ YY_MALLOC_DECL
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}
else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
&& ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" );
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
@ -2052,7 +2038,7 @@ YY_DECL
#line 93 "asn1p_l.l"
#line 2056 "asn1p_l.c"
#line 2042 "asn1p_l.c"
if ( yy_init )
{
@ -3112,7 +3098,7 @@ YY_RULE_SETUP
#line 538 "asn1p_l.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
#line 3116 "asn1p_l.c"
#line 3102 "asn1p_l.c"
case YY_END_OF_BUFFER:
{
@ -3672,15 +3658,11 @@ YY_BUFFER_STATE b;
}
#ifndef _WIN32
#include <unistd.h>
#else
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif
#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )

View File

@ -61,6 +61,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) {
if(p) {
pl->params = p;
pl->params_size = newsize;
memset(&pl->params[pl->params_count], 0,
sizeof(pl->params[0]));
} else {
return -1;
}
@ -69,9 +71,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) {
if(gov) {
pl->params[pl->params_count].governor = asn1p_ref_clone(gov);
if(pl->params[pl->params_count].governor == NULL) {
if(pl->params[pl->params_count].governor == NULL)
return -1;
}
} else {
pl->params[pl->params_count].governor = 0;
}
@ -103,6 +104,7 @@ asn1p_paramlist_clone(asn1p_paramlist_t *pl) {
newpl = NULL;
break;
}
newpl->params[i].into_expr = pl->params[i].into_expr;
}
}

View File

@ -1,17 +1,21 @@
/*
* Structures and prototypes related to parametrization
* Structures and prototypes related to parameterization
*/
#ifndef ASN1_PARSER_PARAMETRIZATION_H
#define ASN1_PARSER_PARAMETRIZATION_H
#ifndef ASN1_PARSER_PARAMETERIZATION_H
#define ASN1_PARSER_PARAMETERIZATION_H
struct asn1p_expr_s; /* Forward declaration */
typedef struct asn1p_paramlist_s {
struct asn1p_param_s {
/* Translated from */
asn1p_ref_t *governor;
char *argument;
/* Translated into */
struct asn1p_expr_s *into_expr;
} *params;
int params_count;
int params_size;
int _lineno;
} asn1p_paramlist_t;
@ -27,4 +31,4 @@ int asn1p_paramlist_add_param(asn1p_paramlist_t *,
asn1p_ref_t *opt_gov, char *arg);
#endif /* ASN1_PARSER_PARAMETRIZATION_H */
#endif /* ASN1_PARSER_PARAMETERIZATION_H */

View File

@ -110,6 +110,13 @@ asn1p_value_fromint(asn1c_integer_t i) {
asn1p_value_t *
asn1p_value_clone(asn1p_value_t *v) {
return asn1p_value_clone_with_resolver(v, 0, 0);
}
asn1p_value_t *
asn1p_value_clone_with_resolver(asn1p_value_t *v,
asn1p_value_t *(*resolver)(asn1p_value_t *, void *rarg),
void *rarg) {
asn1p_value_t *clone = NULL;
if(v) {
switch(v->type) {
@ -142,6 +149,11 @@ asn1p_value_clone(asn1p_value_t *v) {
return asn1p_value_frombits(v->value.binary_vector.bits,
v->value.binary_vector.size_in_bits, 1);
case ATV_REFERENCED:
if(resolver) {
clone = resolver(v, rarg);
if(clone) return clone;
else if(errno != ESRCH) return NULL;
}
return asn1p_value_fromref(v->value.reference, 1);
case ATV_CHOICE_IDENTIFIER: {
char *id = v->value.choice_identifier.identifier;

View File

@ -52,17 +52,20 @@ typedef struct asn1p_value_s {
} asn1p_value_t;
/*
* Constructors and destructor for value.
* Destructor and constructors for value.
* If ref, bits or buffer are omitted, the corresponding function returns
* (asn1p_value_t *)0 with errno = EINVAL.
* Allocated value (where applicable) is guaranteed to be NUL-terminated.
*/
void asn1p_value_free(asn1p_value_t *);
asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy);
asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc);
asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy);
asn1p_value_t *asn1p_value_fromdouble(double);
asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
asn1p_value_t *asn1p_value_clone(asn1p_value_t *);
void asn1p_value_free(asn1p_value_t *);
asn1p_value_t *asn1p_value_clone_with_resolver(asn1p_value_t *,
asn1p_value_t *(*resolver)(asn1p_value_t *, void *rarg),
void *rarg);
#endif /* ASN1_PARSER_VALUE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,248 +1,4 @@
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
TOK_PPEQ = 258,
TOK_whitespace = 259,
TOK_opaque = 260,
TOK_bstring = 261,
TOK_cstring = 262,
TOK_hstring = 263,
TOK_identifier = 264,
TOK_number = 265,
TOK_tuple = 266,
TOK_quadruple = 267,
TOK_number_negative = 268,
TOK_typereference = 269,
TOK_capitalreference = 270,
TOK_typefieldreference = 271,
TOK_valuefieldreference = 272,
TOK_Literal = 273,
TOK_ABSENT = 274,
TOK_ABSTRACT_SYNTAX = 275,
TOK_ALL = 276,
TOK_ANY = 277,
TOK_APPLICATION = 278,
TOK_AUTOMATIC = 279,
TOK_BEGIN = 280,
TOK_BIT = 281,
TOK_BMPString = 282,
TOK_BOOLEAN = 283,
TOK_BY = 284,
TOK_CHARACTER = 285,
TOK_CHOICE = 286,
TOK_CLASS = 287,
TOK_COMPONENT = 288,
TOK_COMPONENTS = 289,
TOK_CONSTRAINED = 290,
TOK_CONTAINING = 291,
TOK_DEFAULT = 292,
TOK_DEFINITIONS = 293,
TOK_DEFINED = 294,
TOK_EMBEDDED = 295,
TOK_ENCODED = 296,
TOK_ENCODING_CONTROL = 297,
TOK_END = 298,
TOK_ENUMERATED = 299,
TOK_EXPLICIT = 300,
TOK_EXPORTS = 301,
TOK_EXTENSIBILITY = 302,
TOK_EXTERNAL = 303,
TOK_FALSE = 304,
TOK_FROM = 305,
TOK_GeneralizedTime = 306,
TOK_GeneralString = 307,
TOK_GraphicString = 308,
TOK_IA5String = 309,
TOK_IDENTIFIER = 310,
TOK_IMPLICIT = 311,
TOK_IMPLIED = 312,
TOK_IMPORTS = 313,
TOK_INCLUDES = 314,
TOK_INSTANCE = 315,
TOK_INSTRUCTIONS = 316,
TOK_INTEGER = 317,
TOK_ISO646String = 318,
TOK_MAX = 319,
TOK_MIN = 320,
TOK_MINUS_INFINITY = 321,
TOK_NULL = 322,
TOK_NumericString = 323,
TOK_OBJECT = 324,
TOK_ObjectDescriptor = 325,
TOK_OCTET = 326,
TOK_OF = 327,
TOK_OPTIONAL = 328,
TOK_PATTERN = 329,
TOK_PDV = 330,
TOK_PLUS_INFINITY = 331,
TOK_PRESENT = 332,
TOK_PrintableString = 333,
TOK_PRIVATE = 334,
TOK_REAL = 335,
TOK_RELATIVE_OID = 336,
TOK_SEQUENCE = 337,
TOK_SET = 338,
TOK_SIZE = 339,
TOK_STRING = 340,
TOK_SYNTAX = 341,
TOK_T61String = 342,
TOK_TAGS = 343,
TOK_TeletexString = 344,
TOK_TRUE = 345,
TOK_TYPE_IDENTIFIER = 346,
TOK_UNIQUE = 347,
TOK_UNIVERSAL = 348,
TOK_UniversalString = 349,
TOK_UTCTime = 350,
TOK_UTF8String = 351,
TOK_VideotexString = 352,
TOK_VisibleString = 353,
TOK_WITH = 354,
TOK_EXCEPT = 355,
TOK_INTERSECTION = 356,
TOK_UNION = 357,
TOK_TwoDots = 358,
TOK_ThreeDots = 359
};
#endif
/* Tokens. */
#define TOK_PPEQ 258
#define TOK_whitespace 259
#define TOK_opaque 260
#define TOK_bstring 261
#define TOK_cstring 262
#define TOK_hstring 263
#define TOK_identifier 264
#define TOK_number 265
#define TOK_tuple 266
#define TOK_quadruple 267
#define TOK_number_negative 268
#define TOK_typereference 269
#define TOK_capitalreference 270
#define TOK_typefieldreference 271
#define TOK_valuefieldreference 272
#define TOK_Literal 273
#define TOK_ABSENT 274
#define TOK_ABSTRACT_SYNTAX 275
#define TOK_ALL 276
#define TOK_ANY 277
#define TOK_APPLICATION 278
#define TOK_AUTOMATIC 279
#define TOK_BEGIN 280
#define TOK_BIT 281
#define TOK_BMPString 282
#define TOK_BOOLEAN 283
#define TOK_BY 284
#define TOK_CHARACTER 285
#define TOK_CHOICE 286
#define TOK_CLASS 287
#define TOK_COMPONENT 288
#define TOK_COMPONENTS 289
#define TOK_CONSTRAINED 290
#define TOK_CONTAINING 291
#define TOK_DEFAULT 292
#define TOK_DEFINITIONS 293
#define TOK_DEFINED 294
#define TOK_EMBEDDED 295
#define TOK_ENCODED 296
#define TOK_ENCODING_CONTROL 297
#define TOK_END 298
#define TOK_ENUMERATED 299
#define TOK_EXPLICIT 300
#define TOK_EXPORTS 301
#define TOK_EXTENSIBILITY 302
#define TOK_EXTERNAL 303
#define TOK_FALSE 304
#define TOK_FROM 305
#define TOK_GeneralizedTime 306
#define TOK_GeneralString 307
#define TOK_GraphicString 308
#define TOK_IA5String 309
#define TOK_IDENTIFIER 310
#define TOK_IMPLICIT 311
#define TOK_IMPLIED 312
#define TOK_IMPORTS 313
#define TOK_INCLUDES 314
#define TOK_INSTANCE 315
#define TOK_INSTRUCTIONS 316
#define TOK_INTEGER 317
#define TOK_ISO646String 318
#define TOK_MAX 319
#define TOK_MIN 320
#define TOK_MINUS_INFINITY 321
#define TOK_NULL 322
#define TOK_NumericString 323
#define TOK_OBJECT 324
#define TOK_ObjectDescriptor 325
#define TOK_OCTET 326
#define TOK_OF 327
#define TOK_OPTIONAL 328
#define TOK_PATTERN 329
#define TOK_PDV 330
#define TOK_PLUS_INFINITY 331
#define TOK_PRESENT 332
#define TOK_PrintableString 333
#define TOK_PRIVATE 334
#define TOK_REAL 335
#define TOK_RELATIVE_OID 336
#define TOK_SEQUENCE 337
#define TOK_SET 338
#define TOK_SIZE 339
#define TOK_STRING 340
#define TOK_SYNTAX 341
#define TOK_T61String 342
#define TOK_TAGS 343
#define TOK_TeletexString 344
#define TOK_TRUE 345
#define TOK_TYPE_IDENTIFIER 346
#define TOK_UNIQUE 347
#define TOK_UNIVERSAL 348
#define TOK_UniversalString 349
#define TOK_UTCTime 350
#define TOK_UTF8String 351
#define TOK_VideotexString 352
#define TOK_VisibleString 353
#define TOK_WITH 354
#define TOK_EXCEPT 355
#define TOK_INTERSECTION 356
#define TOK_UNION 357
#define TOK_TwoDots 358
#define TOK_ThreeDots 359
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 72 "asn1p_y.y"
typedef union YYSTYPE {
typedef union {
asn1p_t *a_grammar;
asn1p_module_flags_e a_module_flags;
asn1p_module_t *a_module;
@ -275,14 +31,108 @@ typedef union YYSTYPE {
struct asn1p_type_tag_s tag;
} tv_nametag;
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 280 "y.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#define TOK_PPEQ 257
#define TOK_whitespace 258
#define TOK_opaque 259
#define TOK_bstring 260
#define TOK_cstring 261
#define TOK_hstring 262
#define TOK_identifier 263
#define TOK_number 264
#define TOK_tuple 265
#define TOK_quadruple 266
#define TOK_number_negative 267
#define TOK_typereference 268
#define TOK_capitalreference 269
#define TOK_typefieldreference 270
#define TOK_valuefieldreference 271
#define TOK_Literal 272
#define TOK_ABSENT 273
#define TOK_ABSTRACT_SYNTAX 274
#define TOK_ALL 275
#define TOK_ANY 276
#define TOK_APPLICATION 277
#define TOK_AUTOMATIC 278
#define TOK_BEGIN 279
#define TOK_BIT 280
#define TOK_BMPString 281
#define TOK_BOOLEAN 282
#define TOK_BY 283
#define TOK_CHARACTER 284
#define TOK_CHOICE 285
#define TOK_CLASS 286
#define TOK_COMPONENT 287
#define TOK_COMPONENTS 288
#define TOK_CONSTRAINED 289
#define TOK_CONTAINING 290
#define TOK_DEFAULT 291
#define TOK_DEFINITIONS 292
#define TOK_DEFINED 293
#define TOK_EMBEDDED 294
#define TOK_ENCODED 295
#define TOK_ENCODING_CONTROL 296
#define TOK_END 297
#define TOK_ENUMERATED 298
#define TOK_EXPLICIT 299
#define TOK_EXPORTS 300
#define TOK_EXTENSIBILITY 301
#define TOK_EXTERNAL 302
#define TOK_FALSE 303
#define TOK_FROM 304
#define TOK_GeneralizedTime 305
#define TOK_GeneralString 306
#define TOK_GraphicString 307
#define TOK_IA5String 308
#define TOK_IDENTIFIER 309
#define TOK_IMPLICIT 310
#define TOK_IMPLIED 311
#define TOK_IMPORTS 312
#define TOK_INCLUDES 313
#define TOK_INSTANCE 314
#define TOK_INSTRUCTIONS 315
#define TOK_INTEGER 316
#define TOK_ISO646String 317
#define TOK_MAX 318
#define TOK_MIN 319
#define TOK_MINUS_INFINITY 320
#define TOK_NULL 321
#define TOK_NumericString 322
#define TOK_OBJECT 323
#define TOK_ObjectDescriptor 324
#define TOK_OCTET 325
#define TOK_OF 326
#define TOK_OPTIONAL 327
#define TOK_PATTERN 328
#define TOK_PDV 329
#define TOK_PLUS_INFINITY 330
#define TOK_PRESENT 331
#define TOK_PrintableString 332
#define TOK_PRIVATE 333
#define TOK_REAL 334
#define TOK_RELATIVE_OID 335
#define TOK_SEQUENCE 336
#define TOK_SET 337
#define TOK_SIZE 338
#define TOK_STRING 339
#define TOK_SYNTAX 340
#define TOK_T61String 341
#define TOK_TAGS 342
#define TOK_TeletexString 343
#define TOK_TRUE 344
#define TOK_TYPE_IDENTIFIER 345
#define TOK_UNIQUE 346
#define TOK_UNIVERSAL 347
#define TOK_UniversalString 348
#define TOK_UTCTime 349
#define TOK_UTF8String 350
#define TOK_VideotexString 351
#define TOK_VisibleString 352
#define TOK_WITH 353
#define TOK_EXCEPT 354
#define TOK_INTERSECTION 355
#define TOK_UNION 356
#define TOK_TwoDots 357
#define TOK_ThreeDots 358
extern YYSTYPE asn1p_lval;

View File

@ -270,8 +270,8 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
%type <tv_str> optIdentifier
%type <a_parg> ParameterArgumentName
%type <a_plist> ParameterArgumentList
%type <a_expr> ActualParameter
%type <a_expr> ActualParameterList
%type <a_expr> Specialization
%type <a_expr> Specializations
%type <a_aid> AssignedIdentifier /* OID/DefinedValue */
%type <a_oid> ObjectIdentifier /* OID */
%type <a_oid> optObjectIdentifier /* Optional OID */
@ -774,8 +774,7 @@ DataTypeReference:
$$ = $6;
assert($$->Identifier == 0);
$$->Identifier = $1;
$$->params = $3;
$$->meta_type = AMT_PARAMTYPE;
$$->lhs_params = $3;
}
;
@ -828,33 +827,37 @@ ParameterArgumentName:
}
;
ActualParameterList:
ActualParameter {
Specializations:
Specialization {
$$ = asn1p_expr_new(yylineno);
checkmem($$);
asn1p_expr_add($$, $1);
}
| ActualParameterList ',' ActualParameter {
| Specializations ',' Specialization {
$$ = $1;
asn1p_expr_add($$, $3);
}
;
ActualParameter:
Specialization:
Type {
$$ = $1;
}
| Identifier {
asn1p_ref_t *ref;
$$ = asn1p_expr_new(yylineno);
checkmem($$);
$$->Identifier = $1;
$$->expr_type = A1TC_REFERENCE;
$$->meta_type = AMT_VALUE;
ref = asn1p_ref_new(yylineno);
asn1p_ref_add_component(ref, $1, RLT_lowercase);
$$->value = asn1p_value_fromref(ref, 0);
}
;
/*
| '{' ActualParameter '}' {
| '{' Specialization '}' {
$$ = asn1p_expr_new(yylineno);
checkmem($$);
asn1p_expr_add($$, $2);
@ -1223,23 +1226,6 @@ TypeDeclarationSet:
$$->expr_type = ASN_TYPE_ANY;
$$->meta_type = AMT_TYPE;
}
/*
* A parametrized assignment.
*/
| TypeRefName '{' ActualParameterList '}' {
int ret;
$$ = $3;
assert($$->expr_type == 0);
assert($$->meta_type == 0);
assert($$->reference == 0);
$$->reference = asn1p_ref_new(yylineno);
checkmem($$->reference);
ret = asn1p_ref_add_component($$->reference, $1, RLT_UNKNOWN);
checkmem(ret == 0);
free($1);
$$->expr_type = A1TC_PARAMETRIZED;
$$->meta_type = AMT_TYPE;
}
/*
* A DefinedType reference.
* "CLASS1.&id.&id2"
@ -1257,6 +1243,17 @@ TypeDeclarationSet:
$$->expr_type = A1TC_REFERENCE;
$$->meta_type = AMT_TYPEREF;
}
/*
* A parametrized assignment.
*/
| ComplexTypeReference '{' Specializations '}' {
$$ = asn1p_expr_new(yylineno);
checkmem($$);
$$->reference = $1;
$$->rhs_pspecs = $3;
$$->expr_type = A1TC_REFERENCE;
$$->meta_type = AMT_TYPEREF;
}
| TOK_INSTANCE TOK_OF ComplexTypeReference {
$$ = asn1p_expr_new(yylineno);
checkmem($$);

View File

@ -165,6 +165,15 @@ _asn1p_apply_module2expr(asn1p_expr_t *expr, asn1p_module_t *mod) {
TQ_FOR(e, &(expr->members), next) {
_asn1p_apply_module2expr(e, mod);
}
/*
* Do to parameterization.
*/
if(expr->rhs_pspecs) {
TQ_FOR(e, &(expr->rhs_pspecs->members), next) {
_asn1p_apply_module2expr(e, mod);
}
}
}
static int

View File

@ -42,7 +42,7 @@ typedef intmax_t asn1c_integer_t;
#include "asn1p_oid.h" /* Object identifiers (OIDs) */
#include "asn1p_ref.h" /* References to custom types */
#include "asn1p_value.h" /* Value definition */
#include "asn1p_param.h" /* Parametrization */
#include "asn1p_param.h" /* Parameterization */
#include "asn1p_constr.h" /* Type Constraints */
#include "asn1p_xports.h" /* IMports/EXports */
#include "asn1p_module.h" /* ASN.1 definition module */

View File

@ -525,11 +525,13 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
INDENT("--<ASN1C.RepresentAsPointer>--\n");
}
if(tc->Identifier)
if(tc->Identifier
&& (!(tc->meta_type == AMT_VALUE && tc->expr_type == A1TC_REFERENCE)
|| level == 0))
INDENT("%s", tc->Identifier);
if(tc->params) {
asn1print_params(tc->params, flags);
if(tc->lhs_params) {
asn1print_params(tc->lhs_params, flags);
}
if(tc->meta_type != AMT_VALUE
@ -559,8 +561,6 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */
printf(" COMPONENTS OF");
break;
case A1TC_PARAMETRIZED:
flags |= APF_NOINDENT;
case A1TC_REFERENCE:
case A1TC_UNIVERVAL:
break;
@ -662,6 +662,16 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
printf("}\n");
}
/* Right hand specialization */
if(tc->rhs_pspecs) {
asn1p_expr_t *se;
printf("{");
TQ_FOR(se, &(tc->rhs_pspecs->members), next) {
asn1print_expr(asn, mod, se, flags, level + 1);
}
printf("}");
}
if(!SEQ_OF && tc->constraints) {
printf(" ");
asn1print_constraint(tc->constraints, flags);
@ -680,7 +690,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
printf(")");
}
} else {
printf(" ::= ");
if(level == 0) printf(" ::= ");
asn1print_value(tc->value, flags);
}
}
@ -746,6 +756,28 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
}
} while(0);
if(flags & APF_PRINT_CLASS_MATRIX
&& tc->lhs_params) do {
int i;
if(tc->specializations.pspecs_count == 0) {
printf("\n-- No specializations found\n");
break;
}
printf("\n-- Specializations list has %d entr%s:\n",
tc->specializations.pspecs_count,
tc->specializations.pspecs_count == 1 ? "y" : "ies");
for(i = 0; i < tc->specializations.pspecs_count; i++) {
asn1p_expr_t *se;
struct asn1p_pspec_s *pspec;
pspec = &tc->specializations.pspec[i];
printf("-- ");
TQ_FOR(se, &(pspec->rhs_pspecs->members), next) {
asn1print_expr(asn, mod, se, flags, level+1);
}
printf("\n");
}
} while(0);
return 0;
}

21
tests/104-param-1-OK.asn1 Normal file
View File

@ -0,0 +1,21 @@
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .104
ModuleParametrization1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 104 }
DEFINITIONS ::=
BEGIN
Collection {T} ::= SET OF T
Bunch ::= SEQUENCE {
field-REAL Collection {REAL},
field-IA5String Collection {IA5String}
}
END

View File

@ -0,0 +1,17 @@
ModuleParametrization1 { iso org(3) dod(6) internet(1) private(4)
enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 104 }
DEFINITIONS ::=
BEGIN
Collection{T} ::= SET OF T
-- Specializations list has 2 entries:
-- REAL
-- IA5String
Bunch ::= SEQUENCE {
field-REAL Collection{ REAL},
field-IA5String Collection{ IA5String}
}
END

View File

@ -0,0 +1,198 @@
/*** <<< INCLUDES [Collection] >>> ***/
#include <REAL.h>
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
#include <IA5String.h>
/*** <<< TYPE-DECLS [Collection] >>> ***/
typedef struct Collection_16P0 {
A_SET_OF(REAL_t) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Collection_16P0_t;
typedef struct Collection_16P1 {
A_SET_OF(IA5String_t) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Collection_16P1_t;
/*** <<< FUNC-DECLS [Collection] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Collection_16P0;
extern asn_TYPE_descriptor_t asn_DEF_Collection_16P1;
/*** <<< STAT-DEFS [Collection] >>> ***/
static asn_TYPE_member_t asn_MBR_Collection_16P0_1[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)),
.tag_mode = 0,
.type = &asn_DEF_REAL,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = ""
},
};
static ber_tlv_tag_t asn_DEF_Collection_16P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_Collection_16P0_specs_1 = {
sizeof(struct Collection_16P0),
offsetof(struct Collection_16P0, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
asn_TYPE_descriptor_t asn_DEF_Collection_16P0 = {
"Collection",
"Collection",
SET_OF_free,
SET_OF_print,
SET_OF_constraint,
SET_OF_decode_ber,
SET_OF_encode_der,
SET_OF_decode_xer,
SET_OF_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Collection_16P0_tags_1,
sizeof(asn_DEF_Collection_16P0_tags_1)
/sizeof(asn_DEF_Collection_16P0_tags_1[0]), /* 1 */
asn_DEF_Collection_16P0_tags_1, /* Same as above */
sizeof(asn_DEF_Collection_16P0_tags_1)
/sizeof(asn_DEF_Collection_16P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_Collection_16P0_1,
1, /* Single element */
&asn_SPC_Collection_16P0_specs_1 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_Collection_16P1_3[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
.type = &asn_DEF_IA5String,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = ""
},
};
static ber_tlv_tag_t asn_DEF_Collection_16P1_tags_3[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_Collection_16P1_specs_3 = {
sizeof(struct Collection_16P1),
offsetof(struct Collection_16P1, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
asn_TYPE_descriptor_t asn_DEF_Collection_16P1 = {
"Collection",
"Collection",
SET_OF_free,
SET_OF_print,
SET_OF_constraint,
SET_OF_decode_ber,
SET_OF_encode_der,
SET_OF_decode_xer,
SET_OF_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Collection_16P1_tags_3,
sizeof(asn_DEF_Collection_16P1_tags_3)
/sizeof(asn_DEF_Collection_16P1_tags_3[0]), /* 1 */
asn_DEF_Collection_16P1_tags_3, /* Same as above */
sizeof(asn_DEF_Collection_16P1_tags_3)
/sizeof(asn_DEF_Collection_16P1_tags_3[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_Collection_16P1_3,
1, /* Single element */
&asn_SPC_Collection_16P1_specs_3 /* Additional specs */
};
/*** <<< INCLUDES [Bunch] >>> ***/
#include <Collection.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Bunch] >>> ***/
typedef struct Bunch {
Collection_16P0_t field_REAL;
Collection_16P1_t field_IA5String;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Bunch_t;
/*** <<< FUNC-DECLS [Bunch] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Bunch;
/*** <<< STAT-DEFS [Bunch] >>> ***/
static asn_TYPE_member_t asn_MBR_Bunch_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Bunch, field_REAL),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Collection_16P0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "field-REAL"
},
{ ATF_NOFLAGS, 0, offsetof(struct Bunch, field_IA5String),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Collection_16P1,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "field-IA5String"
},
};
static ber_tlv_tag_t asn_DEF_Bunch_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_Bunch_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0, 0, 1 }, /* field-REAL at 17 */
{ (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 1, -1, 0 } /* field-IA5String at 18 */
};
static asn_SEQUENCE_specifics_t asn_SPC_Bunch_specs_1 = {
sizeof(struct Bunch),
offsetof(struct Bunch, _asn_ctx),
asn_MAP_Bunch_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_Bunch = {
"Bunch",
"Bunch",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Bunch_tags_1,
sizeof(asn_DEF_Bunch_tags_1)
/sizeof(asn_DEF_Bunch_tags_1[0]), /* 1 */
asn_DEF_Bunch_tags_1, /* Same as above */
sizeof(asn_DEF_Bunch_tags_1)
/sizeof(asn_DEF_Bunch_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_Bunch_1,
2, /* Elements count */
&asn_SPC_Bunch_specs_1 /* Additional specs */
};

21
tests/105-param-2-OK.asn1 Normal file
View File

@ -0,0 +1,21 @@
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .105
ModuleParametrization2
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 105 }
DEFINITIONS ::=
BEGIN
SIGNED {Type} ::= SEQUENCE {
signed Type
}
SignedREAL ::= SIGNED {REAL}
SignedSET ::= SIGNED { SET { a INTEGER } }
END

View File

@ -0,0 +1,451 @@
/*** <<< INCLUDES [SIGNED] >>> ***/
#include <REAL.h>
#include <constr_SEQUENCE.h>
#include <INTEGER.h>
#include <constr_SET.h>
/*** <<< DEPS [SIGNED] >>> ***/
/*
* Method of determining the components presence
*/
typedef enum signed_PR {
signed_PR_a, /* Member a is present */
} signed_PR;
/*** <<< TYPE-DECLS [SIGNED] >>> ***/
typedef struct SIGNED_16P0 {
REAL_t Signed;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SIGNED_16P0_t;
typedef struct SIGNED_16P1 {
struct Signed {
INTEGER_t a;
/* Presence bitmask: ASN_SET_ISPRESENT(psigned, signed_PR_x) */
unsigned int _presence_map
[((1+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Signed;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SIGNED_16P1_t;
/*** <<< FUNC-DECLS [SIGNED] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_SIGNED_16P0;
extern asn_TYPE_descriptor_t asn_DEF_SIGNED_16P1;
/*** <<< STAT-DEFS [SIGNED] >>> ***/
static asn_TYPE_member_t asn_MBR_SIGNED_16P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct SIGNED_16P0, Signed),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)),
.tag_mode = 0,
.type = &asn_DEF_REAL,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed"
},
};
static ber_tlv_tag_t asn_DEF_SIGNED_16P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_SIGNED_16P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), 0, 0, 0 } /* signed at 18 */
};
static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_16P0_specs_1 = {
sizeof(struct SIGNED_16P0),
offsetof(struct SIGNED_16P0, _asn_ctx),
asn_MAP_SIGNED_16P0_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_SIGNED_16P0 = {
"SIGNED",
"SIGNED",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_SIGNED_16P0_tags_1,
sizeof(asn_DEF_SIGNED_16P0_tags_1)
/sizeof(asn_DEF_SIGNED_16P0_tags_1[0]), /* 1 */
asn_DEF_SIGNED_16P0_tags_1, /* Same as above */
sizeof(asn_DEF_SIGNED_16P0_tags_1)
/sizeof(asn_DEF_SIGNED_16P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_SIGNED_16P0_1,
1, /* Elements count */
&asn_SPC_SIGNED_16P0_specs_1 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_signed_4[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Signed, a),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_INTEGER,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "a"
},
};
static ber_tlv_tag_t asn_DEF_signed_tags_4[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_signed_tag2el_4[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* a at 19 */
};
static uint8_t asn_MAP_signed_mmap_4[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7)
};
static asn_SET_specifics_t asn_SPC_signed_specs_4 = {
sizeof(struct Signed),
offsetof(struct Signed, _asn_ctx),
offsetof(struct Signed, _presence_map),
asn_MAP_signed_tag2el_4,
1, /* Count of tags in the map */
asn_MAP_signed_tag2el_4, /* Same as above */
1, /* Count of tags in the CXER map */
0, /* Whether extensible */
(unsigned int *)asn_MAP_signed_mmap_4 /* Mandatory elements map */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_signed_4 = {
"signed",
"signed",
SET_free,
SET_print,
SET_constraint,
SET_decode_ber,
SET_encode_der,
SET_decode_xer,
SET_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_signed_tags_4,
sizeof(asn_DEF_signed_tags_4)
/sizeof(asn_DEF_signed_tags_4[0]), /* 1 */
asn_DEF_signed_tags_4, /* Same as above */
sizeof(asn_DEF_signed_tags_4)
/sizeof(asn_DEF_signed_tags_4[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_signed_4,
1, /* Elements count */
&asn_SPC_signed_specs_4 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_SIGNED_16P1_3[] = {
{ ATF_NOFLAGS, 0, offsetof(struct SIGNED_16P1, Signed),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
.type = &asn_DEF_signed_4,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed"
},
};
static ber_tlv_tag_t asn_DEF_SIGNED_16P1_tags_3[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_SIGNED_16P1_tag2el_3[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0, 0, 0 } /* signed at 19 */
};
static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_16P1_specs_3 = {
sizeof(struct SIGNED_16P1),
offsetof(struct SIGNED_16P1, _asn_ctx),
asn_MAP_SIGNED_16P1_tag2el_3,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_SIGNED_16P1 = {
"SIGNED",
"SIGNED",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_SIGNED_16P1_tags_3,
sizeof(asn_DEF_SIGNED_16P1_tags_3)
/sizeof(asn_DEF_SIGNED_16P1_tags_3[0]), /* 1 */
asn_DEF_SIGNED_16P1_tags_3, /* Same as above */
sizeof(asn_DEF_SIGNED_16P1_tags_3)
/sizeof(asn_DEF_SIGNED_16P1_tags_3[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_SIGNED_16P1_3,
1, /* Elements count */
&asn_SPC_SIGNED_16P1_specs_3 /* Additional specs */
};
/*** <<< INCLUDES [SignedREAL] >>> ***/
#include <SIGNED.h>
/*** <<< TYPE-DECLS [SignedREAL] >>> ***/
typedef SIGNED_16P0_t SignedREAL_t;
/*** <<< FUNC-DECLS [SignedREAL] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_SignedREAL;
asn_struct_free_f SignedREAL_free;
asn_struct_print_f SignedREAL_print;
asn_constr_check_f SignedREAL_constraint;
ber_type_decoder_f SignedREAL_decode_ber;
der_type_encoder_f SignedREAL_encode_der;
xer_type_decoder_f SignedREAL_decode_xer;
xer_type_encoder_f SignedREAL_encode_xer;
/*** <<< CODE [SignedREAL] >>> ***/
int
SignedREAL_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
td->check_constraints = asn_DEF_SIGNED_16P0.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
}
/*
* This type is implemented using SIGNED_16P0,
* so here we adjust the DEF accordingly.
*/
static void
SignedREAL_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_SIGNED_16P0.free_struct;
td->print_struct = asn_DEF_SIGNED_16P0.print_struct;
td->ber_decoder = asn_DEF_SIGNED_16P0.ber_decoder;
td->der_encoder = asn_DEF_SIGNED_16P0.der_encoder;
td->xer_decoder = asn_DEF_SIGNED_16P0.xer_decoder;
td->xer_encoder = asn_DEF_SIGNED_16P0.xer_encoder;
td->uper_decoder = asn_DEF_SIGNED_16P0.uper_decoder;
if(!td->per_constraints)
td->per_constraints = asn_DEF_SIGNED_16P0.per_constraints;
td->elements = asn_DEF_SIGNED_16P0.elements;
td->elements_count = asn_DEF_SIGNED_16P0.elements_count;
td->specifics = asn_DEF_SIGNED_16P0.specifics;
}
void
SignedREAL_free(asn_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
SignedREAL_1_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
SignedREAL_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
SignedREAL_1_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
asn_dec_rval_t
SignedREAL_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const void *bufptr, size_t size, int tag_mode) {
SignedREAL_1_inherit_TYPE_descriptor(td);
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
}
asn_enc_rval_t
SignedREAL_encode_der(asn_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
SignedREAL_1_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
asn_dec_rval_t
SignedREAL_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, const void *bufptr, size_t size) {
SignedREAL_1_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
asn_enc_rval_t
SignedREAL_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
SignedREAL_1_inherit_TYPE_descriptor(td);
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
}
/*** <<< STAT-DEFS [SignedREAL] >>> ***/
static ber_tlv_tag_t asn_DEF_SignedREAL_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_TYPE_descriptor_t asn_DEF_SignedREAL = {
"SignedREAL",
"SignedREAL",
SignedREAL_free,
SignedREAL_print,
SignedREAL_constraint,
SignedREAL_decode_ber,
SignedREAL_encode_der,
SignedREAL_decode_xer,
SignedREAL_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_SignedREAL_tags_1,
sizeof(asn_DEF_SignedREAL_tags_1)
/sizeof(asn_DEF_SignedREAL_tags_1[0]), /* 1 */
asn_DEF_SignedREAL_tags_1, /* Same as above */
sizeof(asn_DEF_SignedREAL_tags_1)
/sizeof(asn_DEF_SignedREAL_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};
/*** <<< INCLUDES [SignedSET] >>> ***/
#include <SIGNED.h>
/*** <<< TYPE-DECLS [SignedSET] >>> ***/
typedef SIGNED_16P1_t SignedSET_t;
/*** <<< FUNC-DECLS [SignedSET] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_SignedSET;
asn_struct_free_f SignedSET_free;
asn_struct_print_f SignedSET_print;
asn_constr_check_f SignedSET_constraint;
ber_type_decoder_f SignedSET_decode_ber;
der_type_encoder_f SignedSET_encode_der;
xer_type_decoder_f SignedSET_decode_xer;
xer_type_encoder_f SignedSET_encode_xer;
/*** <<< CODE [SignedSET] >>> ***/
int
SignedSET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
td->check_constraints = asn_DEF_SIGNED_16P1.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
}
/*
* This type is implemented using SIGNED_16P1,
* so here we adjust the DEF accordingly.
*/
static void
SignedSET_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_SIGNED_16P1.free_struct;
td->print_struct = asn_DEF_SIGNED_16P1.print_struct;
td->ber_decoder = asn_DEF_SIGNED_16P1.ber_decoder;
td->der_encoder = asn_DEF_SIGNED_16P1.der_encoder;
td->xer_decoder = asn_DEF_SIGNED_16P1.xer_decoder;
td->xer_encoder = asn_DEF_SIGNED_16P1.xer_encoder;
td->uper_decoder = asn_DEF_SIGNED_16P1.uper_decoder;
if(!td->per_constraints)
td->per_constraints = asn_DEF_SIGNED_16P1.per_constraints;
td->elements = asn_DEF_SIGNED_16P1.elements;
td->elements_count = asn_DEF_SIGNED_16P1.elements_count;
td->specifics = asn_DEF_SIGNED_16P1.specifics;
}
void
SignedSET_free(asn_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
SignedSET_1_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
SignedSET_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
SignedSET_1_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
asn_dec_rval_t
SignedSET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const void *bufptr, size_t size, int tag_mode) {
SignedSET_1_inherit_TYPE_descriptor(td);
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
}
asn_enc_rval_t
SignedSET_encode_der(asn_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
SignedSET_1_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
asn_dec_rval_t
SignedSET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, const void *bufptr, size_t size) {
SignedSET_1_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
asn_enc_rval_t
SignedSET_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
SignedSET_1_inherit_TYPE_descriptor(td);
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
}
/*** <<< STAT-DEFS [SignedSET] >>> ***/
static ber_tlv_tag_t asn_DEF_SignedSET_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_TYPE_descriptor_t asn_DEF_SignedSET = {
"SignedSET",
"SignedSET",
SignedSET_free,
SignedSET_print,
SignedSET_constraint,
SignedSET_decode_ber,
SignedSET_encode_der,
SignedSET_decode_xer,
SignedSET_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_SignedSET_tags_1,
sizeof(asn_DEF_SignedSET_tags_1)
/sizeof(asn_DEF_SignedSET_tags_1[0]), /* 1 */
asn_DEF_SignedSET_tags_1, /* Same as above */
sizeof(asn_DEF_SignedSET_tags_1)
/sizeof(asn_DEF_SignedSET_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};

View File

@ -0,0 +1,20 @@
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .106
ModuleParametrizationWithConstraints
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 106 }
DEFINITIONS ::=
BEGIN
Narrow {Type} ::= SEQUENCE {
narrower Type (2..5)
}
NarrowInteger ::= Narrow {INTEGER (0..10)}
END

View File

@ -0,0 +1,222 @@
/*** <<< INCLUDES [Narrow] >>> ***/
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Narrow] >>> ***/
typedef struct Narrow_16P0 {
long narrower;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Narrow_16P0_t;
/*** <<< FUNC-DECLS [Narrow] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Narrow_16P0;
/*** <<< CODE [Narrow] >>> ***/
static int
memb_narrower_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
long value;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 2 && value <= 5)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*** <<< STAT-DEFS [Narrow] >>> ***/
static asn_TYPE_member_t asn_MBR_Narrow_16P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Narrow_16P0, narrower),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_narrower_constraint_1,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "narrower"
},
};
static ber_tlv_tag_t asn_DEF_Narrow_16P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_Narrow_16P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* narrower at 18 */
};
static asn_SEQUENCE_specifics_t asn_SPC_Narrow_16P0_specs_1 = {
sizeof(struct Narrow_16P0),
offsetof(struct Narrow_16P0, _asn_ctx),
asn_MAP_Narrow_16P0_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_Narrow_16P0 = {
"Narrow",
"Narrow",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Narrow_16P0_tags_1,
sizeof(asn_DEF_Narrow_16P0_tags_1)
/sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */
asn_DEF_Narrow_16P0_tags_1, /* Same as above */
sizeof(asn_DEF_Narrow_16P0_tags_1)
/sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_Narrow_16P0_1,
1, /* Elements count */
&asn_SPC_Narrow_16P0_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [NarrowInteger] >>> ***/
#include <Narrow.h>
/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/
typedef Narrow_16P0_t NarrowInteger_t;
/*** <<< FUNC-DECLS [NarrowInteger] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger;
asn_struct_free_f NarrowInteger_free;
asn_struct_print_f NarrowInteger_print;
asn_constr_check_f NarrowInteger_constraint;
ber_type_decoder_f NarrowInteger_decode_ber;
der_type_encoder_f NarrowInteger_encode_der;
xer_type_decoder_f NarrowInteger_decode_xer;
xer_type_encoder_f NarrowInteger_encode_xer;
/*** <<< CODE [NarrowInteger] >>> ***/
int
NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
td->check_constraints = asn_DEF_Narrow_16P0.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
}
/*
* This type is implemented using Narrow_16P0,
* so here we adjust the DEF accordingly.
*/
static void
NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_Narrow_16P0.free_struct;
td->print_struct = asn_DEF_Narrow_16P0.print_struct;
td->ber_decoder = asn_DEF_Narrow_16P0.ber_decoder;
td->der_encoder = asn_DEF_Narrow_16P0.der_encoder;
td->xer_decoder = asn_DEF_Narrow_16P0.xer_decoder;
td->xer_encoder = asn_DEF_Narrow_16P0.xer_encoder;
td->uper_decoder = asn_DEF_Narrow_16P0.uper_decoder;
if(!td->per_constraints)
td->per_constraints = asn_DEF_Narrow_16P0.per_constraints;
td->elements = asn_DEF_Narrow_16P0.elements;
td->elements_count = asn_DEF_Narrow_16P0.elements_count;
td->specifics = asn_DEF_Narrow_16P0.specifics;
}
void
NarrowInteger_free(asn_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
asn_dec_rval_t
NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const void *bufptr, size_t size, int tag_mode) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
}
asn_enc_rval_t
NarrowInteger_encode_der(asn_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
asn_dec_rval_t
NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, const void *bufptr, size_t size) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
asn_enc_rval_t
NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
NarrowInteger_1_inherit_TYPE_descriptor(td);
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
}
/*** <<< STAT-DEFS [NarrowInteger] >>> ***/
static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NarrowInteger = {
"NarrowInteger",
"NarrowInteger",
NarrowInteger_free,
NarrowInteger_print,
NarrowInteger_constraint,
NarrowInteger_decode_ber,
NarrowInteger_encode_der,
NarrowInteger_decode_xer,
NarrowInteger_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_NarrowInteger_tags_1,
sizeof(asn_DEF_NarrowInteger_tags_1)
/sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
asn_DEF_NarrowInteger_tags_1, /* Same as above */
sizeof(asn_DEF_NarrowInteger_tags_1)
/sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};

View File

@ -9,15 +9,11 @@ SIGNED{ToBeSigned} ::= SEQUENCE {
signature BIT STRING SIZE(0..256)
}
Certificate ::= SEQUENCE {
toBeSigned SEQUENCE {
Certificate ::= SIGNED{ SEQUENCE {
version INTEGER,
signature OBJECT IDENTIFIER,
issuer Name
},
algorithm OBJECT IDENTIFIER,
signature BIT STRING SIZE(0..256)
}
}}
Name ::= SEQUENCE OF RelativeDistinguishedName

View File

@ -1,5 +1,5 @@
/*** <<< INCLUDES [Certificate] >>> ***/
/*** <<< INCLUDES [SIGNED] >>> ***/
#include <OBJECT_IDENTIFIER.h>
#include <BIT_STRING.h>
@ -7,9 +7,9 @@
#include <Name.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Certificate] >>> ***/
/*** <<< TYPE-DECLS [SIGNED] >>> ***/
typedef struct Certificate {
typedef struct SIGNED_15P0 {
struct toBeSigned {
INTEGER_t version;
OBJECT_IDENTIFIER_t signature;
@ -23,13 +23,13 @@ typedef struct Certificate {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Certificate_t;
} SIGNED_15P0_t;
/*** <<< FUNC-DECLS [Certificate] >>> ***/
/*** <<< FUNC-DECLS [SIGNED] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Certificate;
extern asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0;
/*** <<< CODE [Certificate] >>> ***/
/*** <<< CODE [SIGNED] >>> ***/
static int
memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
@ -63,7 +63,7 @@ memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
}
/*** <<< STAT-DEFS [Certificate] >>> ***/
/*** <<< STAT-DEFS [SIGNED] >>> ***/
static asn_TYPE_member_t asn_MBR_toBeSigned_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version),
@ -136,8 +136,8 @@ asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = {
&asn_SPC_toBeSigned_specs_2 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, toBeSigned),
static asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, toBeSigned),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_toBeSigned_2,
@ -146,7 +146,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.default_value = 0,
.name = "toBeSigned"
},
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, algorithm),
{ ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, algorithm),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0,
.type = &asn_DEF_OBJECT_IDENTIFIER,
@ -155,7 +155,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.default_value = 0,
.name = "algorithm"
},
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, signature),
{ ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, signature),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0,
.type = &asn_DEF_BIT_STRING,
@ -165,26 +165,26 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.name = "signature"
},
};
static ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = {
static ber_tlv_tag_t asn_DEF_SIGNED_15P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_Certificate_tag2el_1[] = {
static asn_TYPE_tag2member_t asn_MAP_SIGNED_15P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature at 17 */
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned at 21 */
};
static asn_SEQUENCE_specifics_t asn_SPC_Certificate_specs_1 = {
sizeof(struct Certificate),
offsetof(struct Certificate, _asn_ctx),
asn_MAP_Certificate_tag2el_1,
static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1 = {
sizeof(struct SIGNED_15P0),
offsetof(struct SIGNED_15P0, _asn_ctx),
asn_MAP_SIGNED_15P0_tag2el_1,
3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_Certificate = {
"Certificate",
"Certificate",
asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0 = {
"SIGNED",
"SIGNED",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
@ -194,6 +194,130 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = {
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_SIGNED_15P0_tags_1,
sizeof(asn_DEF_SIGNED_15P0_tags_1)
/sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
asn_DEF_SIGNED_15P0_tags_1, /* Same as above */
sizeof(asn_DEF_SIGNED_15P0_tags_1)
/sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_SIGNED_15P0_1,
3, /* Elements count */
&asn_SPC_SIGNED_15P0_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [Certificate] >>> ***/
#include <SIGNED.h>
/*** <<< TYPE-DECLS [Certificate] >>> ***/
typedef SIGNED_15P0_t Certificate_t;
/*** <<< FUNC-DECLS [Certificate] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Certificate;
asn_struct_free_f Certificate_free;
asn_struct_print_f Certificate_print;
asn_constr_check_f Certificate_constraint;
ber_type_decoder_f Certificate_decode_ber;
der_type_encoder_f Certificate_encode_der;
xer_type_decoder_f Certificate_decode_xer;
xer_type_encoder_f Certificate_encode_xer;
/*** <<< CODE [Certificate] >>> ***/
int
Certificate_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
td->check_constraints = asn_DEF_SIGNED_15P0.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
}
/*
* This type is implemented using SIGNED_15P0,
* so here we adjust the DEF accordingly.
*/
static void
Certificate_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_SIGNED_15P0.free_struct;
td->print_struct = asn_DEF_SIGNED_15P0.print_struct;
td->ber_decoder = asn_DEF_SIGNED_15P0.ber_decoder;
td->der_encoder = asn_DEF_SIGNED_15P0.der_encoder;
td->xer_decoder = asn_DEF_SIGNED_15P0.xer_decoder;
td->xer_encoder = asn_DEF_SIGNED_15P0.xer_encoder;
td->uper_decoder = asn_DEF_SIGNED_15P0.uper_decoder;
if(!td->per_constraints)
td->per_constraints = asn_DEF_SIGNED_15P0.per_constraints;
td->elements = asn_DEF_SIGNED_15P0.elements;
td->elements_count = asn_DEF_SIGNED_15P0.elements_count;
td->specifics = asn_DEF_SIGNED_15P0.specifics;
}
void
Certificate_free(asn_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
Certificate_1_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
Certificate_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
Certificate_1_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
asn_dec_rval_t
Certificate_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const void *bufptr, size_t size, int tag_mode) {
Certificate_1_inherit_TYPE_descriptor(td);
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
}
asn_enc_rval_t
Certificate_encode_der(asn_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
Certificate_1_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
asn_dec_rval_t
Certificate_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, const void *bufptr, size_t size) {
Certificate_1_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
asn_enc_rval_t
Certificate_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
Certificate_1_inherit_TYPE_descriptor(td);
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
}
/*** <<< STAT-DEFS [Certificate] >>> ***/
static ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
asn_TYPE_descriptor_t asn_DEF_Certificate = {
"Certificate",
"Certificate",
Certificate_free,
Certificate_print,
Certificate_constraint,
Certificate_decode_ber,
Certificate_encode_der,
Certificate_decode_xer,
Certificate_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_Certificate_tags_1,
sizeof(asn_DEF_Certificate_tags_1)
/sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
@ -201,9 +325,8 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = {
sizeof(asn_DEF_Certificate_tags_1)
/sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_Certificate_1,
3, /* Elements count */
&asn_SPC_Certificate_specs_1 /* Additional specs */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};

View File

@ -8,10 +8,7 @@ DirectoryString{INTEGER:maxSize} ::= CHOICE {
utf8String UTF8String (SIZE(1..maxSize))
}
DS1 ::= CHOICE {
teletexString TeletexString (SIZE(1..128)),
utf8String UTF8String (SIZE(1..128))
}
DS1 ::= DirectoryString{ub-name}
ub-name INTEGER ::= 128

View File

@ -8,12 +8,8 @@ TestType{Parameter} ::= SEQUENCE {
}
TestChoice ::= CHOICE {
type1 SEQUENCE {
common INTEGER (1..10) DEFAULT 0
},
type2 [0] IMPLICIT SEQUENCE {
common BOOLEAN DEFAULT 0
}
type1 TestType{ INTEGER (1..10)},
type2 [0] IMPLICIT TestType{ BOOLEAN}
}
END
@ -28,12 +24,8 @@ AutoType{Parameter} ::= SEQUENCE {
}
AutoChoice ::= CHOICE {
type1 [0] IMPLICIT SEQUENCE {
common [0] IMPLICIT INTEGER ((0..1))((0))
},
type2 [1] IMPLICIT SEQUENCE {
common [0] IMPLICIT BOOLEAN (0)
}
type1 [0] IMPLICIT AutoType{ INTEGER (0..1)},
type2 [1] IMPLICIT AutoType{ BOOLEAN}
}
END

View File

@ -1,50 +1,34 @@
/*** <<< INCLUDES [TestChoice] >>> ***/
/*** <<< INCLUDES [TestType] >>> ***/
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
#include <BOOLEAN.h>
#include <constr_CHOICE.h>
/*** <<< DEPS [TestChoice] >>> ***/
/*** <<< TYPE-DECLS [TestType] >>> ***/
typedef enum TestChoice_PR {
TestChoice_PR_NOTHING, /* No components present */
TestChoice_PR_type1,
TestChoice_PR_type2,
} TestChoice_PR;
/*** <<< TYPE-DECLS [TestChoice] >>> ***/
typedef struct TestChoice {
TestChoice_PR present;
union TestChoice_u {
struct type1 {
long common /* DEFAULT 0 */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} type1;
struct type2 {
BOOLEAN_t common /* DEFAULT 0 */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} type2;
} choice;
typedef struct TestType_16P0 {
long common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} TestChoice_t;
} TestType_16P0_t;
typedef struct TestType_16P1 {
BOOLEAN_t common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} TestType_16P1_t;
/*** <<< FUNC-DECLS [TestChoice] >>> ***/
/*** <<< FUNC-DECLS [TestType] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_TestChoice;
extern asn_TYPE_descriptor_t asn_DEF_TestType_16P0;
extern asn_TYPE_descriptor_t asn_DEF_TestType_16P1;
/*** <<< CODE [TestChoice] >>> ***/
/*** <<< CODE [TestType] >>> ***/
static int
memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
memb_common_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
long value;
@ -69,50 +53,37 @@ memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
}
/*** <<< STAT-DEFS [TestChoice] >>> ***/
/*** <<< STAT-DEFS [TestType] >>> ***/
static int asn_DFL_3_set_0(void **sptr) {
long *st = *sptr;
if(!st) {
st = (*sptr = CALLOC(1, sizeof(*st)));
if(!st) return -1;
}
/* Install default value 0 */
*st = 0;
return 0;
}
static asn_TYPE_member_t asn_MBR_type1_2[] = {
{ ATF_NOFLAGS, 1, offsetof(struct type1, common),
static asn_TYPE_member_t asn_MBR_TestType_16P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct TestType_16P0, common),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_common_constraint_2,
.memb_constraints = memb_common_constraint_1,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = asn_DFL_3_set_0, /* DEFAULT 0 */
.default_value = 0,
.name = "common"
},
};
static ber_tlv_tag_t asn_DEF_type1_tags_2[] = {
static ber_tlv_tag_t asn_DEF_TestType_16P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_type1_tag2el_2[] = {
static asn_TYPE_tag2member_t asn_MAP_TestType_16P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* common at 20 */
};
static asn_SEQUENCE_specifics_t asn_SPC_type1_specs_2 = {
sizeof(struct type1),
offsetof(struct type1, _asn_ctx),
asn_MAP_type1_tag2el_2,
static asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1 = {
sizeof(struct TestType_16P0),
offsetof(struct TestType_16P0, _asn_ctx),
asn_MAP_TestType_16P0_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_type1_2 = {
"type1",
"type1",
asn_TYPE_descriptor_t asn_DEF_TestType_16P0 = {
"TestType",
"TestType",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
@ -122,61 +93,47 @@ asn_TYPE_descriptor_t asn_DEF_type1_2 = {
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_type1_tags_2,
sizeof(asn_DEF_type1_tags_2)
/sizeof(asn_DEF_type1_tags_2[0]), /* 1 */
asn_DEF_type1_tags_2, /* Same as above */
sizeof(asn_DEF_type1_tags_2)
/sizeof(asn_DEF_type1_tags_2[0]), /* 1 */
asn_DEF_TestType_16P0_tags_1,
sizeof(asn_DEF_TestType_16P0_tags_1)
/sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */
asn_DEF_TestType_16P0_tags_1, /* Same as above */
sizeof(asn_DEF_TestType_16P0_tags_1)
/sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_type1_2,
asn_MBR_TestType_16P0_1,
1, /* Elements count */
&asn_SPC_type1_specs_2 /* Additional specs */
&asn_SPC_TestType_16P0_specs_1 /* Additional specs */
};
static int asn_DFL_5_set_0(void **sptr) {
BOOLEAN_t *st = *sptr;
if(!st) {
st = (*sptr = CALLOC(1, sizeof(*st)));
if(!st) return -1;
}
/* Install default value 0 */
*st = 0;
return 0;
}
static asn_TYPE_member_t asn_MBR_type2_4[] = {
{ ATF_NOFLAGS, 1, offsetof(struct type2, common),
static asn_TYPE_member_t asn_MBR_TestType_16P1_3[] = {
{ ATF_NOFLAGS, 0, offsetof(struct TestType_16P1, common),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
.tag_mode = 0,
.type = &asn_DEF_BOOLEAN,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = asn_DFL_5_set_0, /* DEFAULT 0 */
.default_value = 0,
.name = "common"
},
};
static ber_tlv_tag_t asn_DEF_type2_tags_4[] = {
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
static ber_tlv_tag_t asn_DEF_TestType_16P1_tags_3[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_type2_tag2el_4[] = {
static asn_TYPE_tag2member_t asn_MAP_TestType_16P1_tag2el_3[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 } /* common at 21 */
};
static asn_SEQUENCE_specifics_t asn_SPC_type2_specs_4 = {
sizeof(struct type2),
offsetof(struct type2, _asn_ctx),
asn_MAP_type2_tag2el_4,
static asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3 = {
sizeof(struct TestType_16P1),
offsetof(struct TestType_16P1, _asn_ctx),
asn_MAP_TestType_16P1_tag2el_3,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_type2_4 = {
"type2",
"type2",
asn_TYPE_descriptor_t asn_DEF_TestType_16P1 = {
"TestType",
"TestType",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
@ -186,23 +143,56 @@ asn_TYPE_descriptor_t asn_DEF_type2_4 = {
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_type2_tags_4,
sizeof(asn_DEF_type2_tags_4)
/sizeof(asn_DEF_type2_tags_4[0]) - 1, /* 1 */
asn_DEF_type2_tags_4, /* Same as above */
sizeof(asn_DEF_type2_tags_4)
/sizeof(asn_DEF_type2_tags_4[0]), /* 2 */
asn_DEF_TestType_16P1_tags_3,
sizeof(asn_DEF_TestType_16P1_tags_3)
/sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */
asn_DEF_TestType_16P1_tags_3, /* Same as above */
sizeof(asn_DEF_TestType_16P1_tags_3)
/sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_type2_4,
asn_MBR_TestType_16P1_3,
1, /* Elements count */
&asn_SPC_type2_specs_4 /* Additional specs */
&asn_SPC_TestType_16P1_specs_3 /* Additional specs */
};
/*** <<< INCLUDES [TestChoice] >>> ***/
#include <TestType.h>
#include <constr_CHOICE.h>
/*** <<< DEPS [TestChoice] >>> ***/
typedef enum TestChoice_PR {
TestChoice_PR_NOTHING, /* No components present */
TestChoice_PR_type1,
TestChoice_PR_type2,
} TestChoice_PR;
/*** <<< TYPE-DECLS [TestChoice] >>> ***/
typedef struct TestChoice {
TestChoice_PR present;
union TestChoice_u {
TestType_16P0_t type1;
TestType_16P1_t type2;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} TestChoice_t;
/*** <<< FUNC-DECLS [TestChoice] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_TestChoice;
/*** <<< STAT-DEFS [TestChoice] >>> ***/
static asn_TYPE_member_t asn_MBR_TestChoice_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type1),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_type1_2,
.type = &asn_DEF_TestType_16P0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
@ -211,7 +201,7 @@ static asn_TYPE_member_t asn_MBR_TestChoice_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type2),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_type2_4,
.type = &asn_DEF_TestType_16P1,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
@ -219,8 +209,8 @@ static asn_TYPE_member_t asn_MBR_TestChoice_1[] = {
},
};
static asn_TYPE_tag2member_t asn_MAP_TestChoice_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 at 16 */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 at 20 */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 at 21 */
};
static asn_CHOICE_specifics_t asn_SPC_TestChoice_specs_1 = {
sizeof(struct TestChoice),
@ -255,52 +245,36 @@ asn_TYPE_descriptor_t asn_DEF_TestChoice = {
};
/*** <<< INCLUDES [AutoChoice] >>> ***/
/*** <<< INCLUDES [AutoType] >>> ***/
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
#include <BOOLEAN.h>
#include <constr_CHOICE.h>
/*** <<< DEPS [AutoChoice] >>> ***/
/*** <<< TYPE-DECLS [AutoType] >>> ***/
typedef enum AutoChoice_PR {
AutoChoice_PR_NOTHING, /* No components present */
AutoChoice_PR_type1,
AutoChoice_PR_type2,
} AutoChoice_PR;
/*** <<< TYPE-DECLS [AutoChoice] >>> ***/
typedef struct AutoChoice {
AutoChoice_PR present;
union AutoChoice_u {
struct type1 {
long common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} type1;
struct type2 {
BOOLEAN_t common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} type2;
} choice;
typedef struct AutoType_34P0 {
long common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AutoChoice_t;
} AutoType_34P0_t;
typedef struct AutoType_34P1 {
BOOLEAN_t common;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AutoType_34P1_t;
/*** <<< FUNC-DECLS [AutoChoice] >>> ***/
/*** <<< FUNC-DECLS [AutoType] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_AutoChoice;
extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P0;
extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P1;
/*** <<< CODE [AutoChoice] >>> ***/
/*** <<< CODE [AutoType] >>> ***/
static int
memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
memb_common_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
long value;
@ -325,7 +299,7 @@ memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
}
static int
memb_common_constraint_4(asn_TYPE_descriptor_t *td, const void *sptr,
memb_common_constraint_3(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
BOOLEAN_t value;
@ -350,39 +324,37 @@ memb_common_constraint_4(asn_TYPE_descriptor_t *td, const void *sptr,
}
/*** <<< STAT-DEFS [AutoChoice] >>> ***/
/*** <<< STAT-DEFS [AutoType] >>> ***/
static asn_TYPE_member_t asn_MBR_type1_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct type1, common),
static asn_TYPE_member_t asn_MBR_AutoType_34P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AutoType_34P0, common),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_common_constraint_2,
.memb_constraints = memb_common_constraint_1,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "common"
},
};
static ber_tlv_tag_t asn_DEF_type1_tags_2[] = {
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
static ber_tlv_tag_t asn_DEF_AutoType_34P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_type1_tag2el_2[] = {
static asn_TYPE_tag2member_t asn_MAP_AutoType_34P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 37 */
};
static asn_SEQUENCE_specifics_t asn_SPC_type1_specs_2 = {
sizeof(struct type1),
offsetof(struct type1, _asn_ctx),
asn_MAP_type1_tag2el_2,
static asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1 = {
sizeof(struct AutoType_34P0),
offsetof(struct AutoType_34P0, _asn_ctx),
asn_MAP_AutoType_34P0_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_type1_2 = {
"type1",
"type1",
asn_TYPE_descriptor_t asn_DEF_AutoType_34P0 = {
"AutoType",
"AutoType",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
@ -392,49 +364,47 @@ asn_TYPE_descriptor_t asn_DEF_type1_2 = {
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_type1_tags_2,
sizeof(asn_DEF_type1_tags_2)
/sizeof(asn_DEF_type1_tags_2[0]) - 1, /* 1 */
asn_DEF_type1_tags_2, /* Same as above */
sizeof(asn_DEF_type1_tags_2)
/sizeof(asn_DEF_type1_tags_2[0]), /* 2 */
asn_DEF_AutoType_34P0_tags_1,
sizeof(asn_DEF_AutoType_34P0_tags_1)
/sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */
asn_DEF_AutoType_34P0_tags_1, /* Same as above */
sizeof(asn_DEF_AutoType_34P0_tags_1)
/sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_type1_2,
asn_MBR_AutoType_34P0_1,
1, /* Elements count */
&asn_SPC_type1_specs_2 /* Additional specs */
&asn_SPC_AutoType_34P0_specs_1 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_type2_4[] = {
{ ATF_NOFLAGS, 0, offsetof(struct type2, common),
static asn_TYPE_member_t asn_MBR_AutoType_34P1_3[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AutoType_34P1, common),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_BOOLEAN,
.memb_constraints = memb_common_constraint_4,
.memb_constraints = memb_common_constraint_3,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "common"
},
};
static ber_tlv_tag_t asn_DEF_type2_tags_4[] = {
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
static ber_tlv_tag_t asn_DEF_AutoType_34P1_tags_3[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_type2_tag2el_4[] = {
static asn_TYPE_tag2member_t asn_MAP_AutoType_34P1_tag2el_3[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 38 */
};
static asn_SEQUENCE_specifics_t asn_SPC_type2_specs_4 = {
sizeof(struct type2),
offsetof(struct type2, _asn_ctx),
asn_MAP_type2_tag2el_4,
static asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3 = {
sizeof(struct AutoType_34P1),
offsetof(struct AutoType_34P1, _asn_ctx),
asn_MAP_AutoType_34P1_tag2el_3,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_type2_4 = {
"type2",
"type2",
asn_TYPE_descriptor_t asn_DEF_AutoType_34P1 = {
"AutoType",
"AutoType",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
@ -444,23 +414,56 @@ asn_TYPE_descriptor_t asn_DEF_type2_4 = {
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_type2_tags_4,
sizeof(asn_DEF_type2_tags_4)
/sizeof(asn_DEF_type2_tags_4[0]) - 1, /* 1 */
asn_DEF_type2_tags_4, /* Same as above */
sizeof(asn_DEF_type2_tags_4)
/sizeof(asn_DEF_type2_tags_4[0]), /* 2 */
asn_DEF_AutoType_34P1_tags_3,
sizeof(asn_DEF_AutoType_34P1_tags_3)
/sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */
asn_DEF_AutoType_34P1_tags_3, /* Same as above */
sizeof(asn_DEF_AutoType_34P1_tags_3)
/sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_type2_4,
asn_MBR_AutoType_34P1_3,
1, /* Elements count */
&asn_SPC_type2_specs_4 /* Additional specs */
&asn_SPC_AutoType_34P1_specs_3 /* Additional specs */
};
/*** <<< INCLUDES [AutoChoice] >>> ***/
#include <AutoType.h>
#include <constr_CHOICE.h>
/*** <<< DEPS [AutoChoice] >>> ***/
typedef enum AutoChoice_PR {
AutoChoice_PR_NOTHING, /* No components present */
AutoChoice_PR_type1,
AutoChoice_PR_type2,
} AutoChoice_PR;
/*** <<< TYPE-DECLS [AutoChoice] >>> ***/
typedef struct AutoChoice {
AutoChoice_PR present;
union AutoChoice_u {
AutoType_34P0_t type1;
AutoType_34P1_t type2;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} AutoChoice_t;
/*** <<< FUNC-DECLS [AutoChoice] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_AutoChoice;
/*** <<< STAT-DEFS [AutoChoice] >>> ***/
static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type1),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_type1_2,
.type = &asn_DEF_AutoType_34P0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
@ -469,7 +472,7 @@ static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type2),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_type2_4,
.type = &asn_DEF_AutoType_34P1,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
@ -477,8 +480,8 @@ static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = {
},
};
static asn_TYPE_tag2member_t asn_MAP_AutoChoice_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 at 34 */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 at 34 */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 at 37 */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 at 38 */
};
static asn_CHOICE_specifics_t asn_SPC_AutoChoice_specs_1 = {
sizeof(struct AutoChoice),