summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-14 18:06:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:06:45 -0500
commitd222c5e7ae8b9b422ad551d379636f62e3d2041f (patch)
tree52a48e1354d2c3d8e16e716eb090eb0c72bc6bc1 /source4/pidl/lib/Parse/Pidl
parent151f422247e4f9a9645baf639adaf2dbd9557f13 (diff)
downloadsamba-d222c5e7ae8b9b422ad551d379636f62e3d2041f.tar.gz
samba-d222c5e7ae8b9b422ad551d379636f62e3d2041f.tar.bz2
samba-d222c5e7ae8b9b422ad551d379636f62e3d2041f.zip
r25166: Simplify can_contain_deferred and add tests for it.
(This used to be commit 1afc7dd4d33f05d58121defed88faf8fcee3df8f)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl')
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm30
1 files changed, 13 insertions, 17 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index 0ec4e6523b..033217c8bf 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -35,7 +35,7 @@ use vars qw($VERSION);
$VERSION = '0.01';
@ISA = qw(Exporter);
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
-@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType);
+@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar ParseType can_contain_deferred);
use strict;
use Parse::Pidl qw(warning fatal);
@@ -264,7 +264,7 @@ sub GetElementLevelTable($)
TYPE => "DATA",
DATA_TYPE => $e->{TYPE},
IS_DEFERRED => $is_deferred,
- CONTAINS_DEFERRED => can_contain_deferred($e),
+ CONTAINS_DEFERRED => can_contain_deferred($e->{TYPE}),
IS_SURROUNDING => 0 #FIXME
});
@@ -279,29 +279,25 @@ sub GetElementLevelTable($)
sub can_contain_deferred($)
{
sub can_contain_deferred($);
- my $e = shift;
+ my ($type) = @_;
+
+ return 1 unless (hasType($type)); # assume the worst
- return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE}));
- return 1 unless (hasType($e->{TYPE})); # assume the worst
+ $type = getType($type);
- my $type = getType($e->{TYPE});
+ return 0 if (Parse::Pidl::Typelist::is_scalar($type));
return 1 if ($type->{TYPE} eq "DECLARE"); # assume the worst
if ($type->{TYPE} eq "TYPEDEF") {
- return 0 unless defined($type->{DATA}->{ELEMENTS});
+ return can_contain_deferred($type->{DATA});
+ }
- foreach my $x (@{$type->{DATA}->{ELEMENTS}}) {
- return 1 if ($x->{POINTERS});
- return 1 if (can_contain_deferred ($x));
- }
- } else {
- return 0 unless defined($type->{ELEMENTS});
+ return 0 unless defined($type->{ELEMENTS});
- foreach my $x (@{$type->{ELEMENTS}}) {
- return 1 if ($x->{POINTERS});
- return 1 if (can_contain_deferred ($x));
- }
+ foreach my $x (@{$type->{ELEMENTS}}) {
+ return 1 if ($x->{POINTERS});
+ return 1 if (can_contain_deferred ($x));
}
return 0;