diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-18 18:44:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:48:33 -0500 |
commit | 0515f728e64dde0c197aee6180dce79ad281d5f8 (patch) | |
tree | a90230e7c7bf5b93a8922852163291f729e39f39 /source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm | |
parent | d425796fff07b8bc7b9eb49bc8db71aff9c1161f (diff) | |
download | samba-0515f728e64dde0c197aee6180dce79ad281d5f8.tar.gz samba-0515f728e64dde0c197aee6180dce79ad281d5f8.tar.bz2 samba-0515f728e64dde0c197aee6180dce79ad281d5f8.zip |
r21433: Get rid of the COM support code - it's not used and unmaintained. We can
always bring it back if we need to. This code was getting in the way while
refactoring.
Add some tests for TDR.
Get rid of typedef in lib/registry/tdr_regf.idl and fix the
TDR code to be able to deal with it.
(This used to be commit 1ad0f99a439f0d52a735b391bf9900d50171aca5)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm index cde5da2b6b..f1f23bf84b 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm @@ -1,6 +1,6 @@ ################################################### # Trivial Parser Generator -# Copyright jelmer@samba.org 2005 +# Copyright jelmer@samba.org 2005-2007 # released under the GNU GPL package Parse::Pidl::Samba4::TDR; @@ -8,13 +8,17 @@ use Parse::Pidl qw(fatal); use Parse::Pidl::Util qw(has_property ParseExpr is_constant); use Parse::Pidl::Samba4 qw(is_intree choose_header); +use Exporter; +@ISA = qw(Exporter); +@EXPORT_OK = qw(ParserType $ret $ret_hdr); + use vars qw($VERSION); $VERSION = '0.01'; use strict; -my $ret; -my $ret_hdr; +our $ret; +our $ret_hdr; my $tabs = ""; sub indent() { $tabs.="\t"; } @@ -117,14 +121,14 @@ sub ParserElement($$$) sub ParserStruct($$$$) { - my ($e,$n,$t,$p) = @_; + my ($e,$t,$p) = @_; - fn_declare($p,,"NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", struct $n *v)"); + fn_declare($p,"NTSTATUS tdr_$t\_$e->{NAME} (struct tdr_$t *tdr".typearg($t).", struct $e->{NAME} *v)"); pidl "{"; indent; pidl "int i;" if (ContainsArray($e)); if ($t eq "print") { - pidl "tdr->print(tdr, \"\%-25s: struct $n\", name);"; + pidl "tdr->print(tdr, \"\%-25s: struct $e->{NAME}\", name);"; pidl "tdr->level++;"; } @@ -141,16 +145,16 @@ sub ParserStruct($$$$) deindent; pidl "}"; } -sub ParserUnion($$$$) +sub ParserUnion($$$) { - my ($e,$n,$t,$p) = @_; + my ($e,$t,$p) = @_; - fn_declare($p,"NTSTATUS tdr_$t\_$n(struct tdr_$t *tdr".typearg($t).", int level, union $n *v)"); + fn_declare($p,"NTSTATUS tdr_$t\_$e->{NAME}(struct tdr_$t *tdr".typearg($t).", int level, union $e->{NAME} *v)"); pidl "{"; indent; pidl "int i;" if (ContainsArray($e)); if ($t eq "print") { - pidl "tdr->print(tdr, \"\%-25s: union $n\", name);"; + pidl "tdr->print(tdr, \"\%-25s: union $e->{NAME}\", name);"; pidl "tdr->level++;"; } @@ -174,19 +178,19 @@ sub ParserUnion($$$$) deindent; pidl "}"; } -sub ParserBitmap($$$$) +sub ParserBitmap($$$) { - my ($e,$n,$t,$p) = @_; + my ($e,$t,$p) = @_; return if ($p); - pidl "#define tdr_$t\_$n tdr_$t\_" . Parse::Pidl::Typelist::bitmap_type_fn($e); + pidl "#define tdr_$t\_$e->{NAME} tdr_$t\_" . Parse::Pidl::Typelist::bitmap_type_fn($e); } -sub ParserEnum($$$$) +sub ParserEnum($$$) { - my ($e,$n,$t,$p) = @_; + my ($e,$t,$p) = @_; my $bt = ($e->{PROPERTIES}->{base_type} or "uint8"); - fn_declare($p, "NTSTATUS tdr_$t\_$n (struct tdr_$t *tdr".typearg($t).", enum $n *v)"); + fn_declare($p, "NTSTATUS tdr_$t\_$e->{NAME} (struct tdr_$t *tdr".typearg($t).", enum $e->{NAME} *v)"); pidl "{"; if ($t eq "pull") { pidl "\t$bt\_t r;"; @@ -201,17 +205,27 @@ sub ParserEnum($$$$) pidl "}"; } -sub ParserTypedef($$) +sub ParserTypedef($$$) +{ + my ($e,$t,$p) = @_; + + ParserType($e->{DATA},$t); +} + +sub ParserType($$) { my ($e,$t) = @_; return if (has_property($e, "no$t")); - $e->{PROPERTIES} = $e->{DATA}->{PROPERTIES}; - - { STRUCT => \&ParserStruct, UNION => \&ParserUnion, - ENUM => \&ParserEnum, BITMAP => \&ParserBitmap - }->{$e->{DATA}->{TYPE}}->($e->{DATA}, $e->{NAME}, $t, has_property($e, "public")); + my $handlers = { + STRUCT => \&ParserStruct, UNION => \&ParserUnion, + ENUM => \&ParserEnum, BITMAP => \&ParserBitmap, + TYPEDEF => \&ParserTypedef + }; + + $handlers->{$e->{TYPE}}->($e, $t, has_property($e, "public")) + if (defined($handlers->{$e->{TYPE}})); pidl ""; } @@ -224,10 +238,9 @@ sub ParserInterface($) pidl_hdr "#define __TDR_$x->{NAME}_HEADER__"; foreach (@{$x->{DATA}}) { - next if ($_->{TYPE} ne "TYPEDEF"); - ParserTypedef($_, "pull"); - ParserTypedef($_, "push"); - ParserTypedef($_, "print"); + ParserType($_, "pull"); + ParserType($_, "push"); + ParserType($_, "print"); } pidl_hdr "#endif /* __TDR_$x->{NAME}_HEADER__ */"; |