pidl: added ifdef guards around ndr headers
authorAndrew Tridgell <tridge@samba.org>
Tue, 28 Sep 2010 04:03:45 +0000 (21:03 -0700)
committerAndrew Tridgell <tridge@samba.org>
Tue, 28 Sep 2010 05:55:05 +0000 (22:55 -0700)
this prevents us parsing the leading headers needlessly

pidl/lib/Parse/Pidl/Samba4/Header.pm

index be1df4b1183ec4f27e05719577d7385195e835c0..9788b2c12396d8e25fa3fbf4ec7166e6efb9c039 100644 (file)
@@ -5,7 +5,6 @@
 # released under the GNU GPL
 
 package Parse::Pidl::Samba4::Header;
 # released under the GNU GPL
 
 package Parse::Pidl::Samba4::Header;
-
 require Exporter;
 
 @ISA = qw(Exporter);
 require Exporter;
 
 @ISA = qw(Exporter);
@@ -412,6 +411,20 @@ sub Parse($)
        $res = "";
        %headerstructs = ();
        pidl "/* header auto-generated by pidl */\n\n";
        $res = "";
        %headerstructs = ();
        pidl "/* header auto-generated by pidl */\n\n";
+
+       my $ifacename = "";
+
+       # work out a unique interface name
+       foreach (@{$ndr}) {
+               if ($_->{TYPE} eq "INTERFACE") {
+                       $ifacename = $_->{NAME};
+                       last;
+               }
+       }
+
+       pidl "#ifndef _PIDL_HEADER_$ifacename\n";
+       pidl "#define _PIDL_HEADER_$ifacename\n\n";
+
        if (!is_intree()) {
                pidl "#include <util/data_blob.h>\n";
        }
        if (!is_intree()) {
                pidl "#include <util/data_blob.h>\n";
        }
@@ -428,6 +441,8 @@ sub Parse($)
                ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});
        }
 
                ($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});
        }
 
+       pidl "#endif /* _PIDL_HEADER_$ifacename */\n";
+
        return $res;
 }
 
        return $res;
 }