diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-25 15:19:55 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:43 -0500 |
commit | 25d57c0ad8704894ee055f74bab2f33b688a7d72 (patch) | |
tree | bfbd7f36b15f2dee6bb31dd9134c668ca495d78b /source4/pidl | |
parent | d3ced46329fe5caa590d2f0b132763d7d1825ffd (diff) | |
download | samba-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')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm | 79 | ||||
-rwxr-xr-x | source4/pidl/pidl | 31 |
2 files changed, 41 insertions, 69 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; diff --git a/source4/pidl/pidl b/source4/pidl/pidl index 92395dbac2..d1b8c4480b 100755 --- a/source4/pidl/pidl +++ b/source4/pidl/pidl @@ -17,7 +17,7 @@ pidl - An IDL compiler written in Perl pidl --help -pidl [--outputdir[=OUTNAME]] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--swig[=OUTPUT]] [--uint-enums] [--ndr-parser[=OUTPUT]] [--client] [--server] [--dcom-proxy] [--com-header] [--warn-compat] [--quiet] [--verbose] [--template] [--eth-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-header=[OUTPUT]] [--tdr-parser[=OUTPUT]] [--samba3-header[=OUTPUT]] [--samba3-parser=[OUTPUT]] [--samba3-server=[OUTPUT]] [--samba3-template[=OUTPUT]] [--samba3-client[=OUTPUT]] [<idlfile>.idl]... +pidl [--outputdir[=OUTNAME]] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--swig[=OUTPUT]] [--uint-enums] [--ndr-parser[=OUTPUT]] [--client] [--server] [--dcom-proxy] [--com-header] [--warn-compat] [--quiet] [--verbose] [--template] [--eth-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-header[=OUTPUT]] [--samba3-parser=[OUTPUT]] [--samba3-server=[OUTPUT]] [--samba3-template[=OUTPUT]] [--samba3-client[=OUTPUT]] [<idlfile>.idl]... =head1 DESCRIPTION @@ -77,6 +77,12 @@ Generate a C file and C header containing NDR parsers. The filename for the parser defaults to ndr_OUTNAME.c. The header filename will be the parser filename with the extension changed from .c to .h. +=item I<--tdr-parser> + +Generate a C file and C header containing TDR parsers. The filename for +the parser defaults to tdr_OUTNAME.c. The header filename will be the +parser filename with the extension changed from .c to .h. + =item I<--server> Generate boilerplate for the RPC server that implements @@ -360,7 +366,7 @@ usesgetlasterror, vararg, vi_progid, wire_marshal. $ ./pidl --eth-parser -- atsvc.idl # Generating a TDR parser and header - $ ./pidl --tdr-parser --tdr-header --header -- regf.idl + $ ./pidl --tdr-parser --header -- regf.idl # Generating a Samba3 parser, client and server $ ./pidl --samba3-parser --samba3-server --samba3-client -- dfs.idl @@ -462,7 +468,6 @@ my($opt_template) = 0; my($opt_client); my($opt_server); my($opt_ndr_parser); -my($opt_tdr_header); my($opt_tdr_parser); my($opt_eth_parser); my($opt_swig); @@ -503,7 +508,6 @@ Samba 4 output: --uint-enums don't use C enums, instead use uint* types --ndr-parser[=OUTFILE] create a C NDR parser [ndr_BASENAME.c] --client[=OUTFILE] create a C NDR client [ndr_BASENAME_c.c] - --tdr-header[=OUTFILE] create a C TDR header file [tdr_BASENAME.h] --tdr-parser[=OUTFILE] create a C TDR parser [tdr_BASENAME.c] --ejs[=OUTFILE] create ejs wrapper file [BASENAME_ejs.c] --swig[=OUTFILE] create swig wrapper file [BASENAME.i] @@ -541,7 +545,6 @@ my $result = GetOptions ( 'samba3-client:s' => \$opt_samba3_client, 'header:s' => \$opt_header, 'server:s' => \$opt_server, - 'tdr-header:s' => \$opt_tdr_header, 'tdr-parser:s' => \$opt_tdr_parser, 'template' => \$opt_template, 'ndr-parser:s' => \$opt_ndr_parser, @@ -656,10 +659,10 @@ sub process_file($) SaveStructure($ndr_file, $ndr) or die "Failed to save $ndr_file\n"; } + my $gen_header = ($opt_header or "$outputdir/$basename.h"); if (defined($opt_header)) { - my $header = ($opt_header or "$outputdir/$basename.h"); require Parse::Pidl::Samba4::Header; - FileSave($header, Parse::Pidl::Samba4::Header::Parse($pidl)); + FileSave($gen_header, Parse::Pidl::Samba4::Header::Parse($pidl)); } my $h_filename = "$outputdir/ndr_$basename.h"; @@ -744,16 +747,14 @@ $dcom FileSave($eheader, $dh) if defined($dh); } - my $tdr_parser = ($opt_tdr_parser or "$outputdir/tdr_$basename.c"); - my $tdr_header = ($opt_tdr_header or "$outputdir/tdr_$basename.h"); if (defined($opt_tdr_parser)) { + my $tdr_parser = ($opt_tdr_parser or "$outputdir/tdr_$basename.c"); + my $tdr_header = $tdr_parser; + $tdr_header =~ s/\.c$/\.h/; require Parse::Pidl::Samba4::TDR; - FileSave($tdr_parser, Parse::Pidl::Samba4::TDR::Parser($pidl, $tdr_header)); - } - - if (defined($opt_tdr_header)) { - require Parse::Pidl::Samba4::TDR; - FileSave($tdr_header, Parse::Pidl::Samba4::TDR::Header($pidl, $outputdir,$basename)); + my ($hdr,$prsr) = Parse::Pidl::Samba4::TDR::Parser($pidl, $tdr_header, $gen_header); + FileSave($tdr_parser, $prsr); + FileSave($tdr_header, $hdr); } if ($opt_template) { |