Commit d64be68b authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Fix the problem when ActualParameter to parameterized type is a Type

When ActualParameter to a parameterized type is a Type, commit
59b9e705 will produce C struct types using ActualParameter,
which are conflict with the C struct types for these Types themselves.

For example, the following typedef has duplicate definition of
UCI_OnPUSCH_t :

typedef struct UCI_OnPUSCH {
	UCI_OnPUSCH_PR present;
	union UCI_OnPUSCH_u {
		NULL_t	 release;
		UCI_OnPUSCH_t	 setup;
	} choice;

	/* Context for parsing across buffer boundaries */
	asn_struct_ctx_t _asn_ctx;
} UCI_OnPUSCH_t;

With this commit, if ActualParameter is a Type, then prefix it
with Parameterized Type name.

typedef struct SetupRelease_UCI_OnPUSCH {
	SetupRelease_UCI_OnPUSCH_PR present;
	union SetupRelease_UCI_OnPUSCH_u {
		NULL_t	 release;
		UCI_OnPUSCH_t	 setup;
	} choice;

	/* Context for parsing across buffer boundaries */
	asn_struct_ctx_t _asn_ctx;
} SetupRelease_UCI_OnPUSCH_t;

As for ActualParameter is ObjectSet, used in S1AP ... etc, it doesn't
prefix generated typedefs for keeping names shorter.

This commit can replace item 3 of

https://github.com/vlm/asn1c/issues/282#issuecomment-390838895

which solve part of #282.
parent 0bb89078
......@@ -58,7 +58,7 @@ asn1f_parameterization_fork(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *rhs_ps
if(!exc) return NULL;
if(rarg.resolved_name) {
free(exc->Identifier);
exc->Identifier = strdup(rarg.resolved_name);
exc->Identifier = rarg.resolved_name;
exc->_lineno = 0;
}
rpc = asn1p_expr_clone(rhs_pspecs, 0);
......@@ -147,12 +147,13 @@ resolve_expr(asn1p_expr_t *expr_to_resolve, void *resolver_arg) {
? strdup(expr_to_resolve->Identifier) : 0;
if(expr->meta_type == AMT_TYPEREF) {
asn1p_ref_t *ref = expr->reference;
rarg->resolved_name = ref->components[ref->comp_count - 1].name;
rarg->resolved_name = calloc(1, strlen(rarg->original_expr->Identifier) + strlen(ref->components[ref->comp_count - 1].name) + 2);
sprintf(rarg->resolved_name, "%s_%s", rarg->original_expr->Identifier, ref->components[ref->comp_count - 1].name);
} else if(expr->meta_type == AMT_VALUESET) {
asn1p_constraint_t *ct = expr->constraints;
if(ct->type == ACT_EL_TYPE) {
asn1p_ref_t *ref = ct->containedSubtype->value.v_type->reference;
rarg->resolved_name = ref->components[ref->comp_count - 1].name;
rarg->resolved_name = strdup(ref->components[ref->comp_count - 1].name);
}
}
return nex;
......
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