File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ Section.prototype.described = function (item) {
8181 return types . described ( types . wrap_ulong ( this . typecode ) , types . wrap ( item || this . content ) ) ;
8282} ;
8383
84+ Section . prototype . collect_sections = function ( sections ) {
85+ if ( this . multiple ) {
86+ for ( var i = 0 ; i < this . content . length ; i ++ ) {
87+ sections . push ( this . described ( this . content [ i ] ) ) ;
88+ }
89+ } else {
90+ sections . push ( this . described ( ) ) ;
91+ }
92+ } ;
93+
8494define_composite_section ( {
8595 name :'header' ,
8696 code :0x70 ,
@@ -136,14 +146,8 @@ define_map_section({name:'footer', code:0x78});
136146
137147
138148function wrap_body ( sections , msg ) {
139- if ( msg . body && msg . body . constructor === Section ) {
140- if ( msg . body . multiple ) {
141- msg . body . content . forEach ( function ( s ) {
142- sections . push ( msg . body . described ( s ) ) ;
143- } ) ;
144- } else {
145- sections . push ( msg . body . described ( ) ) ;
146- }
149+ if ( msg . body && msg . body . collect_sections ) {
150+ msg . body . collect_sections ( sections ) ;
147151 } else {
148152 sections . push ( types . described ( types . wrap_ulong ( 0x77 ) , types . wrap ( msg . body ) ) ) ;
149153 }
You can’t perform that action at this time.
0 commit comments