aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-04-10 07:53:37 +0200
committerBjörn Gustavsson <[email protected]>2013-05-31 14:52:23 +0200
commite3d18eb865c7bcba21836837b1c4c415e7c857e8 (patch)
treeb66e812d6851808ac37831ee17c5500e42c2df72
parent4001ac2a291e26d9fa912dbeefbe92278aceb345 (diff)
downloadotp-e3d18eb865c7bcba21836837b1c4c415e7c857e8.tar.gz
otp-e3d18eb865c7bcba21836837b1c4c415e7c857e8.tar.bz2
otp-e3d18eb865c7bcba21836837b1c4c415e7c857e8.zip
BER: Fix handling of a constructed default value for a class
-rw-r--r--lib/asn1/src/asn1ct_gen_ber_bin_v2.erl4
-rw-r--r--lib/asn1/test/asn1_SUITE_data/InfObj.asn24
-rw-r--r--lib/asn1/test/testInfObj.erl9
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
index 52d8210321..96100b1b2f 100644
--- a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
@@ -799,8 +799,8 @@ gen_encode_default_call(ClassName,FieldName,Type) ->
Tag = [encode_tag_val(decode_class(X#tag.class),X#tag.form,X#tag.number)|| X <- OTag],
case asn1ct_gen:type(InnerType) of
{constructed,bif} ->
-%% asn1ct_gen:gen_encode_constructed(Erules,Typename,InnerType,Type);
- emit([" 'enc_",ClassName,'_',FieldName,"'(Bytes)"]),
+ emit([" 'enc_",ClassName,'_',FieldName,"'",
+ "(Val, ",{asis,Tag},")"]),
[#typedef{name=list_to_atom(lists:concat([ClassName,'_',FieldName])),
typespec=Type}];
{primitive,bif} ->
diff --git a/lib/asn1/test/asn1_SUITE_data/InfObj.asn b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
index ff11b36788..61d9d23ea2 100644
--- a/lib/asn1/test/asn1_SUITE_data/InfObj.asn
+++ b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
@@ -180,6 +180,30 @@ MyPdu ::= SEQUENCE {
str MY-CLASS.&stringValue ({MyObjectSet}{@int})
}
+--
+-- Class with constructed default
+--
+
+CONSTRUCTED-DEFAULT ::= CLASS {
+ &id INTEGER UNIQUE,
+ &Type DEFAULT SEQUENCE { a INTEGER, b BOOLEAN },
+ &ok BOOLEAN DEFAULT TRUE
+}
+
+constructed1 CONSTRUCTED-DEFAULT ::= { &id 1 }
+constructed2 CONSTRUCTED-DEFAULT ::= { &id 2, &ok false }
+
+ConstructedDefaultSet CONSTRUCTED-DEFAULT ::= {
+ constructed1 |
+ constructed2 |
+ { &id 3, &Type BOOLEAN }
+}
+
+ConstructedPdu ::= SEQUENCE {
+ id CONSTRUCTED-DEFAULT.&id ({ConstructedDefaultSet}),
+ content CONSTRUCTED-DEFAULT.&Type ({ConstructedDefaultSet}{@id})
+}
+
END
diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl
index c0f86eab60..d9890e4358 100644
--- a/lib/asn1/test/testInfObj.erl
+++ b/lib/asn1/test/testInfObj.erl
@@ -51,7 +51,14 @@ main(_Erule) ->
roundtrip('InfObj', 'MyPdu', {'MyPdu',42,12,false,"string"}),
roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,"hello"},
42,true,"longer string"}),
- roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}).
+ roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}),
+
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',1,{'CONSTRUCTED-DEFAULT_Type',-2001,true}}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',2,{'CONSTRUCTED-DEFAULT_Type',999,false}}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',3,true}).
roundtrip(M, T, V) ->