From: Stefan Metzmacher Date: Fri, 23 Aug 2024 15:25:34 +0000 (+0200) Subject: pidl:Samba4/Header: only include ntstatus.h if required X-Git-Tag: tdb-1.4.13~1287 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f10160af8959a7211cea4d16d777141d8c52bfea;p=thirdparty%2Fsamba.git pidl:Samba4/Header: only include ntstatus.h if required Pair-Programmed-With: Volker Lendecke Signed-off-by: Stefan Metzmacher Signed-off-by: Volker Lendecke Reviewed-by: Jennifer Sutton --- diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm index a0b002f6724..aef3338e90b 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -13,7 +13,7 @@ require Exporter; use strict; use warnings; use Parse::Pidl qw(fatal); -use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference); +use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference scalarTypeUsed); use Parse::Pidl::Util qw(has_property is_constant unmake_str ParseExpr); use Parse::Pidl::Samba4 qw(is_intree ElementStars ArrayBrackets choose_header); @@ -437,7 +437,6 @@ sub Parse($) $res = ""; %headerstructs = (); - pidl "/* header auto-generated by pidl */\n\n"; my $ifacename = ""; @@ -449,6 +448,17 @@ sub Parse($) } } + foreach (@{$ndr}) { + ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_); + ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); + ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); + ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); + } + + my $res2 = $res; + $res = ""; + pidl "/* header auto-generated by pidl */\n\n"; + pidl "#ifndef _PIDL_HEADER_$ifacename\n"; pidl "#define _PIDL_HEADER_$ifacename\n\n"; @@ -457,16 +467,12 @@ sub Parse($) } pidl "#include \n"; pidl "\n"; - # FIXME: Include this only if NTSTATUS was actually used - pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n"; + if (scalarTypeUsed("NTSTATUS")) { + pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n"; + } pidl "\n"; - foreach (@{$ndr}) { - ($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_); - ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); - ($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}}); - ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}}); - } + $res .= $res2; pidl "#endif /* _PIDL_HEADER_$ifacename */\n";