Skip to content

Commit

Permalink
moved -DASN_PDU_COLLECTION into compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
vlm committed Sep 17, 2006
1 parent cc7c94e commit a9532f4
Show file tree
Hide file tree
Showing 21 changed files with 1,402 additions and 1,321 deletions.
15 changes: 4 additions & 11 deletions examples/sample.makefile.regen
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,22 @@ if test -z "$ASN1PDU" \
exit
fi

ASN1DEFPDU=`echo "$ASN1PDU" | tr - _`

../../asn1c/asn1c -S ../../skeletons ${ASN1CMDOPTS} ${ASN1MODULES} || exit $?

if test ! -f Makefile.am.sample ; then
echo "Makefile.am.sample is missing"
exit 1
fi

CFLAGS=""

ASN1DEFPDU=`echo "$ASN1PDU" | tr - _`
CFLAGS="-DPDU=${ASN1DEFPDU}"
if test -f config.h ; then
CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
fi

FIXEDPDU=`echo "[$ASN1CMDOPTS]" | sed -e "s/.*-pdu=auto.*//"`
if test ! "$FIXEDPDU" ; then
CFLAGS="$CFLAGS -DASN_PDU_COLLECTION"
CFLAGS="-DHAVE_CONFIG_H $CFLAGS"
fi

set -x
cat Makefile.am.sample \
| sed -e "s/^CFLAGS.*/CFLAGS +=$CFLAGS -DPDU=${ASN1DEFPDU} -I./" \
| sed -e "s/^CFLAGS += /CFLAGS += ${CFLAGS} /" \
| sed -e "s/^all: /all: ${ASN1PDU}.c /" \
| sed -e "s/progname/${PROGNAME}/" \
> Makefile.$$
Expand Down
2 changes: 1 addition & 1 deletion examples/sample.source.RRC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4740,7 +4740,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = rrc-dump
CFLAGS += -DHAVE_CONFIG_H -DASN_PDU_COLLECTION -DPDU=DL_DCCH_Message -I.
CFLAGS += -DHAVE_CONFIG_H -DPDU=DL_DCCH_Message -DASN_PDU_COLLECTION -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}

all: DL-DCCH-Message.c $(TARGET)
Expand Down
3 changes: 2 additions & 1 deletion libasn1compiler/asn1c_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
"# This file may be used as an input for make(3)\n"
"# Remove the lines below to convert it into a pure .am file\n"
"TARGET = progname\n"
"CFLAGS += -I.\n"
"CFLAGS +=%s -I.\n"
"OBJS=${ASN_MODULE_SOURCES:.c=.o}"
" ${ASN_CONVERTER_SOURCES:.c=.o}\n"
"\nall: $(TARGET)\n"
Expand All @@ -150,6 +150,7 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
"\n\trm -f $(OBJS)\n"
"\nregen: regenerate-from-asn1-source\n"
"\nregenerate-from-asn1-source:\n\t"
, (arg->flags & A1C_PDU_AUTO) ? " -DASN_PDU_COLLECTION" : ""
);

for(i = 0; i < argc; i++)
Expand Down
2 changes: 1 addition & 1 deletion libasn1fix/asn1fix_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_expr_t *rhs_pspecs, as
if(TQ_FIRST(&classfield->members)) {
/* Already have something */
} else {
expr = asn1p_expr_new(classfield->_lineno);
expr = asn1p_expr_new(classfield->_lineno, mod);
expr->expr_type = ASN_TYPE_ANY;
expr->meta_type = AMT_TYPE;
asn1p_expr_add(classfield, expr);
Expand Down
2 changes: 1 addition & 1 deletion libasn1fix/asn1fix_constr.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ asn1f_fix_constr_ext(arg_t *arg) {

if(arg->mod->module_flags & MSF_EXTENSIBILITY_IMPLIED
&& ext_count == 0) {
v = asn1p_expr_new(0);
v = asn1p_expr_new(0, arg->mod);
if(v) {
v->Identifier = strdup("...");
v->expr_type = A1TC_EXTENSIBLE;
Expand Down
8 changes: 8 additions & 0 deletions libasn1fix/asn1fix_constraint_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ asn1constraint_compatible(asn1p_expr_type_e expr_type,
return 0;
case ACT_CT_CTDBY:
return 1;
case ACT_CT_CTNG: /* X.682, #11 */
switch(expr_type) {
case ASN_BASIC_OCTET_STRING:
case ASN_BASIC_BIT_STRING:
return 1;
default:
return 0;
}
case ACT_CA_SET:
case ACT_CA_CRC:
case ACT_CA_CSV:
Expand Down
2 changes: 1 addition & 1 deletion libasn1fix/asn1fix_cws.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ _asn1f_assign_cell_value(arg_t *arg, struct asn1p_ioc_row_s *row, struct asn1p_i
FATAL("Value %s at line %d is too large for this compiler! Contact the asn1c author.\n", p, arg->expr->_lineno);
return -1;
}
expr = asn1p_expr_new(arg->expr->_lineno);
expr = asn1p_expr_new(arg->expr->_lineno, arg->expr->module);
expr->Identifier = p;
expr->meta_type = AMT_VALUE;
expr->expr_type = ASN_BASIC_INTEGER;
Expand Down
2 changes: 2 additions & 0 deletions libasn1fix/asn1fix_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ asn1f_printable_value(asn1p_value_t *v) {
/* Buffer is guaranteed to be null-terminated */
assert(v->value.string.buf[v->value.string.size] == '\0');
return (char *)v->value.string.buf;
case ATV_TYPE:
return "<Type>";
case ATV_BITVECTOR:
{
uint8_t *bitvector;
Expand Down
2 changes: 2 additions & 0 deletions libasn1parser/asn1p_constr.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ asn1p_constraint_type2str(enum asn1p_constraint_type_e type) {
return "MultipleTypeConstraints";
case ACT_CT_CTDBY:
return "UserDefinedConstraint";
case ACT_CT_CTNG:
return "ContentsConstraint";
case ACT_CA_SET:
return "SET";
case ACT_CA_CRC:
Expand Down
3 changes: 2 additions & 1 deletion libasn1parser/asn1p_constr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ typedef struct asn1p_constraint_s {
ACT_CT_WCOMP, /* WITH COMPONENT */
ACT_CT_WCOMPS, /* WITH COMPONENTS */
ACT_CT_CTDBY, /* CONSTRAINED BY */
ACT_CT_CTNG, /* CONTAINING Type */
/*
* Arrays of constraints.
*/
ACT_CA_SET, /* A set of constraints: (c1)(c2) */
ACT_CA_CRC, /* Comp. relation c-t: ({a})({@b}) */
ACT_CA_CRC, /* Comp. relation c-t: ({a}{@b}) */
ACT_CA_CSV, /* Comma-separated constraints array */
ACT_CA_UNI, /* UNION (|) */
ACT_CA_INT, /* INTERSECTION (^) */
Expand Down
8 changes: 4 additions & 4 deletions libasn1parser/asn1p_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ static asn1p_value_t *value_resolver(asn1p_value_t *, void *arg);
* Construct a new empty types collection.
*/
asn1p_expr_t *
asn1p_expr_new(int _lineno) {
asn1p_expr_new(int _lineno, asn1p_module_t *mod) {
asn1p_expr_t *expr;

expr = calloc(1, sizeof *expr);
if(expr) {
TQ_INIT(&(expr->members));
expr->spec_index = -1;
expr->module = mod;
expr->_lineno = _lineno;
}

Expand Down Expand Up @@ -96,7 +97,7 @@ asn1p_expr_clone_impl(asn1p_expr_t *expr, int skip_extensions, asn1p_expr_t *(*r
return NULL; /* Hard error */
}
}
if(!clone) clone = asn1p_expr_new(expr->_lineno);
if(!clone) clone = asn1p_expr_new(expr->_lineno, expr->module);
if(!clone) return NULL;

/*
Expand All @@ -106,7 +107,6 @@ asn1p_expr_clone_impl(asn1p_expr_t *expr, int skip_extensions, asn1p_expr_t *(*r
CLCOPY(expr_type);
CLCOPY(tag);
CLCOPY(marker.flags); /* OPTIONAL/DEFAULT */
CLCOPY(module);
CLCOPY(_mark);

clone->data = 0; /* Do not clone this */
Expand Down Expand Up @@ -165,7 +165,7 @@ value_resolver(asn1p_value_t *value, void *rarg) {
}

ref = value->value.reference;
tmpexpr = asn1p_expr_new(ref->_lineno);
tmpexpr = asn1p_expr_new(ref->_lineno, 0);
tmpexpr->meta_type = AMT_TYPEREF;
tmpexpr->expr_type = A1TC_REFERENCE;
tmpexpr->reference = ref;
Expand Down
2 changes: 1 addition & 1 deletion libasn1parser/asn1p_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ typedef struct asn1p_expr_s {
/*
* Constructor and destructor.
*/
asn1p_expr_t *asn1p_expr_new(int _lineno);
asn1p_expr_t *asn1p_expr_new(int _lineno, struct asn1p_module_s *);
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),
Expand Down
2 changes: 1 addition & 1 deletion libasn1parser/asn1p_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ asn1p_module_new() {

mod = calloc(1, sizeof *mod);
if(mod) {
TQ_INIT(&(mod->imports));
TQ_INIT(&(mod->exports));
TQ_INIT(&(mod->imports));
TQ_INIT(&(mod->members));
}
return mod;
Expand Down
26 changes: 15 additions & 11 deletions libasn1parser/asn1p_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
#ifndef ASN1_PARSER_MODULE_H
#define ASN1_PARSER_MODULE_H

struct asn1p_module_s;

/*
* A simple container for several modules.
*/
typedef struct asn1p_s {
TQ_HEAD(struct asn1p_module_s) modules;
} asn1p_t;

asn1p_t *asn1p_new(void);
void asn1p_delete(asn1p_t *asn);

/*
* Flags specific to a module.
*/
Expand Down Expand Up @@ -71,6 +83,9 @@ typedef struct asn1p_module_s {
TQ_ENTRY(struct asn1p_module_s)
mod_next;

/* All modules */
asn1p_t *asn1p;

/*
* Internally useful properties.
*/
Expand All @@ -85,15 +100,4 @@ typedef struct asn1p_module_s {
asn1p_module_t *asn1p_module_new(void);
void asn1p_module_free(asn1p_module_t *mod);

/*
* No more than a container for several modules.
*/
typedef struct asn1p_s {
TQ_HEAD(struct asn1p_module_s) modules;
} asn1p_t;

asn1p_t *asn1p_new(void);
void asn1p_delete(asn1p_t *asn);


#endif /* ASN1_PARSER_MODULE_H */
15 changes: 15 additions & 0 deletions libasn1parser/asn1p_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ asn1p_value_fromint(asn1c_integer_t i) {
return v;
}

asn1p_value_t *
asn1p_value_fromtype(asn1p_expr_t *expr) {
asn1p_value_t *v = calloc(1, sizeof *v);
if(v) {
v->value.v_type = expr;
v->type = ATV_TYPE;
}
return v;
}

asn1p_value_t *
asn1p_value_clone(asn1p_value_t *v) {
return asn1p_value_clone_with_resolver(v, 0, 0);
Expand All @@ -149,6 +159,8 @@ asn1p_value_clone_with_resolver(asn1p_value_t *v,
return calloc(1, sizeof(*clone));
case ATV_REAL:
return asn1p_value_fromdouble(v->value.v_double);
case ATV_TYPE:
return asn1p_value_fromtype(v->value.v_type);
case ATV_INTEGER:
case ATV_MIN:
case ATV_MAX:
Expand Down Expand Up @@ -213,6 +225,9 @@ asn1p_value_free(asn1p_value_t *v) {
case ATV_NOVALUE:
case ATV_NULL:
break;
case ATV_TYPE:
asn1p_expr_free(v->value.v_type);
break;
case ATV_REAL:
case ATV_INTEGER:
case ATV_MIN:
Expand Down
4 changes: 4 additions & 0 deletions libasn1parser/asn1p_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define ASN1_PARSER_VALUE_H

struct asn1p_constraint_s; /* Forward declaration */
struct asn1p_expr_s;

/*
* A wrapper around various kinds of values.
Expand All @@ -15,6 +16,7 @@ typedef struct asn1p_value_s {
*/
enum {
ATV_NOVALUE,
ATV_TYPE, /* A type (as in CONTAINING Type) */
ATV_NULL, /* A "NULL" value of type NULL. */
ATV_REAL, /* A constant floating-point value */
ATV_INTEGER, /* An integer constant */
Expand All @@ -34,6 +36,7 @@ typedef struct asn1p_value_s {

union {
struct asn1p_constraint_s *constraint; /* ValueSet */
struct asn1p_expr_s *v_type; /* Type */
asn1p_ref_t *reference;
asn1c_integer_t v_integer;
double v_double;
Expand Down Expand Up @@ -68,6 +71,7 @@ asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc);
asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy);
asn1p_value_t *asn1p_value_fromdouble(double);
asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
asn1p_value_t *asn1p_value_fromtype(struct asn1p_expr_s *);
asn1p_value_t *asn1p_value_clone(asn1p_value_t *);
asn1p_value_t *asn1p_value_clone_with_resolver(asn1p_value_t *,
asn1p_value_t *(*resolver)(asn1p_value_t *, void *rarg),
Expand Down
Loading

0 comments on commit a9532f4

Please sign in to comment.