summaryrefslogtreecommitdiff
path: root/source4/pidl/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-25 15:19:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:43 -0500
commit25d57c0ad8704894ee055f74bab2f33b688a7d72 (patch)
treebfbd7f36b15f2dee6bb31dd9134c668ca495d78b /source4/pidl/lib
parentd3ced46329fe5caa590d2f0b132763d7d1825ffd (diff)
downloadsamba-25d57c0ad8704894ee055f74bab2f33b688a7d72.tar.gz
samba-25d57c0ad8704894ee055f74bab2f33b688a7d72.tar.bz2
samba-25d57c0ad8704894ee055f74bab2f33b688a7d72.zip
r12483: Remove --tdr-header option (merged into --tdr-parser)
(This used to be commit 45013467f57d646f3db099862665d2631272b446)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm79
1 files changed, 25 insertions, 54 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
index 524ed08bfa..789fb7adbe 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm
@@ -11,14 +11,15 @@ $VERSION = '0.01';
use strict;
-my $ret = "";
+my $ret;
+my $ret_hdr;
my $tabs = "";
sub indent() { $tabs.="\t"; }
sub deindent() { $tabs = substr($tabs, 1); }
sub pidl($) { $ret .= $tabs.(shift)."\n"; }
+sub pidl_hdr($) { $ret_hdr .= (shift)."\n"; }
sub fatal($$) { my ($e,$s) = @_; die("$e->{FILE}:$e->{LINE}: $s\n"); }
-sub static($) { my $p = shift; return("static ") unless ($p); return ""; }
sub typearg($) {
my $t = shift;
return(", const char *name") if ($t eq "print");
@@ -26,6 +27,12 @@ sub typearg($) {
return("");
}
+sub fn_declare($$)
+{
+ my ($p, $d) = @_;
+ if ($p) { pidl $d; pidl_hdr "$d;"; } else { pidl "static $d"; }
+}
+
sub ContainsArray($)
{
my $e = shift;
@@ -111,7 +118,7 @@ sub ParserStruct($$$$)
{
my ($e,$n,$t,$p) = @_;
- pidl static($p)."NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", struct $n *v)";
+ fn_declare($p,,"NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", struct $n *v)");
pidl "{"; indent;
pidl "int i;" if (ContainsArray($e));
@@ -137,7 +144,7 @@ sub ParserUnion($$$$)
{
my ($e,$n,$t,$p) = @_;
- pidl static($p)."NTSTATUS tdr_$t\_$n(struct tdr_$t *tdr".typearg($t).", int level, union $n *v)";
+ fn_declare($p,"NTSTATUS tdr_$t\_$n(struct tdr_$t *tdr".typearg($t).", int level, union $n *v)");
pidl "{"; indent;
pidl "int i;" if (ContainsArray($e));
@@ -178,7 +185,7 @@ sub ParserEnum($$$$)
my ($e,$n,$t,$p) = @_;
my $bt = ($e->{PROPERTIES}->{base_type} or "uint8");
- pidl static($p)."NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", enum $n *v)";
+ fn_declare($p, "NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", enum $n *v)");
pidl "{";
if ($t eq "pull") {
pidl "\t$bt\_t r;";
@@ -211,6 +218,9 @@ sub ParserTypedef($$)
sub ParserInterface($)
{
my $x = shift;
+
+ pidl_hdr "#ifndef __TDR_$x->{NAME}_HEADER__";
+ pidl_hdr "#define __TDR_$x->{NAME}_HEADER__";
foreach (@{$x->{DATA}}) {
next if ($_->{TYPE} ne "TYPEDEF");
@@ -218,63 +228,24 @@ sub ParserInterface($)
ParserTypedef($_, "push");
ParserTypedef($_, "print");
}
+
+ pidl_hdr "#endif /* __TDR_$x->{NAME}_HEADER__ */";
}
-sub Parser($$)
+sub Parser($$$)
{
- my ($idl,$hdrname) = @_;
- $ret = "";
+ my ($idl,$hdrname,$baseheader) = @_;
+ $ret = ""; $ret_hdr = "";
pidl "/* autogenerated by pidl */";
pidl "#include \"includes.h\"";
pidl "#include \"$hdrname\"";
pidl "";
- foreach (@$idl) { ParserInterface($_) if ($_->{TYPE} eq "INTERFACE"); }
- return $ret;
-}
-
-sub HeaderInterface($$)
-{
- my ($x,$outputdir) = @_;
-
- pidl "#ifndef __TDR_$x->{NAME}_HEADER__";
- pidl "#define __TDR_$x->{NAME}_HEADER__";
-
- foreach my $e (@{$x->{DATA}}) {
- next unless ($e->{TYPE} eq "TYPEDEF");
- next unless has_property($e, "public");
-
- my $switch = "";
+ pidl_hdr "/* autogenerated by pidl */";
+ pidl_hdr "#include \"$baseheader\"";
+ pidl_hdr "";
- $switch = ", int level" if ($e->{DATA}->{TYPE} eq "UNION");
-
- if ($e->{DATA}->{TYPE} eq "BITMAP") {
- # FIXME
- } else {
- my ($n, $d) = ($e->{NAME}, lc($e->{DATA}->{TYPE}));
- pidl "NTSTATUS tdr_pull\_$n(struct tdr_pull *tdr, TALLOC_CTX *ctx$switch, $d $n *v);";
- pidl "NTSTATUS tdr_print\_$n(struct tdr_print *tdr, const char *name$switch, $d $n *v);";
- pidl "NTSTATUS tdr_push\_$n(struct tdr_push *tdr$switch, $d $n *v);";
- }
-
- pidl "";
- }
-
- pidl "#endif /* __TDR_$x->{NAME}_HEADER__ */";
-}
-
-sub Header($$$)
-{
- my ($idl,$outputdir,$basename) = @_;
- $ret = "";
- pidl "/* Generated by pidl */";
-
- pidl "#include \"$outputdir/$basename.h\"";
- pidl "";
-
- foreach (@$idl) {
- HeaderInterface($_, $outputdir) if ($_->{TYPE} eq "INTERFACE");
- }
- return $ret;
+ foreach (@$idl) { ParserInterface($_) if ($_->{TYPE} eq "INTERFACE"); }
+ return ($ret_hdr, $ret);
}
1;