~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/asn1/src/asn1ct_gen_ber_bin_v2.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% ``The contents of this file are subject to the Erlang Public License,
 
1
%%<copyright>
 
2
%% <year>2002-2008</year>
 
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
 
4
%%</copyright>
 
5
%%<legalnotice>
 
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
 
%% retrieved via the world wide web at http://www.erlang.org/.
6
 
%% 
 
10
%% retrieved online at http://www.erlang.org/.
 
11
%%
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
11
 
%% 
12
 
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
%% AB. All Rights Reserved.''
15
 
%% 
16
 
%%     $Id$
 
16
%%
 
17
%% The Initial Developer of the Original Code is Ericsson AB.
 
18
%%</legalnotice>
17
19
%%
18
20
-module(asn1ct_gen_ber_bin_v2).
19
21
 
147
149
%% encode ComponentType
148
150
%%===============================================================================
149
151
 
150
 
gen_encode(Erules,Tname,{'ComponentType',_Pos,Cname,Type,_Prop,_Tags}) ->
 
152
gen_encode(Erules,Tname,#'ComponentType'{name=Cname,typespec=Type}) ->
151
153
    NewTname = [Cname|Tname],
152
154
    %% The tag is set to [] to avoid that it is
153
155
    %% taken into account twice, both as a component/alternative (passed as
253
255
            emit_encode_func('null',Value,DoTag);
254
256
        'OBJECT IDENTIFIER' ->
255
257
            emit_encode_func("object_identifier",Value,DoTag);
 
258
        'RELATIVE-OID' ->
 
259
            emit_encode_func("relative_oid",Value,DoTag);
256
260
        'ObjectDescriptor' ->
257
261
            emit_encode_func('restricted_string',Constraint,Value,
258
262
                             ?T_ObjectDescriptor,DoTag);
261
265
        'NumericString' ->
262
266
            emit_encode_func('restricted_string',Constraint,Value,
263
267
                             ?T_NumericString,DoTag);
264
 
        'TeletexString' ->
 
268
        TString when TString == 'TeletexString';
 
269
                     TString == 'T61String' ->
265
270
            emit_encode_func('restricted_string',Constraint,Value,
266
271
                             ?T_TeletexString,DoTag);
267
272
        'VideotexString' ->
520
525
%% decode ComponentType
521
526
%%===============================================================================
522
527
 
523
 
gen_decode(Erules,Tname,{'ComponentType',_Pos,Cname,Type,_Prop,_Tags}) ->
 
528
gen_decode(Erules,Tname,#'ComponentType'{name=Cname,typespec=Type}) ->
524
529
    NewTname = [Cname|Tname],
525
530
    %% The tag is set to [] to avoid that it is
526
531
    %% taken into account twice, both as a component/alternative (passed as
637
642
        'OBJECT IDENTIFIER' ->
638
643
            emit({"?RT_BER:decode_object_identifier(",BytesVar,","}),
639
644
            add_func({decode_object_identifier,2});
 
645
        'RELATIVE-OID' ->
 
646
            emit({"?RT_BER:decode_relative_oid(",BytesVar,","}),
 
647
            add_func({decode_relative_oid,2});
640
648
        'ObjectDescriptor' ->
641
649
            emit({"?RT_BER:decode_restricted_string(",
642
650
                  BytesVar,",",{asis,Constraint},",",{asis,?T_ObjectDescriptor},","}),
648
656
            emit({"?RT_BER:decode_restricted_string",AsBin,"(",
649
657
                  BytesVar,",",{asis,Constraint},",",{asis,?T_NumericString},","}),
650
658
            add_func({decode_restricted_string,4});
651
 
        'TeletexString' ->
 
659
        TString when TString == 'TeletexString';
 
660
                     TString == 'T61String' ->
652
661
            emit({"?RT_BER:decode_restricted_string",AsBin,"(",
653
662
                  BytesVar,",",{asis,Constraint},",",{asis,?T_TeletexString},","}),
654
663
            add_func({decode_restricted_string,4});
1276
1285
          Name,"'(T,V,O) end"]).
1277
1286
    
1278
1287
emit_default_getenc(ObjSetName,UniqueName) ->
1279
 
    emit(["'getenc_",ObjSetName,"'(",{asis,UniqueName},", _) ->",nl]),
1280
 
    emit([indent(3),"fun(C,V,_) -> exit({'Type not compatible with table constraint',{component,C},{value,V}}) end"]).
 
1288
    emit(["'getenc_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
 
1289
    emit([indent(3),"fun(C,V,_) -> exit({'Type not compatible with table constraint',{component,C},{value,V}, {unique_name_and_value,",{asis,UniqueName},", ErrV}}) end"]).
1281
1290
 
1282
1291
%% gen_inlined_enc_funs for each object iterates over all fields of a
1283
1292
%% class, and for each typefield it checks if the object has that
1495
1504
    ok.
1496
1505
 
1497
1506
emit_default_getdec(ObjSetName,UniqueName) ->
1498
 
    emit(["'getdec_",ObjSetName,"'(",{asis,UniqueName},", _) ->",nl]),
1499
 
    emit([indent(2), "fun(C,V,_) -> exit({{component,C},{value,V}}) end"]).
 
1507
    emit(["'getdec_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
 
1508
    emit([indent(2), "fun(C,V,_) -> exit({{component,C},{value,V},{unique_name_and_value,",{asis,UniqueName},", ErrV}}) end"]).
1500
1509
 
1501
1510
gen_inlined_dec_funs(Fields,[{typefield,Name,Prop}|Rest],
1502
1511
                     ObjSetName,NthObj) ->
1675
1684
decode_type('ENUMERATED') -> 10;
1676
1685
decode_type('EMBEDDED_PDV') -> 11;
1677
1686
decode_type('UTF8String') -> 12;
 
1687
decode_type('RELATIVE-OID') -> 13;
1678
1688
decode_type('SEQUENCE') -> 16;
1679
1689
decode_type('SEQUENCE OF') -> 16;
1680
1690
decode_type('SET') -> 17;
1682
1692
decode_type('NumericString') -> 18;  
1683
1693
decode_type('PrintableString') -> 19;  
1684
1694
decode_type('TeletexString') -> 20;  
 
1695
decode_type('T61String') -> 20;
1685
1696
decode_type('VideotexString') -> 21;  
1686
1697
decode_type('IA5String') -> 22;  
1687
1698
decode_type('UTCTime') -> 23;