From a4fe56c06a95bf5278a4a0efdd976febc2b9866b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 14:59:21 +0000 Subject: r12481: Move parser-specific utility functions to idl.yp, remove some unused functions Allow the use of non-typedef structs and unions when declaring variables. Allow the use of the 'signed' and 'unsigned' qualifiers for integer types (This used to be commit bc6b45e242c8d7b2ef1a6e6d3eb172c27afd952d) --- source4/pidl/idl.yp | 59 +- source4/pidl/lib/Parse/Pidl/IDL.pm | 1032 ++++++++++++++++++++--------------- source4/pidl/lib/Parse/Pidl/Util.pm | 42 -- 3 files changed, 641 insertions(+), 492 deletions(-) diff --git a/source4/pidl/idl.yp b/source4/pidl/idl.yp index 430f7e1b06..62f636cb00 100644 --- a/source4/pidl/idl.yp +++ b/source4/pidl/idl.yp @@ -140,15 +140,22 @@ usertype: struct | union | enum | bitmap; typedecl: usertype ';' { $_[1] }; -type: usertype | identifier - | void { "void" } +sign: 'signed' | 'unsigned'; + +existingtype: + | sign identifier { "$_[1] $_[2]" } + | identifier ; -enum: 'enum' optional_identifier '{' enum_elements '}' +type: usertype | existingtype | void { "void" } ; + +enum_body: '{' enum_elements '}' { $_[2] }; +opt_enum_body: | enum_body; +enum: 'enum' optional_identifier opt_enum_body {{ "TYPE" => "ENUM", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ; @@ -161,11 +168,13 @@ enum_element: identifier | identifier '=' anytext { "$_[1]$_[2]$_[3]" } ; -bitmap: 'bitmap' optional_identifier '{' bitmap_elements '}' +bitmap_body: '{' bitmap_elements '}' { $_[2] }; +opt_bitmap_body: | bitmap_body; +bitmap: 'bitmap' optional_identifier opt_bitmap_body {{ "TYPE" => "BITMAP", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ; @@ -177,11 +186,14 @@ bitmap_elements: bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" } ; -struct: 'struct' optional_identifier '{' element_list1 '}' +struct_body: '{' element_list1 '}' { $_[2] }; +opt_struct_body: | struct_body; + +struct: 'struct' optional_identifier opt_struct_body {{ "TYPE" => "STRUCT", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ; @@ -200,7 +212,7 @@ empty_element: property_list ';' base_or_empty: base_element ';' | empty_element; optional_base_element: - property_list base_or_empty { $_[2]->{PROPERTIES} = Parse::Pidl::Util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } + property_list base_or_empty { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ; union_elements: @@ -208,11 +220,14 @@ union_elements: | union_elements optional_base_element { push(@{$_[1]}, $_[2]); $_[1] } ; -union: 'union' optional_identifier '{' union_elements '}' +union_body: '{' union_elements '}' { $_[2] }; +opt_union_body: | union_body; + +union: 'union' optional_identifier opt_union_body {{ "TYPE" => "UNION", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ; @@ -256,11 +271,11 @@ array_len: property_list: #empty - | property_list '[' properties ']' { Parse::Pidl::Util::FlattenHash([$_[1],$_[3]]); } + | property_list '[' properties ']' { FlattenHash([$_[1],$_[3]]); } ; properties: property { $_[1] } - | properties ',' property { Parse::Pidl::Util::FlattenHash([$_[1], $_[3]]); } + | properties ',' property { FlattenHash([$_[1], $_[3]]); } ; property: identifier {{ "$_[1]" => "1" }} @@ -321,7 +336,21 @@ optional_semicolon: # start code %% -use Parse::Pidl::Util; +##################################################################### +# flatten an array of hashes into a single hash +sub FlattenHash($) +{ + my $a = shift; + my %b; + for my $d (@{$a}) { + for my $k (keys %{$d}) { + $b{$k} = $d->{$k}; + } + } + return \%b; +} + + ##################################################################### # traverse a perl data structure removing any empty arrays or @@ -405,7 +434,7 @@ again: $parser->YYData->{LAST_TOKEN} = $1; if ($1 =~ /^(coclass|interface|const|typedef|declare|union - |struct|enum|bitmap|void)$/x) { + |struct|enum|bitmap|void|unsigned|signed)$/x) { return $1; } return('IDENTIFIER',$1); diff --git a/source4/pidl/lib/Parse/Pidl/IDL.pm b/source4/pidl/lib/Parse/Pidl/IDL.pm index 4988ae572a..60439b8601 100644 --- a/source4/pidl/lib/Parse/Pidl/IDL.pm +++ b/source4/pidl/lib/Parse/Pidl/IDL.pm @@ -509,7 +509,7 @@ sub new { ACTIONS => { '' => 2 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { 'interface' => 3, 'coclass' => 4, @@ -559,7 +559,7 @@ sub new { } }, {#State 9 - DEFAULT => -92 + DEFAULT => -109 }, {#State 10 ACTIONS => { @@ -570,10 +570,10 @@ sub new { ACTIONS => { "(" => 16 }, - DEFAULT => -67 + DEFAULT => -84 }, {#State 12 - DEFAULT => -65 + DEFAULT => -82 }, {#State 13 ACTIONS => { @@ -602,7 +602,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'listtext' => 26, @@ -621,7 +621,7 @@ sub new { } }, {#State 18 - DEFAULT => -64 + DEFAULT => -81 }, {#State 19 ACTIONS => { @@ -643,13 +643,13 @@ sub new { } }, {#State 22 - DEFAULT => -96 + DEFAULT => -113 }, {#State 23 - DEFAULT => -74 + DEFAULT => -91 }, {#State 24 - DEFAULT => -76 + DEFAULT => -93 }, {#State 25 ACTIONS => { @@ -669,7 +669,7 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -69 + DEFAULT => -86 }, {#State 26 ACTIONS => { @@ -678,13 +678,13 @@ sub new { } }, {#State 27 - DEFAULT => -75 + DEFAULT => -92 }, {#State 28 - DEFAULT => -95 + DEFAULT => -112 }, {#State 29 - DEFAULT => -66 + DEFAULT => -83 }, {#State 30 DEFAULT => -9 @@ -699,7 +699,7 @@ sub new { "const" => 60, "struct" => 63 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { 'typedecl' => 64, 'function' => 53, @@ -720,7 +720,7 @@ sub new { ACTIONS => { ";" => 71 }, - DEFAULT => -97, + DEFAULT => -114, GOTOS => { 'optional_semicolon' => 72 } @@ -739,7 +739,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 74, @@ -753,7 +753,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 75, @@ -767,7 +767,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 76, @@ -781,7 +781,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 77, @@ -795,7 +795,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 78, @@ -809,7 +809,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 79, @@ -823,7 +823,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 80, @@ -838,7 +838,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 82, @@ -852,7 +852,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 83, @@ -866,7 +866,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 84, @@ -880,7 +880,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 80, @@ -895,7 +895,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 86, @@ -909,7 +909,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 87, @@ -923,7 +923,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 88, @@ -937,7 +937,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 89, @@ -951,7 +951,7 @@ sub new { 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, 'anytext' => 90, @@ -960,10 +960,10 @@ sub new { } }, {#State 50 - DEFAULT => -68 + DEFAULT => -85 }, {#State 51 - DEFAULT => -63, + DEFAULT => -80, GOTOS => { 'property_list' => 91 } @@ -972,7 +972,7 @@ sub new { ACTIONS => { 'IDENTIFIER' => 92 }, - DEFAULT => -94, + DEFAULT => -111, GOTOS => { 'optional_identifier' => 93 } @@ -991,7 +991,7 @@ sub new { "const" => 60, "struct" => 63 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { 'typedecl' => 64, 'function' => 53, @@ -1015,30 +1015,34 @@ sub new { {#State 56 ACTIONS => { 'IDENTIFIER' => 9, + "signed" => 102, "union" => 52, "enum" => 65, "bitmap" => 66, - "[" => 7, 'void' => 97, + "unsigned" => 103, + "[" => 7, "struct" => 63 }, GOTOS => { + 'existingtype' => 101, + 'bitmap' => 67, + 'usertype' => 98, 'identifier' => 99, 'struct' => 59, 'enum' => 61, - 'type' => 100, + 'type' => 104, 'union' => 70, - 'bitmap' => 67, - 'usertype' => 98 + 'sign' => 100 } }, {#State 57 DEFAULT => -10 }, {#State 58 - DEFAULT => -63, + DEFAULT => -80, GOTOS => { - 'property_list' => 101 + 'property_list' => 105 } }, {#State 59 @@ -1049,7 +1053,7 @@ sub new { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 102 + 'identifier' => 106 } }, {#State 61 @@ -1062,9 +1066,9 @@ sub new { ACTIONS => { 'IDENTIFIER' => 92 }, - DEFAULT => -94, + DEFAULT => -111, GOTOS => { - 'optional_identifier' => 103 + 'optional_identifier' => 107 } }, {#State 64 @@ -1074,18 +1078,18 @@ sub new { ACTIONS => { 'IDENTIFIER' => 92 }, - DEFAULT => -94, + DEFAULT => -111, GOTOS => { - 'optional_identifier' => 104 + 'optional_identifier' => 108 } }, {#State 66 ACTIONS => { 'IDENTIFIER' => 92 }, - DEFAULT => -94, + DEFAULT => -111, GOTOS => { - 'optional_identifier' => 105 + 'optional_identifier' => 109 } }, {#State 67 @@ -1101,14 +1105,14 @@ sub new { DEFAULT => -27 }, {#State 71 - DEFAULT => -98 + DEFAULT => -115 }, {#State 72 DEFAULT => -4 }, {#State 73 ACTIONS => { - ";" => 106 + ";" => 110 } }, {#State 74 @@ -1129,7 +1133,7 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -86 + DEFAULT => -103 }, {#State 75 ACTIONS => { @@ -1140,7 +1144,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -77 + DEFAULT => -94 }, {#State 76 ACTIONS => { @@ -1160,7 +1164,7 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -85 + DEFAULT => -102 }, {#State 77 ACTIONS => { @@ -1180,7 +1184,7 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -81 + DEFAULT => -98 }, {#State 78 ACTIONS => { @@ -1200,7 +1204,7 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -89 + DEFAULT => -106 }, {#State 79 ACTIONS => { @@ -1211,7 +1215,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -88 + DEFAULT => -105 }, {#State 80 ACTIONS => { @@ -1231,12 +1235,12 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -71 + DEFAULT => -88 }, {#State 81 ACTIONS => { - "}" => 107, - "," => 108 + "}" => 111, + "," => 112 } }, {#State 82 @@ -1248,7 +1252,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -83 + DEFAULT => -100 }, {#State 83 ACTIONS => { @@ -1259,7 +1263,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -84 + DEFAULT => -101 }, {#State 84 ACTIONS => { @@ -1279,12 +1283,12 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -87 + DEFAULT => -104 }, {#State 85 ACTIONS => { - "," => 108, - ")" => 109 + "," => 112, + ")" => 113 } }, {#State 86 @@ -1296,7 +1300,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -82 + DEFAULT => -99 }, {#State 87 ACTIONS => { @@ -1307,7 +1311,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -79 + DEFAULT => -96 }, {#State 88 ACTIONS => { @@ -1318,7 +1322,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -78 + DEFAULT => -95 }, {#State 89 ACTIONS => { @@ -1329,7 +1333,7 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -80 + DEFAULT => -97 }, {#State 90 ACTIONS => { @@ -1349,43 +1353,52 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -70 + DEFAULT => -87 }, {#State 91 ACTIONS => { 'IDENTIFIER' => 9, + "signed" => 102, "union" => 52, "enum" => 65, "bitmap" => 66, - "[" => 7, 'void' => 97, + "unsigned" => 103, + "[" => 7, "struct" => 63 }, GOTOS => { + 'existingtype' => 101, + 'bitmap' => 67, + 'usertype' => 98, 'identifier' => 99, 'struct' => 59, 'enum' => 61, - 'type' => 110, + 'type' => 114, 'union' => 70, - 'bitmap' => 67, - 'usertype' => 98 + 'sign' => 100 } }, {#State 92 - DEFAULT => -93 + DEFAULT => -110 }, {#State 93 ACTIONS => { - "{" => 111 + "{" => 116 + }, + DEFAULT => -65, + GOTOS => { + 'union_body' => 117, + 'opt_union_body' => 115 } }, {#State 94 ACTIONS => { ";" => 71 }, - DEFAULT => -97, + DEFAULT => -114, GOTOS => { - 'optional_semicolon' => 112 + 'optional_semicolon' => 118 } }, {#State 95 @@ -1395,178 +1408,237 @@ sub new { DEFAULT => -30 }, {#State 97 - DEFAULT => -33 + DEFAULT => -38 }, {#State 98 - DEFAULT => -31 + DEFAULT => -36 }, {#State 99 - DEFAULT => -32 + DEFAULT => -35 }, {#State 100 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 113 + 'identifier' => 119 } }, {#State 101 + DEFAULT => -37 + }, + {#State 102 + DEFAULT => -31 + }, + {#State 103 + DEFAULT => -32 + }, + {#State 104 ACTIONS => { - "enum" => 117, - "bitmap" => 118, + 'IDENTIFIER' => 9 + }, + GOTOS => { + 'identifier' => 120 + } + }, + {#State 105 + ACTIONS => { + "enum" => 124, + "bitmap" => 125, "[" => 7 }, GOTOS => { - 'decl_enum' => 114, - 'decl_bitmap' => 115, - 'decl_type' => 116 + 'decl_enum' => 121, + 'decl_bitmap' => 122, + 'decl_type' => 123 } }, - {#State 102 - DEFAULT => -52, + {#State 106 + DEFAULT => -69, GOTOS => { - 'pointers' => 119 + 'pointers' => 126 } }, - {#State 103 + {#State 107 ACTIONS => { - "{" => 120 + "{" => 128 + }, + DEFAULT => -55, + GOTOS => { + 'struct_body' => 127, + 'opt_struct_body' => 129 } }, - {#State 104 + {#State 108 ACTIONS => { - "{" => 121 + "{" => 130 + }, + DEFAULT => -40, + GOTOS => { + 'opt_enum_body' => 132, + 'enum_body' => 131 } }, - {#State 105 + {#State 109 ACTIONS => { - "{" => 122 + "{" => 134 + }, + DEFAULT => -48, + GOTOS => { + 'bitmap_body' => 135, + 'opt_bitmap_body' => 133 } }, - {#State 106 + {#State 110 DEFAULT => -6 }, - {#State 107 + {#State 111 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 123, + 'anytext' => 136, 'text' => 24, 'constant' => 27 } }, - {#State 108 + {#State 112 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 124, + 'anytext' => 137, 'text' => 24, 'constant' => 27 } }, - {#State 109 + {#State 113 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 125, + 'anytext' => 138, 'text' => 24, 'constant' => 27 } }, - {#State 110 + {#State 114 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 126 + 'identifier' => 139 } }, - {#State 111 - DEFAULT => -48, + {#State 115 + DEFAULT => -67 + }, + {#State 116 + DEFAULT => -62, GOTOS => { - 'union_elements' => 127 + 'union_elements' => 140 } }, - {#State 112 + {#State 117 + DEFAULT => -66 + }, + {#State 118 DEFAULT => -7 }, - {#State 113 + {#State 119 + DEFAULT => -34 + }, + {#State 120 ACTIONS => { - "(" => 128 + "(" => 141 } }, - {#State 114 + {#State 121 DEFAULT => -21 }, - {#State 115 + {#State 122 DEFAULT => -22 }, - {#State 116 + {#State 123 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 129 + 'identifier' => 142 } }, - {#State 117 + {#State 124 DEFAULT => -23 }, - {#State 118 + {#State 125 DEFAULT => -24 }, - {#State 119 + {#State 126 ACTIONS => { 'IDENTIFIER' => 9, - "*" => 131 + "*" => 144 }, GOTOS => { - 'identifier' => 130 + 'identifier' => 143 } }, - {#State 120 - DEFAULT => -54, + {#State 127 + DEFAULT => -56 + }, + {#State 128 + DEFAULT => -71, GOTOS => { - 'element_list1' => 132 + 'element_list1' => 145 } }, - {#State 121 + {#State 129 + DEFAULT => -57 + }, + {#State 130 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 133, - 'enum_element' => 134, - 'enum_elements' => 135 + 'identifier' => 146, + 'enum_element' => 147, + 'enum_elements' => 148 } }, - {#State 122 + {#State 131 + DEFAULT => -41 + }, + {#State 132 + DEFAULT => -42 + }, + {#State 133 + DEFAULT => -50 + }, + {#State 134 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 138, - 'bitmap_elements' => 137, - 'bitmap_element' => 136 + 'identifier' => 151, + 'bitmap_elements' => 150, + 'bitmap_element' => 149 } }, - {#State 123 + {#State 135 + DEFAULT => -49 + }, + {#State 136 ACTIONS => { "-" => 35, ":" => 34, @@ -1584,9 +1656,9 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -91 + DEFAULT => -108 }, - {#State 124 + {#State 137 ACTIONS => { "-" => 35, ":" => 34, @@ -1604,9 +1676,9 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -72 + DEFAULT => -89 }, - {#State 125 + {#State 138 ACTIONS => { ":" => 34, "<" => 37, @@ -1615,258 +1687,263 @@ sub new { "{" => 40, "=" => 43 }, - DEFAULT => -90 + DEFAULT => -107 }, - {#State 126 + {#State 139 ACTIONS => { - "[" => 139 + "[" => 152 }, - DEFAULT => -60, + DEFAULT => -77, GOTOS => { - 'array_len' => 140 + 'array_len' => 153 } }, - {#State 127 + {#State 140 ACTIONS => { - "}" => 141 + "}" => 154 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { - 'optional_base_element' => 143, - 'property_list' => 142 + 'optional_base_element' => 156, + 'property_list' => 155 } }, - {#State 128 + {#State 141 ACTIONS => { - "," => -56, - "void" => 147, - ")" => -56 + "," => -73, + "void" => 160, + ")" => -73 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { - 'base_element' => 144, - 'element_list2' => 146, - 'property_list' => 145 + 'base_element' => 157, + 'element_list2' => 159, + 'property_list' => 158 } }, - {#State 129 + {#State 142 ACTIONS => { - ";" => 148 + ";" => 161 } }, - {#State 130 + {#State 143 ACTIONS => { - "[" => 139, - "=" => 150 + "[" => 152, + "=" => 163 }, GOTOS => { - 'array_len' => 149 + 'array_len' => 162 } }, - {#State 131 - DEFAULT => -53 + {#State 144 + DEFAULT => -70 }, - {#State 132 + {#State 145 ACTIONS => { - "}" => 151 + "}" => 164 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { - 'base_element' => 152, - 'property_list' => 145 + 'base_element' => 165, + 'property_list' => 158 } }, - {#State 133 + {#State 146 ACTIONS => { - "=" => 153 + "=" => 166 }, - DEFAULT => -37 + DEFAULT => -45 }, - {#State 134 - DEFAULT => -35 + {#State 147 + DEFAULT => -43 }, - {#State 135 + {#State 148 ACTIONS => { - "}" => 154, - "," => 155 + "}" => 167, + "," => 168 } }, - {#State 136 - DEFAULT => -40 + {#State 149 + DEFAULT => -51 }, - {#State 137 + {#State 150 ACTIONS => { - "}" => 156, - "," => 157 + "}" => 169, + "," => 170 } }, - {#State 138 + {#State 151 ACTIONS => { - "=" => 158 + "=" => 171 } }, - {#State 139 + {#State 152 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, - "]" => 159, + "]" => 172, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 160, + 'anytext' => 173, 'text' => 24, 'constant' => 27 } }, - {#State 140 + {#State 153 ACTIONS => { - ";" => 161 + ";" => 174 } }, - {#State 141 - DEFAULT => -50 + {#State 154 + DEFAULT => -64 }, - {#State 142 + {#State 155 ACTIONS => { "[" => 7 }, - DEFAULT => -63, + DEFAULT => -80, GOTOS => { - 'base_or_empty' => 162, - 'base_element' => 163, - 'empty_element' => 164, - 'property_list' => 165 + 'base_or_empty' => 175, + 'base_element' => 176, + 'empty_element' => 177, + 'property_list' => 178 } }, - {#State 143 - DEFAULT => -49 + {#State 156 + DEFAULT => -63 }, - {#State 144 - DEFAULT => -58 + {#State 157 + DEFAULT => -75 }, - {#State 145 + {#State 158 ACTIONS => { 'IDENTIFIER' => 9, + "signed" => 102, "union" => 52, "enum" => 65, "bitmap" => 66, - "[" => 7, 'void' => 97, + "unsigned" => 103, + "[" => 7, "struct" => 63 }, + DEFAULT => -33, GOTOS => { + 'existingtype' => 101, + 'bitmap' => 67, + 'usertype' => 98, 'identifier' => 99, 'struct' => 59, 'enum' => 61, - 'type' => 166, + 'type' => 179, 'union' => 70, - 'bitmap' => 67, - 'usertype' => 98 + 'sign' => 100 } }, - {#State 146 + {#State 159 ACTIONS => { - "," => 167, - ")" => 168 + "," => 180, + ")" => 181 } }, - {#State 147 - DEFAULT => -57 + {#State 160 + DEFAULT => -74 }, - {#State 148 + {#State 161 DEFAULT => -20 }, - {#State 149 + {#State 162 ACTIONS => { - "=" => 169 + "=" => 182 } }, - {#State 150 + {#State 163 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 170, + 'anytext' => 183, 'text' => 24, 'constant' => 27 } }, - {#State 151 - DEFAULT => -43 + {#State 164 + DEFAULT => -54 }, - {#State 152 + {#State 165 ACTIONS => { - ";" => 171 + ";" => 184 } }, - {#State 153 + {#State 166 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 172, + 'anytext' => 185, 'text' => 24, 'constant' => 27 } }, - {#State 154 - DEFAULT => -34 + {#State 167 + DEFAULT => -39 }, - {#State 155 + {#State 168 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 133, - 'enum_element' => 173 + 'identifier' => 146, + 'enum_element' => 186 } }, - {#State 156 - DEFAULT => -39 + {#State 169 + DEFAULT => -47 }, - {#State 157 + {#State 170 ACTIONS => { 'IDENTIFIER' => 9 }, GOTOS => { - 'identifier' => 138, - 'bitmap_element' => 174 + 'identifier' => 151, + 'bitmap_element' => 187 } }, - {#State 158 + {#State 171 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 175, + 'anytext' => 188, 'text' => 24, 'constant' => 27 } }, - {#State 159 + {#State 172 ACTIONS => { - "[" => 139 + "[" => 152 }, - DEFAULT => -60, + DEFAULT => -77, GOTOS => { - 'array_len' => 176 + 'array_len' => 189 } }, - {#State 160 + {#State 173 ACTIONS => { "-" => 35, ":" => 34, @@ -1882,84 +1959,89 @@ sub new { "(" => 44, "*" => 46, "." => 47, - "]" => 177, + "]" => 190, ">" => 48 } }, - {#State 161 + {#State 174 DEFAULT => -25 }, - {#State 162 - DEFAULT => -47 + {#State 175 + DEFAULT => -61 }, - {#State 163 + {#State 176 ACTIONS => { - ";" => 178 + ";" => 191 } }, - {#State 164 - DEFAULT => -46 + {#State 177 + DEFAULT => -60 }, - {#State 165 + {#State 178 ACTIONS => { 'IDENTIFIER' => 9, + "signed" => 102, "union" => 52, - ";" => 179, + ";" => 192, "enum" => 65, "bitmap" => 66, 'void' => 97, + "unsigned" => 103, "[" => 7, "struct" => 63 }, + DEFAULT => -33, GOTOS => { + 'existingtype' => 101, + 'bitmap' => 67, + 'usertype' => 98, 'identifier' => 99, 'struct' => 59, 'enum' => 61, - 'type' => 166, + 'type' => 179, 'union' => 70, - 'bitmap' => 67, - 'usertype' => 98 + 'sign' => 100 } }, - {#State 166 - DEFAULT => -52, + {#State 179 + DEFAULT => -69, GOTOS => { - 'pointers' => 180 + 'pointers' => 193 } }, - {#State 167 - DEFAULT => -63, + {#State 180 + DEFAULT => -80, GOTOS => { - 'base_element' => 181, - 'property_list' => 145 + 'base_element' => 194, + 'property_list' => 158 } }, - {#State 168 + {#State 181 ACTIONS => { - ";" => 182 + ";" => 195 } }, - {#State 169 + {#State 182 ACTIONS => { 'CONSTANT' => 28, 'TEXT' => 22, 'IDENTIFIER' => 9 }, - DEFAULT => -73, + DEFAULT => -90, GOTOS => { 'identifier' => 23, - 'anytext' => 183, + 'anytext' => 196, 'text' => 24, 'constant' => 27 } }, - {#State 170 + {#State 183 ACTIONS => { "-" => 35, ":" => 34, "?" => 36, "<" => 37, - ";" => 184, + ";" => 197, "+" => 39, "~" => 38, "&" => 41, @@ -1973,10 +2055,10 @@ sub new { ">" => 48 } }, - {#State 171 - DEFAULT => -55 + {#State 184 + DEFAULT => -72 }, - {#State 172 + {#State 185 ACTIONS => { "-" => 35, ":" => 34, @@ -1994,15 +2076,15 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -38 + DEFAULT => -46 }, - {#State 173 - DEFAULT => -36 + {#State 186 + DEFAULT => -44 }, - {#State 174 - DEFAULT => -41 + {#State 187 + DEFAULT => -52 }, - {#State 175 + {#State 188 ACTIONS => { "-" => 35, ":" => 34, @@ -2020,48 +2102,48 @@ sub new { "." => 47, ">" => 48 }, - DEFAULT => -42 + DEFAULT => -53 }, - {#State 176 - DEFAULT => -61 + {#State 189 + DEFAULT => -78 }, - {#State 177 + {#State 190 ACTIONS => { - "[" => 139 + "[" => 152 }, - DEFAULT => -60, + DEFAULT => -77, GOTOS => { - 'array_len' => 185 + 'array_len' => 198 } }, - {#State 178 - DEFAULT => -45 + {#State 191 + DEFAULT => -59 }, - {#State 179 - DEFAULT => -44 + {#State 192 + DEFAULT => -58 }, - {#State 180 + {#State 193 ACTIONS => { 'IDENTIFIER' => 9, - "*" => 131 + "*" => 144 }, GOTOS => { - 'identifier' => 186 + 'identifier' => 199 } }, - {#State 181 - DEFAULT => -59 + {#State 194 + DEFAULT => -76 }, - {#State 182 + {#State 195 DEFAULT => -19 }, - {#State 183 + {#State 196 ACTIONS => { "-" => 35, ":" => 34, "?" => 36, "<" => 37, - ";" => 187, + ";" => 200, "+" => 39, "~" => 38, "&" => 41, @@ -2075,26 +2157,26 @@ sub new { ">" => 48 } }, - {#State 184 + {#State 197 DEFAULT => -17 }, - {#State 185 - DEFAULT => -62 + {#State 198 + DEFAULT => -79 }, - {#State 186 + {#State 199 ACTIONS => { - "[" => 139 + "[" => 152 }, - DEFAULT => -60, + DEFAULT => -77, GOTOS => { - 'array_len' => 188 + 'array_len' => 201 } }, - {#State 187 + {#State 200 DEFAULT => -18 }, - {#State 188 - DEFAULT => -51 + {#State 201 + DEFAULT => -68 } ], yyrules => @@ -2300,90 +2382,144 @@ sub { $_[1] } ], [#Rule 31 - 'type', 1, undef + 'sign', 1, undef ], [#Rule 32 - 'type', 1, undef + 'sign', 1, undef ], [#Rule 33 + 'existingtype', 0, undef + ], + [#Rule 34 + 'existingtype', 2, +sub +#line 146 "idl.yp" +{ "$_[1] $_[2]" } + ], + [#Rule 35 + 'existingtype', 1, undef + ], + [#Rule 36 + 'type', 1, undef + ], + [#Rule 37 + 'type', 1, undef + ], + [#Rule 38 'type', 1, sub -#line 144 "idl.yp" +#line 150 "idl.yp" { "void" } ], - [#Rule 34 - 'enum', 5, + [#Rule 39 + 'enum_body', 3, +sub +#line 152 "idl.yp" +{ $_[2] } + ], + [#Rule 40 + 'opt_enum_body', 0, undef + ], + [#Rule 41 + 'opt_enum_body', 1, undef + ], + [#Rule 42 + 'enum', 3, sub -#line 148 "idl.yp" +#line 155 "idl.yp" {{ "TYPE" => "ENUM", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ], - [#Rule 35 + [#Rule 43 'enum_elements', 1, sub -#line 156 "idl.yp" +#line 163 "idl.yp" { [ $_[1] ] } ], - [#Rule 36 + [#Rule 44 'enum_elements', 3, sub -#line 157 "idl.yp" +#line 164 "idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 37 + [#Rule 45 'enum_element', 1, undef ], - [#Rule 38 + [#Rule 46 'enum_element', 3, sub -#line 161 "idl.yp" +#line 168 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 39 - 'bitmap', 5, + [#Rule 47 + 'bitmap_body', 3, +sub +#line 171 "idl.yp" +{ $_[2] } + ], + [#Rule 48 + 'opt_bitmap_body', 0, undef + ], + [#Rule 49 + 'opt_bitmap_body', 1, undef + ], + [#Rule 50 + 'bitmap', 3, sub -#line 165 "idl.yp" +#line 174 "idl.yp" {{ "TYPE" => "BITMAP", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ], - [#Rule 40 + [#Rule 51 'bitmap_elements', 1, sub -#line 173 "idl.yp" +#line 182 "idl.yp" { [ $_[1] ] } ], - [#Rule 41 + [#Rule 52 'bitmap_elements', 3, sub -#line 174 "idl.yp" +#line 183 "idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 42 + [#Rule 53 'bitmap_element', 3, sub -#line 177 "idl.yp" +#line 186 "idl.yp" { "$_[1] ( $_[3] )" } ], - [#Rule 43 - 'struct', 5, + [#Rule 54 + 'struct_body', 3, sub -#line 181 "idl.yp" +#line 189 "idl.yp" +{ $_[2] } + ], + [#Rule 55 + 'opt_struct_body', 0, undef + ], + [#Rule 56 + 'opt_struct_body', 1, undef + ], + [#Rule 57 + 'struct', 3, +sub +#line 193 "idl.yp" {{ "TYPE" => "STRUCT", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ], - [#Rule 44 + [#Rule 58 'empty_element', 2, sub -#line 189 "idl.yp" +#line 201 "idl.yp" {{ "NAME" => "", "TYPE" => "EMPTY", @@ -2394,41 +2530,53 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 45 + [#Rule 59 'base_or_empty', 2, undef ], - [#Rule 46 + [#Rule 60 'base_or_empty', 1, undef ], - [#Rule 47 + [#Rule 61 'optional_base_element', 2, sub -#line 203 "idl.yp" -{ $_[2]->{PROPERTIES} = Parse::Pidl::Util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } +#line 215 "idl.yp" +{ $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ], - [#Rule 48 + [#Rule 62 'union_elements', 0, undef ], - [#Rule 49 + [#Rule 63 'union_elements', 2, sub -#line 208 "idl.yp" +#line 220 "idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 50 - 'union', 5, + [#Rule 64 + 'union_body', 3, +sub +#line 223 "idl.yp" +{ $_[2] } + ], + [#Rule 65 + 'opt_union_body', 0, undef + ], + [#Rule 66 + 'opt_union_body', 1, undef + ], + [#Rule 67 + 'union', 3, sub -#line 212 "idl.yp" +#line 227 "idl.yp" {{ "TYPE" => "UNION", "NAME" => $_[2], - "ELEMENTS" => $_[4] + "ELEMENTS" => $_[3] }} ], - [#Rule 51 + [#Rule 68 'base_element', 5, sub -#line 220 "idl.yp" +#line 235 "idl.yp" {{ "NAME" => $_[4], "TYPE" => $_[2], @@ -2439,238 +2587,238 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 52 + [#Rule 69 'pointers', 0, sub -#line 234 "idl.yp" +#line 249 "idl.yp" { 0 } ], - [#Rule 53 + [#Rule 70 'pointers', 2, sub -#line 235 "idl.yp" +#line 250 "idl.yp" { $_[1]+1 } ], - [#Rule 54 + [#Rule 71 'element_list1', 0, undef ], - [#Rule 55 + [#Rule 72 'element_list1', 3, sub -#line 240 "idl.yp" +#line 255 "idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 56 + [#Rule 73 'element_list2', 0, undef ], - [#Rule 57 + [#Rule 74 'element_list2', 1, undef ], - [#Rule 58 + [#Rule 75 'element_list2', 1, sub -#line 246 "idl.yp" +#line 261 "idl.yp" { [ $_[1] ] } ], - [#Rule 59 + [#Rule 76 'element_list2', 3, sub -#line 247 "idl.yp" +#line 262 "idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 60 + [#Rule 77 'array_len', 0, undef ], - [#Rule 61 + [#Rule 78 'array_len', 3, sub -#line 252 "idl.yp" +#line 267 "idl.yp" { push(@{$_[3]}, "*"); $_[3] } ], - [#Rule 62 + [#Rule 79 'array_len', 4, sub -#line 253 "idl.yp" +#line 268 "idl.yp" { push(@{$_[4]}, "$_[2]"); $_[4] } ], - [#Rule 63 + [#Rule 80 'property_list', 0, undef ], - [#Rule 64 + [#Rule 81 'property_list', 4, sub -#line 259 "idl.yp" -{ Parse::Pidl::Util::FlattenHash([$_[1],$_[3]]); } +#line 274 "idl.yp" +{ FlattenHash([$_[1],$_[3]]); } ], - [#Rule 65 + [#Rule 82 'properties', 1, sub -#line 262 "idl.yp" +#line 277 "idl.yp" { $_[1] } ], - [#Rule 66 + [#Rule 83 'properties', 3, sub -#line 263 "idl.yp" -{ Parse::Pidl::Util::FlattenHash([$_[1], $_[3]]); } +#line 278 "idl.yp" +{ FlattenHash([$_[1], $_[3]]); } ], - [#Rule 67 + [#Rule 84 'property', 1, sub -#line 266 "idl.yp" +#line 281 "idl.yp" {{ "$_[1]" => "1" }} ], - [#Rule 68 + [#Rule 85 'property', 4, sub -#line 267 "idl.yp" +#line 282 "idl.yp" {{ "$_[1]" => "$_[3]" }} ], - [#Rule 69 + [#Rule 86 'listtext', 1, undef ], - [#Rule 70 + [#Rule 87 'listtext', 3, sub -#line 272 "idl.yp" +#line 287 "idl.yp" { "$_[1] $_[3]" } ], - [#Rule 71 + [#Rule 88 'commalisttext', 1, undef ], - [#Rule 72 + [#Rule 89 'commalisttext', 3, sub -#line 277 "idl.yp" +#line 292 "idl.yp" { "$_[1],$_[3]" } ], - [#Rule 73 + [#Rule 90 'anytext', 0, sub -#line 281 "idl.yp" +#line 296 "idl.yp" { "" } ], - [#Rule 74 + [#Rule 91 'anytext', 1, undef ], - [#Rule 75 + [#Rule 92 'anytext', 1, undef ], - [#Rule 76 + [#Rule 93 'anytext', 1, undef ], - [#Rule 77 + [#Rule 94 'anytext', 3, sub -#line 283 "idl.yp" +#line 298 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 78 + [#Rule 95 'anytext', 3, sub -#line 284 "idl.yp" +#line 299 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 79 + [#Rule 96 'anytext', 3, sub -#line 285 "idl.yp" +#line 300 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 80 + [#Rule 97 'anytext', 3, sub -#line 286 "idl.yp" +#line 301 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 81 + [#Rule 98 'anytext', 3, sub -#line 287 "idl.yp" +#line 302 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 82 + [#Rule 99 'anytext', 3, sub -#line 288 "idl.yp" +#line 303 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 83 + [#Rule 100 'anytext', 3, sub -#line 289 "idl.yp" +#line 304 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 84 + [#Rule 101 'anytext', 3, sub -#line 290 "idl.yp" +#line 305 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 85 + [#Rule 102 'anytext', 3, sub -#line 291 "idl.yp" +#line 306 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 86 + [#Rule 103 'anytext', 3, sub -#line 292 "idl.yp" +#line 307 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 87 + [#Rule 104 'anytext', 3, sub -#line 293 "idl.yp" +#line 308 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 88 + [#Rule 105 'anytext', 3, sub -#line 294 "idl.yp" +#line 309 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 89 + [#Rule 106 'anytext', 3, sub -#line 295 "idl.yp" +#line 310 "idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 90 + [#Rule 107 'anytext', 5, sub -#line 296 "idl.yp" +#line 311 "idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 91 + [#Rule 108 'anytext', 5, sub -#line 297 "idl.yp" +#line 312 "idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 92 + [#Rule 109 'identifier', 1, undef ], - [#Rule 93 + [#Rule 110 'optional_identifier', 1, undef ], - [#Rule 94 + [#Rule 111 'optional_identifier', 0, undef ], - [#Rule 95 + [#Rule 112 'constant', 1, undef ], - [#Rule 96 + [#Rule 113 'text', 1, sub -#line 311 "idl.yp" +#line 326 "idl.yp" { "\"$_[1]\"" } ], - [#Rule 97 + [#Rule 114 'optional_semicolon', 0, undef ], - [#Rule 98 + [#Rule 115 'optional_semicolon', 1, undef ] ], @@ -2678,10 +2826,24 @@ sub bless($self,$class); } -#line 322 "idl.yp" +#line 337 "idl.yp" + + +##################################################################### +# flatten an array of hashes into a single hash +sub FlattenHash($) +{ + my $a = shift; + my %b; + for my $d (@{$a}) { + for my $k (keys %{$d}) { + $b{$k} = $d->{$k}; + } + } + return \%b; +} -use Parse::Pidl::Util; ##################################################################### # traverse a perl data structure removing any empty arrays or @@ -2765,7 +2927,7 @@ again: $parser->YYData->{LAST_TOKEN} = $1; if ($1 =~ /^(coclass|interface|const|typedef|declare|union - |struct|enum|bitmap|void)$/x) { + |struct|enum|bitmap|void|unsigned|signed)$/x) { return $1; } return('IDENTIFIER',$1); diff --git a/source4/pidl/lib/Parse/Pidl/Util.pm b/source4/pidl/lib/Parse/Pidl/Util.pm index fec1301a59..ec6a1420ab 100644 --- a/source4/pidl/lib/Parse/Pidl/Util.pm +++ b/source4/pidl/lib/Parse/Pidl/Util.pm @@ -12,48 +12,6 @@ $VERSION = '0.01'; use strict; -##################################################################### -# flatten an array of arrays into a single array -sub FlattenArray2($) -{ - my $a = shift; - my @b; - for my $d (@{$a}) { - for my $d1 (@{$d}) { - push(@b, $d1); - } - } - return \@b; -} - -##################################################################### -# flatten an array of arrays into a single array -sub FlattenArray($) -{ - my $a = shift; - my @b; - for my $d (@{$a}) { - for my $d1 (@{$d}) { - push(@b, $d1); - } - } - return \@b; -} - -##################################################################### -# flatten an array of hashes into a single hash -sub FlattenHash($) -{ - my $a = shift; - my %b; - for my $d (@{$a}) { - for my $k (keys %{$d}) { - $b{$k} = $d->{$k}; - } - } - return \%b; -} - ##################################################################### # a dumper wrapper to prevent dependence on the Data::Dumper module # unless we actually need it -- cgit