Commit a00d6b37 authored by Lev Walkin's avatar Lev Walkin

refactored parameterization support

parent 25b8f280
0.9.21: 2006-Mar-14 0.9.21: 2006-Mar-20
* skeletons/standard-modules directory is now used for standard types. * skeletons/standard-modules directory is now used for standard types.
* Fixed class field access problem (Test case 98) * Fixed class field access problem (Test case 98)
(Severity: medim; Security impact: none) (Severity: medim; Security impact: none)
* Refactored Information Object Classes parsing. * Refactored Information Object Classes parsing.
* Refactored Parameterization support.
0.9.20: 2006-Mar-06 0.9.20: 2006-Mar-06
......
This diff is collapsed.
...@@ -33,27 +33,40 @@ reserved_keyword(const char *str) { ...@@ -33,27 +33,40 @@ reserved_keyword(const char *str) {
* Convert unsafe characters to underscores. * Convert unsafe characters to underscores.
*/ */
char * 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 char *storage;
static int storage_size; static int storage_size;
int nodelimiter = 0; int nodelimiter = 0;
va_list ap; va_list ap;
char *str; char *str;
char *nextstr; char *nextstr;
char *first = 0;
char *second = 0;
size_t size; size_t size;
char *p; char *p;
if(arg1 == NULL) if(expr) {
return NULL; /*
* 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;
}
/* va_start(ap, expr);
* Estimate the necessary storage size
*/
size = strlen(arg1);
va_start(ap, arg1);
while((str = va_arg(ap, char *))) while((str = va_arg(ap, char *)))
size += 1 + strlen(str); size += 1 + strlen(str);
va_end(ap); va_end(ap);
if(size == -1) return NULL;
/* /*
* Make sure we have this amount of storage. * Make sure we have this amount of storage.
...@@ -72,12 +85,23 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) { ...@@ -72,12 +85,23 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
/* /*
* Fill-in the storage. * Fill-in the storage.
*/ */
va_start(ap, arg1); va_start(ap, expr);
str = arg1;
p = storage; p = storage;
for(str = arg1; str; str = nextstr) { nextstr = "";
for(p = storage, str = 0; str || nextstr; str = nextstr) {
int subst_made = 0; 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') { if(str[0] == ' ' && str[1] == '\0') {
*p++ = ' '; *p++ = ' ';
...@@ -85,7 +109,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) { ...@@ -85,7 +109,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
continue; continue;
} }
if(str != arg1 && !nodelimiter) if(str != first && !nodelimiter)
*p++ = '_'; /* Delimiter between tokens */ *p++ = '_'; /* Delimiter between tokens */
nodelimiter = 0; nodelimiter = 0;
...@@ -94,7 +118,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) { ...@@ -94,7 +118,7 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
* with C/C++ language keywords. * with C/C++ language keywords.
*/ */
if((flags & AMI_CHECK_RESERVED) if((flags & AMI_CHECK_RESERVED)
&& str == arg1 && !nextstr && reserved_keyword(str)) { && str == first && !nextstr && reserved_keyword(str)) {
*p++ = toupper(*str++); *p++ = toupper(*str++);
/* Fall through */ /* Fall through */
} }
...@@ -123,7 +147,9 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) { ...@@ -123,7 +147,9 @@ asn1c_make_identifier(enum ami_flags_e flags, char *arg1, ...) {
char * char *
asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { 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 *top_parent;
asn1p_expr_t *terminal;
char *typename; char *typename;
/* Rewind to the topmost parent expression */ /* Rewind to the topmost parent expression */
...@@ -145,15 +171,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { ...@@ -145,15 +171,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
* Resolve it and use instead. * Resolve it and use instead.
*/ */
tmp.expr = asn1f_class_access_ex(arg->asn, 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; if(!tmp.expr) return NULL;
return asn1c_type_name(&tmp, tmp.expr, _format); return asn1c_type_name(&tmp, tmp.expr, _format);
} }
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
if(_format == TNF_RSAFE) { 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) { if(terminal && terminal->expr_type & ASN_CONSTR_MASK) {
typename = terminal->Identifier; typename = terminal->Identifier;
} }
...@@ -165,29 +191,17 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { ...@@ -165,29 +191,17 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
* switch to a recursion-safe type naming * switch to a recursion-safe type naming
* ("struct foo" instead of "foo_t"). * ("struct foo" instead of "foo_t").
*/ */
asn1p_expr_t *terminal;
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
if(terminal && terminal == top_parent) { if(terminal && terminal == top_parent) {
_format = TNF_RSAFE; _format = TNF_RSAFE;
} }
} }
break;
#if 0 if(terminal && terminal->spec_index != -1) {
case ASN_CONSTR_SEQUENCE_OF: exprid = terminal;
case ASN_CONSTR_SET_OF: typename = 0;
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;
} }
break; break;
#endif
case ASN_BASIC_INTEGER: case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED: case ASN_BASIC_ENUMERATED:
case ASN_BASIC_REAL: case ASN_BASIC_REAL:
...@@ -229,13 +243,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { ...@@ -229,13 +243,15 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
switch(_format) { switch(_format) {
case TNF_UNMODIFIED: case TNF_UNMODIFIED:
case TNF_INCLUDE: 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: case TNF_SAFE:
return asn1c_make_identifier(0, typename, 0); return asn1c_make_identifier(0, exprid, typename, 0);
case TNF_CTYPE: /* C type */ 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 */ case TNF_RSAFE: /* Recursion-safe type */
return asn1c_make_identifier(AMI_CHECK_RESERVED, return asn1c_make_identifier(AMI_CHECK_RESERVED, 0,
"struct", " ", typename, 0); "struct", " ", typename, 0);
} }
......
...@@ -10,7 +10,7 @@ enum ami_flags_e { ...@@ -10,7 +10,7 @@ enum ami_flags_e {
AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */ AMI_MASK_ONLY_SPACES = 1, /* Mask only spaces, everything else's safe */
AMI_CHECK_RESERVED = 2, /* Check against reserved keywords */ 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. * Return the type name of the specified expression.
......
...@@ -102,8 +102,7 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...); ...@@ -102,8 +102,7 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
int saved_target = arg->target->target; \ int saved_target = arg->target->target; \
REDIR(OT_FUNC_DECLS); \ REDIR(OT_FUNC_DECLS); \
OUT_NOINDENT("extern asn_TYPE_descriptor_t " \ OUT_NOINDENT("extern asn_TYPE_descriptor_t " \
"asn_DEF_%s;\n", \ "asn_DEF_%s;\n", MKID(expr)); \
MKID(expr->Identifier)); \
REDIR(saved_target); \ REDIR(saved_target); \
} while(0) } while(0)
......
...@@ -215,7 +215,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int argc, int optc, char **a ...@@ -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_c, argc, optc, argv);
generate_preamble(arg, fp_h, 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, fprintf(fp_h,
"#ifndef\t_%s_H_\n" "#ifndef\t_%s_H_\n"
"#define\t_%s_H_\n" "#define\t_%s_H_\n"
...@@ -477,8 +477,7 @@ generate_pdu_collection_file(arg_t *arg) { ...@@ -477,8 +477,7 @@ generate_pdu_collection_file(arg_t *arg) {
continue; continue;
fprintf(fp, "extern struct asn_TYPE_descriptor_s " fprintf(fp, "extern struct asn_TYPE_descriptor_s "
"asn_DEF_%s;\n", "asn_DEF_%s;\n",
asn1c_make_identifier(0, arg->expr->Identifier, asn1c_make_identifier(0, arg->expr, NULL));
NULL));
} }
} }
...@@ -496,8 +495,7 @@ generate_pdu_collection_file(arg_t *arg) { ...@@ -496,8 +495,7 @@ generate_pdu_collection_file(arg_t *arg) {
arg->expr->module->ModuleName, arg->expr->module->ModuleName,
arg->expr->module->source_file_name); arg->expr->module->source_file_name);
fprintf(fp, "\t&asn_DEF_%s,\t\n", fprintf(fp, "\t&asn_DEF_%s,\t\n",
asn1c_make_identifier(0, arg->expr->Identifier, asn1c_make_identifier(0, arg->expr, NULL));
NULL));
} }
} }
......
...@@ -43,7 +43,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags, ...@@ -43,7 +43,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
ret = asn1c_compile_expr(arg); ret = asn1c_compile_expr(arg);
if(ret) { 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->Identifier,
arg->expr->expr_type, arg->expr->expr_type,
arg->expr->meta_type, arg->expr->meta_type,
...@@ -82,10 +82,26 @@ asn1c_compile_expr(arg_t *arg) { ...@@ -82,10 +82,26 @@ asn1c_compile_expr(arg_t *arg) {
expr->Identifier, expr->Identifier,
expr->_lineno); expr->_lineno);
ret = type_cb(arg); if(expr->lhs_params && expr->spec_index == -1) {
int i;
if(arg->target->destination[OT_TYPE_DECLS].indent_level == 0) ret = 0;
OUT(";\n"); 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 { } else {
ret = -1; ret = -1;
/* /*
...@@ -94,7 +110,6 @@ asn1c_compile_expr(arg_t *arg) { ...@@ -94,7 +110,6 @@ asn1c_compile_expr(arg_t *arg) {
* certain expressions need not to be compiled at all. * certain expressions need not to be compiled at all.
*/ */
switch(expr->meta_type) { switch(expr->meta_type) {
case AMT_PARAMTYPE:
case AMT_OBJECT: case AMT_OBJECT:
case AMT_OBJECTCLASS: case AMT_OBJECTCLASS:
case AMT_OBJECTFIELD: case AMT_OBJECTFIELD:
......
...@@ -15,6 +15,7 @@ static int asn1f_resolve_constraints(arg_t *arg); /* For subtype constraints */ ...@@ -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_constraints(arg_t *arg); /* For subtype constraints */
static int asn1f_check_duplicate(arg_t *arg); static int asn1f_check_duplicate(arg_t *arg);
static int asn1f_apply_unique_index(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; arg_t a1f_replace_me_with_proper_interface_arg;
...@@ -179,71 +180,21 @@ asn1f_fix_module__phase_1(arg_t *arg) { ...@@ -179,71 +180,21 @@ asn1f_fix_module__phase_1(arg_t *arg) {
*/ */
TQ_FOR(expr, &(arg->mod->members), next) { TQ_FOR(expr, &(arg->mod->members), next) {
arg->expr = expr; arg->expr = expr;
ret = phase_1_1(arg, 0);
/* Check whether this type is a duplicate */
ret = asn1f_check_duplicate(arg);
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); 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. * Make sure everybody's behaving well.
*/ */
assert(arg->expr == expr); 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 * 5. Automatic tagging
...@@ -295,16 +246,9 @@ asn1f_fix_module__phase_2(arg_t *arg) { ...@@ -295,16 +246,9 @@ asn1f_fix_module__phase_2(arg_t *arg) {
int rvalue = 0; int rvalue = 0;
int ret; int ret;
TQ_FOR(expr, &(arg->mod->members), next) {
}
TQ_FOR(expr, &(arg->mod->members), next) { TQ_FOR(expr, &(arg->mod->members), next) {
arg->expr = expr; arg->expr = expr;
if(expr->meta_type == AMT_PARAMTYPE)
/* Do not process the parametrized types here */
continue;
/* /*
* Dereference DEFAULT values. * Dereference DEFAULT values.
*/ */
...@@ -330,6 +274,88 @@ asn1f_fix_module__phase_2(arg_t *arg) { ...@@ -330,6 +274,88 @@ asn1f_fix_module__phase_2(arg_t *arg) {
return rvalue; 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 static int
asn1f_fix_simple(arg_t *arg) { asn1f_fix_simple(arg_t *arg) {
int rvalue = 0; int rvalue = 0;
......
#include "asn1fix_internal.h" #include "asn1fix_internal.h"
asn1p_expr_t * 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 *ioclass;
asn1p_expr_t *classfield; asn1p_expr_t *classfield;
asn1p_expr_t *expr; asn1p_expr_t *expr;
...@@ -20,14 +20,16 @@ asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { ...@@ -20,14 +20,16 @@ asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) {
tmpref = *ref; tmpref = *ref;
tmpref.comp_count = 1; tmpref.comp_count = 1;
ioclass = asn1f_lookup_symbol(arg, mod, &tmpref); ioclass = asn1f_lookup_symbol(arg, mod, rhs_pspecs, &tmpref);
if(ioclass == NULL) { if(ioclass == NULL) {
errno = ESRCH; errno = ESRCH;
return NULL; return NULL;
} }
if(ioclass->expr_type == A1TC_REFERENCE) { if(ioclass->expr_type == A1TC_REFERENCE) {
ioclass = asn1f_lookup_symbol(arg, ioclass = asn1f_lookup_symbol(arg,
ioclass->module, ioclass->reference); ioclass->module,
ioclass->rhs_pspecs,
ioclass->reference);
if(ioclass == NULL) { if(ioclass == NULL) {
errno = ESRCH; errno = ESRCH;
return NULL; return NULL;
......
...@@ -4,12 +4,6 @@ ...@@ -4,12 +4,6 @@
/* /*
* Fetch the element from the class-related stuff (thing) by its reference. * 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 *); asn1p_expr_t *asn1f_class_access(arg_t *, asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, 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 *);
#endif /* _ASN1FIX_CLASS_H_ */ #endif /* _ASN1FIX_CLASS_H_ */
...@@ -471,7 +471,8 @@ _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { ...@@ -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); 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 */ if(!a) return 0; /* Already FATAL()'ed somewhere else */
WITH_MODULE(a->module, ret = _asn1f_compare_tags(arg, a, b)); WITH_MODULE(a->module, ret = _asn1f_compare_tags(arg, a, b));
return ret; return ret;
......
...@@ -30,7 +30,7 @@ asn1constraint_pullup(arg_t *arg) { ...@@ -30,7 +30,7 @@ asn1constraint_pullup(arg_t *arg) {
asn1p_expr_t *parent_expr; asn1p_expr_t *parent_expr;
assert(ref); 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(!parent_expr) {
if(errno != EEXIST) { if(errno != EEXIST) {
DEBUG("\tWhile fetching parent constraints: " DEBUG("\tWhile fetching parent constraints: "
...@@ -259,6 +259,7 @@ constraint_type_resolve(arg_t *arg, asn1p_constraint_t *ct) { ...@@ -259,6 +259,7 @@ constraint_type_resolve(arg_t *arg, asn1p_constraint_t *ct) {
assert(ct->containedSubtype->type == ATV_REFERENCED); assert(ct->containedSubtype->type == ATV_REFERENCED);
rtype = asn1f_lookup_symbol(arg, arg->expr->module, rtype = asn1f_lookup_symbol(arg, arg->expr->module,
arg->expr->rhs_pspecs,
ct->containedSubtype->value.reference); ct->containedSubtype->value.reference);
if(!rtype) { if(!rtype) {
FATAL("Cannot find type \"%s\" in constraints at line %d", FATAL("Cannot find type \"%s\" in constraints at line %d",
......
...@@ -206,7 +206,7 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_row_s *row, struct asn1p_i ...@@ -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); asn1p_ref_add_component(ref, p, RLT_UNKNOWN);
assert(ref); assert(ref);
expr = asn1f_lookup_symbol(arg, arg->mod, ref); expr = asn1f_lookup_symbol(arg, arg->mod, arg->expr->rhs_pspecs, ref);
if(!expr) { if(!expr) {
FATAL("Cannot find %s referenced by %s at line %d", FATAL("Cannot find %s referenced by %s at line %d",
p, arg->expr->Identifier, p, arg->expr->Identifier,
......
...@@ -6,9 +6,6 @@ asn1f_fix_dereference_types(arg_t *arg) { ...@@ -6,9 +6,6 @@ asn1f_fix_dereference_types(arg_t *arg) {
asn1p_expr_t *type_expr; asn1p_expr_t *type_expr;
int r_value = 0; int r_value = 0;
if(expr->expr_type == A1TC_PARAMETRIZED)
return asn1f_fix_parametrized_assignment(arg);
if(expr->expr_type != A1TC_REFERENCE if(expr->expr_type != A1TC_REFERENCE
|| expr->meta_type != AMT_TYPEREF) { || expr->meta_type != AMT_TYPEREF) {
//assert(expr->reference == 0); //assert(expr->reference == 0);
......
...@@ -20,13 +20,14 @@ asn1f_lookup_symbol_ex( ...@@ -20,13 +20,14 @@ asn1f_lookup_symbol_ex(
arg.debug = a1f_replace_me_with_proper_interface_arg.debug; 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 * asn1p_expr_t *
asn1f_class_access_ex(asn1p_t *asn, asn1f_class_access_ex(asn1p_t *asn,
asn1p_module_t *mod, asn1p_module_t *mod,
asn1p_expr_t *expr, asn1p_expr_t *expr,
asn1p_expr_t *rhs_pspecs,
asn1p_ref_t *ref) { asn1p_ref_t *ref) {
arg_t arg; arg_t arg;
...@@ -38,7 +39,7 @@ asn1f_class_access_ex(asn1p_t *asn, ...@@ -38,7 +39,7 @@ asn1f_class_access_ex(asn1p_t *asn,
arg.eh = a1f_replace_me_with_proper_interface_arg.eh; arg.eh = a1f_replace_me_with_proper_interface_arg.eh;
arg.debug = a1f_replace_me_with_proper_interface_arg.debug; 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 * asn1p_expr_t *
......
...@@ -25,7 +25,7 @@ asn1p_expr_t *asn1f_lookup_symbol_ex( ...@@ -25,7 +25,7 @@ asn1p_expr_t *asn1f_lookup_symbol_ex(
* Exportable version of an asn1f_class_access(). * Exportable version of an asn1f_class_access().
*/ */
asn1p_expr_t *asn1f_class_access_ex(asn1p_t *asn, asn1p_module_t *mod, 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(). * Exportable version of asn1f_find_terminal_type().
......
...@@ -143,7 +143,8 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type) ...@@ -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 * Then, it is a reference. For a reference, try to resolve type
* and try again. * 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) { if(next_expr == NULL) {
errno = ESRCH; errno = ESRCH;
return -1; return -1;
......
...@@ -62,7 +62,7 @@ typedef struct arg_s { ...@@ -62,7 +62,7 @@ typedef struct arg_s {
#include "asn1fix_constr.h" /* Constructed types */ #include "asn1fix_constr.h" /* Constructed types */
#include "asn1fix_class.h" /* CLASS support */ #include "asn1fix_class.h" /* CLASS support */
#include "asn1fix_cws.h" /* CLASS WITH SYNTAX 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_retrieve.h" /* Data retrieval */
#include "asn1fix_enum.h" /* Process ENUMERATED */ #include "asn1fix_enum.h" /* Process ENUMERATED */
#include "asn1fix_integer.h" /* Process INTEGER */ #include "asn1fix_integer.h" /* Process INTEGER */
......
...@@ -196,6 +196,17 @@ asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) { ...@@ -196,6 +196,17 @@ asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) {
assert(expr); 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. * Invoke the callback at this very level.
*/ */
......
This diff is collapsed.
#ifndef _ASN1FIX_PARAMETRIZATION_H_ #ifndef _ASN1FIX_PARAMETERIZATION_H_
#define _ASN1FIX_PARAMETRIZATION_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_ */
...@@ -146,7 +146,7 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) { ...@@ -146,7 +146,7 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) {
} }
static asn1p_expr_t * 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_expr_t *ref_tc; /* Referenced tc */
asn1p_module_t *imports_from; asn1p_module_t *imports_from;
char *modulename; char *modulename;
...@@ -193,7 +193,7 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int ...@@ -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. * This is a reference to a CLASS-related stuff.
* Employ a separate function for that. * Employ a separate function for that.
*/ */
extract = asn1f_class_access(arg, mod, ref); extract = asn1f_class_access(arg, mod, rhs_pspecs, ref);
return extract; return extract;
} else { } else {
...@@ -255,7 +255,8 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int ...@@ -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); 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) if(!expr && !(arg->expr->_mark & TM_BROKEN)
&& !(imports_from->_tags & MT_STANDARD_MODULE)) { && !(imports_from->_tags & MT_STANDARD_MODULE)) {
arg->expr->_mark |= TM_BROKEN; 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 ...@@ -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) if(strcmp(ref_tc->Identifier, identifier) == 0)
break; break;
} }
if(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; return ref_tc;
}
/*
* Not found in the current module.
* Search in our default standard module.
*/
{ {
/* Search inside standard module */ /* Search inside standard module */
static asn1p_oid_t *uioc_oid; 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 ...@@ -335,8 +365,9 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref, int
asn1p_expr_t * asn1p_expr_t *
asn1f_lookup_symbol(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { asn1f_lookup_symbol(arg_t *arg,
return asn1f_lookup_symbol_impl(arg, mod, ref, 0); 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 * asn1p_expr_t *
...@@ -397,7 +428,7 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, enum ftt_what what) { ...@@ -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. * 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) { if(tc == NULL) {
DEBUG("\tSymbol \"%s\" not found: %s", DEBUG("\tSymbol \"%s\" not found: %s",
asn1f_printable_reference(ref), asn1f_printable_reference(ref),
......
...@@ -39,6 +39,7 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg, ...@@ -39,6 +39,7 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg,
*/ */
asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg,
asn1p_module_t *mod, asn1p_module_t *mod,
asn1p_expr_t *rhs_pspecs,
asn1p_ref_t *ref); asn1p_ref_t *ref);
/* /*
......
...@@ -66,7 +66,7 @@ asn1f_fetch_tags_impl(arg_t *arg, struct asn1p_type_tag_s **tags, int count, int ...@@ -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) { if(expr->meta_type == AMT_TYPEREF) {
asn1p_expr_t *nexpr; asn1p_expr_t *nexpr;
DEBUG("Following the reference %s", expr->Identifier); 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(nexpr == NULL) {
if(errno != EEXIST) /* -fknown-extern-type */ if(errno != EEXIST) /* -fknown-extern-type */
return -1; return -1;
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
...@@ -45,14 +46,20 @@ asn1p_constraint_free(asn1p_constraint_t *ct) { ...@@ -45,14 +46,20 @@ asn1p_constraint_free(asn1p_constraint_t *ct) {
asn1p_constraint_t * asn1p_constraint_t *
asn1p_constraint_clone(asn1p_constraint_t *src) { 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; asn1p_constraint_t *clone;
#define CLONE(field, func) do { if(src->field) { \ #define CLONE(field, func) do { if(src->field) { \
clone->field = func(src->field); \ clone->field = func(src->field, vr, varg); \
if(clone->field == NULL) { \ if(clone->field == NULL) { \
asn1p_constraint_free(clone); \ asn1p_constraint_free(clone); \
return NULL; \ return NULL; \
} \ } \
} } while(0) } } while(0)
clone = asn1p_constraint_new(src->_lineno); clone = asn1p_constraint_new(src->_lineno);
...@@ -61,14 +68,14 @@ asn1p_constraint_clone(asn1p_constraint_t *src) { ...@@ -61,14 +68,14 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
clone->type = src->type; clone->type = src->type;
clone->presence = src->presence; clone->presence = src->presence;
CLONE(containedSubtype, asn1p_value_clone); CLONE(containedSubtype, asn1p_value_clone_with_resolver);
CLONE(value, asn1p_value_clone); CLONE(value, asn1p_value_clone_with_resolver);
CLONE(range_start, asn1p_value_clone); CLONE(range_start, asn1p_value_clone_with_resolver);
CLONE(range_stop, asn1p_value_clone); CLONE(range_stop, asn1p_value_clone_with_resolver);
for(i = 0; i < src->el_count; i++) { for(i = 0; i < src->el_count; i++) {
asn1p_constraint_t *t; asn1p_constraint_t *t;
t = asn1p_constraint_clone(src->elements[i]); t = asn1p_constraint_clone_with_resolver(src->elements[i], vr, varg);
if(!t) { if(!t) {
asn1p_constraint_free(clone); asn1p_constraint_free(clone);
return NULL; return NULL;
...@@ -86,32 +93,55 @@ asn1p_constraint_clone(asn1p_constraint_t *src) { ...@@ -86,32 +93,55 @@ asn1p_constraint_clone(asn1p_constraint_t *src) {
return clone; return clone;
} }
int /*
asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) { * Make sure there's enough space to add an element.
assert(into); */
assert(what); static int
asn1p_constraint_make_memory(asn1p_constraint_t *ct) {
/* if(ct->el_count == ct->el_size) {
* Make sure there's enough space to add an element. unsigned int newsize = ct->el_size ? ct->el_size << 2 : 4;
*/
if(into->el_count == into->el_size) {
unsigned int newsize = into->el_size?into->el_size<<2:4;
void *p; void *p;
p = realloc(into->elements, p = realloc(ct->elements, newsize * sizeof(ct->elements[0]));
newsize * sizeof(into->elements[0]));
if(p) { if(p) {
into->elements = p; ct->elements = p;
into->el_size = newsize; ct->el_size = newsize;
} else { } else {
return -1; return -1;
} }
} }
return 0;
}
int
asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) {
assert(into);
assert(what);
if(asn1p_constraint_make_memory(into))
return -1;
into->elements[into->el_count++] = what; into->elements[into->el_count++] = what;
return 0; 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 * char *
asn1p_constraint_type2str(enum asn1p_constraint_type_e type) { asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
......
...@@ -76,10 +76,14 @@ void asn1p_constraint_free(asn1p_constraint_t *); ...@@ -76,10 +76,14 @@ void asn1p_constraint_free(asn1p_constraint_t *);
* Clone the constraint and all its children. * 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(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. * 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_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 */ #endif /* ASN1_PARSER_CONSTRAINT_H */
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
#include "asn1parser.h" #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. * Construct a new empty types collection.
*/ */
...@@ -16,6 +19,7 @@ asn1p_expr_new(int _lineno) { ...@@ -16,6 +19,7 @@ asn1p_expr_new(int _lineno) {
expr = calloc(1, sizeof *expr); expr = calloc(1, sizeof *expr);
if(expr) { if(expr) {
TQ_INIT(&(expr->members)); TQ_INIT(&(expr->members));
expr->spec_index = -1;
expr->_lineno = _lineno; expr->_lineno = _lineno;
} }
...@@ -24,22 +28,63 @@ asn1p_expr_new(int _lineno) { ...@@ -24,22 +28,63 @@ asn1p_expr_new(int _lineno) {
asn1p_expr_t * asn1p_expr_t *
asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) { 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 */ asn1p_expr_t *tcmemb; /* Child of tc */
int hit_ext = 0; 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 CLCOPY(field) do { clone->field = expr->field; } while(0)
#define CLCLONE(field, func) do { if(expr->field) { \ #define CLCLONE(field, func) do { if(expr->field) { \
clone->field = func(expr->field); \ clone->field = func(expr->field); \
if(clone->field == NULL) { \ if(clone->field == NULL) { \
asn1p_expr_free(clone); \ asn1p_expr_free(clone); \
return NULL; \ 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) } } 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. * Copy simple fields.
*/ */
...@@ -58,10 +103,10 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) { ...@@ -58,10 +103,10 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
*/ */
CLCLONE(Identifier, strdup); CLCLONE(Identifier, strdup);
CLCLONE(reference, asn1p_ref_clone); CLCLONE(reference, asn1p_ref_clone);
CLCLONE(constraints, asn1p_constraint_clone); CLVRCLONE(constraints, asn1p_constraint_clone_with_resolver);
CLCLONE(combined_constraints, asn1p_constraint_clone); CLVRCLONE(combined_constraints, asn1p_constraint_clone_with_resolver);
CLCLONE(params, asn1p_paramlist_clone); CLCLONE(lhs_params, asn1p_paramlist_clone);
CLCLONE(value, asn1p_value_clone); CLVRCLONE(value, asn1p_value_clone_with_resolver);
CLCLONE(marker.default_value, asn1p_value_clone); CLCLONE(marker.default_value, asn1p_value_clone);
CLCLONE(with_syntax, asn1p_wsyntx_clone); CLCLONE(with_syntax, asn1p_wsyntx_clone);
...@@ -78,7 +123,7 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) { ...@@ -78,7 +123,7 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
} }
if(hit_ext == 1) continue; /* Skip between ...'s */ 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) { if(cmemb == NULL) {
asn1p_expr_free(clone); asn1p_expr_free(clone);
return NULL; return NULL;
...@@ -89,6 +134,48 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) { ...@@ -89,6 +134,48 @@ asn1p_expr_clone(asn1p_expr_t *expr, int skip_extensions) {
return clone; 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. * Add expression as a member of another.
*/ */
...@@ -125,8 +212,8 @@ asn1p_expr_free(asn1p_expr_t *expr) { ...@@ -125,8 +212,8 @@ asn1p_expr_free(asn1p_expr_t *expr) {
asn1p_constraint_free(expr->constraints); asn1p_constraint_free(expr->constraints);
if(expr->combined_constraints) if(expr->combined_constraints)
asn1p_constraint_free(expr->combined_constraints); asn1p_constraint_free(expr->combined_constraints);
if(expr->params) if(expr->lhs_params)
asn1p_paramlist_free(expr->params); asn1p_paramlist_free(expr->lhs_params);
if(expr->value) if(expr->value)
asn1p_value_free(expr->value); asn1p_value_free(expr->value);
if(expr->marker.default_value) if(expr->marker.default_value)
......
...@@ -11,7 +11,6 @@ typedef enum asn1p_expr_meta { ...@@ -11,7 +11,6 @@ typedef enum asn1p_expr_meta {
AMT_INVALID, AMT_INVALID,
AMT_TYPE, /* Type1 ::= INTEGER */ AMT_TYPE, /* Type1 ::= INTEGER */
AMT_TYPEREF, /* Type2 ::= Type1 */ AMT_TYPEREF, /* Type2 ::= Type1 */
AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */
AMT_VALUE, /* value1 Type1 ::= 1 */ AMT_VALUE, /* value1 Type1 ::= 1 */
AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */ AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */
AMT_OBJECT, /* object CLASS ::= {...} */ AMT_OBJECT, /* object CLASS ::= {...} */
...@@ -35,7 +34,6 @@ typedef enum asn1p_expr_type { ...@@ -35,7 +34,6 @@ typedef enum asn1p_expr_type {
A1TC_OPAQUE, /* Opaque data encoded as a bitvector */ A1TC_OPAQUE, /* Opaque data encoded as a bitvector */
A1TC_EXTENSIBLE, /* An extension marker "..." */ A1TC_EXTENSIBLE, /* An extension marker "..." */
A1TC_COMPONENTS_OF, /* COMPONENTS OF clause */ A1TC_COMPONENTS_OF, /* COMPONENTS OF clause */
A1TC_PARAMETRIZED, /* A parametrized type declaration */
A1TC_VALUESET, /* Value set definition */ A1TC_VALUESET, /* Value set definition */
A1TC_CLASSDEF, /* Information Object Class */ A1TC_CLASSDEF, /* Information Object Class */
A1TC_INSTANCE, /* Instance of Object Class */ A1TC_INSTANCE, /* Instance of Object Class */
...@@ -148,10 +146,27 @@ typedef struct asn1p_expr_s { ...@@ -148,10 +146,27 @@ typedef struct asn1p_expr_s {
asn1p_constraint_t *combined_constraints; asn1p_constraint_t *combined_constraints;
/* /*
* A list of parameters for parametrized type declaration * Left hand side parameters for parametrized type declaration
* (AMT_PARAMTYPE). * 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). * The actual value (DefinedValue or inlined value).
...@@ -258,6 +273,9 @@ typedef struct asn1p_expr_s { ...@@ -258,6 +273,9 @@ typedef struct asn1p_expr_s {
*/ */
asn1p_expr_t *asn1p_expr_new(int _lineno); 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(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_add(asn1p_expr_t *to, asn1p_expr_t *what);
void asn1p_expr_free(asn1p_expr_t *expr); void asn1p_expr_free(asn1p_expr_t *expr);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#include <stdio.h> #include <stdio.h>
#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus #ifdef c_plusplus
...@@ -41,9 +41,7 @@ ...@@ -41,9 +41,7 @@
#ifdef __cplusplus #ifdef __cplusplus
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#endif
/* Use prototypes in function declarations. */ /* Use prototypes in function declarations. */
#define YY_USE_PROTOS #define YY_USE_PROTOS
...@@ -83,7 +81,6 @@ ...@@ -83,7 +81,6 @@
#define YY_PROTO(proto) () #define YY_PROTO(proto) ()
#endif #endif
/* Returned upon end-of-file. */ /* Returned upon end-of-file. */
#define YY_NULL 0 #define YY_NULL 0
...@@ -1887,7 +1884,7 @@ static asn1c_integer_t _lex_atoi(const char *ptr); ...@@ -1887,7 +1884,7 @@ static asn1c_integer_t _lex_atoi(const char *ptr);
/* Newline */ /* Newline */
/* White-space */ /* White-space */
#line 1891 "asn1p_l.c" #line 1888 "asn1p_l.c"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
...@@ -1987,20 +1984,9 @@ YY_MALLOC_DECL ...@@ -1987,20 +1984,9 @@ YY_MALLOC_DECL
YY_FATAL_ERROR( "input in flex scanner failed" ); \ YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \ result = n; \
} \ } \
else \ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
{ \ && ferror( yyin ) ) \
errno=0; \ YY_FATAL_ERROR( "input in flex scanner failed" );
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); \
} \
}
#endif #endif
/* No semi-colon after return; correct usage is to write "yyterminate();" - /* No semi-colon after return; correct usage is to write "yyterminate();" -
...@@ -2052,7 +2038,7 @@ YY_DECL ...@@ -2052,7 +2038,7 @@ YY_DECL
#line 93 "asn1p_l.l" #line 93 "asn1p_l.l"
#line 2056 "asn1p_l.c" #line 2042 "asn1p_l.c"
if ( yy_init ) if ( yy_init )
{ {
...@@ -3112,7 +3098,7 @@ YY_RULE_SETUP ...@@ -3112,7 +3098,7 @@ YY_RULE_SETUP
#line 538 "asn1p_l.l" #line 538 "asn1p_l.l"
YY_FATAL_ERROR( "flex scanner jammed" ); YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK YY_BREAK
#line 3116 "asn1p_l.c" #line 3102 "asn1p_l.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
...@@ -3672,15 +3658,11 @@ YY_BUFFER_STATE b; ...@@ -3672,15 +3658,11 @@ YY_BUFFER_STATE b;
} }
#ifndef _WIN32
#include <unistd.h>
#else
#ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int )); extern int isatty YY_PROTO(( int ));
#endif #endif
#endif #endif
#endif
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
......
...@@ -61,6 +61,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) { ...@@ -61,6 +61,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) {
if(p) { if(p) {
pl->params = p; pl->params = p;
pl->params_size = newsize; pl->params_size = newsize;
memset(&pl->params[pl->params_count], 0,
sizeof(pl->params[0]));
} else { } else {
return -1; return -1;
} }
...@@ -69,9 +71,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) { ...@@ -69,9 +71,8 @@ asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) {
if(gov) { if(gov) {
pl->params[pl->params_count].governor = asn1p_ref_clone(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; return -1;
}
} else { } else {
pl->params[pl->params_count].governor = 0; pl->params[pl->params_count].governor = 0;
} }
...@@ -103,6 +104,7 @@ asn1p_paramlist_clone(asn1p_paramlist_t *pl) { ...@@ -103,6 +104,7 @@ asn1p_paramlist_clone(asn1p_paramlist_t *pl) {
newpl = NULL; newpl = NULL;
break; break;
} }
newpl->params[i].into_expr = pl->params[i].into_expr;
} }
} }
......
/* /*
* Structures and prototypes related to parametrization * Structures and prototypes related to parameterization
*/ */
#ifndef ASN1_PARSER_PARAMETRIZATION_H #ifndef ASN1_PARSER_PARAMETERIZATION_H
#define ASN1_PARSER_PARAMETRIZATION_H #define ASN1_PARSER_PARAMETERIZATION_H
struct asn1p_expr_s; /* Forward declaration */
typedef struct asn1p_paramlist_s { typedef struct asn1p_paramlist_s {
struct asn1p_param_s { struct asn1p_param_s {
/* Translated from */
asn1p_ref_t *governor; asn1p_ref_t *governor;
char *argument; char *argument;
/* Translated into */
struct asn1p_expr_s *into_expr;
} *params; } *params;
int params_count; int params_count;
int params_size; int params_size;
int _lineno; int _lineno;
} asn1p_paramlist_t; } asn1p_paramlist_t;
...@@ -27,4 +31,4 @@ int asn1p_paramlist_add_param(asn1p_paramlist_t *, ...@@ -27,4 +31,4 @@ int asn1p_paramlist_add_param(asn1p_paramlist_t *,
asn1p_ref_t *opt_gov, char *arg); asn1p_ref_t *opt_gov, char *arg);
#endif /* ASN1_PARSER_PARAMETRIZATION_H */ #endif /* ASN1_PARSER_PARAMETERIZATION_H */
...@@ -110,6 +110,13 @@ asn1p_value_fromint(asn1c_integer_t i) { ...@@ -110,6 +110,13 @@ asn1p_value_fromint(asn1c_integer_t i) {
asn1p_value_t * asn1p_value_t *
asn1p_value_clone(asn1p_value_t *v) { 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; asn1p_value_t *clone = NULL;
if(v) { if(v) {
switch(v->type) { switch(v->type) {
...@@ -142,6 +149,11 @@ asn1p_value_clone(asn1p_value_t *v) { ...@@ -142,6 +149,11 @@ asn1p_value_clone(asn1p_value_t *v) {
return asn1p_value_frombits(v->value.binary_vector.bits, return asn1p_value_frombits(v->value.binary_vector.bits,
v->value.binary_vector.size_in_bits, 1); v->value.binary_vector.size_in_bits, 1);
case ATV_REFERENCED: 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); return asn1p_value_fromref(v->value.reference, 1);
case ATV_CHOICE_IDENTIFIER: { case ATV_CHOICE_IDENTIFIER: {
char *id = v->value.choice_identifier.identifier; char *id = v->value.choice_identifier.identifier;
......
...@@ -52,17 +52,20 @@ typedef struct asn1p_value_s { ...@@ -52,17 +52,20 @@ typedef struct asn1p_value_s {
} asn1p_value_t; } asn1p_value_t;
/* /*
* Constructors and destructor for value. * Destructor and constructors for value.
* If ref, bits or buffer are omitted, the corresponding function returns * If ref, bits or buffer are omitted, the corresponding function returns
* (asn1p_value_t *)0 with errno = EINVAL. * (asn1p_value_t *)0 with errno = EINVAL.
* Allocated value (where applicable) is guaranteed to be NUL-terminated. * 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_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_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_frombuf(char *buffer, int size, int do_copy);
asn1p_value_t *asn1p_value_fromdouble(double); asn1p_value_t *asn1p_value_fromdouble(double);
asn1p_value_t *asn1p_value_fromint(asn1c_integer_t); asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
asn1p_value_t *asn1p_value_clone(asn1p_value_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 */ #endif /* ASN1_PARSER_VALUE_H */
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.1. */ typedef union {
/* 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 {
asn1p_t *a_grammar; asn1p_t *a_grammar;
asn1p_module_flags_e a_module_flags; asn1p_module_flags_e a_module_flags;
asn1p_module_t *a_module; asn1p_module_t *a_module;
...@@ -275,14 +31,108 @@ typedef union YYSTYPE { ...@@ -275,14 +31,108 @@ typedef union YYSTYPE {
struct asn1p_type_tag_s tag; struct asn1p_type_tag_s tag;
} tv_nametag; } tv_nametag;
} YYSTYPE; } YYSTYPE;
/* Line 1447 of yacc.c. */ #define TOK_PPEQ 257
#line 280 "y.tab.h" #define TOK_whitespace 258
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ #define TOK_opaque 259
# define YYSTYPE_IS_DECLARED 1 #define TOK_bstring 260
# define YYSTYPE_IS_TRIVIAL 1 #define TOK_cstring 261
#endif #define TOK_hstring 262
#define TOK_identifier 263
extern YYSTYPE asn1p_lval; #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;
...@@ -270,8 +270,8 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr); ...@@ -270,8 +270,8 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
%type <tv_str> optIdentifier %type <tv_str> optIdentifier
%type <a_parg> ParameterArgumentName %type <a_parg> ParameterArgumentName
%type <a_plist> ParameterArgumentList %type <a_plist> ParameterArgumentList
%type <a_expr> ActualParameter %type <a_expr> Specialization
%type <a_expr> ActualParameterList %type <a_expr> Specializations
%type <a_aid> AssignedIdentifier /* OID/DefinedValue */ %type <a_aid> AssignedIdentifier /* OID/DefinedValue */
%type <a_oid> ObjectIdentifier /* OID */ %type <a_oid> ObjectIdentifier /* OID */
%type <a_oid> optObjectIdentifier /* Optional OID */ %type <a_oid> optObjectIdentifier /* Optional OID */
...@@ -774,8 +774,7 @@ DataTypeReference: ...@@ -774,8 +774,7 @@ DataTypeReference:
$$ = $6; $$ = $6;
assert($$->Identifier == 0); assert($$->Identifier == 0);
$$->Identifier = $1; $$->Identifier = $1;
$$->params = $3; $$->lhs_params = $3;
$$->meta_type = AMT_PARAMTYPE;
} }
; ;
...@@ -828,33 +827,37 @@ ParameterArgumentName: ...@@ -828,33 +827,37 @@ ParameterArgumentName:
} }
; ;
ActualParameterList: Specializations:
ActualParameter { Specialization {
$$ = asn1p_expr_new(yylineno); $$ = asn1p_expr_new(yylineno);
checkmem($$); checkmem($$);
asn1p_expr_add($$, $1); asn1p_expr_add($$, $1);
} }
| ActualParameterList ',' ActualParameter { | Specializations ',' Specialization {
$$ = $1; $$ = $1;
asn1p_expr_add($$, $3); asn1p_expr_add($$, $3);
} }
; ;
ActualParameter: Specialization:
Type { Type {
$$ = $1; $$ = $1;
} }
| Identifier { | Identifier {
asn1p_ref_t *ref;
$$ = asn1p_expr_new(yylineno); $$ = asn1p_expr_new(yylineno);
checkmem($$); checkmem($$);
$$->Identifier = $1; $$->Identifier = $1;
$$->expr_type = A1TC_REFERENCE; $$->expr_type = A1TC_REFERENCE;
$$->meta_type = AMT_VALUE; $$->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); $$ = asn1p_expr_new(yylineno);
checkmem($$); checkmem($$);
asn1p_expr_add($$, $2); asn1p_expr_add($$, $2);
...@@ -1223,23 +1226,6 @@ TypeDeclarationSet: ...@@ -1223,23 +1226,6 @@ TypeDeclarationSet:
$$->expr_type = ASN_TYPE_ANY; $$->expr_type = ASN_TYPE_ANY;
$$->meta_type = AMT_TYPE; $$->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. * A DefinedType reference.
* "CLASS1.&id.&id2" * "CLASS1.&id.&id2"
...@@ -1257,6 +1243,17 @@ TypeDeclarationSet: ...@@ -1257,6 +1243,17 @@ TypeDeclarationSet:
$$->expr_type = A1TC_REFERENCE; $$->expr_type = A1TC_REFERENCE;
$$->meta_type = AMT_TYPEREF; $$->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 { | TOK_INSTANCE TOK_OF ComplexTypeReference {
$$ = asn1p_expr_new(yylineno); $$ = asn1p_expr_new(yylineno);
checkmem($$); checkmem($$);
......
...@@ -165,6 +165,15 @@ _asn1p_apply_module2expr(asn1p_expr_t *expr, asn1p_module_t *mod) { ...@@ -165,6 +165,15 @@ _asn1p_apply_module2expr(asn1p_expr_t *expr, asn1p_module_t *mod) {
TQ_FOR(e, &(expr->members), next) { TQ_FOR(e, &(expr->members), next) {
_asn1p_apply_module2expr(e, mod); _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 static int
......
...@@ -42,7 +42,7 @@ typedef intmax_t asn1c_integer_t; ...@@ -42,7 +42,7 @@ typedef intmax_t asn1c_integer_t;
#include "asn1p_oid.h" /* Object identifiers (OIDs) */ #include "asn1p_oid.h" /* Object identifiers (OIDs) */
#include "asn1p_ref.h" /* References to custom types */ #include "asn1p_ref.h" /* References to custom types */
#include "asn1p_value.h" /* Value definition */ #include "asn1p_value.h" /* Value definition */
#include "asn1p_param.h" /* Parametrization */ #include "asn1p_param.h" /* Parameterization */
#include "asn1p_constr.h" /* Type Constraints */ #include "asn1p_constr.h" /* Type Constraints */
#include "asn1p_xports.h" /* IMports/EXports */ #include "asn1p_xports.h" /* IMports/EXports */
#include "asn1p_module.h" /* ASN.1 definition module */ #include "asn1p_module.h" /* ASN.1 definition module */
......
...@@ -525,11 +525,13 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -525,11 +525,13 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
INDENT("--<ASN1C.RepresentAsPointer>--\n"); 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); INDENT("%s", tc->Identifier);
if(tc->params) { if(tc->lhs_params) {
asn1print_params(tc->params, flags); asn1print_params(tc->lhs_params, flags);
} }
if(tc->meta_type != AMT_VALUE 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 ...@@ -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 */ SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */
printf(" COMPONENTS OF"); printf(" COMPONENTS OF");
break; break;
case A1TC_PARAMETRIZED:
flags |= APF_NOINDENT;
case A1TC_REFERENCE: case A1TC_REFERENCE:
case A1TC_UNIVERVAL: case A1TC_UNIVERVAL:
break; break;
...@@ -662,6 +662,16 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -662,6 +662,16 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
printf("}\n"); 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) { if(!SEQ_OF && tc->constraints) {
printf(" "); printf(" ");
asn1print_constraint(tc->constraints, flags); asn1print_constraint(tc->constraints, flags);
...@@ -680,7 +690,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -680,7 +690,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
printf(")"); printf(")");
} }
} else { } else {
printf(" ::= "); if(level == 0) printf(" ::= ");
asn1print_value(tc->value, flags); asn1print_value(tc->value, flags);
} }
} }
...@@ -746,6 +756,28 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -746,6 +756,28 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
} }
} while(0); } 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; return 0;
} }
......
-- 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
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
/*** <<< 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 */
};
-- 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
This diff is collapsed.
-- 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
/*** <<< 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 */
};
...@@ -9,15 +9,11 @@ SIGNED{ToBeSigned} ::= SEQUENCE { ...@@ -9,15 +9,11 @@ SIGNED{ToBeSigned} ::= SEQUENCE {
signature BIT STRING SIZE(0..256) signature BIT STRING SIZE(0..256)
} }
Certificate ::= SEQUENCE { Certificate ::= SIGNED{ SEQUENCE {
toBeSigned SEQUENCE {
version INTEGER, version INTEGER,
signature OBJECT IDENTIFIER, signature OBJECT IDENTIFIER,
issuer Name issuer Name
}, }}
algorithm OBJECT IDENTIFIER,
signature BIT STRING SIZE(0..256)
}
Name ::= SEQUENCE OF RelativeDistinguishedName Name ::= SEQUENCE OF RelativeDistinguishedName
......
/*** <<< INCLUDES [Certificate] >>> ***/ /*** <<< INCLUDES [SIGNED] >>> ***/
#include <OBJECT_IDENTIFIER.h> #include <OBJECT_IDENTIFIER.h>
#include <BIT_STRING.h> #include <BIT_STRING.h>
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include <Name.h> #include <Name.h>
#include <constr_SEQUENCE.h> #include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Certificate] >>> ***/ /*** <<< TYPE-DECLS [SIGNED] >>> ***/
typedef struct Certificate { typedef struct SIGNED_15P0 {
struct toBeSigned { struct toBeSigned {
INTEGER_t version; INTEGER_t version;
OBJECT_IDENTIFIER_t signature; OBJECT_IDENTIFIER_t signature;
...@@ -23,13 +23,13 @@ typedef struct Certificate { ...@@ -23,13 +23,13 @@ typedef struct Certificate {
/* Context for parsing across buffer boundaries */ /* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx; 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 static int
memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, 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, ...@@ -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[] = { static asn_TYPE_member_t asn_MBR_toBeSigned_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version), { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version),
...@@ -136,8 +136,8 @@ asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = { ...@@ -136,8 +136,8 @@ asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = {
&asn_SPC_toBeSigned_specs_2 /* Additional specs */ &asn_SPC_toBeSigned_specs_2 /* Additional specs */
}; };
static asn_TYPE_member_t asn_MBR_Certificate_1[] = { static asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Certificate, toBeSigned), { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, toBeSigned),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0, .tag_mode = 0,
.type = &asn_DEF_toBeSigned_2, .type = &asn_DEF_toBeSigned_2,
...@@ -146,7 +146,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { ...@@ -146,7 +146,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.default_value = 0, .default_value = 0,
.name = "toBeSigned" .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 = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
.tag_mode = 0, .tag_mode = 0,
.type = &asn_DEF_OBJECT_IDENTIFIER, .type = &asn_DEF_OBJECT_IDENTIFIER,
...@@ -155,7 +155,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { ...@@ -155,7 +155,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.default_value = 0, .default_value = 0,
.name = "algorithm" .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 = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0, .tag_mode = 0,
.type = &asn_DEF_BIT_STRING, .type = &asn_DEF_BIT_STRING,
...@@ -165,26 +165,26 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { ...@@ -165,26 +165,26 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = {
.name = "signature" .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)) (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 | (3 << 2)), 2, 0, 0 }, /* signature at 17 */
{ (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */ { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned at 21 */ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned at 21 */
}; };
static asn_SEQUENCE_specifics_t asn_SPC_Certificate_specs_1 = { static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1 = {
sizeof(struct Certificate), sizeof(struct SIGNED_15P0),
offsetof(struct Certificate, _asn_ctx), offsetof(struct SIGNED_15P0, _asn_ctx),
asn_MAP_Certificate_tag2el_1, asn_MAP_SIGNED_15P0_tag2el_1,
3, /* Count of tags in the map */ 3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */ 0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */ -1, /* Start extensions */
-1 /* Stop extensions */ -1 /* Stop extensions */
}; };
asn_TYPE_descriptor_t asn_DEF_Certificate = { asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0 = {
"Certificate", "SIGNED",
"Certificate", "SIGNED",
SEQUENCE_free, SEQUENCE_free,
SEQUENCE_print, SEQUENCE_print,
SEQUENCE_constraint, SEQUENCE_constraint,
...@@ -194,6 +194,130 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = { ...@@ -194,6 +194,130 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = {
SEQUENCE_encode_xer, SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */ 0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */ 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, asn_DEF_Certificate_tags_1,
sizeof(asn_DEF_Certificate_tags_1) sizeof(asn_DEF_Certificate_tags_1)
/sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */ /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
...@@ -201,9 +325,8 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = { ...@@ -201,9 +325,8 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = {
sizeof(asn_DEF_Certificate_tags_1) sizeof(asn_DEF_Certificate_tags_1)
/sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */ /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
0, /* No PER visible constraints */ 0, /* No PER visible constraints */
asn_MBR_Certificate_1, 0, 0, /* Defined elsewhere */
3, /* Elements count */ 0 /* No specifics */
&asn_SPC_Certificate_specs_1 /* Additional specs */
}; };
......
...@@ -8,10 +8,7 @@ DirectoryString{INTEGER:maxSize} ::= CHOICE { ...@@ -8,10 +8,7 @@ DirectoryString{INTEGER:maxSize} ::= CHOICE {
utf8String UTF8String (SIZE(1..maxSize)) utf8String UTF8String (SIZE(1..maxSize))
} }
DS1 ::= CHOICE { DS1 ::= DirectoryString{ub-name}
teletexString TeletexString (SIZE(1..128)),
utf8String UTF8String (SIZE(1..128))
}
ub-name INTEGER ::= 128 ub-name INTEGER ::= 128
......
...@@ -8,12 +8,8 @@ TestType{Parameter} ::= SEQUENCE { ...@@ -8,12 +8,8 @@ TestType{Parameter} ::= SEQUENCE {
} }
TestChoice ::= CHOICE { TestChoice ::= CHOICE {
type1 SEQUENCE { type1 TestType{ INTEGER (1..10)},
common INTEGER (1..10) DEFAULT 0 type2 [0] IMPLICIT TestType{ BOOLEAN}
},
type2 [0] IMPLICIT SEQUENCE {
common BOOLEAN DEFAULT 0
}
} }
END END
...@@ -28,12 +24,8 @@ AutoType{Parameter} ::= SEQUENCE { ...@@ -28,12 +24,8 @@ AutoType{Parameter} ::= SEQUENCE {
} }
AutoChoice ::= CHOICE { AutoChoice ::= CHOICE {
type1 [0] IMPLICIT SEQUENCE { type1 [0] IMPLICIT AutoType{ INTEGER (0..1)},
common [0] IMPLICIT INTEGER ((0..1))((0)) type2 [1] IMPLICIT AutoType{ BOOLEAN}
},
type2 [1] IMPLICIT SEQUENCE {
common [0] IMPLICIT BOOLEAN (0)
}
} }
END END
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment