The branch, v4-0-test has been updated
       via  3f2edcc341e5b0e4369e8f601ef0cb6ecf73b4c7 (commit)
       via  6b3817c2250b94307ffcbd9f8eeb9a593eb7a82d (commit)
       via  d7970d70329e0d4f9de30ccfcedd03e583817fa2 (commit)
       via  aa8518521b2a6a7110c84c4981c53acce7389ee9 (commit)
      from  dc15c8833599a1cb8f51c2b5390925410cbf4e12 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 3f2edcc341e5b0e4369e8f601ef0cb6ecf73b4c7
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Sun Feb 3 02:54:23 2008 +0100

    wkssvc.idl: fix idl for wkssvc_NetrGetJoinableOus[2]()
    
    metze

commit 6b3817c2250b94307ffcbd9f8eeb9a593eb7a82d
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Thu Jan 31 15:04:22 2008 +0100

    pidl/Samba4::NDR::Parser: fix support for embedded "ref" pointers
    
    The memory allocation of embedded "ref" pointers needs to be the
    same as for all other embedded pointers.
    
    metze

commit d7970d70329e0d4f9de30ccfcedd03e583817fa2
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Fri Feb 1 23:09:37 2008 +0100

    pidl/NDR: fix handling of multilevel pointers in function elements
    
    The 2nd or higher level of wire pointers needs to be marked as deferred.
    
    metze

commit aa8518521b2a6a7110c84c4981c53acce7389ee9
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Fri Feb 1 10:30:47 2008 +0100

    pidl: get the pointer types correct when an element has multiple pointers
    
    Only the first level gets the pointer type from the
    pointer property, the others get them from
    the pointer_default() interface property
    
    see http://msdn2.microsoft.com/en-us/library/aa378984(VS.85).aspx
    (Here they talk about the rightmost pointer, but testing shows
    they mean the leftmost pointer.)
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source/librpc/idl/wkssvc.idl                    |   12 +-
 source/pidl/lib/Parse/Pidl/NDR.pm               |   37 ++-
 source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm |   14 +-
 source/pidl/tests/ndr.pl                        |  289 ++++++++++++++++++++++-
 4 files changed, 324 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/librpc/idl/wkssvc.idl b/source/librpc/idl/wkssvc.idl
index 38c16c7..023ce59 100644
--- a/source/librpc/idl/wkssvc.idl
+++ b/source/librpc/idl/wkssvc.idl
@@ -647,7 +647,11 @@ import "srvsvc.idl", "lsa.idl";
                [in,unique] [string,charset(UTF16)] uint16 *Account,
                [in,unique] [string,charset(UTF16)] uint16 *unknown,
                [in,out,ref] uint32 *num_ous,
-               [out,ref] [size_is(*num_ous)] [string,charset(UTF16)] uint16 
***ous
+               /*
+                * this is a [ref] pointer to a [unique] pointer to an
+                * array of [unique] pointers to a string array
+                */
+               [out,ref] [size_is(,*num_ous)] [string,charset(UTF16)] uint16 
***ous
                );
 
        typedef [flag(NDR_PAHEX)] struct {
@@ -731,7 +735,11 @@ import "srvsvc.idl", "lsa.idl";
                [in,unique] [string,charset(UTF16)] uint16 *Account,
                [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
                [in,out,ref] uint32 *num_ous,
-               [out,ref] [size_is(*num_ous)] [string,charset(UTF16)] uint16 
***ous
+               /*
+                * this is a [ref] pointer to a [unique] pointer to an
+                * array of [unique] pointers to a string array
+                */
+               [out,ref] [size_is(,*num_ous)] [string,charset(UTF16)] uint16 
***ous
                );
 
        /*****************************/
diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm 
b/source/pidl/lib/Parse/Pidl/NDR.pm
index fb1e658..86ed1a8 100644
--- a/source/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source/pidl/lib/Parse/Pidl/NDR.pm
@@ -72,9 +72,9 @@ my $scalar_alignment = {
        'ipv4address' => 4
 };
 
-sub GetElementLevelTable($)
+sub GetElementLevelTable($$)
 {
-       my $e = shift;
+       my ($e, $pointer_default) = @_;
 
        my $order = [];
        my $is_deferred = 0;
@@ -157,32 +157,45 @@ sub GetElementLevelTable($)
 
        # Next, all the pointers
        foreach my $i (1..$e->{POINTERS}) {
-               my $pt = pointer_type($e);
-
                my $level = "EMBEDDED";
                # Top level "ref" pointers do not have a referrent identifier
-               $level = "TOP" if ( defined($pt) 
-                               and $i == 1
-                               and $e->{PARENT}->{TYPE} eq "FUNCTION");
+               $level = "TOP" if ($i == 1 and $e->{PARENT}->{TYPE} eq 
"FUNCTION");
+
+               my $pt;
+               #
+               # Only the first level gets the pointer type from the
+               # pointer property, the others get them from
+               # the pointer_default() interface property
+               #
+               # see 
http://msdn2.microsoft.com/en-us/library/aa378984(VS.85).aspx
+               # (Here they talk about the rightmost pointer, but testing shows
+               #  they mean the leftmost pointer.)
+               #
+               # --metze
+               #
+               $pt = pointer_type($e);
+               if ($i > 1) {
+                       $is_deferred = 1 if ($pt ne "ref" and 
$e->{PARENT}->{TYPE} eq "FUNCTION");
+                       $pt = $pointer_default;
+               }
 
                push (@$order, { 
                        TYPE => "POINTER",
-                       # for now, there can only be one pointer type per 
element
-                       POINTER_TYPE => pointer_type($e),
+                       POINTER_TYPE => $pt,
                        POINTER_INDEX => $pointer_idx,
                        IS_DEFERRED => "$is_deferred",
                        LEVEL => $level
                });
 
                warning($e, "top-level \[out\] pointer `$e->{NAME}' is not a 
\[ref\] pointer") 
-                       if ($i == 1 and pointer_type($e) ne "ref" and 
+                       if ($i == 1 and $pt ne "ref" and
                                $e->{PARENT}->{TYPE} eq "FUNCTION" and 
                                not has_property($e, "in"));
 
                $pointer_idx++;
                
                # everything that follows will be deferred
-               $is_deferred = 1 if ($e->{PARENT}->{TYPE} ne "FUNCTION");
+               $is_deferred = 1 if ($level ne "TOP");
 
                my $array_size = shift @size_is;
                my $array_length;
@@ -391,7 +404,7 @@ sub ParseElement($$)
                NAME => $e->{NAME},
                TYPE => $e->{TYPE},
                PROPERTIES => $e->{PROPERTIES},
-               LEVELS => GetElementLevelTable($e),
+               LEVELS => GetElementLevelTable($e, $pointer_default),
                REPRESENTATION_TYPE => ($e->{PROPERTIES}->{represent_as} or 
$e->{TYPE}),
                ALIGN => align_type($e->{TYPE}),
                ORIGINAL => $e
diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm 
b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 81a8bf8..6e6d227 100644
--- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -929,7 +929,7 @@ sub ParseMemCtxPullFlags($$$$)
                                        ($nl->{DATA_TYPE} eq "string"));
                if ($next_is_array or $next_is_string) {
                        return undef;
-               } else {
+               } elsif ($l->{LEVEL} eq "TOP") {
                        $mem_flags = "LIBNDR_FLAG_REF_ALLOC";
                }
        }
@@ -1129,10 +1129,7 @@ sub ParsePtrPull($$$$$)
        my $next_is_string = (($nl->{TYPE} eq "DATA") and 
                                                 ($nl->{DATA_TYPE} eq 
"string"));
 
-       if ($l->{POINTER_TYPE} eq "ref") {
-               if ($l->{LEVEL} eq "EMBEDDED") {
-                       $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, 
&_ptr_$e->{NAME}));");
-               }
+       if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") {
 
                if (!$next_is_array and !$next_is_string) {
                        $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) 
{");
@@ -1141,16 +1138,19 @@ sub ParsePtrPull($$$$$)
                }
                
                return;
+       } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") {
+               $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, 
&_ptr_$e->{NAME}));");
        } elsif (($l->{POINTER_TYPE} eq "unique") or 
                 ($l->{POINTER_TYPE} eq "relative") or
                 ($l->{POINTER_TYPE} eq "full")) {
                $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, 
&_ptr_$e->{NAME}));");
-               $self->pidl("if (_ptr_$e->{NAME}) {");
-               $self->indent;
        } else {
                die("Unhandled pointer type $l->{POINTER_TYPE}");
        }
 
+       $self->pidl("if (_ptr_$e->{NAME}) {");
+       $self->indent;
+
        # Don't do this for arrays, they're allocated at the actual level 
        # of the array
        unless ($next_is_array or $next_is_string) { 
diff --git a/source/pidl/tests/ndr.pl b/source/pidl/tests/ndr.pl
index 7fcc7ef..504b7ec 100755
--- a/source/pidl/tests/ndr.pl
+++ b/source/pidl/tests/ndr.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 40;
+use Test::More tests => 46;
 use FindBin qw($RealBin);
 use lib "$RealBin";
 use Util;
@@ -22,7 +22,7 @@ my $e = {
        'PARENT' => { TYPE => 'STRUCT' },
        'LINE' => 42 };
 
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
        {
                'IS_DEFERRED' => 0,
                'LEVEL_INDEX' => 0,
@@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e), [
        }
 ]);
 
-my $ne = ParseElement($e, undef);
+my $ne = ParseElement($e, "unique");
 is($ne->{ORIGINAL}, $e);
 is($ne->{NAME}, "v");
 is($ne->{ALIGN}, 1);
@@ -60,7 +60,7 @@ $e = {
        'TYPE' => 'uint8',
        'LINE' => 42 };
 
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
        {
                LEVEL_INDEX => 0,
                IS_DEFERRED => 0,
@@ -90,7 +90,7 @@ $e = {
        'PARENT' => { TYPE => 'STRUCT' },
        'LINE' => 42 };
 
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
        {
                LEVEL_INDEX => 0,
                IS_DEFERRED => 0,
@@ -128,7 +128,7 @@ $e = {
        'PARENT' => { TYPE => 'STRUCT' },
        'LINE' => 42 };
 
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
        {
                LEVEL_INDEX => 0,
                IS_DEFERRED => 0,
@@ -147,6 +147,97 @@ is_deeply(GetElementLevelTable($e), [
        }
 ]);
 
+# Case 3 : ref pointers
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"ref" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'STRUCT' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 0,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               'IS_DEFERRED' => 1,
+               'LEVEL_INDEX' => 3,
+               'DATA_TYPE' => 'uint8',
+               'CONTAINS_DEFERRED' => 0,
+               'TYPE' => 'DATA',
+               'IS_SURROUNDING' => 0,
+       }
+]);
+
+# Case 3 : ref pointers
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"ref" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'STRUCT' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 0,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               'IS_DEFERRED' => 1,
+               'LEVEL_INDEX' => 3,
+               'DATA_TYPE' => 'uint8',
+               'CONTAINS_DEFERRED' => 0,
+               'TYPE' => 'DATA',
+               'IS_SURROUNDING' => 0,
+       }
+]);
 
 # Case 4 : top-level ref pointers
 #
@@ -159,7 +250,7 @@ $e = {
        'PARENT' => { TYPE => 'FUNCTION' },
        'LINE' => 42 };
 
-is_deeply(GetElementLevelTable($e), [
+is_deeply(GetElementLevelTable($e, "unique"), [
        {
                LEVEL_INDEX => 0,
                IS_DEFERRED => 0,
@@ -178,6 +269,190 @@ is_deeply(GetElementLevelTable($e), [
        }
 ]);
 
+# Case 4 : top-level ref pointers, triple with pointer_default("unique")
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"ref" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'FUNCTION' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 0,
+               LEVEL => 'TOP'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               'IS_DEFERRED' => 1,
+               'LEVEL_INDEX' => 3,
+               'DATA_TYPE' => 'uint8',
+               'CONTAINS_DEFERRED' => 0,
+               'TYPE' => 'DATA',
+               'IS_SURROUNDING' => 0,
+       }
+]);
+
+# Case 4 : top-level unique pointers, triple with pointer_default("unique")
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"unique" => 1, "in" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'FUNCTION' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "unique"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 0,
+               LEVEL => 'TOP'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               'IS_DEFERRED' => 1,
+               'LEVEL_INDEX' => 3,
+               'DATA_TYPE' => 'uint8',
+               'CONTAINS_DEFERRED' => 0,
+               'TYPE' => 'DATA',
+               'IS_SURROUNDING' => 0,
+       }
+]);
+
+# Case 4 : top-level unique pointers, triple with pointer_default("ref")
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"unique" => 1, "in" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'FUNCTION' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "unique",
+               POINTER_INDEX => 0,
+               LEVEL => 'TOP'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               'IS_DEFERRED' => 1,
+               'LEVEL_INDEX' => 3,
+               'DATA_TYPE' => 'uint8',
+               'CONTAINS_DEFERRED' => 0,
+               'TYPE' => 'DATA',
+               'IS_SURROUNDING' => 0,
+       }
+]);
+
+# Case 4 : top-level ref pointers, triple with pointer_default("ref")
+#
+$e = {
+       'FILE' => 'foo.idl',
+       'NAME' => 'v',
+       'PROPERTIES' => {"ref" => 1},
+       'POINTERS' => 3,
+       'TYPE' => 'uint8',
+       'PARENT' => { TYPE => 'FUNCTION' },
+       'LINE' => 42 };
+
+is_deeply(GetElementLevelTable($e, "ref"), [
+       {
+               LEVEL_INDEX => 0,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 0,
+               LEVEL => 'TOP'
+       },
+       {
+               LEVEL_INDEX => 1,
+               IS_DEFERRED => 0,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 1,
+               LEVEL => 'EMBEDDED'
+       },
+       {
+               LEVEL_INDEX => 2,
+               IS_DEFERRED => 1,
+               TYPE => 'POINTER',
+               POINTER_TYPE => "ref",
+               POINTER_INDEX => 2,
+               LEVEL => 'EMBEDDED'
+       },


-- 
Samba Shared Repository

Reply via email to