summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/dump.pm8
-rw-r--r--source4/build/pidl/header.pm10
-rw-r--r--source4/build/pidl/idl.pm461
-rw-r--r--source4/build/pidl/idl.yp52
-rw-r--r--source4/build/pidl/ndr.pm98
-rw-r--r--source4/build/pidl/needed.pm22
-rw-r--r--source4/build/pidl/util.pm2
-rw-r--r--source4/build/pidl/validator.pm14
8 files changed, 276 insertions, 391 deletions
diff --git a/source4/build/pidl/dump.pm b/source4/build/pidl/dump.pm
index 640bc3a120..00a57b10b4 100644
--- a/source4/build/pidl/dump.pm
+++ b/source4/build/pidl/dump.pm
@@ -98,11 +98,11 @@ sub DumpUnionElement($)
my($element) = shift;
my($res);
- if ($element->{CASE} eq "default") {
+ if (util::has_property($element, "default")) {
$res .= "[default] ;\n";
} else {
- $res .= "[case($element->{CASE})] ";
- $res .= DumpElement($element->{DATA}), if defined($element->{DATA});
+ $res .= "[case($element->{PROPERTIES}->{case})] ";
+ $res .= DumpElement($element), if defined($element);
$res .= ";\n";
}
@@ -119,7 +119,7 @@ sub DumpUnion($)
(defined $union->{PROPERTIES}) &&
($res .= DumpProperties($union->{PROPERTIES}));
$res .= "union {\n";
- foreach my $e (@{$union->{DATA}}) {
+ foreach my $e (@{$union->{ELEMENTS}}) {
$res .= DumpUnionElement($e);
}
$res .= "}";
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index c6b5fef3d3..fa3e669242 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -153,12 +153,12 @@ sub HeaderUnion($$)
(defined $union->{PROPERTIES}) && HeaderProperties($union->{PROPERTIES});
$res .= "\nunion $name {\n";
$tab_depth++;
- foreach my $e (@{$union->{DATA}}) {
- if ($e->{TYPE} eq "UNION_ELEMENT") {
- if (! defined $done{$e->{DATA}->{NAME}}) {
- HeaderElement($e->{DATA});
+ foreach my $e (@{$union->{ELEMENTS}}) {
+ if ($e->{TYPE} ne "EMPTY") {
+ if (! defined $done{$e->{NAME}}) {
+ HeaderElement($e);
}
- $done{$e->{DATA}->{NAME}} = 1;
+ $done{$e->{NAME}} = 1;
}
}
$tab_depth--;
diff --git a/source4/build/pidl/idl.pm b/source4/build/pidl/idl.pm
index cbfe8e10e3..99db357062 100644
--- a/source4/build/pidl/idl.pm
+++ b/source4/build/pidl/idl.pm
@@ -1241,12 +1241,9 @@ sub new {
DEFAULT => -7
},
{#State 94
- ACTIONS => {
- "[" => 111
- },
+ DEFAULT => -45,
GOTOS => {
- 'union_elements' => 109,
- 'union_element' => 110
+ 'union_elements' => 109
}
},
{#State 95
@@ -1254,9 +1251,9 @@ sub new {
'IDENTIFIER' => 9
},
GOTOS => {
- 'identifier' => 112,
- 'enum_element' => 113,
- 'enum_elements' => 114
+ 'identifier' => 110,
+ 'enum_element' => 111,
+ 'enum_elements' => 112
}
},
{#State 96
@@ -1264,20 +1261,20 @@ sub new {
'IDENTIFIER' => 9
},
GOTOS => {
- 'identifier' => 117,
- 'bitmap_elements' => 116,
- 'bitmap_element' => 115
+ 'identifier' => 115,
+ 'bitmap_elements' => 114,
+ 'bitmap_element' => 113
}
},
{#State 97
ACTIONS => {
- "(" => 118
+ "(" => 116
}
},
{#State 98
DEFAULT => -51,
GOTOS => {
- 'element_list1' => 119
+ 'element_list1' => 117
}
},
{#State 99
@@ -1297,16 +1294,16 @@ sub new {
'IDENTIFIER' => 9
},
GOTOS => {
- 'identifier' => 120
+ 'identifier' => 118
}
},
{#State 104
ACTIONS => {
- "[" => 123,
- "=" => 122
+ "[" => 121,
+ "=" => 120
},
GOTOS => {
- 'array_len' => 121
+ 'array_len' => 119
}
},
{#State 105
@@ -1350,94 +1347,86 @@ sub new {
},
{#State 108
ACTIONS => {
- "[" => 123
+ "[" => 121
},
DEFAULT => -57,
GOTOS => {
- 'array_len' => 124
+ 'array_len' => 122
}
},
{#State 109
ACTIONS => {
- "}" => 125,
- "[" => 111
+ "}" => 123
},
+ DEFAULT => -60,
GOTOS => {
- 'union_element' => 126
+ 'optional_base_element' => 125,
+ 'property_list' => 124
}
},
{#State 110
- DEFAULT => -42
- },
- {#State 111
ACTIONS => {
- "case" => 127,
- "default" => 128
- }
- },
- {#State 112
- ACTIONS => {
- "=" => 129
+ "=" => 126
},
DEFAULT => -34
},
- {#State 113
+ {#State 111
DEFAULT => -32
},
- {#State 114
+ {#State 112
ACTIONS => {
- "}" => 130,
- "," => 131
+ "}" => 127,
+ "," => 128
}
},
- {#State 115
+ {#State 113
DEFAULT => -37
},
- {#State 116
+ {#State 114
ACTIONS => {
- "}" => 132,
- "," => 133
+ "}" => 129,
+ "," => 130
}
},
- {#State 117
+ {#State 115
ACTIONS => {
- "=" => 134
+ "=" => 131
}
},
- {#State 118
+ {#State 116
ACTIONS => {
"," => -53,
- "void" => 137,
+ "void" => 134,
")" => -53
},
DEFAULT => -60,
GOTOS => {
- 'base_element' => 135,
- 'element_list2' => 138,
- 'property_list' => 136
+ 'base_element' => 132,
+ 'element_list2' => 135,
+ 'property_list' => 133
}
},
- {#State 119
+ {#State 117
ACTIONS => {
- "}" => 139
+ "}" => 136
},
DEFAULT => -60,
GOTOS => {
- 'base_element' => 140,
- 'property_list' => 136
+ 'base_element' => 137,
+ 'property_list' => 133
}
},
- {#State 120
+ {#State 118
ACTIONS => {
- ";" => 141
+ ";" => 138
}
},
- {#State 121
+ {#State 119
ACTIONS => {
- "=" => 142
+ "=" => 139
}
},
- {#State 122
+ {#State 120
ACTIONS => {
'IDENTIFIER' => 9,
'CONSTANT' => 28,
@@ -1447,47 +1436,49 @@ sub new {
GOTOS => {
'identifier' => 23,
'text' => 24,
- 'anytext' => 143,
+ 'anytext' => 140,
'constant' => 27
}
},
- {#State 123
+ {#State 121
ACTIONS => {
'IDENTIFIER' => 9,
'CONSTANT' => 28,
'TEXT' => 22,
- "]" => 145
+ "]" => 142
},
DEFAULT => -70,
GOTOS => {
'identifier' => 23,
'text' => 24,
- 'anytext' => 144,
+ 'anytext' => 141,
'constant' => 27
}
},
- {#State 124
+ {#State 122
ACTIONS => {
- ";" => 146
+ ";" => 143
}
},
- {#State 125
- DEFAULT => -41
- },
- {#State 126
- DEFAULT => -43
+ {#State 123
+ DEFAULT => -47
},
- {#State 127
+ {#State 124
ACTIONS => {
- "(" => 147
+ "[" => 7
+ },
+ DEFAULT => -60,
+ GOTOS => {
+ 'base_or_empty' => 144,
+ 'base_element' => 145,
+ 'empty_element' => 146,
+ 'property_list' => 147
}
},
- {#State 128
- ACTIONS => {
- "]" => 148
- }
+ {#State 125
+ DEFAULT => -46
},
- {#State 129
+ {#State 126
ACTIONS => {
'CONSTANT' => 28,
'TEXT' => 22,
@@ -1497,35 +1488,35 @@ sub new {
GOTOS => {
'identifier' => 23,
'text' => 24,
- 'anytext' => 149,
+ 'anytext' => 148,
'constant' => 27
}
},
- {#State 130
+ {#State 127
DEFAULT => -31
},
- {#State 131
+ {#State 128
ACTIONS => {
'IDENTIFIER' => 9
},
GOTOS => {
- 'identifier' => 112,
- 'enum_element' => 150
+ 'identifier' => 110,
+ 'enum_element' => 149
}
},
- {#State 132
+ {#State 129
DEFAULT => -36
},
- {#State 133
+ {#State 130
ACTIONS => {
'IDENTIFIER' => 9
},
GOTOS => {
- 'identifier' => 117,
- 'bitmap_element' => 151
+ 'identifier' => 115,
+ 'bitmap_element' => 150
}
},
- {#State 134
+ {#State 131
ACTIONS => {
'CONSTANT' => 28,
'TEXT' => 22,
@@ -1535,14 +1526,14 @@ sub new {
GOTOS => {
'identifier' => 23,
'text' => 24,
- 'anytext' => 152,
+ 'anytext' => 151,
'constant' => 27
}
},
- {#State 135
+ {#State 132
DEFAULT => -55
},
- {#State 136
+ {#State 133
ACTIONS => {
'IDENTIFIER' => 9,
"union" => 76,
@@ -1556,32 +1547,32 @@ sub new {
'identifier' => 81,
'struct' => 82,
'enum' => 83,
- 'type' => 153,
+ 'type' => 152,
'union' => 85,
'bitmap' => 80
}
},
- {#State 137
+ {#State 134
DEFAULT => -54
},
- {#State 138
+ {#State 135
ACTIONS => {
- "," => 154,
- ")" => 155
+ "," => 153,
+ ")" => 154
}
},
- {#State 139
+ {#State 136
DEFAULT => -40
},
- {#State 140
+ {#State 137
ACTIONS => {
- ";" => 156
+ ";" => 155
}
},
- {#State 141
+ {#State 138
DEFAULT => -19
},
- {#State 142
+ {#State 139
ACTIONS => {
'IDENTIFIER' => 9,
'CONSTANT' => 28,
@@ -1591,15 +1582,15 @@ sub new {
GOTOS => {
'identifier' => 23,
'text' => 24,
- 'anytext' => 157,
+ 'anytext' => 156,
'constant' => 27
}
},
- {#State 143
+ {#State 140
ACTIONS => {
"-" => 35,
"<" => 36,
- ";" => 158,
+ ";" => 157,
"+" => 37,
"&" => 39,
"{" => 38,
@@ -1611,7 +1602,7 @@ sub new {
">" => 45
}
},
- {#State 144
+ {#State 141
ACTIONS => {
"-" => 35,
"<" => 36,
@@ -1622,42 +1613,49 @@ sub new {
"(" => 42,
"|" => 41,
"*" => 43,
- "]" => 159,
+ "]" => 158,
"." => 44,
">" => 45
}
},
- {#State 145
+ {#State 142
DEFAULT => -58
},
- {#State 146
+ {#State 143
DEFAULT => -24
},
- {#State 147
+ {#State 144
+ DEFAULT => -44
+ },
+ {#State 145
ACTIONS => {
- 'IDENTIFIER' => 9,
- 'CONSTANT' => 28,
- 'TEXT' => 22
- },
- DEFAULT => -70,
- GOTOS => {
- 'identifier' => 23,
- 'text' => 24,
- 'anytext' => 160,
- 'constant' => 27
+ ";" => 159
}
},
- {#State 148
+ {#State 146
+ DEFAULT => -43
+ },
+ {#State 147
ACTIONS => {
- ";" => 161
+ 'IDENTIFIER' => 9,
+ "union" => 76,
+ ";" => 160,
+ "enum" => 77,
+ "[" => 7,
+ 'void' => 79,
+ "bitmap" => 78,
+ "struct" => 86
},
- DEFAULT => -60,
GOTOS => {
- 'base_element' => 162,
- 'property_list' => 136
+ 'identifier' => 81,
+ 'struct' => 82,
+ 'enum' => 83,
+ 'type' => 152,
+ 'union' => 85,
+ 'bitmap' => 80
}
},
- {#State 149
+ {#State 148
ACTIONS => {
"-" => 35,
"<" => 36,
@@ -1673,13 +1671,13 @@ sub new {
},
DEFAULT => -35
},
- {#State 150
+ {#State 149
DEFAULT => -33
},
- {#State 151
+ {#State 150
DEFAULT => -38
},
- {#State 152
+ {#State 151
ACTIONS => {
"-" => 35,
"<" => 36,
@@ -1695,32 +1693,32 @@ sub new {
},
DEFAULT => -39
},
- {#State 153
+ {#State 152
DEFAULT => -49,
GOTOS => {
- 'pointers' => 163
+ 'pointers' => 161
}
},
- {#State 154
+ {#State 153
DEFAULT => -60,
GOTOS => {
- 'base_element' => 164,
- 'property_list' => 136
+ 'base_element' => 162,
+ 'property_list' => 133
}
},
- {#State 155
+ {#State 154
ACTIONS => {
- ";" => 165
+ ";" => 163
}
},
- {#State 156
+ {#State 155
DEFAULT => -52
},
- {#State 157
+ {#State 156
ACTIONS => {
"-" => 35,
"<" => 36,
- ";" => 166,
+ ";" => 164,
"+" => 37,
"&" => 39,
"{" => 38,
@@ -1732,97 +1730,50 @@ sub new {
">" => 45
}
},
- {#State 158
+ {#State 157
DEFAULT => -16
},
- {#State 159
+ {#State 158
DEFAULT => -59
},
+ {#State 159
+ DEFAULT => -42
+ },
{#State 160
- ACTIONS => {
- "-" => 35,
- "<" => 36,
- "+" => 37,
- "&" => 39,
- "{" => 38,
- "/" => 40,
- "(" => 42,
- "|" => 41,
- "*" => 43,
- ")" => 167,
- "." => 44,
- ">" => 45
- }
+ DEFAULT => -41
},
{#State 161
- DEFAULT => -47
- },
- {#State 162
- ACTIONS => {
- ";" => 168
- }
- },
- {#State 163
ACTIONS => {
'IDENTIFIER' => 9,
- "*" => 170
+ "*" => 166
},
GOTOS => {
- 'identifier' => 169
+ 'identifier' => 165
}
},
- {#State 164
+ {#State 162
DEFAULT => -56
},
- {#State 165
+ {#State 163
DEFAULT => -18
},
- {#State 166
+ {#State 164
DEFAULT => -17
},
- {#State 167
- ACTIONS => {
- "]" => 171
- }
- },
- {#State 168
- DEFAULT => -46
- },
- {#State 169
+ {#State 165
ACTIONS => {
- "[" => 123
+ "[" => 121
},
DEFAULT => -57,
GOTOS => {
- 'array_len' => 172
+ 'array_len' => 167
}
},
- {#State 170
+ {#State 166
DEFAULT => -50
},
- {#State 171
- ACTIONS => {
- ";" => 173
- },
- DEFAULT => -60,
- GOTOS => {
- 'base_element' => 174,
- 'property_list' => 136
- }
- },
- {#State 172
+ {#State 167
DEFAULT => -48
- },
- {#State 173
- DEFAULT => -45
- },
- {#State 174
- ACTIONS => {
- ";" => 175
- }
- },
- {#State 175
- DEFAULT => -44
}
],
yyrules =>
@@ -2078,68 +2029,50 @@ sub
}}
],
[#Rule 41
- 'union', 4,
+ 'empty_element', 2,
sub
#line 167 "build/pidl/idl.yp"
{{
- "TYPE" => "UNION",
- "DATA" => $_[3]
+ "NAME" => "",
+ "TYPE" => "EMPTY",
+ "PROPERTIES" => $_[0],
+ "POINTERS" => 0
}}
],
[#Rule 42
- 'union_elements', 1,
-sub
-#line 174 "build/pidl/idl.yp"
-{ [ $_[1] ] }
+ 'base_or_empty', 2, undef
],
[#Rule 43
- 'union_elements', 2,
-sub
-#line 175 "build/pidl/idl.yp"
-{ push(@{$_[1]}, $_[2]); $_[1] }
+ 'base_or_empty', 1, undef
],
[#Rule 44
- 'union_element', 8,
+ 'optional_base_element', 2,
sub
-#line 180 "build/pidl/idl.yp"
-{{
- "TYPE" => "UNION_ELEMENT",
- "CASE" => $_[4],
- "DATA" => $_[7]
- }}
+#line 178 "build/pidl/idl.yp"
+{ $_[2]->{PROPERTIES} = util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
],
[#Rule 45
- 'union_element', 7,
-sub
-#line 186 "build/pidl/idl.yp"
-{{
- "TYPE" => "EMPTY",
- "CASE" => $_[4],
- }}
+ 'union_elements', 0, undef
],
[#Rule 46
- 'union_element', 5,
+ 'union_elements', 2,
sub
-#line 191 "build/pidl/idl.yp"
-{{
- "TYPE" => "UNION_ELEMENT",
- "CASE" => "default",
- "DATA" => $_[4]
- }}
+#line 183 "build/pidl/idl.yp"
+{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 47
- 'union_element', 4,
+ 'union', 4,
sub
-#line 197 "build/pidl/idl.yp"
+#line 187 "build/pidl/idl.yp"
{{
- "TYPE" => "EMPTY",
- "CASE" => "default",
- }}
+ "TYPE" => "UNION",
+ "ELEMENTS" => $_[3]
+ }}
],
[#Rule 48
'base_element', 5,
sub
-#line 204 "build/pidl/idl.yp"
+#line 194 "build/pidl/idl.yp"
{{
"NAME" => $_[4],
"TYPE" => $_[2],
@@ -2151,13 +2084,13 @@ sub
[#Rule 49
'pointers', 0,
sub
-#line 216 "build/pidl/idl.yp"
+#line 206 "build/pidl/idl.yp"
{ 0 }
],
[#Rule 50
'pointers', 2,
sub
-#line 217 "build/pidl/idl.yp"
+#line 207 "build/pidl/idl.yp"
{ $_[1]+1 }
],
[#Rule 51
@@ -2166,7 +2099,7 @@ sub
[#Rule 52
'element_list1', 3,
sub
-#line 224 "build/pidl/idl.yp"
+#line 212 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 53
@@ -2178,13 +2111,13 @@ sub
[#Rule 55
'element_list2', 1,
sub
-#line 230 "build/pidl/idl.yp"
+#line 218 "build/pidl/idl.yp"
{ [ $_[1] ] }
],
[#Rule 56
'element_list2', 3,
sub
-#line 231 "build/pidl/idl.yp"
+#line 219 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[3]); $_[1] }
],
[#Rule 57
@@ -2193,13 +2126,13 @@ sub
[#Rule 58
'array_len', 2,
sub
-#line 236 "build/pidl/idl.yp"
+#line 224 "build/pidl/idl.yp"
{ "*" }
],
[#Rule 59
'array_len', 3,
sub
-#line 237 "build/pidl/idl.yp"
+#line 225 "build/pidl/idl.yp"
{ "$_[2]" }
],
[#Rule 60
@@ -2208,31 +2141,31 @@ sub
[#Rule 61
'property_list', 4,
sub
-#line 243 "build/pidl/idl.yp"
+#line 231 "build/pidl/idl.yp"
{ util::FlattenHash([$_[1],$_[3]]); }
],
[#Rule 62
'properties', 1,
sub
-#line 246 "build/pidl/idl.yp"
+#line 234 "build/pidl/idl.yp"
{ $_[1] }
],
[#Rule 63
'properties', 3,
sub
-#line 247 "build/pidl/idl.yp"
+#line 235 "build/pidl/idl.yp"
{ util::FlattenHash([$_[1], $_[3]]); }
],
[#Rule 64
'property', 1,
sub
-#line 250 "build/pidl/idl.yp"
+#line 238 "build/pidl/idl.yp"
{{ "$_[1]" => "1" }}
],
[#Rule 65
'property', 4,
sub
-#line 251 "build/pidl/idl.yp"
+#line 239 "build/pidl/idl.yp"
{{ "$_[1]" => "$_[3]" }}
],
[#Rule 66
@@ -2241,7 +2174,7 @@ sub
[#Rule 67
'listtext', 3,
sub
-#line 256 "build/pidl/idl.yp"
+#line 244 "build/pidl/idl.yp"
{ "$_[1] $_[3]" }
],
[#Rule 68
@@ -2250,13 +2183,13 @@ sub
[#Rule 69
'commalisttext', 3,
sub
-#line 261 "build/pidl/idl.yp"
+#line 249 "build/pidl/idl.yp"
{ "$_[1],$_[3]" }
],
[#Rule 70
'anytext', 0,
sub
-#line 265 "build/pidl/idl.yp"
+#line 253 "build/pidl/idl.yp"
{ "" }
],
[#Rule 71
@@ -2271,67 +2204,67 @@ sub
[#Rule 74
'anytext', 3,
sub
-#line 267 "build/pidl/idl.yp"
+#line 255 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 75
'anytext', 3,
sub
-#line 268 "build/pidl/idl.yp"
+#line 256 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 76
'anytext', 3,
sub
-#line 269 "build/pidl/idl.yp"
+#line 257 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 77
'anytext', 3,
sub
-#line 270 "build/pidl/idl.yp"
+#line 258 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 78
'anytext', 3,
sub
-#line 271 "build/pidl/idl.yp"
+#line 259 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 79
'anytext', 3,
sub
-#line 272 "build/pidl/idl.yp"
+#line 260 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 80
'anytext', 3,
sub
-#line 273 "build/pidl/idl.yp"
+#line 261 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 81
'anytext', 3,
sub
-#line 274 "build/pidl/idl.yp"
+#line 262 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 82
'anytext', 3,
sub
-#line 275 "build/pidl/idl.yp"
+#line 263 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 83
'anytext', 5,
sub
-#line 276 "build/pidl/idl.yp"
+#line 264 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
],
[#Rule 84
'anytext', 5,
sub
-#line 277 "build/pidl/idl.yp"
+#line 265 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
],
[#Rule 85
@@ -2343,7 +2276,7 @@ sub
[#Rule 87
'text', 1,
sub
-#line 286 "build/pidl/idl.yp"
+#line 274 "build/pidl/idl.yp"
{ "\"$_[1]\"" }
],
[#Rule 88
@@ -2357,7 +2290,7 @@ sub
bless($self,$class);
}
-#line 297 "build/pidl/idl.yp"
+#line 285 "build/pidl/idl.yp"
use util;
@@ -2417,7 +2350,7 @@ again:
$parser->YYData->{LAST_TOKEN} = $1;
if ($1 =~
/^(coclass|interface|const|typedef|declare|union
- |struct|enum|bitmap|void|case|default)$/x) {
+ |struct|enum|bitmap|void)$/x) {
return $1;
}
return('IDENTIFIER',$1);
diff --git a/source4/build/pidl/idl.yp b/source4/build/pidl/idl.yp
index 4e4071d317..ae13c29543 100644
--- a/source4/build/pidl/idl.yp
+++ b/source4/build/pidl/idl.yp
@@ -163,41 +163,31 @@ struct: 'struct' '{' element_list1 '}'
}}
;
-union: 'union' '{' union_elements '}'
- {{
- "TYPE" => "UNION",
- "DATA" => $_[3]
+empty_element: property_list ';'
+ {{
+ "NAME" => "",
+ "TYPE" => "EMPTY",
+ "PROPERTIES" => $_[0],
+ "POINTERS" => 0
}}
;
+base_or_empty: base_element ';' | empty_element;
+
+optional_base_element:
+ property_list base_or_empty { $_[2]->{PROPERTIES} = util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
+;
+
union_elements:
- union_element { [ $_[1] ] }
- | union_elements union_element { push(@{$_[1]}, $_[2]); $_[1] }
+ #empty
+ | union_elements optional_base_element { push(@{$_[1]}, $_[2]); $_[1] }
;
-union_element:
- '[' 'case' '(' anytext ')' ']' base_element ';'
- {{
- "TYPE" => "UNION_ELEMENT",
- "CASE" => $_[4],
- "DATA" => $_[7]
- }}
- | '[' 'case' '(' anytext ')' ']' ';'
- {{
- "TYPE" => "EMPTY",
- "CASE" => $_[4],
- }}
- | '[' 'default' ']' base_element ';'
- {{
- "TYPE" => "UNION_ELEMENT",
- "CASE" => "default",
- "DATA" => $_[4]
- }}
- | '[' 'default' ']' ';'
- {{
- "TYPE" => "EMPTY",
- "CASE" => "default",
- }}
+union: 'union' '{' union_elements '}'
+ {{
+ "TYPE" => "UNION",
+ "ELEMENTS" => $_[3]
+ }}
;
base_element: property_list type pointers identifier array_len
@@ -217,8 +207,6 @@ pointers:
| pointers '*' { $_[1]+1 }
;
-
-
element_list1:
#empty
| element_list1 base_element ';' { push(@{$_[1]}, $_[2]); $_[1] }
@@ -353,7 +341,7 @@ again:
$parser->YYData->{LAST_TOKEN} = $1;
if ($1 =~
/^(coclass|interface|const|typedef|declare|union
- |struct|enum|bitmap|void|case|default)$/x) {
+ |struct|enum|bitmap|void)$/x) {
return $1;
}
return('IDENTIFIER',$1);
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index d05b250d85..02fb46d51b 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -305,7 +305,7 @@ sub end_flags($)
#####################################################################
-# work out the correct alignment for a structure
+# work out the correct alignment for a structure or union
sub struct_alignment
{
my $s = shift;
@@ -329,35 +329,6 @@ sub struct_alignment
}
#####################################################################
-# work out the correct alignment for a union
-sub union_alignment
-{
- my $u = shift;
-
- my $align = 1;
-
- foreach my $e (@{$u->{DATA}}) {
- my $a = 1;
-
- if ($e->{TYPE} eq "EMPTY") {
- next;
- }
-
- if (need_wire_pointer($e->{DATA})) {
- $a = 4;
- } else {
- $a = align_type($e->{DATA}->{TYPE});
- }
-
- if ($align < $a) {
- $align = $a;
- }
- }
-
- return $align;
-}
-
-#####################################################################
# align a type
sub align_type
{
@@ -369,12 +340,8 @@ sub align_type
}
if (defined $typedefs{$e}) {
- if ($typedefs{$e}->{DATA}->{TYPE} eq "STRUCT") {
+ if ($typedefs{$e}->{DATA}->{TYPE} eq "STRUCT" or $typedefs{$e}->{DATA}->{TYPE} eq "UNION") {
return struct_alignment($typedefs{$e}->{DATA});
- } elsif ($typedefs{$e}->{DATA}->{TYPE} eq "UNION") {
- if (defined $typedefs{$e}->{DATA}) {
- return union_alignment($typedefs{$e}->{DATA});
- }
} elsif ($typedefs{$e}->{DATA}->{TYPE} eq "ENUM") {
return align_type(util::enum_type_fn(util::get_enum($e)));
} elsif ($typedefs{$e}->{DATA}->{TYPE} eq "BITMAP") {
@@ -1192,15 +1159,15 @@ sub ParseUnionPush($)
# pidl "\tNDR_CHECK(ndr_push_align(ndr, $align));\n";
pidl "\tswitch (level) {\n";
- foreach my $el (@{$e->{DATA}}) {
- if ($el->{CASE} eq "default") {
+ foreach my $el (@{$e->{ELEMENTS}}) {
+ if (util::has_property($el, "default")) {
pidl "\tdefault:\n";
$have_default = 1;
} else {
- pidl "\tcase $el->{CASE}:\n";
+ pidl "\tcase $el->{PROPERTIES}->{case}:\n";
}
- if ($el->{TYPE} eq "UNION_ELEMENT") {
- ParseElementPushScalar($el->{DATA}, "r->", "NDR_SCALARS");
+ if ($el->{TYPE} ne "EMPTY") {
+ ParseElementPushScalar($el, "r->", "NDR_SCALARS");
}
pidl "\tbreak;\n\n";
}
@@ -1212,14 +1179,14 @@ sub ParseUnionPush($)
pidl "buffers:\n";
pidl "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n";
pidl "\tswitch (level) {\n";
- foreach my $el (@{$e->{DATA}}) {
- if ($el->{CASE} eq "default") {
+ foreach my $el (@{$e->{ELEMENTS}}) {
+ if (util::has_property($el, "default")) {
pidl "\tdefault:\n";
} else {
- pidl "\tcase $el->{CASE}:\n";
+ pidl "\tcase $el->{PROPERTIES}->{case}:\n";
}
- if ($el->{TYPE} eq "UNION_ELEMENT") {
- ParseElementPushBuffer($el->{DATA}, "r->", "NDR_BUFFERS");
+ if ($el->{TYPE} ne "EMPTY") {
+ ParseElementPushBuffer($el, "r->", "NDR_BUFFERS");
}
pidl "\tbreak;\n\n";
}
@@ -1243,15 +1210,15 @@ sub ParseUnionPrint($)
start_flags($e);
pidl "\tswitch (level) {\n";
- foreach my $el (@{$e->{DATA}}) {
- if ($el->{CASE} eq "default") {
+ foreach my $el (@{$e->{ELEMENTS}}) {
+ if (util::has_property($el, "default")) {
$have_default = 1;
pidl "\tdefault:\n";
} else {
- pidl "\tcase $el->{CASE}:\n";
+ pidl "\tcase $el->{PROPERTIES}->{case}:\n";
}
- if ($el->{TYPE} eq "UNION_ELEMENT") {
- ParseElementPrintScalar($el->{DATA}, "r->");
+ if ($el->{TYPE} ne "EMPTY") {
+ ParseElementPrintScalar($el, "r->");
}
pidl "\tbreak;\n\n";
}
@@ -1280,19 +1247,18 @@ sub ParseUnionPull($)
# pidl "\tNDR_CHECK(ndr_pull_align(ndr, $align));\n";
pidl "\tswitch (level) {\n";
- foreach my $el (@{$e->{DATA}}) {
- if ($el->{CASE} eq "default") {
+ foreach my $el (@{$e->{ELEMENTS}}) {
+ if (util::has_property($el, "default")) {
pidl "\tdefault: {\n";
$have_default = 1;
} else {
- pidl "\tcase $el->{CASE}: {\n";
+ pidl "\tcase $el->{PROPERTIES}->{case}: {\n";
}
- if ($el->{TYPE} eq "UNION_ELEMENT") {
- my $e2 = $el->{DATA};
- if ($e2->{POINTERS}) {
- pidl "\t\tuint32_t _ptr_$e2->{NAME};\n";
+ if ($el->{TYPE} ne "EMPTY") {
+ if ($el->{POINTERS}) {
+ pidl "\t\tuint32_t _ptr_$el->{NAME};\n";
}
- ParseElementPullScalar($el->{DATA}, "r->", "NDR_SCALARS");
+ ParseElementPullScalar($el, "r->", "NDR_SCALARS");
}
pidl "\tbreak; }\n\n";
}
@@ -1304,14 +1270,14 @@ sub ParseUnionPull($)
pidl "buffers:\n";
pidl "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n";
pidl "\tswitch (level) {\n";
- foreach my $el (@{$e->{DATA}}) {
- if ($el->{CASE} eq "default") {
+ foreach my $el (@{$e->{ELEMENTS}}) {
+ if (util::has_property($el, "default")) {
pidl "\tdefault:\n";
} else {
- pidl "\tcase $el->{CASE}:\n";
+ pidl "\tcase $el->{PROPERTIES}->{case}:\n";
}
- if ($el->{TYPE} eq "UNION_ELEMENT") {
- ParseElementPullBuffer($el->{DATA}, "r->", "NDR_BUFFERS");
+ if ($el->{TYPE} ne "EMPTY") {
+ ParseElementPullBuffer($el, "r->", "NDR_BUFFERS");
}
pidl "\tbreak;\n\n";
}
@@ -1866,18 +1832,23 @@ sub ParseInterface($)
}
}
+ # Push functions
foreach my $d (@{$data}) {
($d->{TYPE} eq "TYPEDEF") &&
ParseTypedefPush($d);
($d->{TYPE} eq "FUNCTION") &&
ParseFunctionPush($d);
}
+
+ # Pull functions
foreach my $d (@{$data}) {
($d->{TYPE} eq "TYPEDEF") &&
ParseTypedefPull($d);
($d->{TYPE} eq "FUNCTION") &&
ParseFunctionPull($d);
}
+
+ # Print functions
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "TYPEDEF" &&
!util::has_property($d, "noprint")) {
@@ -1889,6 +1860,7 @@ sub ParseInterface($)
}
}
+ # Size functions
foreach my $d (@{$data}) {
($d->{TYPE} eq "TYPEDEF") &&
ParseTypedefNdrSize($d);
diff --git a/source4/build/pidl/needed.pm b/source4/build/pidl/needed.pm
index 37edbef83b..b70cb28356 100644
--- a/source4/build/pidl/needed.pm
+++ b/source4/build/pidl/needed.pm
@@ -38,7 +38,7 @@ sub NeededTypedef($)
$needed{"push_$t->{NAME}"} = 0;
}
- if ($t->{DATA}->{TYPE} eq "STRUCT") {
+ if ($t->{DATA}->{TYPE} eq "STRUCT" or $t->{DATA}->{TYPE} eq "UNION") {
if (util::has_property($t, "gensize")) {
$needed{"ndr_size_$t->{NAME}"} = 1;
}
@@ -53,26 +53,6 @@ sub NeededTypedef($)
}
}
}
- if ($t->{DATA}->{TYPE} eq "UNION") {
- if (util::has_property($t, "gensize")) {
- $needed{"ndr_size_$t->{NAME}"} = 1;
- }
-
- for my $e (@{$t->{DATA}->{DATA}}) {
- $e->{PARENT} = $t->{DATA};
- if ($e->{TYPE} eq "UNION_ELEMENT") {
- if ($needed{"pull_$t->{NAME}"}) {
- $needed{"pull_$e->{DATA}->{TYPE}"} = 1;
- }
- if ($needed{"push_$t->{NAME}"}) {
- $needed{"push_$e->{DATA}->{TYPE}"} = 1;
- }
- if ($needed{"ndr_size_$t->{NAME}"}) {
- $needed{"ndr_size_$e->{DATA}->{TYPE}"} = 1;
- }
- }
- }
- }
}
#####################################################################
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index bc8e0c9ed5..f46fa76f0e 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -168,7 +168,7 @@ sub get_interface($$)
}
#####################################################################
-# see if a pidl property list contains a give property
+# see if a pidl property list contains a given property
sub has_property($$)
{
my($e) = shift;
diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm
index c9b717434f..775f9b46aa 100644
--- a/source4/build/pidl/validator.pm
+++ b/source4/build/pidl/validator.pm
@@ -4,6 +4,7 @@
# released under the GNU GPL
package IdlValidator;
+use Data::Dumper;
use strict;
@@ -66,8 +67,19 @@ sub ValidStruct($)
sub ValidUnion($)
{
my($union) = shift;
- foreach my $e (@{$union->{DATA}}) {
+ foreach my $e (@{$union->{ELEMENTS}}) {
$e->{PARENT} = $union;
+
+ if (defined($e->{PROPERTIES}->{default}) and
+ defined($e->{PROPERTIES}->{case})) {
+ fatal "Union member $e->{NAME} can not have both default and case properties!\n";
+ }
+
+ unless (defined ($e->{PROPERTIES}->{default}) or
+ defined ($e->{PROPERTIES}->{case})) {
+ fatal "Union member $e->{NAME} must have default or case property\n";
+ }
+
ValidElement($e);
}
}