summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-16 03:44:32 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-16 03:44:32 +0000
commite2ffb64d7a2bf8280b058ac3ce462d9cee281a98 (patch)
tree1e3f291f7ef9a7ca90d77433b01077643f14c2ef /source4/build/pidl
parent2c6b585f2de11d4facfe06b8e8db789d22955716 (diff)
downloadsamba-e2ffb64d7a2bf8280b058ac3ce462d9cee281a98.tar.gz
samba-e2ffb64d7a2bf8280b058ac3ce462d9cee281a98.tar.bz2
samba-e2ffb64d7a2bf8280b058ac3ce462d9cee281a98.zip
some compilers can't handle structures with no elements. Generate
dummy elements if need be. (This used to be commit b6fdc984023a76a6c77d03cb3ec12c6c18d215a6)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/header.pm62
1 files changed, 46 insertions, 16 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index f7072633b9..507455d1a1 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -194,6 +194,20 @@ sub HeaderFunctionInOut($$)
}
}
+#####################################################################
+# determine if we need an "in" or "out" section
+sub HeaderFunctionInOut_needed($$)
+{
+ my($fn) = shift;
+ my($prop) = shift;
+ foreach my $e (@{$fn->{DATA}}) {
+ if (util::has_property($e, $prop)) {
+ return 1;
+ }
+ }
+ return undef;
+}
+
#####################################################################
# parse a function
@@ -202,24 +216,40 @@ sub HeaderFunction($)
my($fn) = shift;
$res .= "\nstruct $fn->{NAME} {\n";
$tab_depth++;
- tabs();
- $res .= "struct {\n";
- $tab_depth++;
- HeaderFunctionInOut($fn, "in");
- $tab_depth--;
- tabs();
- $res .= "} in;\n\n";
- tabs();
- $res .= "struct {\n";
- $tab_depth++;
- HeaderFunctionInOut($fn, "out");
- if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
+ my $needed = 0;
+
+ if (HeaderFunctionInOut_needed($fn, "in")) {
tabs();
- $res .= "$fn->{RETURN_TYPE} result;\n";
+ $res .= "struct {\n";
+ $tab_depth++;
+ HeaderFunctionInOut($fn, "in");
+ $tab_depth--;
+ tabs();
+ $res .= "} in;\n\n";
+ $needed++;
}
- $tab_depth--;
- tabs();
- $res .= "} out;\n\n";
+
+ if (HeaderFunctionInOut_needed($fn, "out")) {
+ tabs();
+ $res .= "struct {\n";
+ $tab_depth++;
+ HeaderFunctionInOut($fn, "out");
+ if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
+ tabs();
+ $res .= "$fn->{RETURN_TYPE} result;\n";
+ }
+ $tab_depth--;
+ tabs();
+ $res .= "} out;\n\n";
+ $needed++;
+ }
+
+ if (! $needed) {
+ # sigh - some compilers don't like empty structures
+ tabs();
+ $res .= "int _dummy_element;\n";
+ }
+
$tab_depth--;
$res .= "};\n\n";
}