summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-20 00:57:00 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-20 00:57:00 +0000
commitfd15fc58e7b4dbe0d4eda81f979c8de97e9ac7ee (patch)
tree7dac35a824edf404097bb088d10425ed8cf73bfc /source4/build
parent940ce958a6914fb9b70de3cf95a0c062063e2253 (diff)
downloadsamba-fd15fc58e7b4dbe0d4eda81f979c8de97e9ac7ee.tar.gz
samba-fd15fc58e7b4dbe0d4eda81f979c8de97e9ac7ee.tar.bz2
samba-fd15fc58e7b4dbe0d4eda81f979c8de97e9ac7ee.zip
* added support for empty case elements (including default cases)
* changed to midl syntax using [case(x)] instead of case(x) (This used to be commit 6ecdb25e137c25e6bf9a7037a4eb602ae1afc514)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/header.pm4
-rw-r--r--source4/build/pidl/idl.gram15
-rw-r--r--source4/build/pidl/parser.pm60
3 files changed, 49 insertions, 30 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index 60605fb619..0822ca0e06 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -90,7 +90,9 @@ sub HeaderUnionElement($)
{
my($element) = shift;
$res .= "/* [case($element->{CASE})] */ ";
- HeaderElement($element->{DATA});
+ if ($element->{TYPE} eq "UNION_ELEMENT") {
+ HeaderElement($element->{DATA});
+ }
}
#####################################################################
diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram
index 9b265b8cba..d90c2238b4 100644
--- a/source4/build/pidl/idl.gram
+++ b/source4/build/pidl/idl.gram
@@ -54,24 +54,29 @@ union: property_list(s?) 'union' <commit> '{' union_element(s?) '}'
}}
| <error?>
-union_element: '[' 'case' '(' constant ')' ']' base_element ';'
+union_element:
+ '[' 'case' '(' constant ')' ']' base_element ';'
{{
"TYPE" => "UNION_ELEMENT",
"CASE" => $item{constant},
"DATA" => $item{base_element}
}}
- | 'case' '(' constant ')' base_element ';'
+ | '[' 'case' '(' constant ')' ']' ';'
{{
- "TYPE" => "UNION_ELEMENT",
+ "TYPE" => "EMPTY",
"CASE" => $item{constant},
- "DATA" => $item{base_element}
}}
- | 'default' base_element ';'
+ | '[' 'default' ']' base_element ';'
{{
"TYPE" => "UNION_ELEMENT",
"CASE" => "default",
"DATA" => $item{base_element}
}}
+ | '[' 'default' ']' ';'
+ {{
+ "TYPE" => "EMPTY",
+ "CASE" => "default",
+ }}
base_element: property_list(s?) type pointer(s?) identifier array_len(?)
{{
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index a5cf68669a..c859dd56c9 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -7,6 +7,7 @@
package IdlParser;
use Data::Dumper;
+use strict;
my($res);
@@ -69,7 +70,7 @@ sub find_size_var($$)
if ($size =~ /ndr->/) {
return $size;
}
-
+
if ($fn->{TYPE} ne "FUNCTION") {
return "r->$size";
}
@@ -574,7 +575,6 @@ sub ParseStructPush($)
$res .= "\tNDR_CHECK(ndr_push_align(ndr, $align));\n";
foreach my $e (@{$struct->{ELEMENTS}}) {
- $e->{PARENT} = $struct;
ParseElementPushScalar($e, "r->", "NDR_SCALARS");
}
@@ -631,7 +631,6 @@ sub ParseStructPull($)
# declare any internal pointers we need
foreach my $e (@{$struct->{ELEMENTS}}) {
- $e->{PARENT} = $struct;
if (util::need_wire_pointer($e)) {
$res .= "\tuint32 _ptr_$e->{NAME};\n";
}
@@ -685,7 +684,9 @@ sub ParseUnionPush($)
} else {
$res .= "\tcase $el->{CASE}:\n";
}
- ParseElementPushScalar($el->{DATA}, "r->", "NDR_SCALARS");
+ if ($el->{TYPE} eq "UNION_ELEMENT") {
+ ParseElementPushScalar($el->{DATA}, "r->", "NDR_SCALARS");
+ }
$res .= "\tbreak;\n\n";
}
if (! $have_default) {
@@ -703,7 +704,9 @@ sub ParseUnionPush($)
} else {
$res .= "\tcase $el->{CASE}:\n";
}
- ParseElementPushBuffer($el->{DATA}, "r->", "ndr_flags");
+ if ($el->{TYPE} eq "UNION_ELEMENT") {
+ ParseElementPushBuffer($el->{DATA}, "r->", "ndr_flags");
+ }
$res .= "\tbreak;\n\n";
}
if (! $have_default) {
@@ -729,7 +732,9 @@ sub ParseUnionPrint($)
} else {
$res .= "\tcase $el->{CASE}:\n";
}
- ParseElementPrintScalar($el->{DATA}, "r->");
+ if ($el->{TYPE} eq "UNION_ELEMENT") {
+ ParseElementPrintScalar($el->{DATA}, "r->");
+ }
$res .= "\tbreak;\n\n";
}
if (! $have_default) {
@@ -760,11 +765,13 @@ sub ParseUnionPull($)
} else {
$res .= "\tcase $el->{CASE}: {\n";
}
- my $e2 = $el->{DATA};
- if ($e2->{POINTERS}) {
- $res .= "\t\tuint32 _ptr_$e2->{NAME};\n";
+ if ($el->{TYPE} eq "UNION_ELEMENT") {
+ my $e2 = $el->{DATA};
+ if ($e2->{POINTERS}) {
+ $res .= "\t\tuint32 _ptr_$e2->{NAME};\n";
+ }
+ ParseElementPullScalar($el->{DATA}, "r->", "NDR_SCALARS");
}
- ParseElementPullScalar($el->{DATA}, "r->", "NDR_SCALARS");
$res .= "\tbreak; }\n\n";
}
if (! $have_default) {
@@ -782,7 +789,9 @@ sub ParseUnionPull($)
} else {
$res .= "\tcase $el->{CASE}:\n";
}
- ParseElementPullBuffer($el->{DATA}, "r->", "NDR_BUFFERS");
+ if ($el->{TYPE} eq "UNION_ELEMENT") {
+ ParseElementPullBuffer($el->{DATA}, "r->", "NDR_BUFFERS");
+ }
$res .= "\tbreak;\n\n";
}
if (! $have_default) {
@@ -970,7 +979,6 @@ sub ParseFunctionPush($)
foreach my $e (@{$function->{DATA}}) {
if (util::has_property($e, "in")) {
- $e->{PARENT} = $function;
if (util::array_size($e)) {
if (util::need_wire_pointer($e)) {
$res .= "\tNDR_CHECK(ndr_push_ptr(ndr, r->in.$e->{NAME}));\n";
@@ -1010,7 +1018,6 @@ sub ParseFunctionPull($)
foreach my $e (@{$fn->{DATA}}) {
if (util::has_property($e, "out")) {
- $e->{PARENT} = $fn;
if (util::array_size($e)) {
if (util::need_wire_pointer($e)) {
$res .= "\tNDR_CHECK(ndr_pull_uint32(ndr, _ptr_$e->{NAME}));\n";
@@ -1082,6 +1089,7 @@ sub NeededFunction($)
$needed{"pull_$fn->{NAME}"} = 1;
$needed{"push_$fn->{NAME}"} = 1;
foreach my $e (@{$fn->{DATA}}) {
+ $e->{PARENT} = $fn;
if (util::has_property($e, "out")) {
$needed{"pull_$e->{TYPE}"} = 1;
}
@@ -1100,21 +1108,25 @@ sub NeededTypedef($)
}
if ($t->{DATA}->{TYPE} eq "STRUCT") {
for my $e (@{$t->{DATA}->{ELEMENTS}}) {
- if ($needed{"pull_$t->{NAME}"}) {
- $needed{"pull_$e->{TYPE}"} = 1;
- }
- if ($needed{"push_$t->{NAME}"}) {
- $needed{"push_$e->{TYPE}"} = 1;
- }
+ $e->{PARENT} = $t->{DATA};
+ if ($needed{"pull_$t->{NAME}"}) {
+ $needed{"pull_$e->{TYPE}"} = 1;
+ }
+ if ($needed{"push_$t->{NAME}"}) {
+ $needed{"push_$e->{TYPE}"} = 1;
}
}
+ }
if ($t->{DATA}->{TYPE} eq "UNION") {
for my $e (@{$t->{DATA}->{DATA}}) {
- if ($needed{"pull_$t->{NAME}"}) {
- $needed{"pull_$e->{DATA}->{TYPE}"} = 1;
- }
- if ($needed{"push_$t->{NAME}"}) {
- $needed{"push_$e->{DATA}->{TYPE}"} = 1;
+ $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;
+ }
}
}
}