1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

r21681: Fix bug in the parsing code that parsed "struct foo;" the same as

"struct foo {};".

Reported by one of the OpenChange folks, thanks!
(This used to be commit d65b520f08ea4ee82c35ff334a58aa6ffc403d67)
This commit is contained in:
Jelmer Vernooij 2007-03-04 14:16:52 +00:00 committed by Gerald (Jerry) Carter
parent 1ec8f79bae
commit 035adfb943
6 changed files with 1247 additions and 1264 deletions

View File

@ -1,5 +1,3 @@
- allow [public] on typedefs only
- EJS output backend shouldn't use the NDR levels stuff but instead
as the "C levels" and NDR levels don't necessarily match.
@ -8,14 +6,19 @@
- compatibility mode for generating MIDL-readable data:
- strip out pidl-specific properties
- remove declare in favor of typedef
- make bitmap an optional attribute on enum
- support nested elements
- support typedefs properly
- improve represent_as(): allow it to be used for arrays and other complex
types
- support typedefs properly (e.g. allow "typedef void **bla;")
- make typedefs generate real typedefs
- improve represent_as(): allow it to be used for arrays and other complex
types
- --explain-ndr option that dumps out parse tree ?
- seperate tables for NDR and DCE/RPC
- maybe no tables for NDR at all? we only need them for ndrdump
and that can use dlsym()
- allow data structures outside of interfaces

View File

@ -66,23 +66,17 @@ interface_names:
| interface_names 'interface' identifier ';' { push(@{$_[1]}, $_[2]); $_[1] }
;
interface: property_list 'interface' identifier base_interface '{' definitions '}' optional_semicolon
interface: property_list 'interface' identifier '{' definitions '}' optional_semicolon
{{
"TYPE" => "INTERFACE",
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"BASE" => $_[4],
"DATA" => $_[6],
"DATA" => $_[5],
"FILE" => $_[0]->YYData->{FILE},
"LINE" => $_[0]->YYData->{LINE},
}}
;
base_interface:
#empty
| ':' identifier { $_[2] }
;
definitions:
definition { [ $_[1] ] }
| definitions definition { push(@{$_[1]}, $_[2]); $_[1] }
@ -293,7 +287,7 @@ pointers:
;
element_list1:
#empty
{ [] }
| element_list1 base_element ';' { push(@{$_[1]}, $_[2]); $_[1] }
;
@ -407,10 +401,6 @@ sub CleanData($)
if (ref($v) eq "ARRAY") {
foreach my $i (0 .. $#{$v}) {
CleanData($v->[$i]);
if (ref($v->[$i]) eq "ARRAY" && $#{$v->[$i]}==-1) {
$v->[$i] = undef;
next;
}
}
# this removes any undefined elements from the array
@{$v} = grep { defined $_ } @{$v};
@ -418,7 +408,6 @@ sub CleanData($)
foreach my $x (keys %{$v}) {
CleanData($v->{$x});
if (!defined $v->{$x}) { delete($v->{$x}); next; }
if (ref($v->{$x}) eq "ARRAY" && $#{$v->{$x}}==-1) { delete($v->{$x}); next; }
}
}
return $v;

File diff suppressed because it is too large Load Diff

View File

@ -271,10 +271,13 @@ sub GetElementLevelTable($)
#####################################################################
# see if a type contains any deferred data
sub can_contain_deferred
sub can_contain_deferred($)
{
sub can_contain_deferred($);
my $e = shift;
print "$e->{NAME}\n";
return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE}));
return 1 unless (hasType($e->{TYPE})); # assume the worst

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use Test::More tests => 12;
use Test::More tests => 14;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@ -42,3 +42,9 @@ like(parse_idl("interface p { struct x { struct y z; }; };"),
like(parse_idl("interface p { struct x { union y z; }; };"),
qr/struct x.*{.*union y z;.*}.*;/sm, "tagged type union member");
like(parse_idl("interface p { struct x { }; };"),
qr/struct x.*{.*char _empty_;.*}.*;/sm, "empty struct");
like(parse_idl("interface p { struct x; };"),
qr/struct x;/sm, "struct declaration");

View File

@ -4,7 +4,7 @@
# Published under the GNU General Public License
use strict;
use Test::More tests => 62 * 2;
use Test::More tests => 63 * 2 + 2;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_errors);
@ -107,3 +107,17 @@ testfail "import-nosemicolon", "import \"foo.idl\"",
"<import-nosemicolon>:0: Syntax error near 'foo.idl'\n";
testok "import-multiple", "import \"foo.idl\", \"bar.idl\";";
testok "include-multiple", "include \"foo.idl\", \"bar.idl\";";
testok "empty-struct", "interface test { struct foo { }; }";
my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", "<foo>");
is_deeply($x,
[ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
{ 'NAME' => 'x', 'TYPE' => 'STRUCT', ELEMENTS => [] } ],
'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
$x = Parse::Pidl::IDL::parse_string("interface foo { struct x; }", "<foo>");
is_deeply($x,
[ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
{ 'NAME' => 'x', 'TYPE' => 'STRUCT' } ],
'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);