From 25d57c0ad8704894ee055f74bab2f33b688a7d72 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 15:19:55 +0000 Subject: r12483: Remove --tdr-header option (merged into --tdr-parser) (This used to be commit 45013467f57d646f3db099862665d2631272b446) --- source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm | 79 ++++++++++--------------------- 1 file changed, 25 insertions(+), 54 deletions(-) (limited to 'source4/pidl/lib') 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; -- cgit