From e2ffb64d7a2bf8280b058ac3ce462d9cee281a98 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 03:44:32 +0000 Subject: some compilers can't handle structures with no elements. Generate dummy elements if need be. (This used to be commit b6fdc984023a76a6c77d03cb3ec12c6c18d215a6) --- source4/build/pidl/header.pm | 62 ++++++++++++++++++++++++++++++++------------ 1 file 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"; } -- cgit