File 2437-Clean-up-use-of-asn1ct_gen-emit-1.patch of Package erlang

From e145beaa7102858c95315ec48ad04d0b57b6f018 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 14 Mar 2017 08:29:23 +0100
Subject: [PATCH 06/10] Clean up use of asn1ct_gen:emit/1

Stop up using asn1ct_gen:emit/1 with a tuple instead of a list.
Also remove the remaining uses of asn1ct_gen:demit/1.
---
 lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl |  3 +++
 lib/asn1/src/asn1ct_constructed_per.erl        | 12 ++++++------
 lib/asn1/src/asn1ct_gen_ber_bin_v2.erl         | 25 +++++++++++++------------
 lib/asn1/src/asn1ct_gen_per.erl                |  8 ++++----
 4 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
index f13668e27..e94f25af5 100644
--- a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
@@ -1462,6 +1462,9 @@ print_attribute_comment(InnerType,Pos,Cname,Prop) ->
     case InnerType of
 	#'Externaltypereference'{module=XModule,type=Name} ->
 	    emit([nl,"%% attribute ",Cname,"(",Pos,")   External ",XModule,":",Name]);
+        _ when is_tuple(InnerType) ->
+	    emit([nl,"%% attribute ",Cname,"(",Pos,") with type "|
+                  tuple_to_list(InnerType)]);
 	_ ->
 	    emit([nl,"%% attribute ",Cname,"(",Pos,") with type ",InnerType])
     end,
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index c745f30e8..c3d1dae90 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -686,7 +686,7 @@ gen_decode_choice(Erules,Typename,D) when is_record(D,type) ->
     {'CHOICE',CompList} = D#type.def,
     Ext = extensible_enc(CompList),
     gen_dec_choice(Erules,Typename,CompList,Ext),
-    emit({".",nl}).
+    emit([".",nl]).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Encode generator for SEQUENCE OF type
@@ -781,7 +781,7 @@ gen_decode_sof_components(Erule, Name, Typename, SeqOrSetOf, Cont) ->
     case asn1ct_gen:type(Conttype) of
 	{primitive,bif} ->
 	    asn1ct_gen_per:gen_dec_prim(Erule, Cont, "Bytes"),
-	    emit({com,nl});
+	    emit([com,nl]);
 	{constructed,bif} ->
 	    NewTypename = [Constructed_Suffix|Typename],
 	    emit([{asis,dec_func(asn1ct_gen:list2name(NewTypename))},
@@ -792,7 +792,7 @@ gen_decode_sof_components(Erule, Name, Typename, SeqOrSetOf, Cont) ->
 	'ASN1_OPEN_TYPE' ->
 	    asn1ct_gen_per:gen_dec_prim(Erule, #type{def='ASN1_OPEN_TYPE'},
 					"Bytes"),
-	    emit({com,nl});
+	    emit([com,nl]);
 	_ ->
 	    emit([{asis,dec_func(Conttype)},"(Bytes),",nl])
     end,
@@ -1494,9 +1494,9 @@ gen_dec_component_no_val(_, Type, {'DEFAULT',DefVal0}) ->
     DefVal = asn1ct_gen:conform_value(Type, DefVal0),
     emit([{asis,DefVal}]);
 gen_dec_component_no_val(_, _, 'OPTIONAL') ->
-    emit({"asn1_NOVALUE"});
+    emit(["asn1_NOVALUE"]);
 gen_dec_component_no_val({ext,_,_}, _, mandatory) ->
-    emit({"asn1_NOVALUE"}).
+    emit(["asn1_NOVALUE"]).
 
 dec_map_extaddgroup_no_val(Ext, Type, Comp) ->
     L0 = [dec_map_extaddgroup_no_val_1(N, P, Ext, Type) ||
@@ -1907,7 +1907,7 @@ emit_extaddgroupTerms(VarSeries,[_]) ->
     ok;
 emit_extaddgroupTerms(VarSeries,[_|Rest]) ->
     asn1ct_name:new(VarSeries),
-    emit({{curr,VarSeries},","}),
+    emit([{curr,VarSeries},","]),
     emit_extaddgroupTerms(VarSeries,Rest);
 emit_extaddgroupTerms(_,[]) ->
     ok.
diff --git a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
index 5bbb3ff52..429b14f8b 100644
--- a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
@@ -496,7 +496,7 @@ gen_decode_user(Erules,D) when is_record(D,typedef) ->
 	    asn1ct_name:new(len),
 	    gen_dec_prim(Def#type{def='ASN1_OPEN_TYPE'},
 			 BytesVar, {string,"TagIn"}),
-	    emit({".",nl,nl});
+	    emit([".",nl,nl]);
 	{primitive,bif} ->
 	    asn1ct_name:new(len),
 	    gen_dec_prim(Def, BytesVar, {string,"TagIn"}),
@@ -507,8 +507,7 @@ gen_decode_user(Erules,D) when is_record(D,typedef) ->
 	TheType ->
 	    DecFunName = mkfuncname(TheType,dec),
 	    emit([DecFunName,"(",BytesVar,
-		  ", TagIn)"]),
-	    emit([".",nl,nl])
+		  ", TagIn).",nl,nl])
     end.
 
 
@@ -738,9 +737,10 @@ gen_obj_code(Erules,_Module,Obj) when is_record(Obj,typedef) ->
     #'Externaltypereference'{module=M,type=ClName} = Def#'Object'.classname,
     Class = asn1_db:dbget(M,ClName),
     {object,_,Fields} = Def#'Object'.def,
-    emit({nl,nl,nl,"%%================================"}),
-    emit({nl,"%%  ",ObjName}),
-    emit({nl,"%%================================",nl}),
+    emit([nl,nl,nl,
+          "%%================================",nl,
+          "%%  ",ObjName,nl,
+          "%%================================",nl]),
     EncConstructed =
 	gen_encode_objectfields(ClName,get_class_fields(Class),
 				ObjName,Fields,[]),
@@ -1143,9 +1143,10 @@ gen_objectset_code(Erules,ObjSet) ->
     ClassDef = asn1_db:dbget(ClassModule,ClassName),
     UniqueFName = Def#'ObjectSet'.uniquefname,
     Set = Def#'ObjectSet'.set,
-    emit({nl,nl,nl,"%%================================"}),
-    emit({nl,"%%  ",ObjSetName}),
-    emit({nl,"%%================================",nl}),
+    emit([nl,nl,nl,
+          "%%================================",nl,
+          "%%  ",ObjSetName,nl,
+          "%%================================",nl]),
     case ClassName of
 	{_Module,ExtClassName} ->
 	    gen_objset_code(Erules,ObjSetName,UniqueFName,Set,ExtClassName,ClassDef);
@@ -1204,7 +1205,7 @@ gen_objset_enc(_,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName,
     Acc;
 gen_objset_enc(_, ObjSetName, UniqueName, [], _, _, _, Acc) ->
     emit_default_getenc(ObjSetName, UniqueName),
-    emit({".",nl,nl}),
+    emit([".",nl,nl]),
     Acc.
 
 emit_ext_fun(EncDec,ModuleName,Name) ->
@@ -1310,14 +1311,14 @@ emit_inner_of_fun(TDef=#typedef{name={ExtMod,Name},typespec=Type},
 		  InternalDefFunName,"'(Val, ",{asis,Tag},")"]),
 	    {[TDef#typedef{name=InternalDefFunName}],1};
 	_ ->
-	    emit({indent(12),"'",ExtMod,"':'enc_",Name,"'(Val",{asis,Tag},")"}),
+	    emit([indent(12),"'",ExtMod,"':'enc_",Name,"'(Val",{asis,Tag},")"]),
 	    {[],0}
     end;
 emit_inner_of_fun(#typedef{name=Name},_) ->
 %    OTag = Type#type.tag,
 % remove    Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
 %    Tag = [encode_tag_val(decode_class(X#tag.class),X#tag.form,X#tag.number)|| X <- OTag],
-    emit({indent(12),"'enc_",Name,"'(Val)"}),
+    emit([indent(12),"'enc_",Name,"'(Val)"]),
     {[],0};
 emit_inner_of_fun(Type,_) when is_record(Type,type) ->
     CurrMod = get(currmod),
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index b5bfeed76..79e58395c 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -101,10 +101,10 @@ gen_encode_user(Erules,D) when is_record(D,typedef) ->
     case asn1ct_gen:type(InnerType) of
 	{primitive,bif} ->
 	    gen_encode_prim(Erules, Def),
-	    emit({".",nl});
+	    emit([".",nl]);
 	'ASN1_OPEN_TYPE' ->
 	    gen_encode_prim(Erules, Def#type{def='ASN1_OPEN_TYPE'}),
-	    emit({".",nl});
+	    emit([".",nl]);
 	{constructed,bif} ->
 	    asn1ct_gen:gen_encode_constructed(Erules,Typename,InnerType,D);
 	#'Externaltypereference'{module=CurrMod,type=Etype} ->
@@ -257,10 +257,10 @@ gen_decode_user(Erules,D) when is_record(D,typedef) ->
     case asn1ct_gen:type(InnerType) of
 	{primitive,bif} ->
 	    gen_dec_prim(Erules,Def,"Bytes"),
-	    emit({".",nl,nl});
+	    emit([".",nl,nl]);
 	'ASN1_OPEN_TYPE' ->
 	    gen_dec_prim(Erules,Def#type{def='ASN1_OPEN_TYPE'},"Bytes"),
-	    emit({".",nl,nl});
+	    emit([".",nl,nl]);
 	{constructed,bif} ->
 	    asn1ct_gen:gen_decode_constructed(Erules,Typename,InnerType,D);
 	#'Externaltypereference'{}=Etype ->
-- 
2.12.0

openSUSE Build Service is sponsored by