diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-22 16:39:56 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-22 16:39:56 +0100 |
commit | 4075a2ba982ea56ff925e0a33839f0760fd71911 (patch) | |
tree | 87d87734257f814b7960a843e54455c447f34a9e /source4/pidl/lib/Parse/Pidl/Typelist.pm | |
parent | 24da29746998de1001d18871dcbe8d37643667d5 (diff) | |
parent | 35c68316442808a135aafa864d19592108a4d879 (diff) | |
download | samba-4075a2ba982ea56ff925e0a33839f0760fd71911.tar.gz samba-4075a2ba982ea56ff925e0a33839f0760fd71911.tar.bz2 samba-4075a2ba982ea56ff925e0a33839f0760fd71911.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-python
(This used to be commit 2f57e25f8f692889d9e057e13256f8a24c5ec10c)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Typelist.pm')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Typelist.pm | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index b2069c784b..8ba1ae47af 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -7,9 +7,9 @@ package Parse::Pidl::Typelist; require Exporter; @ISA = qw(Exporter); -@EXPORT_OK = qw(hasType getType mapTypeName scalar_is_reference expandAlias +@EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias mapScalarType addType typeIs is_scalar enum_type_fn - bitmap_type_fn mapType + bitmap_type_fn mapType typeHasBody ); use vars qw($VERSION); $VERSION = '0.01'; @@ -59,6 +59,7 @@ my %aliases = ( "boolean8" => "uint8", "boolean32" => "uint32", "DWORD" => "uint32", + "uint" => "uint32", "int" => "int32", "WORD" => "uint16", "char" => "uint8", @@ -95,6 +96,20 @@ sub addType($) $types{$t->{NAME}} = $t; } +sub resolveType($) +{ + my ($ctype) = @_; + + if (not hasType($ctype)) { + # assume struct typedef + return { TYPE => "TYPEDEF", NAME => $ctype, DATA => { TYPE => "STRUCT" } }; + } else { + return getType($ctype); + } + + return $ctype; +} + sub getType($) { my $t = shift; @@ -135,11 +150,12 @@ sub is_scalar($) sub is_scalar($); my $type = shift; - return 1 if (ref($type) eq "HASH" and $type->{TYPE} eq "SCALAR"); + return 1 if (ref($type) eq "HASH" and + ($type->{TYPE} eq "SCALAR" or $type->{TYPE} eq "ENUM" or + $type->{TYPE} eq "BITMAP")); if (my $dt = getType($type)) { - return is_scalar($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF" or - $dt->{TYPE} eq "DECLARE"); + return is_scalar($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF"); return 1 if ($dt->{TYPE} eq "SCALAR" or $dt->{TYPE} eq "ENUM" or $dt->{TYPE} eq "BITMAP"); } @@ -150,7 +166,7 @@ sub is_scalar($) sub scalar_is_reference($) { my $name = shift; - + return 1 if (grep(/^$name$/, @reference_scalars)); return 0; } @@ -208,13 +224,25 @@ sub bitmap_type_fn($) return "uint32"; } +sub typeHasBody($) +{ + sub typeHasBody($); + my ($e) = @_; + + if ($e->{TYPE} eq "TYPEDEF") { + return 0 unless(defined($e->{DATA})); + return typeHasBody($e->{DATA}); + } + + return defined($e->{ELEMENTS}); +} + sub mapType($$) { sub mapType($$); my ($t, $n) = @_; return mapType($t->{DATA}, $n) if ($t->{TYPE} eq "TYPEDEF"); - return mapType($t->{DATA}, $n) if ($t->{TYPE} eq "DECLARE"); return mapScalarType($n) if ($t->{TYPE} eq "SCALAR"); return "enum $n" if ($t->{TYPE} eq "ENUM"); return "struct $n" if ($t->{TYPE} eq "STRUCT"); @@ -240,7 +268,7 @@ sub mapTypeName($) sub LoadIdl($) { - my $idl = shift; + my ($idl) = @_; foreach my $x (@{$idl}) { next if $x->{TYPE} ne "INTERFACE"; @@ -248,7 +276,6 @@ sub LoadIdl($) foreach my $y (@{$x->{DATA}}) { addType($y) if ( $y->{TYPE} eq "TYPEDEF" - or $y->{TYPE} eq "DECLARE" or $y->{TYPE} eq "UNION" or $y->{TYPE} eq "STRUCT" or $y->{TYPE} eq "ENUM" @@ -257,6 +284,11 @@ sub LoadIdl($) } } +sub GenerateTypeLib() +{ + return Parse::Pidl::Util::MyDumper(\%types); +} + RegisterScalars(); 1; |