aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-06-27 14:49:12 +0200
committerBjörn Gustavsson <[email protected]>2013-08-30 10:13:16 +0200
commit9033435e5b8051608c7e867051c1a8e6b946d2a9 (patch)
tree788ee5070999eb5d67b4c370175b71be2bc74d05 /lib/asn1/src/asn1ct_gen_per.erl
parentbf13576de7f8a3cd56a268e3bf9cdf6535ea2334 (diff)
downloadotp-9033435e5b8051608c7e867051c1a8e6b946d2a9.tar.gz
otp-9033435e5b8051608c7e867051c1a8e6b946d2a9.tar.bz2
otp-9033435e5b8051608c7e867051c1a8e6b946d2a9.zip
Remove broken support for multiple UNIQUE
According to the ASN.1 standard, having multiple UNIQUE in class is allowed. For example: C ::= CLASS { &id1 INTEGER UNIQUE, &id2 INTEGER UNIQUE } In practice, no one uses multiple UNIQUE. The ASN.1 compiler will crash if a class with multiple UNIQUE is used, but the backends have half-hearted support for multiple UNIQUE in that they generate helper functions similar to: getenc_OBJECT_SET(id1, 42) -> fun enc_XXX/3; ... Since we have no plans to implement support for multiple UNIQUE (no one seems to have missed it), simplify the helper functions like this: getenc_OBJECT_SET(42) -> fun enc_XXX/3; ...
Diffstat (limited to 'lib/asn1/src/asn1ct_gen_per.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index a3c1f01961..17ecdeefbf 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -641,8 +641,7 @@ gen_objset_enc(_,_,{unique,undefined},_,_,_,_,_) ->
[];
gen_objset_enc(Erule, ObjSetName, UniqueName, [{ObjName,Val,Fields}|T],
ClName, ClFields, NthObj, Acc)->
- emit(["'getenc_",ObjSetName,"'(",{asis,UniqueName},",",{asis,Val},
- ") ->",nl]),
+ emit(["'getenc_",ObjSetName,"'(",{asis,Val},") ->",nl]),
CurrMod = get(currmod),
{InternalFunc,NewNthObj}=
case ObjName of
@@ -664,14 +663,14 @@ gen_objset_enc(Erule, ObjSetName, UniqueName, [{ObjName,Val,Fields}|T],
NewNthObj, InternalFunc ++ Acc);
gen_objset_enc(uper, ObjSetName, _UniqueName, ['EXTENSIONMARK'],
_ClName, _ClFields, _NthObj, Acc) ->
- emit({"'getenc_",ObjSetName,"'(_, _) ->",nl}),
+ emit(["'getenc_",ObjSetName,"'(_) ->",nl]),
emit({indent(3),"fun(_, Val, _) ->",nl}),
emit([indent(6),"Val",nl,
indent(3),"end.",nl,nl]),
Acc;
gen_objset_enc(per, ObjSetName, _UniqueName, ['EXTENSIONMARK'],
_ClName, _ClFields, _NthObj, Acc) ->
- emit(["'getenc_",ObjSetName,"'(_, _) ->",nl,
+ emit(["'getenc_",ObjSetName,"'(_) ->",nl,
indent(3),"fun(_, Val, _) ->",nl,
indent(6),"BinVal = if",nl,
indent(9),"is_list(Val) -> list_to_binary(Val);",nl,
@@ -696,7 +695,7 @@ emit_ext_encfun(ModuleName,Name) ->
Name,"'(T,V,O) end"]).
emit_default_getenc(ObjSetName,UniqueName) ->
- emit(["'getenc_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
+ emit(["'getenc_",ObjSetName,"'(ErrV) ->",nl]),
emit([indent(4),"fun(C,V,_) -> exit({'Type not compatible with table constraint',{component,C},{value,V},{unique_name_and_value,",{asis,UniqueName},",ErrV}}) end"]).
@@ -803,8 +802,7 @@ gen_objset_dec(_, _, {unique,undefined}, _, _, _, _) ->
ok;
gen_objset_dec(Erule, ObjSName, UniqueName, [{ObjName,Val,Fields}|T], ClName,
ClFields, NthObj)->
- emit({"'getdec_",ObjSName,"'(",{asis,UniqueName},",",{asis,Val},
- ") ->",nl}),
+ emit(["'getdec_",ObjSName,"'(",{asis,Val},") ->",nl]),
CurrMod = get(currmod),
NewNthObj=
case ObjName of
@@ -825,7 +823,7 @@ gen_objset_dec(Erule, ObjSName, UniqueName, [{ObjName,Val,Fields}|T], ClName,
gen_objset_dec(Erule, ObjSName, UniqueName, T, ClName, ClFields, NewNthObj);
gen_objset_dec(_Erule, ObjSetName, _UniqueName, ['EXTENSIONMARK'],
_ClName, _ClFields, _NthObj) ->
- emit({"'getdec_",ObjSetName,"'(_, _) ->",nl}),
+ emit(["'getdec_",ObjSetName,"'(_) ->",nl]),
emit({indent(3),"fun(Attr1, Bytes, _,_) ->",nl}),
emit({indent(6),"{Bytes,Attr1}",nl}),
emit({indent(3),"end.",nl,nl}),
@@ -840,7 +838,7 @@ emit_ext_decfun(ModuleName,Name) ->
Name,"'(T,V,O1,O2) end"]).
emit_default_getdec(ObjSetName,UniqueName) ->
- emit(["'getdec_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
+ emit(["'getdec_",ObjSetName,"'(ErrV) ->",nl]),
emit([indent(2), "fun(C,V,_,_) -> exit({{component,C},{value,V},{unique_name_and_value,",{asis,UniqueName},",ErrV}}) end"]).