r5709: Leave out the pull/push call with NDR_BUFFERS for not just
authorJelmer Vernooij <jelmer@samba.org>
Wed, 9 Mar 2005 15:39:55 +0000 (15:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:11:00 +0000 (13:11 -0500)
scalars but also for structs/unions containing only scalars.

source/build/pidl/ndr.pm

index fce7f26f9398e09da117a42e495118fb309dc751..fcd6f6d6ddbd1ee34b89ac171cb1673ea61ad4dc 100644 (file)
@@ -171,8 +171,7 @@ sub need_wire_pointer($)
 sub need_buffers_section($)
 {
        my $e = shift;
-       if ((is_scalar_type($e->{TYPE}) || util::has_property($e, "subcontext")) &&
-           $e->{POINTERS} == 0 && 
+       if (!can_contain_deferred($e) &&
            !util::array_size($e)) {
                return 0;
        }
@@ -407,6 +406,26 @@ sub align_type
        return $tmp;
 }
 
+#####################################################################
+# see if a type contains any deferred data 
+sub can_contain_deferred
+{
+       my $e = shift;
+
+       return 1 if ($e->{POINTERS});
+       return 0 if (is_scalar_type($e->{TYPE}));
+       return 0 if (util::has_property($e, "subcontext"));
+       return 1 unless (typelist::hasType($e->{TYPE})); # assume the worst
+
+       my $type = typelist::getType($e->{TYPE});
+
+       foreach my $x (@{$type->{DATA}->{ELEMENTS}}) {
+               return 1 if (can_contain_deferred ($x));
+       }
+       
+       return 0;
+}
+
 #####################################################################
 # parse array preceding data - push side
 sub ParseArrayPushPreceding($$$)