From ab2e1394d0a66ca13750e1b6f4ced07f4a0f3453 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 30 Jan 2008 20:25:40 +0100 Subject: [PATCH 01/19] pidl: be consistent and always ask pkg-config only for 'ndr' metze --- source/pidl/tests/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/pidl/tests/Util.pm b/source/pidl/tests/Util.pm index 82ab130e5ae..4ad216a6a10 100644 --- a/source/pidl/tests/Util.pm +++ b/source/pidl/tests/Util.pm @@ -134,7 +134,7 @@ $c $cc = "cc"; } - my $flags = `pkg-config --libs --cflags ndr samba-config`; + my $flags = `pkg-config --libs --cflags ndr`; my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; From fc69e3f829a83aae311b4849d91509fcfa47816b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 30 Jan 2008 20:30:27 +0100 Subject: [PATCH 02/19] libndr: depend on samba-config, so that callers doesn't need to know about it metze --- source/librpc/ndr.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/librpc/ndr.pc.in b/source/librpc/ndr.pc.in index 4317397dc76..ed4c4592144 100644 --- a/source/librpc/ndr.pc.in +++ b/source/librpc/ndr.pc.in @@ -5,7 +5,7 @@ includedir=@includedir@ Name: ndr Description: Network Data Representation Core Library -Requires: talloc +Requires: samba-config talloc Version: 0.0.1 Libs: -L${libdir} -lndr Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 From eb3af24926977208a8099c848a510704d2ae3524 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 31 Jan 2008 09:48:46 +1100 Subject: [PATCH 03/19] merged tdb transaction fix --- source/lib/tdb/common/transaction.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/lib/tdb/common/transaction.c b/source/lib/tdb/common/transaction.c index c3e7a4e2c06..4e2127be644 100644 --- a/source/lib/tdb/common/transaction.c +++ b/source/lib/tdb/common/transaction.c @@ -321,6 +321,9 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off, if (blk == tdb->transaction->num_blocks-1 && off + len > tdb->transaction->last_block_size) { + if (off >= tdb->transaction->last_block_size) { + return 0; + } len = tdb->transaction->last_block_size - off; } From c630bece38eed3278466c2934763fcd8dcfb0610 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 Jan 2008 14:48:15 +0100 Subject: [PATCH 04/19] pidl/Samba4::NDR::Parser: pass down the correct $var_name to AllocateArrayLevel() metze --- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 02d3a809927..9350a1087d1 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -375,7 +375,7 @@ sub ParseArrayPullHeader($$$$$$) } if (not $l->{IS_FIXED} and not is_charset_array($e, $l)) { - $self->AllocateArrayLevel($e,$l,$ndr,$env,$size); + $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size); } return $length; @@ -2058,9 +2058,7 @@ sub ParseFunctionPush($$) sub AllocateArrayLevel($$$$$$) { - my ($self,$e,$l,$ndr,$env,$size) = @_; - - my $var = ParseExpr($e->{NAME}, $env, $e->{ORIGINAL}); + my ($self,$e,$l,$ndr,$var,$size) = @_; my $pl = GetPrevLevel($e, $l); if (defined($pl) and From 2ac47f5ab670f971f41f99700dbfb3655fd6737f Mon Sep 17 00:00:00 2001 From: Amin Azez Date: Thu, 31 Jan 2008 17:04:30 +0000 Subject: [PATCH 05/19] Fix sending of large nttrans responses. req_grow_data was growing the original req, not this_req which was being used for the current fragment. --- source/smb_server/smb/nttrans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/smb_server/smb/nttrans.c b/source/smb_server/smb/nttrans.c index fe65b7a6675..dd2ec15e39c 100644 --- a/source/smb_server/smb/nttrans.c +++ b/source/smb_server/smb/nttrans.c @@ -527,7 +527,7 @@ static void reply_nttrans_send(struct ntvfs_request *ntvfs) this_req = req; } - req_grow_data(req, this_param + this_data + (align1 + align2)); + req_grow_data(this_req, this_param + this_data + (align1 + align2)); SSVAL(this_req->out.vwv, 0, 0); /* reserved */ SCVAL(this_req->out.vwv, 2, 0); /* reserved */ From 74bf021aa7016ace02a0238e71573f18016e3722 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 07:00:50 +0100 Subject: [PATCH 06/19] pidl/Samba4::NDR::Parse: move the calculation of NDR_PULL_SET_MEM_CTX() flags into one function metze --- .../pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 70 +++++++------------ 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 9350a1087d1..2415b516c8e 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -890,15 +890,17 @@ sub CalcNdrFlags($$$) return undef; } -sub ParseMemCtxPullStart($$$$) +sub ParseMemCtxPullFlags($$$$) { - my ($self, $e, $l, $ptr_name) = @_; + my ($self, $e, $l) = @_; - my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}"; - my $mem_c_ctx = $ptr_name; - my $mem_c_flags = "0"; + return undef unless ($l->{TYPE} eq "POINTER" or $l->{TYPE} eq "ARRAY"); - return if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED}); + return undef if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED}); + return undef if has_fast_array($e, $l); + return undef if is_charset_array($e, $l); + + my $mem_flags = "0"; if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) { my $nl = GetNextLevel($e, $l); @@ -906,12 +908,25 @@ sub ParseMemCtxPullStart($$$$) my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); if ($next_is_array or $next_is_string) { - return; + return undef; } else { - $mem_c_flags = "LIBNDR_FLAG_REF_ALLOC"; + $mem_flags = "LIBNDR_FLAG_REF_ALLOC"; } } + return $mem_flags; +} + +sub ParseMemCtxPullStart($$$$) +{ + my ($self, $e, $l, $ptr_name) = @_; + + my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}"; + my $mem_c_ctx = $ptr_name; + my $mem_c_flags = $self->ParseMemCtxPullFlags($e, $l); + + return unless defined($mem_c_flags); + $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX(ndr);"); $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_c_ctx, $mem_c_flags);"); } @@ -921,21 +936,9 @@ sub ParseMemCtxPullEnd($$$) my ($self, $e, $l) = @_; my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}"; - my $mem_r_flags = "0"; + my $mem_r_flags = $self->ParseMemCtxPullFlags($e, $l); - return if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED}); - - if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) { - my $nl = GetNextLevel($e, $l); - my $next_is_array = ($nl->{TYPE} eq "ARRAY"); - my $next_is_string = (($nl->{TYPE} eq "DATA") and - ($nl->{DATA_TYPE} eq "string")); - if ($next_is_array or $next_is_string) { - return; - } else { - $mem_r_flags = "LIBNDR_FLAG_REF_ALLOC"; - } - } + return unless defined($mem_r_flags); $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_r_ctx, $mem_r_flags);"); } @@ -1441,31 +1444,12 @@ sub DeclareArrayVariables($$) } } -sub need_decl_mem_ctx($$) -{ - my ($e,$l) = @_; - - return 0 if has_fast_array($e,$l); - return 0 if is_charset_array($e,$l); - return 1 if (($l->{TYPE} eq "ARRAY") and not $l->{IS_FIXED}); - - if (($l->{TYPE} eq "POINTER") and ($l->{POINTER_TYPE} eq "ref")) { - my $nl = GetNextLevel($e, $l); - my $next_is_array = ($nl->{TYPE} eq "ARRAY"); - my $next_is_string = (($nl->{TYPE} eq "DATA") and - ($nl->{DATA_TYPE} eq "string")); - return 0 if ($next_is_array or $next_is_string); - } - return 1 if ($l->{TYPE} eq "POINTER"); - - return 0; -} - sub DeclareMemCtxVariables($$) { my ($self,$e) = @_; foreach my $l (@{$e->{LEVELS}}) { - if (need_decl_mem_ctx($e, $l)) { + my $mem_flags = $self->ParseMemCtxPullFlags($e, $l); + if (defined($mem_flags)) { $self->pidl("TALLOC_CTX *_mem_save_$e->{NAME}_$l->{LEVEL_INDEX};"); } } From fdf9bcb163516f7d96675ae0dce2917afb8f86d3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 Jan 2008 15:30:50 +0100 Subject: [PATCH 07/19] pidl/IDL: don't strip ',' from the properties content metze --- source/pidl/idl.yp | 7 +- source/pidl/lib/Parse/Pidl/IDL.pm | 941 ++++++++---------- source/pidl/lib/Parse/Pidl/NDR.pm | 2 +- .../pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 12 +- 4 files changed, 447 insertions(+), 515 deletions(-) diff --git a/source/pidl/idl.yp b/source/pidl/idl.yp index d2543c580cf..028b628e18d 100644 --- a/source/pidl/idl.yp +++ b/source/pidl/idl.yp @@ -293,12 +293,7 @@ properties: property { $_[1] } ; property: identifier {{ "$_[1]" => "1" }} - | identifier '(' listtext ')' {{ "$_[1]" => "$_[3]" }} -; - -listtext: - anytext - | listtext ',' anytext { "$_[1] $_[3]" } + | identifier '(' commalisttext ')' {{ "$_[1]" => "$_[3]" }} ; commalisttext: diff --git a/source/pidl/lib/Parse/Pidl/IDL.pm b/source/pidl/lib/Parse/Pidl/IDL.pm index 35e1d7bcd75..aeee69e3063 100644 --- a/source/pidl/lib/Parse/Pidl/IDL.pm +++ b/source/pidl/lib/Parse/Pidl/IDL.pm @@ -124,7 +124,7 @@ sub new { } }, {#State 16 - DEFAULT => -116 + DEFAULT => -114 }, {#State 17 DEFAULT => -11 @@ -184,7 +184,7 @@ sub new { } }, {#State 26 - DEFAULT => -112 + DEFAULT => -110 }, {#State 27 ACTIONS => { @@ -263,17 +263,17 @@ sub new { }, {#State 40 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'text' => 61, - 'listtext' => 57, 'anytext' => 56, - 'constant' => 58 + 'constant' => 57, + 'commalisttext' => 59 } }, {#State 41 @@ -392,28 +392,28 @@ sub new { DEFAULT => -89 }, {#State 57 + DEFAULT => -93 + }, + {#State 58 + DEFAULT => -113 + }, + {#State 59 ACTIONS => { "," => 97, ")" => 98 } }, - {#State 58 - DEFAULT => -95 - }, - {#State 59 - DEFAULT => -115 - }, {#State 60 - DEFAULT => -94 + DEFAULT => -92 }, {#State 61 - DEFAULT => -96 + DEFAULT => -94 }, {#State 62 ACTIONS => { ";" => 99 }, - DEFAULT => -117, + DEFAULT => -115, GOTOS => { 'optional_semicolon' => 100 } @@ -430,7 +430,7 @@ sub new { ACTIONS => { ";" => 99 }, - DEFAULT => -117, + DEFAULT => -115, GOTOS => { 'optional_semicolon' => 102 } @@ -466,7 +466,7 @@ sub new { ACTIONS => { 'IDENTIFIER' => 104 }, - DEFAULT => -114, + DEFAULT => -112, GOTOS => { 'optional_identifier' => 105 } @@ -501,7 +501,7 @@ sub new { ACTIONS => { 'IDENTIFIER' => 104 }, - DEFAULT => -114, + DEFAULT => -112, GOTOS => { 'optional_identifier' => 107 } @@ -516,7 +516,7 @@ sub new { ACTIONS => { 'IDENTIFIER' => 104 }, - DEFAULT => -114, + DEFAULT => -112, GOTOS => { 'optional_identifier' => 108 } @@ -525,7 +525,7 @@ sub new { ACTIONS => { 'IDENTIFIER' => 104 }, - DEFAULT => -114, + DEFAULT => -112, GOTOS => { 'optional_identifier' => 109 } @@ -549,242 +549,242 @@ sub new { }, {#State 82 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 112, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 83 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 113, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 84 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 114, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 85 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 115, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 86 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 116, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 87 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 117, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 88 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 118, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 89 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 119, + 'anytext' => 56, 'text' => 61, - 'constant' => 58, - 'commalisttext' => 120 + 'constant' => 57, + 'commalisttext' => 119 } }, {#State 90 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 121, + 'anytext' => 120, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 91 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 122, + 'anytext' => 121, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 92 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 123, + 'anytext' => 122, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 93 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 119, + 'anytext' => 56, 'text' => 61, - 'constant' => 58, - 'commalisttext' => 124 + 'constant' => 57, + 'commalisttext' => 123 } }, {#State 94 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 125, + 'anytext' => 124, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 95 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 126, + 'anytext' => 125, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 96 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 127, + 'anytext' => 126, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 97 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 128, + 'anytext' => 127, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 98 DEFAULT => -88 }, {#State 99 - DEFAULT => -118 + DEFAULT => -116 }, {#State 100 DEFAULT => -13 }, {#State 101 ACTIONS => { - ";" => 129 + ";" => 128 } }, {#State 102 @@ -795,20 +795,20 @@ sub new { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 130 + 'identifier' => 129 } }, {#State 104 - DEFAULT => -113 + DEFAULT => -111 }, {#State 105 ACTIONS => { - "{" => 132 + "{" => 131 }, DEFAULT => -68, GOTOS => { - 'union_body' => 133, - 'opt_union_body' => 131 + 'union_body' => 132, + 'opt_union_body' => 130 } }, {#State 106 @@ -816,46 +816,46 @@ sub new { }, {#State 107 ACTIONS => { - "{" => 135 + "{" => 134 }, DEFAULT => -58, GOTOS => { - 'struct_body' => 134, - 'opt_struct_body' => 136 + 'struct_body' => 133, + 'opt_struct_body' => 135 } }, {#State 108 ACTIONS => { - "{" => 137 + "{" => 136 }, DEFAULT => -41, GOTOS => { - 'opt_enum_body' => 139, - 'enum_body' => 138 + 'opt_enum_body' => 138, + 'enum_body' => 137 } }, {#State 109 ACTIONS => { - "{" => 141 + "{" => 140 }, DEFAULT => -49, GOTOS => { - 'bitmap_body' => 142, - 'opt_bitmap_body' => 140 + 'bitmap_body' => 141, + 'opt_bitmap_body' => 139 } }, {#State 110 ACTIONS => { - "(" => 143 + "(" => 142 } }, {#State 111 ACTIONS => { 'IDENTIFIER' => 26, - "*" => 145 + "*" => 144 }, GOTOS => { - 'identifier' => 144 + 'identifier' => 143 } }, {#State 112 @@ -876,7 +876,7 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -106 + DEFAULT => -104 }, {#State 113 ACTIONS => { @@ -887,7 +887,7 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -97 + DEFAULT => -95 }, {#State 114 ACTIONS => { @@ -907,7 +907,7 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -101 + DEFAULT => -99 }, {#State 115 ACTIONS => { @@ -927,7 +927,7 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -109 + DEFAULT => -107 }, {#State 116 ACTIONS => { @@ -938,7 +938,7 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -108 + DEFAULT => -106 }, {#State 117 ACTIONS => { @@ -949,7 +949,7 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -99 + DEFAULT => -97 }, {#State 118 ACTIONS => { @@ -969,33 +969,24 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -105 + DEFAULT => -103 }, {#State 119 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -91 + "}" => 145, + "," => 97 + } }, {#State 120 ACTIONS => { - "}" => 146, - "," => 147 - } + ":" => 82, + "<" => 84, + "~" => 85, + "?" => 88, + "{" => 89, + "=" => 92 + }, + DEFAULT => -101 }, {#State 121 ACTIONS => { @@ -1006,20 +997,9 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -103 + DEFAULT => -102 }, {#State 122 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -104 - }, - {#State 123 ACTIONS => { "-" => 83, ":" => 82, @@ -1037,13 +1017,24 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -107 + DEFAULT => -105 + }, + {#State 123 + ACTIONS => { + "," => 97, + ")" => 146 + } }, {#State 124 ACTIONS => { - "," => 147, - ")" => 148 - } + ":" => 82, + "<" => 84, + "~" => 85, + "?" => 88, + "{" => 89, + "=" => 92 + }, + DEFAULT => -100 }, {#State 125 ACTIONS => { @@ -1054,7 +1045,7 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -102 + DEFAULT => -96 }, {#State 126 ACTIONS => { @@ -1068,17 +1059,6 @@ sub new { DEFAULT => -98 }, {#State 127 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -100 - }, - {#State 128 ACTIONS => { "-" => 83, ":" => 82, @@ -1098,221 +1078,207 @@ sub new { }, DEFAULT => -90 }, - {#State 129 + {#State 128 DEFAULT => -15 }, - {#State 130 + {#State 129 ACTIONS => { - "[" => 149 + "[" => 147 }, DEFAULT => -80, GOTOS => { - 'array_len' => 150 + 'array_len' => 148 } }, - {#State 131 + {#State 130 DEFAULT => -70 }, - {#State 132 + {#State 131 DEFAULT => -65, GOTOS => { - 'union_elements' => 151 + 'union_elements' => 149 } }, - {#State 133 + {#State 132 DEFAULT => -69 }, - {#State 134 + {#State 133 DEFAULT => -59 }, - {#State 135 + {#State 134 DEFAULT => -74, GOTOS => { - 'element_list1' => 152 + 'element_list1' => 150 } }, - {#State 136 + {#State 135 DEFAULT => -60 }, - {#State 137 + {#State 136 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 153, - 'enum_element' => 154, - 'enum_elements' => 155 + 'identifier' => 151, + 'enum_element' => 152, + 'enum_elements' => 153 } }, - {#State 138 + {#State 137 DEFAULT => -42 }, - {#State 139 + {#State 138 DEFAULT => -43 }, - {#State 140 + {#State 139 DEFAULT => -51 }, - {#State 141 + {#State 140 ACTIONS => { 'IDENTIFIER' => 26 }, DEFAULT => -54, GOTOS => { - 'identifier' => 158, - 'bitmap_element' => 157, - 'bitmap_elements' => 156, - 'opt_bitmap_elements' => 159 + 'identifier' => 156, + 'bitmap_element' => 155, + 'bitmap_elements' => 154, + 'opt_bitmap_elements' => 157 } }, - {#State 142 + {#State 141 DEFAULT => -50 }, - {#State 143 + {#State 142 ACTIONS => { "," => -76, - "void" => 163, + "void" => 161, ")" => -76 }, DEFAULT => -83, GOTOS => { - 'base_element' => 160, - 'element_list2' => 162, - 'property_list' => 161 + 'base_element' => 158, + 'element_list2' => 160, + 'property_list' => 159 + } + }, + {#State 143 + ACTIONS => { + "[" => 147, + "=" => 163 + }, + GOTOS => { + 'array_len' => 162 } }, {#State 144 - ACTIONS => { - "[" => 149, - "=" => 165 - }, - GOTOS => { - 'array_len' => 164 - } - }, - {#State 145 DEFAULT => -73 }, - {#State 146 + {#State 145 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 166, + 'anytext' => 164, 'text' => 61, - 'constant' => 58 + 'constant' => 57 + } + }, + {#State 146 + ACTIONS => { + 'CONSTANT' => 58, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -91, + GOTOS => { + 'identifier' => 60, + 'anytext' => 165, + 'text' => 61, + 'constant' => 57 } }, {#State 147 ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, + "]" => 166, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 167, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, {#State 148 ACTIONS => { - 'CONSTANT' => 59, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -93, - GOTOS => { - 'identifier' => 60, - 'anytext' => 168, - 'text' => 61, - 'constant' => 58 + ";" => 168 } }, {#State 149 ACTIONS => { - 'CONSTANT' => 59, - 'TEXT' => 16, - "]" => 169, - 'IDENTIFIER' => 26 + "}" => 169 }, - DEFAULT => -93, + DEFAULT => -83, GOTOS => { - 'identifier' => 60, - 'anytext' => 170, - 'text' => 61, - 'constant' => 58 + 'optional_base_element' => 171, + 'property_list' => 170 } }, {#State 150 - ACTIONS => { - ";" => 171 - } - }, - {#State 151 ACTIONS => { "}" => 172 }, DEFAULT => -83, GOTOS => { - 'optional_base_element' => 174, - 'property_list' => 173 + 'base_element' => 173, + 'property_list' => 159 } }, - {#State 152 + {#State 151 ACTIONS => { - "}" => 175 - }, - DEFAULT => -83, - GOTOS => { - 'base_element' => 176, - 'property_list' => 161 - } - }, - {#State 153 - ACTIONS => { - "=" => 177 + "=" => 174 }, DEFAULT => -46 }, - {#State 154 + {#State 152 DEFAULT => -44 }, - {#State 155 + {#State 153 ACTIONS => { - "}" => 178, - "," => 179 + "}" => 175, + "," => 176 } }, - {#State 156 + {#State 154 ACTIONS => { - "," => 180 + "," => 177 }, DEFAULT => -55 }, - {#State 157 + {#State 155 DEFAULT => -52 }, + {#State 156 + ACTIONS => { + "=" => 178 + } + }, + {#State 157 + ACTIONS => { + "}" => 179 + } + }, {#State 158 - ACTIONS => { - "=" => 181 - } - }, - {#State 159 - ACTIONS => { - "}" => 182 - } - }, - {#State 160 DEFAULT => -78 }, - {#State 161 + {#State 159 ACTIONS => { 'IDENTIFIER' => 26, "signed" => 75, @@ -1329,40 +1295,40 @@ sub new { 'identifier' => 72, 'struct' => 49, 'enum' => 52, - 'type' => 183, + 'type' => 180, 'union' => 54, 'sign' => 73 } }, + {#State 160 + ACTIONS => { + "," => 181, + ")" => 182 + } + }, + {#State 161 + DEFAULT => -77 + }, {#State 162 ACTIONS => { - "," => 184, - ")" => 185 + "=" => 183 } }, {#State 163 - DEFAULT => -77 - }, - {#State 164 ACTIONS => { - "=" => 186 - } - }, - {#State 165 - ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 187, + 'anytext' => 184, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, - {#State 166 + {#State 164 ACTIONS => { "-" => 83, ":" => 82, @@ -1380,29 +1346,9 @@ sub new { "." => 95, ">" => 96 }, - DEFAULT => -111 + DEFAULT => -109 }, - {#State 167 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -92 - }, - {#State 168 + {#State 165 ACTIONS => { ":" => 82, "<" => 84, @@ -1411,18 +1357,18 @@ sub new { "{" => 89, "=" => 92 }, - DEFAULT => -110 + DEFAULT => -108 }, - {#State 169 + {#State 166 ACTIONS => { - "[" => 149 + "[" => 147 }, DEFAULT => -80, GOTOS => { - 'array_len' => 188 + 'array_len' => 185 } }, - {#State 170 + {#State 167 ACTIONS => { "-" => 83, ":" => 82, @@ -1438,130 +1384,130 @@ sub new { "(" => 93, "*" => 87, "." => 95, - "]" => 189, + "]" => 186, ">" => 96 } }, - {#State 171 + {#State 168 DEFAULT => -27 }, - {#State 172 + {#State 169 DEFAULT => -67 }, - {#State 173 + {#State 170 ACTIONS => { "[" => 20 }, DEFAULT => -83, GOTOS => { - 'base_or_empty' => 190, - 'base_element' => 191, - 'empty_element' => 192, - 'property_list' => 193 + 'base_or_empty' => 187, + 'base_element' => 188, + 'empty_element' => 189, + 'property_list' => 190 + } + }, + {#State 171 + DEFAULT => -66 + }, + {#State 172 + DEFAULT => -57 + }, + {#State 173 + ACTIONS => { + ";" => 191 } }, {#State 174 - DEFAULT => -66 + ACTIONS => { + 'CONSTANT' => 58, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -91, + GOTOS => { + 'identifier' => 60, + 'anytext' => 192, + 'text' => 61, + 'constant' => 57 + } }, {#State 175 - DEFAULT => -57 + DEFAULT => -40 }, {#State 176 ACTIONS => { - ";" => 194 + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 151, + 'enum_element' => 193 } }, {#State 177 ACTIONS => { - 'CONSTANT' => 59, + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 156, + 'bitmap_element' => 194 + } + }, + {#State 178 + ACTIONS => { + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, 'anytext' => 195, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, - {#State 178 - DEFAULT => -40 - }, {#State 179 - ACTIONS => { - 'IDENTIFIER' => 26 - }, - GOTOS => { - 'identifier' => 153, - 'enum_element' => 196 - } + DEFAULT => -48 }, {#State 180 - ACTIONS => { - 'IDENTIFIER' => 26 - }, + DEFAULT => -72, GOTOS => { - 'identifier' => 158, - 'bitmap_element' => 197 + 'pointers' => 196 } }, {#State 181 - ACTIONS => { - 'CONSTANT' => 59, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -93, + DEFAULT => -83, GOTOS => { - 'identifier' => 60, - 'anytext' => 198, - 'text' => 61, - 'constant' => 58 + 'base_element' => 197, + 'property_list' => 159 } }, {#State 182 - DEFAULT => -48 + ACTIONS => { + ";" => 198 + } }, {#State 183 - DEFAULT => -72, - GOTOS => { - 'pointers' => 199 - } - }, - {#State 184 - DEFAULT => -83, - GOTOS => { - 'base_element' => 200, - 'property_list' => 161 - } - }, - {#State 185 ACTIONS => { - ";" => 201 - } - }, - {#State 186 - ACTIONS => { - 'CONSTANT' => 59, + 'CONSTANT' => 58, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -93, + DEFAULT => -91, GOTOS => { 'identifier' => 60, - 'anytext' => 202, + 'anytext' => 199, 'text' => 61, - 'constant' => 58 + 'constant' => 57 } }, - {#State 187 + {#State 184 ACTIONS => { "-" => 83, ":" => 82, "?" => 88, "<" => 84, - ";" => 203, + ";" => 200, "+" => 86, "~" => 85, "&" => 90, @@ -1575,34 +1521,34 @@ sub new { ">" => 96 } }, - {#State 188 + {#State 185 DEFAULT => -81 }, - {#State 189 + {#State 186 ACTIONS => { - "[" => 149 + "[" => 147 }, DEFAULT => -80, GOTOS => { - 'array_len' => 204 + 'array_len' => 201 } }, - {#State 190 + {#State 187 DEFAULT => -64 }, - {#State 191 + {#State 188 ACTIONS => { - ";" => 205 + ";" => 202 } }, - {#State 192 + {#State 189 DEFAULT => -63 }, - {#State 193 + {#State 190 ACTIONS => { 'IDENTIFIER' => 26, "signed" => 75, - ";" => 206, + ";" => 203, 'void' => 69, "unsigned" => 79, "[" => 20 @@ -1616,15 +1562,15 @@ sub new { 'identifier' => 72, 'struct' => 49, 'enum' => 52, - 'type' => 183, + 'type' => 180, 'union' => 54, 'sign' => 73 } }, - {#State 194 + {#State 191 DEFAULT => -75 }, - {#State 195 + {#State 192 ACTIONS => { "-" => 83, ":" => 82, @@ -1644,13 +1590,13 @@ sub new { }, DEFAULT => -47 }, - {#State 196 + {#State 193 DEFAULT => -45 }, - {#State 197 + {#State 194 DEFAULT => -53 }, - {#State 198 + {#State 195 ACTIONS => { "-" => 83, ":" => 82, @@ -1670,28 +1616,28 @@ sub new { }, DEFAULT => -56 }, - {#State 199 + {#State 196 ACTIONS => { 'IDENTIFIER' => 26, - "*" => 145 + "*" => 144 }, GOTOS => { - 'identifier' => 207 + 'identifier' => 204 } }, - {#State 200 + {#State 197 DEFAULT => -79 }, - {#State 201 + {#State 198 DEFAULT => -26 }, - {#State 202 + {#State 199 ACTIONS => { "-" => 83, ":" => 82, "?" => 88, "<" => 84, - ";" => 208, + ";" => 205, "+" => 86, "~" => 85, "&" => 90, @@ -1705,31 +1651,31 @@ sub new { ">" => 96 } }, - {#State 203 + {#State 200 DEFAULT => -24 }, - {#State 204 + {#State 201 DEFAULT => -82 }, - {#State 205 + {#State 202 DEFAULT => -62 }, - {#State 206 + {#State 203 DEFAULT => -61 }, - {#State 207 + {#State 204 ACTIONS => { - "[" => 149 + "[" => 147 }, DEFAULT => -80, GOTOS => { - 'array_len' => 209 + 'array_len' => 206 } }, - {#State 208 + {#State 205 DEFAULT => -25 }, - {#State 209 + {#State 206 DEFAULT => -71 } ], @@ -1744,43 +1690,43 @@ sub new { [#Rule 2 'idl', 2, sub -#line 19 "idl.yp" +#line 19 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 3 'idl', 2, sub -#line 20 "idl.yp" +#line 20 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 4 'idl', 2, sub -#line 21 "idl.yp" +#line 21 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 5 'idl', 2, sub -#line 22 "idl.yp" +#line 22 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 6 'idl', 2, sub -#line 23 "idl.yp" +#line 23 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 7 'idl', 2, sub -#line 24 "idl.yp" +#line 24 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 8 'import', 3, sub -#line 27 "idl.yp" +#line 27 "pidl/idl.yp" {{ "TYPE" => "IMPORT", "PATHS" => $_[2], @@ -1791,7 +1737,7 @@ sub [#Rule 9 'include', 3, sub -#line 34 "idl.yp" +#line 34 "pidl/idl.yp" {{ "TYPE" => "INCLUDE", "PATHS" => $_[2], @@ -1802,7 +1748,7 @@ sub [#Rule 10 'importlib', 3, sub -#line 41 "idl.yp" +#line 41 "pidl/idl.yp" {{ "TYPE" => "IMPORTLIB", "PATHS" => $_[2], @@ -1813,19 +1759,19 @@ sub [#Rule 11 'commalist', 1, sub -#line 50 "idl.yp" +#line 50 "pidl/idl.yp" { [ $_[1] ] } ], [#Rule 12 'commalist', 3, sub -#line 51 "idl.yp" +#line 51 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 13 'coclass', 7, sub -#line 55 "idl.yp" +#line 55 "pidl/idl.yp" {{ "TYPE" => "COCLASS", "PROPERTIES" => $_[1], @@ -1841,13 +1787,13 @@ sub [#Rule 15 'interface_names', 4, sub -#line 67 "idl.yp" +#line 67 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 16 'interface', 7, sub -#line 71 "idl.yp" +#line 71 "pidl/idl.yp" {{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], @@ -1860,7 +1806,7 @@ sub [#Rule 17 'cpp_quote', 4, sub -#line 82 "idl.yp" +#line 82 "pidl/idl.yp" {{ "TYPE" => "CPP_QUOTE", "FILE" => $_[0]->YYData->{FILE}, @@ -1871,13 +1817,13 @@ sub [#Rule 18 'definitions', 1, sub -#line 91 "idl.yp" +#line 91 "pidl/idl.yp" { [ $_[1] ] } ], [#Rule 19 'definitions', 2, sub -#line 92 "idl.yp" +#line 92 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 20 @@ -1895,7 +1841,7 @@ sub [#Rule 24 'const', 7, sub -#line 100 "idl.yp" +#line 100 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1909,7 +1855,7 @@ sub [#Rule 25 'const', 8, sub -#line 110 "idl.yp" +#line 110 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1924,7 +1870,7 @@ sub [#Rule 26 'function', 7, sub -#line 124 "idl.yp" +#line 124 "pidl/idl.yp" {{ "TYPE" => "FUNCTION", "NAME" => $_[3], @@ -1938,7 +1884,7 @@ sub [#Rule 27 'typedef', 6, sub -#line 136 "idl.yp" +#line 136 "pidl/idl.yp" {{ "TYPE" => "TYPEDEF", "PROPERTIES" => $_[1], @@ -1964,7 +1910,7 @@ sub [#Rule 32 'typedecl', 2, sub -#line 149 "idl.yp" +#line 149 "pidl/idl.yp" { $_[1] } ], [#Rule 33 @@ -1976,7 +1922,7 @@ sub [#Rule 35 'existingtype', 2, sub -#line 154 "idl.yp" +#line 154 "pidl/idl.yp" { ($_[1]?$_[1]:"signed") ." $_[2]" } ], [#Rule 36 @@ -1991,13 +1937,13 @@ sub [#Rule 39 'type', 1, sub -#line 158 "idl.yp" +#line 158 "pidl/idl.yp" { "void" } ], [#Rule 40 'enum_body', 3, sub -#line 160 "idl.yp" +#line 160 "pidl/idl.yp" { $_[2] } ], [#Rule 41 @@ -2009,7 +1955,7 @@ sub [#Rule 43 'enum', 4, sub -#line 163 "idl.yp" +#line 163 "pidl/idl.yp" {{ "TYPE" => "ENUM", "PROPERTIES" => $_[1], @@ -2020,13 +1966,13 @@ sub [#Rule 44 'enum_elements', 1, sub -#line 172 "idl.yp" +#line 172 "pidl/idl.yp" { [ $_[1] ] } ], [#Rule 45 'enum_elements', 3, sub -#line 173 "idl.yp" +#line 173 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 46 @@ -2035,13 +1981,13 @@ sub [#Rule 47 'enum_element', 3, sub -#line 177 "idl.yp" +#line 177 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 48 'bitmap_body', 3, sub -#line 180 "idl.yp" +#line 180 "pidl/idl.yp" { $_[2] } ], [#Rule 49 @@ -2053,7 +1999,7 @@ sub [#Rule 51 'bitmap', 4, sub -#line 183 "idl.yp" +#line 183 "pidl/idl.yp" {{ "TYPE" => "BITMAP", "PROPERTIES" => $_[1], @@ -2064,13 +2010,13 @@ sub [#Rule 52 'bitmap_elements', 1, sub -#line 192 "idl.yp" +#line 192 "pidl/idl.yp" { [ $_[1] ] } ], [#Rule 53 'bitmap_elements', 3, sub -#line 193 "idl.yp" +#line 193 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 54 @@ -2082,13 +2028,13 @@ sub [#Rule 56 'bitmap_element', 3, sub -#line 198 "idl.yp" +#line 198 "pidl/idl.yp" { "$_[1] ( $_[3] )" } ], [#Rule 57 'struct_body', 3, sub -#line 201 "idl.yp" +#line 201 "pidl/idl.yp" { $_[2] } ], [#Rule 58 @@ -2100,7 +2046,7 @@ sub [#Rule 60 'struct', 4, sub -#line 205 "idl.yp" +#line 205 "pidl/idl.yp" {{ "TYPE" => "STRUCT", "PROPERTIES" => $_[1], @@ -2111,7 +2057,7 @@ sub [#Rule 61 'empty_element', 2, sub -#line 214 "idl.yp" +#line 214 "pidl/idl.yp" {{ "NAME" => "", "TYPE" => "EMPTY", @@ -2131,7 +2077,7 @@ sub [#Rule 64 'optional_base_element', 2, sub -#line 228 "idl.yp" +#line 228 "pidl/idl.yp" { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ], [#Rule 65 @@ -2140,13 +2086,13 @@ sub [#Rule 66 'union_elements', 2, sub -#line 233 "idl.yp" +#line 233 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 67 'union_body', 3, sub -#line 236 "idl.yp" +#line 236 "pidl/idl.yp" { $_[2] } ], [#Rule 68 @@ -2158,7 +2104,7 @@ sub [#Rule 70 'union', 4, sub -#line 240 "idl.yp" +#line 240 "pidl/idl.yp" {{ "TYPE" => "UNION", "PROPERTIES" => $_[1], @@ -2169,7 +2115,7 @@ sub [#Rule 71 'base_element', 5, sub -#line 249 "idl.yp" +#line 249 "pidl/idl.yp" {{ "NAME" => $_[4], "TYPE" => $_[2], @@ -2183,25 +2129,25 @@ sub [#Rule 72 'pointers', 0, sub -#line 263 "idl.yp" +#line 263 "pidl/idl.yp" { 0 } ], [#Rule 73 'pointers', 2, sub -#line 264 "idl.yp" +#line 264 "pidl/idl.yp" { $_[1]+1 } ], [#Rule 74 'element_list1', 0, sub -#line 268 "idl.yp" +#line 268 "pidl/idl.yp" { [] } ], [#Rule 75 'element_list1', 3, sub -#line 269 "idl.yp" +#line 269 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 76 @@ -2213,13 +2159,13 @@ sub [#Rule 78 'element_list2', 1, sub -#line 275 "idl.yp" +#line 275 "pidl/idl.yp" { [ $_[1] ] } ], [#Rule 79 'element_list2', 3, sub -#line 276 "idl.yp" +#line 276 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], [#Rule 80 @@ -2228,13 +2174,13 @@ sub [#Rule 81 'array_len', 3, sub -#line 281 "idl.yp" +#line 281 "pidl/idl.yp" { push(@{$_[3]}, "*"); $_[3] } ], [#Rule 82 'array_len', 4, sub -#line 282 "idl.yp" +#line 282 "pidl/idl.yp" { push(@{$_[4]}, "$_[2]"); $_[4] } ], [#Rule 83 @@ -2243,178 +2189,169 @@ sub [#Rule 84 'property_list', 4, sub -#line 288 "idl.yp" +#line 288 "pidl/idl.yp" { FlattenHash([$_[1],$_[3]]); } ], [#Rule 85 'properties', 1, sub -#line 291 "idl.yp" +#line 291 "pidl/idl.yp" { $_[1] } ], [#Rule 86 'properties', 3, sub -#line 292 "idl.yp" +#line 292 "pidl/idl.yp" { FlattenHash([$_[1], $_[3]]); } ], [#Rule 87 'property', 1, sub -#line 295 "idl.yp" +#line 295 "pidl/idl.yp" {{ "$_[1]" => "1" }} ], [#Rule 88 'property', 4, sub -#line 296 "idl.yp" +#line 296 "pidl/idl.yp" {{ "$_[1]" => "$_[3]" }} ], [#Rule 89 - 'listtext', 1, undef - ], - [#Rule 90 - 'listtext', 3, -sub -#line 301 "idl.yp" -{ "$_[1] $_[3]" } - ], - [#Rule 91 'commalisttext', 1, undef ], - [#Rule 92 + [#Rule 90 'commalisttext', 3, sub -#line 306 "idl.yp" +#line 301 "pidl/idl.yp" { "$_[1],$_[3]" } ], - [#Rule 93 + [#Rule 91 'anytext', 0, sub -#line 310 "idl.yp" +#line 305 "pidl/idl.yp" { "" } ], + [#Rule 92 + 'anytext', 1, undef + ], + [#Rule 93 + 'anytext', 1, undef + ], [#Rule 94 'anytext', 1, undef ], [#Rule 95 - 'anytext', 1, undef + 'anytext', 3, +sub +#line 307 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } ], [#Rule 96 - 'anytext', 1, undef + 'anytext', 3, +sub +#line 308 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } ], [#Rule 97 'anytext', 3, sub -#line 312 "idl.yp" +#line 309 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 98 'anytext', 3, sub -#line 313 "idl.yp" +#line 310 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 99 'anytext', 3, sub -#line 314 "idl.yp" +#line 311 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 100 'anytext', 3, sub -#line 315 "idl.yp" +#line 312 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 101 'anytext', 3, sub -#line 316 "idl.yp" +#line 313 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 102 'anytext', 3, sub -#line 317 "idl.yp" +#line 314 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 103 'anytext', 3, sub -#line 318 "idl.yp" +#line 315 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 104 'anytext', 3, sub -#line 319 "idl.yp" +#line 316 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 105 'anytext', 3, sub -#line 320 "idl.yp" +#line 317 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 106 'anytext', 3, sub -#line 321 "idl.yp" +#line 318 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 107 'anytext', 3, sub -#line 322 "idl.yp" +#line 319 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 108 - 'anytext', 3, + 'anytext', 5, sub -#line 323 "idl.yp" -{ "$_[1]$_[2]$_[3]" } +#line 320 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], [#Rule 109 - 'anytext', 3, + 'anytext', 5, sub -#line 324 "idl.yp" -{ "$_[1]$_[2]$_[3]" } +#line 321 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], [#Rule 110 - 'anytext', 5, -sub -#line 325 "idl.yp" -{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } - ], - [#Rule 111 - 'anytext', 5, -sub -#line 326 "idl.yp" -{ "$_[1]$_[2]$_[3]$_[4]$_[5]" } - ], - [#Rule 112 'identifier', 1, undef ], - [#Rule 113 + [#Rule 111 'optional_identifier', 1, undef ], - [#Rule 114 + [#Rule 112 'optional_identifier', 0, undef ], - [#Rule 115 + [#Rule 113 'constant', 1, undef ], - [#Rule 116 + [#Rule 114 'text', 1, sub -#line 340 "idl.yp" +#line 335 "pidl/idl.yp" { "\"$_[1]\"" } ], - [#Rule 117 + [#Rule 115 'optional_semicolon', 0, undef ], - [#Rule 118 + [#Rule 116 'optional_semicolon', 1, undef ] ], @@ -2422,7 +2359,7 @@ sub bless($self,$class); } -#line 351 "idl.yp" +#line 346 "pidl/idl.yp" use Parse::Pidl qw(error); diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm b/source/pidl/lib/Parse/Pidl/NDR.pm index fc6bfe4c96d..5a34c5f94f6 100644 --- a/source/pidl/lib/Parse/Pidl/NDR.pm +++ b/source/pidl/lib/Parse/Pidl/NDR.pm @@ -688,7 +688,7 @@ sub ParseInterface($) if (!defined $idl->{PROPERTIES}->{endpoint}) { push @endpoints, "\"ncacn_np:[\\\\pipe\\\\" . $idl->{NAME} . "]\""; } else { - @endpoints = split / /, $idl->{PROPERTIES}->{endpoint}; + @endpoints = split /,/, $idl->{PROPERTIES}->{endpoint}; } return { diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 2415b516c8e..8326ce5fb60 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -384,7 +384,7 @@ sub ParseArrayPullHeader($$$$$$) sub compression_alg($$) { my ($e, $l) = @_; - my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION}); + my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION}); return $alg; } @@ -392,7 +392,7 @@ sub compression_alg($$) sub compression_clen($$$) { my ($e, $l, $env) = @_; - my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION}); + my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION}); return ParseExpr($clen, $env, $e->{ORIGINAL}); } @@ -400,7 +400,7 @@ sub compression_clen($$$) sub compression_dlen($$$) { my ($e,$l,$env) = @_; - my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION}); + my ($alg, $clen, $dlen) = split(/,/, $l->{COMPRESSION}); return ParseExpr($dlen, $env, $e->{ORIGINAL}); } @@ -830,7 +830,7 @@ sub ParseDataPull($$$$$$$) if (my $range = has_property($e, "range")) { $var_name = get_value_of($var_name); - my ($low, $high) = split(/ /, $range, 2); + my ($low, $high) = split(/,/, $range, 2); $self->pidl("if ($var_name < $low || $var_name > $high) {"); $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");"); $self->pidl("}"); @@ -2218,7 +2218,7 @@ sub FunctionTable($$) $interface->{PROPERTIES}->{authservice} = "\"host\""; } - my @a = split / /, $interface->{PROPERTIES}->{authservice}; + my @a = split /,/, $interface->{PROPERTIES}->{authservice}; my $authservice_count = $#a + 1; $self->pidl("static const char * const $interface->{NAME}\_authservice_strings[] = {"); @@ -2293,7 +2293,7 @@ sub HeaderInterface($$$) } if (defined $interface->{PROPERTIES}->{helper}) { - $self->HeaderInclude(split / /, $interface->{PROPERTIES}->{helper}); + $self->HeaderInclude(split /,/, $interface->{PROPERTIES}->{helper}); } if (defined $interface->{PROPERTIES}->{uuid}) { From 9781967542b00c279563d435aec72dac1e8c7e9a Mon Sep 17 00:00:00 2001 From: Amin Azez Date: Fri, 1 Feb 2008 16:19:36 +0000 Subject: [PATCH 08/19] Samba4 poor mans debug_ctx() DEBUG(), DEBUGADD() and friends can now use debug_ctx() in the formatting expressions again, e.g. DEBUG(5,("Guid failed to match: %s\n", GUID_string(debug_ctx(), r->guid))); Sadly it's done with macros (again) but when we need to save the 8 or 16 bytes of object code per DEBUG() expression we can do it the Samba 3 way with added thread-safety for Samba 4. That could save up to 200K, allowing 12 bytes for each occurrance of DEBUG... Signed-off-by: Amin Azez --- source/lib/util/debug.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/lib/util/debug.h b/source/lib/util/debug.h index 1895ed53adf..605628174a9 100644 --- a/source/lib/util/debug.h +++ b/source/lib/util/debug.h @@ -41,13 +41,17 @@ struct debug_ops { extern int DEBUGLEVEL; +#define debug_ctx() (_debug_ctx?_debug_ctx:(_debug_ctx=talloc_new(NULL))) + #define DEBUGLVL(level) ((level) <= DEBUGLEVEL) #define _DEBUG(level, body, header) do { \ if (DEBUGLVL(level)) { \ + void* _debug_ctx=NULL; \ if (header) { \ do_debug_header(level, __location__, __FUNCTION__); \ } \ do_debug body; \ + talloc_free(_debug_ctx); \ } \ } while (0) /** From 3c191981436ab3f7dd166a87875ffbac127fbdf5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 18:20:32 +0100 Subject: [PATCH 09/19] pidl: cosmetic fix to use the same value everywhere metze --- source/pidl/lib/Parse/Pidl/NDR.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm b/source/pidl/lib/Parse/Pidl/NDR.pm index 5a34c5f94f6..98e8f183a2b 100644 --- a/source/pidl/lib/Parse/Pidl/NDR.pm +++ b/source/pidl/lib/Parse/Pidl/NDR.pm @@ -623,7 +623,7 @@ sub CheckPointerTypes($$) foreach my $e (@{$s->{ELEMENTS}}) { if ($e->{POINTERS} and not defined(pointer_type($e))) { - $e->{PROPERTIES}->{$default} = 1; + $e->{PROPERTIES}->{$default} = '1'; } } } From 3369015f5d8c425e1a9f9d861471028f03f163bb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 09:49:54 +0100 Subject: [PATCH 10/19] CHECKED... pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a function metze --- .../pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 8326ce5fb60..81e8a216259 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -669,23 +669,39 @@ sub ParsePtrPush($$$$) } } +sub need_pointer_to($$$) +{ + my ($e, $l, $scalar_only) = @_; + + my $t; + if (ref($l->{DATA_TYPE})) { + $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; + } else { + $t = $l->{DATA_TYPE}; + } + + if (not Parse::Pidl::Typelist::is_scalar($t)) { + return 1 if $scalar_only; + } + + if (Parse::Pidl::Typelist::scalar_is_reference($t)) { + return 1; + } + + return 0; +} + sub ParseDataPrint($$$$) { my ($self, $e, $l, $var_name) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE})) { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { + + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - $self->pidl("ndr_print_$t(ndr, \"$e->{NAME}\", $var_name);"); + + $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);"); } else { $self->ParseTypePrint($l->{DATA_TYPE}, $var_name); } @@ -815,12 +831,11 @@ sub ParseDataPull($$$$$$$) { my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { + if (need_pointer_to($e, $l, 0)) { $var_name = get_pointer_to($var_name); } @@ -845,21 +860,15 @@ sub ParseDataPush($$$$$$$) my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE}) eq "HASH") { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - + + my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); + # strings are passed by value rather than reference - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - $self->pidl("NDR_CHECK(ndr_push_$t($ndr, $ndr_flags, $var_name));"); + $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); } else { $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred); } From 29c104944bcad30c6a2a3fa70d527bf0ee8969de Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 09:54:25 +0100 Subject: [PATCH 11/19] CHECKED... TODO:MSG pidl/Samba4::NDR::Parser: fix ... metze --- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 81e8a216259..281018d4ccb 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -42,19 +42,21 @@ sub append_prefix($$) { my ($e, $var_name) = @_; my $pointers = 0; + my $arrays = 0; foreach my $l (@{$e->{LEVELS}}) { if ($l->{TYPE} eq "POINTER") { $pointers++; } elsif ($l->{TYPE} eq "ARRAY") { + $arrays++; if (($pointers == 0) and (not $l->{IS_FIXED}) and (not $l->{IS_INLINE})) { - return get_value_of($var_name); + return get_value_of($var_name); } } elsif ($l->{TYPE} eq "DATA") { if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { - return get_value_of($var_name) unless ($pointers); + return get_value_of($var_name) unless ($pointers or $arrays); } } } @@ -684,8 +686,17 @@ sub need_pointer_to($$$) return 1 if $scalar_only; } + my $arrays = 0; + + foreach my $tl (@{$e->{LEVELS}}) { + last if $l == $tl; + if ($tl->{TYPE} eq "ARRAY") { + $arrays++; + } + } + if (Parse::Pidl::Typelist::scalar_is_reference($t)) { - return 1; + return 1 unless $arrays; } return 0; From 13afc89a87716063180723f0e9cb4f76daca837e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 Jan 2008 14:57:35 +0100 Subject: [PATCH 12/19] CHECKED... pidl/Samba4::NDR::Parser: correctly get the name of an array element When we have "*r->out.ous" (char ***ous, a pointer to a pointer to an array). we need to use "(*r->out.ous)[3]" to access the 3rd element of the array "*r->out.ous[3]" was generated before, but that's the same as "*(r->out.ous[3])". metze --- source/pidl/lib/Parse/Pidl/CUtil.pm | 15 ++++++++++++++- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/CUtil.pm b/source/pidl/lib/Parse/Pidl/CUtil.pm index bd7b16812ce..9deb6ee1779 100644 --- a/source/pidl/lib/Parse/Pidl/CUtil.pm +++ b/source/pidl/lib/Parse/Pidl/CUtil.pm @@ -6,7 +6,7 @@ package Parse::Pidl::CUtil; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(get_pointer_to get_value_of); +@EXPORT = qw(get_pointer_to get_value_of get_array_element); use vars qw($VERSION); $VERSION = '0.01'; @@ -36,4 +36,17 @@ sub get_value_of($) } } +sub get_array_element($$) +{ + my ($var_name, $idx) = @_; + + if ($var_name =~ /^\*.*$/) { + $var_name = "($var_name)"; + } elsif ($var_name =~ /^\&.*$/) { + $var_name = "($var_name)"; + } + + return "$var_name"."[$idx]"; +} + 1; diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 281018d4ccb..81a8bf88cde 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -14,7 +14,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); -use Parse::Pidl::CUtil qw(get_pointer_to get_value_of); +use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -584,7 +584,7 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); @@ -779,7 +779,7 @@ sub ParseElementPrint($$$$) $self->pidl("if (idx_$l->{LEVEL_INDEX}) {"); $self->indent; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); } } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPrint($e, $l, $var_name); @@ -1048,7 +1048,7 @@ sub ParseElementPullLevel my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); $self->ParseMemCtxPullStart($e, $l, $array_name); From 0569139ca2960ec5478829c3e66f7ff69bdb55cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 10:30:47 +0100 Subject: [PATCH 13/19] LOOKS OK... 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 --- source/pidl/lib/Parse/Pidl/NDR.pm | 35 ++-- source/pidl/tests/ndr.pl | 289 +++++++++++++++++++++++++++++- 2 files changed, 306 insertions(+), 18 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm b/source/pidl/lib/Parse/Pidl/NDR.pm index 98e8f183a2b..7d8907c6b58 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,25 +157,38 @@ 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 + # + if ($i == 1) { + $pt = pointer_type($e); + } else { + $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")); @@ -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/tests/ndr.pl b/source/pidl/tests/ndr.pl index 7fcc7ef40e6..758c3dddb7b 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 => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + '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 => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + '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 => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + '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 => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + # representation_type $e = { 'FILE' => 'foo.idl', From 6fcf2456d0e81898b5779ef1650f38b4c5363a80 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 23:09:37 +0100 Subject: [PATCH 14/19] WORKS!!!...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 --- source/pidl/lib/Parse/Pidl/NDR.pm | 8 ++++---- source/pidl/tests/ndr.pl | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm b/source/pidl/lib/Parse/Pidl/NDR.pm index 7d8907c6b58..003eaf0ba74 100644 --- a/source/pidl/lib/Parse/Pidl/NDR.pm +++ b/source/pidl/lib/Parse/Pidl/NDR.pm @@ -173,9 +173,9 @@ sub GetElementLevelTable($$) # # --metze # - if ($i == 1) { - $pt = pointer_type($e); - } else { + $pt = pointer_type($e); + if ($i > 1) { + $is_deferred = 1 if ($pt ne "ref" and $e->{PARENT}->{TYPE} eq "FUNCTION"); $pt = $pointer_default; } @@ -195,7 +195,7 @@ sub GetElementLevelTable($$) $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; diff --git a/source/pidl/tests/ndr.pl b/source/pidl/tests/ndr.pl index 758c3dddb7b..504b7ec8ded 100755 --- a/source/pidl/tests/ndr.pl +++ b/source/pidl/tests/ndr.pl @@ -299,14 +299,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -337,7 +337,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 1, @@ -345,14 +345,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -383,7 +383,7 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 1, @@ -391,14 +391,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -437,14 +437,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, From 8ebf16c0741085fa769fcc2929f275ab49b1ea5d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 Jan 2008 15:04:22 +0100 Subject: [PATCH 15/19] Works!!!...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 --- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 81a8bf88cde..6e6d2276818 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) { From 0bcc8e53d1470ba9dfe93e5d6925b8f4c20c7c66 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Feb 2008 11:13:03 +0100 Subject: [PATCH 16/19] pidl: revert changes it didn't want to push...sorry! 8ebf16c0741085fa769fcc2929f275ab49b1ea5d Works!!!...pidl/Samba4::NDR::Parser: fix support for embedded "ref" pointers 6fcf2456d0e81898b5779ef1650f38b4c5363a80 WORKS!!!...pidl/NDR: fix handling of multilevel pointers in function elements 0569139ca2960ec5478829c3e66f7ff69bdb55cd LOOKS OK... pidl: get the pointer types correct when an element has multiple pointe rs 13afc89a87716063180723f0e9cb4f76daca837e CHECKED... pidl/Samba4::NDR::Parser: correctly get the name of an array element 29c104944bcad30c6a2a3fa70d527bf0ee8969de CHECKED... TODO:MSG pidl/Samba4::NDR::Parser: fix ... 3369015f5d8c425e1a9f9d861471028f03f163bb CHECKED... pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a f unction metze --- source/pidl/lib/Parse/Pidl/CUtil.pm | 15 +- source/pidl/lib/Parse/Pidl/NDR.pm | 37 +-- .../pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 96 +++--- source/pidl/tests/ndr.pl | 289 +----------------- 4 files changed, 58 insertions(+), 379 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/CUtil.pm b/source/pidl/lib/Parse/Pidl/CUtil.pm index 9deb6ee1779..bd7b16812ce 100644 --- a/source/pidl/lib/Parse/Pidl/CUtil.pm +++ b/source/pidl/lib/Parse/Pidl/CUtil.pm @@ -6,7 +6,7 @@ package Parse::Pidl::CUtil; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(get_pointer_to get_value_of get_array_element); +@EXPORT = qw(get_pointer_to get_value_of); use vars qw($VERSION); $VERSION = '0.01'; @@ -36,17 +36,4 @@ sub get_value_of($) } } -sub get_array_element($$) -{ - my ($var_name, $idx) = @_; - - if ($var_name =~ /^\*.*$/) { - $var_name = "($var_name)"; - } elsif ($var_name =~ /^\&.*$/) { - $var_name = "($var_name)"; - } - - return "$var_name"."[$idx]"; -} - 1; diff --git a/source/pidl/lib/Parse/Pidl/NDR.pm b/source/pidl/lib/Parse/Pidl/NDR.pm index 003eaf0ba74..98e8f183a2b 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, $pointer_default) = @_; + my $e = shift; my $order = []; my $is_deferred = 0; @@ -157,45 +157,32 @@ 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 ($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; - } + $level = "TOP" if ( defined($pt) + and $i == 1 + and $e->{PARENT}->{TYPE} eq "FUNCTION"); push (@$order, { TYPE => "POINTER", - POINTER_TYPE => $pt, + # for now, there can only be one pointer type per element + POINTER_TYPE => pointer_type($e), 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 $pt ne "ref" and + if ($i == 1 and pointer_type($e) 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 ($level ne "TOP"); + $is_deferred = 1 if ($e->{PARENT}->{TYPE} ne "FUNCTION"); my $array_size = shift @size_is; my $array_length; @@ -404,7 +391,7 @@ sub ParseElement($$) NAME => $e->{NAME}, TYPE => $e->{TYPE}, PROPERTIES => $e->{PROPERTIES}, - LEVELS => GetElementLevelTable($e, $pointer_default), + LEVELS => GetElementLevelTable($e), 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 6e6d2276818..8326ce5fb60 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -14,7 +14,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); -use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); +use Parse::Pidl::CUtil qw(get_pointer_to get_value_of); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -42,21 +42,19 @@ sub append_prefix($$) { my ($e, $var_name) = @_; my $pointers = 0; - my $arrays = 0; foreach my $l (@{$e->{LEVELS}}) { if ($l->{TYPE} eq "POINTER") { $pointers++; } elsif ($l->{TYPE} eq "ARRAY") { - $arrays++; if (($pointers == 0) and (not $l->{IS_FIXED}) and (not $l->{IS_INLINE})) { - return get_value_of($var_name); + return get_value_of($var_name); } } elsif ($l->{TYPE} eq "DATA") { if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { - return get_value_of($var_name) unless ($pointers or $arrays); + return get_value_of($var_name) unless ($pointers); } } } @@ -584,7 +582,7 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; - $var_name = get_array_element($var_name, $counter); + $var_name = $var_name . "[$counter]"; if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); @@ -671,48 +669,23 @@ sub ParsePtrPush($$$$) } } -sub need_pointer_to($$$) -{ - my ($e, $l, $scalar_only) = @_; - - my $t; - if (ref($l->{DATA_TYPE})) { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - - if (not Parse::Pidl::Typelist::is_scalar($t)) { - return 1 if $scalar_only; - } - - my $arrays = 0; - - foreach my $tl (@{$e->{LEVELS}}) { - last if $l == $tl; - if ($tl->{TYPE} eq "ARRAY") { - $arrays++; - } - } - - if (Parse::Pidl::Typelist::scalar_is_reference($t)) { - return 1 unless $arrays; - } - - return 0; -} - sub ParseDataPrint($$$$) { my ($self, $e, $l, $var_name) = @_; - if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { - - if (need_pointer_to($e, $l, 1)) { + if (not ref($l->{DATA_TYPE}) or + defined($l->{DATA_TYPE}->{NAME})) { + my $t; + if (ref($l->{DATA_TYPE})) { + $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; + } else { + $t = $l->{DATA_TYPE}; + } + if (not Parse::Pidl::Typelist::is_scalar($t) or + Parse::Pidl::Typelist::scalar_is_reference($t)) { $var_name = get_pointer_to($var_name); } - - $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);"); + $self->pidl("ndr_print_$t(ndr, \"$e->{NAME}\", $var_name);"); } else { $self->ParseTypePrint($l->{DATA_TYPE}, $var_name); } @@ -779,7 +752,7 @@ sub ParseElementPrint($$$$) $self->pidl("if (idx_$l->{LEVEL_INDEX}) {"); $self->indent; - $var_name = get_array_element($var_name, $counter); + $var_name = $var_name . "[$counter]"; } } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPrint($e, $l, $var_name); @@ -842,11 +815,12 @@ sub ParseDataPull($$$$$$$) { my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; - if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { + if (not ref($l->{DATA_TYPE}) or + defined($l->{DATA_TYPE}->{NAME})) { my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - if (need_pointer_to($e, $l, 0)) { + if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { $var_name = get_pointer_to($var_name); } @@ -871,15 +845,21 @@ sub ParseDataPush($$$$$$$) my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { - - my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - + my $t; + if (ref($l->{DATA_TYPE}) eq "HASH") { + $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; + } else { + $t = $l->{DATA_TYPE}; + } + # strings are passed by value rather than reference - if (need_pointer_to($e, $l, 1)) { + if (not Parse::Pidl::Typelist::is_scalar($t) or + Parse::Pidl::Typelist::scalar_is_reference($t)) { $var_name = get_pointer_to($var_name); } - $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); + my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); + $self->pidl("NDR_CHECK(ndr_push_$t($ndr, $ndr_flags, $var_name));"); } else { $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred); } @@ -929,7 +909,7 @@ sub ParseMemCtxPullFlags($$$$) ($nl->{DATA_TYPE} eq "string")); if ($next_is_array or $next_is_string) { return undef; - } elsif ($l->{LEVEL} eq "TOP") { + } else { $mem_flags = "LIBNDR_FLAG_REF_ALLOC"; } } @@ -1048,7 +1028,7 @@ sub ParseElementPullLevel my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; - $var_name = get_array_element($var_name, $counter); + $var_name = $var_name . "[$counter]"; $self->ParseMemCtxPullStart($e, $l, $array_name); @@ -1129,7 +1109,10 @@ sub ParsePtrPull($$$$$) my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); - if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") { + if ($l->{POINTER_TYPE} eq "ref") { + if ($l->{LEVEL} eq "EMBEDDED") { + $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));"); + } if (!$next_is_array and !$next_is_string) { $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); @@ -1138,19 +1121,16 @@ 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 504b7ec8ded..7fcc7ef40e6 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 => 46; +use Test::More tests => 40; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -22,7 +22,7 @@ my $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, @@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -my $ne = ParseElement($e, "unique"); +my $ne = ParseElement($e, undef); 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, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -90,7 +90,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -128,7 +128,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -147,97 +147,6 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -# 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 # @@ -250,7 +159,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -269,190 +178,6 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -# 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' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - # representation_type $e = { 'FILE' => 'foo.idl', From 26d7f5bf96cd7e950ceb532402afd6b8a58871ea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 09:49:54 +0100 Subject: [PATCH 17/19] pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a function metze --- .../pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 8326ce5fb60..81e8a216259 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -669,23 +669,39 @@ sub ParsePtrPush($$$$) } } +sub need_pointer_to($$$) +{ + my ($e, $l, $scalar_only) = @_; + + my $t; + if (ref($l->{DATA_TYPE})) { + $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; + } else { + $t = $l->{DATA_TYPE}; + } + + if (not Parse::Pidl::Typelist::is_scalar($t)) { + return 1 if $scalar_only; + } + + if (Parse::Pidl::Typelist::scalar_is_reference($t)) { + return 1; + } + + return 0; +} + sub ParseDataPrint($$$$) { my ($self, $e, $l, $var_name) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE})) { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { + + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - $self->pidl("ndr_print_$t(ndr, \"$e->{NAME}\", $var_name);"); + + $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);"); } else { $self->ParseTypePrint($l->{DATA_TYPE}, $var_name); } @@ -815,12 +831,11 @@ sub ParseDataPull($$$$$$$) { my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; - if (not ref($l->{DATA_TYPE}) or - defined($l->{DATA_TYPE}->{NAME})) { + if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { + if (need_pointer_to($e, $l, 0)) { $var_name = get_pointer_to($var_name); } @@ -845,21 +860,15 @@ sub ParseDataPush($$$$$$$) my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_; if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) { - my $t; - if (ref($l->{DATA_TYPE}) eq "HASH") { - $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}"; - } else { - $t = $l->{DATA_TYPE}; - } - + + my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); + # strings are passed by value rather than reference - if (not Parse::Pidl::Typelist::is_scalar($t) or - Parse::Pidl::Typelist::scalar_is_reference($t)) { + if (need_pointer_to($e, $l, 1)) { $var_name = get_pointer_to($var_name); } - my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); - $self->pidl("NDR_CHECK(ndr_push_$t($ndr, $ndr_flags, $var_name));"); + $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));"); } else { $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred); } From 7c7acae817cd00ab5c915742338b019af79e9193 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 09:54:25 +0100 Subject: [PATCH 18/19] pidl/Samba4::NDR::Parser: fix $var_name for arrays of scalar reference types uint32 num; nstring strings[num]; this should use 'r->strings' instead of '*r->strings' as the pointer to the array. metze --- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 81e8a216259..281018d4ccb 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -42,19 +42,21 @@ sub append_prefix($$) { my ($e, $var_name) = @_; my $pointers = 0; + my $arrays = 0; foreach my $l (@{$e->{LEVELS}}) { if ($l->{TYPE} eq "POINTER") { $pointers++; } elsif ($l->{TYPE} eq "ARRAY") { + $arrays++; if (($pointers == 0) and (not $l->{IS_FIXED}) and (not $l->{IS_INLINE})) { - return get_value_of($var_name); + return get_value_of($var_name); } } elsif ($l->{TYPE} eq "DATA") { if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) { - return get_value_of($var_name) unless ($pointers); + return get_value_of($var_name) unless ($pointers or $arrays); } } } @@ -684,8 +686,17 @@ sub need_pointer_to($$$) return 1 if $scalar_only; } + my $arrays = 0; + + foreach my $tl (@{$e->{LEVELS}}) { + last if $l == $tl; + if ($tl->{TYPE} eq "ARRAY") { + $arrays++; + } + } + if (Parse::Pidl::Typelist::scalar_is_reference($t)) { - return 1; + return 1 unless $arrays; } return 0; From ec0ee2aa5f4bef32f09a426d91c28c985f843038 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 Jan 2008 14:57:35 +0100 Subject: [PATCH 19/19] pidl/Samba4::NDR::Parser: correctly get the name of an array element When we have "*r->out.ous" (char ***ous, a pointer to a pointer to an array of pointers). we need to use "(*r->out.ous)[3]" to access the 3rd element of the array "*r->out.ous[3]" was generated before, but that's the same as "*(r->out.ous[3])" which would mean the array would apply to a different level. This patch prepares support for: [out,ref,size_is(,num)] [string,charset(UTF16)] uint16 ***names; It means a [ref] pointer to a [unique] pointer to an array of [unique] pointers which point to an UTF16 string. metze --- source/pidl/lib/Parse/Pidl/CUtil.pm | 15 ++++++++++++++- source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source/pidl/lib/Parse/Pidl/CUtil.pm b/source/pidl/lib/Parse/Pidl/CUtil.pm index bd7b16812ce..9deb6ee1779 100644 --- a/source/pidl/lib/Parse/Pidl/CUtil.pm +++ b/source/pidl/lib/Parse/Pidl/CUtil.pm @@ -6,7 +6,7 @@ package Parse::Pidl::CUtil; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(get_pointer_to get_value_of); +@EXPORT = qw(get_pointer_to get_value_of get_array_element); use vars qw($VERSION); $VERSION = '0.01'; @@ -36,4 +36,17 @@ sub get_value_of($) } } +sub get_array_element($$) +{ + my ($var_name, $idx) = @_; + + if ($var_name =~ /^\*.*$/) { + $var_name = "($var_name)"; + } elsif ($var_name =~ /^\&.*$/) { + $var_name = "($var_name)"; + } + + return "$var_name"."[$idx]"; +} + 1; diff --git a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 281018d4ccb..81a8bf88cde 100644 --- a/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -14,7 +14,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); -use Parse::Pidl::CUtil qw(get_pointer_to get_value_of); +use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -584,7 +584,7 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); @@ -779,7 +779,7 @@ sub ParseElementPrint($$$$) $self->pidl("if (idx_$l->{LEVEL_INDEX}) {"); $self->indent; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); } } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPrint($e, $l, $var_name); @@ -1048,7 +1048,7 @@ sub ParseElementPullLevel my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); $self->ParseMemCtxPullStart($e, $l, $array_name);