mirror of
https://github.com/samba-team/samba.git
synced 2025-02-24 13:57:43 +03:00
r21430: Support tagged types without typedef. This means:
struct foo { ... }; in IDL will now work. This is the first step towards nested types and using typedefs for partial types (such as "typedef int *bar;"), a requirement for complex uses of represent_as().
This commit is contained in:
parent
88fbf9af24
commit
a716aa70f0
@ -7,10 +7,11 @@
|
|||||||
- strip out pidl-specific properties
|
- strip out pidl-specific properties
|
||||||
|
|
||||||
- support nested elements
|
- support nested elements
|
||||||
- generate names for anonymous tagged types
|
- allow non-typedef structs
|
||||||
|
- generate names for anonymous tagged types. Simple MD5Sum of contents?
|
||||||
- support typedefs properly
|
- support typedefs properly
|
||||||
|
- improve represent_as(): allow it to be used for arrays and other complex
|
||||||
- improve represent_as(): allow it to be used for arrays and other complex types
|
types
|
||||||
|
|
||||||
- --explain-ndr option that dumps out parse tree ?
|
- --explain-ndr option that dumps out parse tree ?
|
||||||
|
|
||||||
|
@ -160,10 +160,10 @@ decl_union: 'union'
|
|||||||
}}
|
}}
|
||||||
;
|
;
|
||||||
|
|
||||||
typedef: 'typedef' property_list type identifier array_len ';'
|
typedef: property_list 'typedef' type identifier array_len ';'
|
||||||
{{
|
{{
|
||||||
"TYPE" => "TYPEDEF",
|
"TYPE" => "TYPEDEF",
|
||||||
"PROPERTIES" => $_[2],
|
"PROPERTIES" => $_[1],
|
||||||
"NAME" => $_[4],
|
"NAME" => $_[4],
|
||||||
"DATA" => $_[3],
|
"DATA" => $_[3],
|
||||||
"ARRAY_LEN" => $_[5],
|
"ARRAY_LEN" => $_[5],
|
||||||
@ -187,11 +187,12 @@ type: usertype | existingtype | void { "void" } ;
|
|||||||
|
|
||||||
enum_body: '{' enum_elements '}' { $_[2] };
|
enum_body: '{' enum_elements '}' { $_[2] };
|
||||||
opt_enum_body: | enum_body;
|
opt_enum_body: | enum_body;
|
||||||
enum: 'enum' optional_identifier opt_enum_body
|
enum: property_list 'enum' optional_identifier opt_enum_body
|
||||||
{{
|
{{
|
||||||
"TYPE" => "ENUM",
|
"TYPE" => "ENUM",
|
||||||
"NAME" => $_[2],
|
"PROPERTIES" => $_[1],
|
||||||
"ELEMENTS" => $_[3]
|
"NAME" => $_[3],
|
||||||
|
"ELEMENTS" => $_[4]
|
||||||
}}
|
}}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -206,11 +207,12 @@ enum_element: identifier
|
|||||||
|
|
||||||
bitmap_body: '{' opt_bitmap_elements '}' { $_[2] };
|
bitmap_body: '{' opt_bitmap_elements '}' { $_[2] };
|
||||||
opt_bitmap_body: | bitmap_body;
|
opt_bitmap_body: | bitmap_body;
|
||||||
bitmap: 'bitmap' optional_identifier opt_bitmap_body
|
bitmap: property_list 'bitmap' optional_identifier opt_bitmap_body
|
||||||
{{
|
{{
|
||||||
"TYPE" => "BITMAP",
|
"TYPE" => "BITMAP",
|
||||||
"NAME" => $_[2],
|
"PROPERTIES" => $_[1],
|
||||||
"ELEMENTS" => $_[3]
|
"NAME" => $_[3],
|
||||||
|
"ELEMENTS" => $_[4]
|
||||||
}}
|
}}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -227,11 +229,12 @@ bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" }
|
|||||||
struct_body: '{' element_list1 '}' { $_[2] };
|
struct_body: '{' element_list1 '}' { $_[2] };
|
||||||
opt_struct_body: | struct_body;
|
opt_struct_body: | struct_body;
|
||||||
|
|
||||||
struct: 'struct' optional_identifier opt_struct_body
|
struct: property_list 'struct' optional_identifier opt_struct_body
|
||||||
{{
|
{{
|
||||||
"TYPE" => "STRUCT",
|
"TYPE" => "STRUCT",
|
||||||
"NAME" => $_[2],
|
"PROPERTIES" => $_[1],
|
||||||
"ELEMENTS" => $_[3]
|
"NAME" => $_[3],
|
||||||
|
"ELEMENTS" => $_[4]
|
||||||
}}
|
}}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -261,11 +264,12 @@ union_elements:
|
|||||||
union_body: '{' union_elements '}' { $_[2] };
|
union_body: '{' union_elements '}' { $_[2] };
|
||||||
opt_union_body: | union_body;
|
opt_union_body: | union_body;
|
||||||
|
|
||||||
union: 'union' optional_identifier opt_union_body
|
union: property_list 'union' optional_identifier opt_union_body
|
||||||
{{
|
{{
|
||||||
"TYPE" => "UNION",
|
"TYPE" => "UNION",
|
||||||
"NAME" => $_[2],
|
"PROPERTIES" => $_[1],
|
||||||
"ELEMENTS" => $_[3]
|
"NAME" => $_[3],
|
||||||
|
"ELEMENTS" => $_[4]
|
||||||
}}
|
}}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -1127,7 +1127,7 @@ sub new {
|
|||||||
[#Rule 2
|
[#Rule 2
|
||||||
'exp', 1,
|
'exp', 1,
|
||||||
sub
|
sub
|
||||||
#line 22 "expr.yp"
|
#line 22 "pidl/expr.yp"
|
||||||
{ "\"$_[1]\"" }
|
{ "\"$_[1]\"" }
|
||||||
],
|
],
|
||||||
[#Rule 3
|
[#Rule 3
|
||||||
@ -1139,199 +1139,199 @@ sub
|
|||||||
[#Rule 5
|
[#Rule 5
|
||||||
'exp', 2,
|
'exp', 2,
|
||||||
sub
|
sub
|
||||||
#line 25 "expr.yp"
|
#line 25 "pidl/expr.yp"
|
||||||
{ "~$_[2]" }
|
{ "~$_[2]" }
|
||||||
],
|
],
|
||||||
[#Rule 6
|
[#Rule 6
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 26 "expr.yp"
|
#line 26 "pidl/expr.yp"
|
||||||
{ "$_[1] + $_[3]" }
|
{ "$_[1] + $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 7
|
[#Rule 7
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 27 "expr.yp"
|
#line 27 "pidl/expr.yp"
|
||||||
{ "$_[1] - $_[3]" }
|
{ "$_[1] - $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 8
|
[#Rule 8
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 28 "expr.yp"
|
#line 28 "pidl/expr.yp"
|
||||||
{ "$_[1] * $_[3]" }
|
{ "$_[1] * $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 9
|
[#Rule 9
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 29 "expr.yp"
|
#line 29 "pidl/expr.yp"
|
||||||
{ "$_[1] % $_[3]" }
|
{ "$_[1] % $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 10
|
[#Rule 10
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 30 "expr.yp"
|
#line 30 "pidl/expr.yp"
|
||||||
{ "$_[1] < $_[3]" }
|
{ "$_[1] < $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 11
|
[#Rule 11
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 31 "expr.yp"
|
#line 31 "pidl/expr.yp"
|
||||||
{ "$_[1] > $_[3]" }
|
{ "$_[1] > $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 12
|
[#Rule 12
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 32 "expr.yp"
|
#line 32 "pidl/expr.yp"
|
||||||
{ "$_[1] | $_[3]" }
|
{ "$_[1] | $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 13
|
[#Rule 13
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 33 "expr.yp"
|
#line 33 "pidl/expr.yp"
|
||||||
{ "$_[1] == $_[3]" }
|
{ "$_[1] == $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 14
|
[#Rule 14
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 34 "expr.yp"
|
#line 34 "pidl/expr.yp"
|
||||||
{ "$_[1] <= $_[3]" }
|
{ "$_[1] <= $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 15
|
[#Rule 15
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 35 "expr.yp"
|
#line 35 "pidl/expr.yp"
|
||||||
{ "$_[1] => $_[3]" }
|
{ "$_[1] => $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 16
|
[#Rule 16
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 36 "expr.yp"
|
#line 36 "pidl/expr.yp"
|
||||||
{ "$_[1] << $_[3]" }
|
{ "$_[1] << $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 17
|
[#Rule 17
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 37 "expr.yp"
|
#line 37 "pidl/expr.yp"
|
||||||
{ "$_[1] >> $_[3]" }
|
{ "$_[1] >> $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 18
|
[#Rule 18
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 38 "expr.yp"
|
#line 38 "pidl/expr.yp"
|
||||||
{ "$_[1] != $_[3]" }
|
{ "$_[1] != $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 19
|
[#Rule 19
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 39 "expr.yp"
|
#line 39 "pidl/expr.yp"
|
||||||
{ "$_[1] || $_[3]" }
|
{ "$_[1] || $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 20
|
[#Rule 20
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 40 "expr.yp"
|
#line 40 "pidl/expr.yp"
|
||||||
{ "$_[1] && $_[3]" }
|
{ "$_[1] && $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 21
|
[#Rule 21
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 41 "expr.yp"
|
#line 41 "pidl/expr.yp"
|
||||||
{ "$_[1] & $_[3]" }
|
{ "$_[1] & $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 22
|
[#Rule 22
|
||||||
'exp', 5,
|
'exp', 5,
|
||||||
sub
|
sub
|
||||||
#line 42 "expr.yp"
|
#line 42 "pidl/expr.yp"
|
||||||
{ "$_[1]?$_[3]:$_[5]" }
|
{ "$_[1]?$_[3]:$_[5]" }
|
||||||
],
|
],
|
||||||
[#Rule 23
|
[#Rule 23
|
||||||
'exp', 2,
|
'exp', 2,
|
||||||
sub
|
sub
|
||||||
#line 43 "expr.yp"
|
#line 43 "pidl/expr.yp"
|
||||||
{ "~$_[1]" }
|
{ "~$_[1]" }
|
||||||
],
|
],
|
||||||
[#Rule 24
|
[#Rule 24
|
||||||
'exp', 2,
|
'exp', 2,
|
||||||
sub
|
sub
|
||||||
#line 44 "expr.yp"
|
#line 44 "pidl/expr.yp"
|
||||||
{ "not $_[1]" }
|
{ "not $_[1]" }
|
||||||
],
|
],
|
||||||
[#Rule 25
|
[#Rule 25
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 45 "expr.yp"
|
#line 45 "pidl/expr.yp"
|
||||||
{ "$_[1] / $_[3]" }
|
{ "$_[1] / $_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 26
|
[#Rule 26
|
||||||
'exp', 2,
|
'exp', 2,
|
||||||
sub
|
sub
|
||||||
#line 46 "expr.yp"
|
#line 46 "pidl/expr.yp"
|
||||||
{ "-$_[2]" }
|
{ "-$_[2]" }
|
||||||
],
|
],
|
||||||
[#Rule 27
|
[#Rule 27
|
||||||
'exp', 2,
|
'exp', 2,
|
||||||
sub
|
sub
|
||||||
#line 47 "expr.yp"
|
#line 47 "pidl/expr.yp"
|
||||||
{ "&$_[2]" }
|
{ "&$_[2]" }
|
||||||
],
|
],
|
||||||
[#Rule 28
|
[#Rule 28
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 48 "expr.yp"
|
#line 48 "pidl/expr.yp"
|
||||||
{ "$_[1]^$_[3]" }
|
{ "$_[1]^$_[3]" }
|
||||||
],
|
],
|
||||||
[#Rule 29
|
[#Rule 29
|
||||||
'exp', 3,
|
'exp', 3,
|
||||||
sub
|
sub
|
||||||
#line 49 "expr.yp"
|
#line 49 "pidl/expr.yp"
|
||||||
{ "($_[2])" }
|
{ "($_[2])" }
|
||||||
],
|
],
|
||||||
[#Rule 30
|
[#Rule 30
|
||||||
'possible_pointer', 1,
|
'possible_pointer', 1,
|
||||||
sub
|
sub
|
||||||
#line 53 "expr.yp"
|
#line 53 "pidl/expr.yp"
|
||||||
{ $_[0]->_Lookup($_[1]) }
|
{ $_[0]->_Lookup($_[1]) }
|
||||||
],
|
],
|
||||||
[#Rule 31
|
[#Rule 31
|
||||||
'possible_pointer', 2,
|
'possible_pointer', 2,
|
||||||
sub
|
sub
|
||||||
#line 54 "expr.yp"
|
#line 54 "pidl/expr.yp"
|
||||||
{ $_[0]->_Dereference($_[2]); "*$_[2]" }
|
{ $_[0]->_Dereference($_[2]); "*$_[2]" }
|
||||||
],
|
],
|
||||||
[#Rule 32
|
[#Rule 32
|
||||||
'var', 1,
|
'var', 1,
|
||||||
sub
|
sub
|
||||||
#line 57 "expr.yp"
|
#line 57 "pidl/expr.yp"
|
||||||
{ $_[0]->_Use($_[1]) }
|
{ $_[0]->_Use($_[1]) }
|
||||||
],
|
],
|
||||||
[#Rule 33
|
[#Rule 33
|
||||||
'var', 3,
|
'var', 3,
|
||||||
sub
|
sub
|
||||||
#line 58 "expr.yp"
|
#line 58 "pidl/expr.yp"
|
||||||
{ $_[0]->_Use("$_[1].$_[3]") }
|
{ $_[0]->_Use("$_[1].$_[3]") }
|
||||||
],
|
],
|
||||||
[#Rule 34
|
[#Rule 34
|
||||||
'var', 3,
|
'var', 3,
|
||||||
sub
|
sub
|
||||||
#line 59 "expr.yp"
|
#line 59 "pidl/expr.yp"
|
||||||
{ "($_[2])" }
|
{ "($_[2])" }
|
||||||
],
|
],
|
||||||
[#Rule 35
|
[#Rule 35
|
||||||
'var', 3,
|
'var', 3,
|
||||||
sub
|
sub
|
||||||
#line 60 "expr.yp"
|
#line 60 "pidl/expr.yp"
|
||||||
{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
|
{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] }
|
||||||
],
|
],
|
||||||
[#Rule 36
|
[#Rule 36
|
||||||
'func', 4,
|
'func', 4,
|
||||||
sub
|
sub
|
||||||
#line 64 "expr.yp"
|
#line 64 "pidl/expr.yp"
|
||||||
{ "$_[1]($_[3])" }
|
{ "$_[1]($_[3])" }
|
||||||
],
|
],
|
||||||
[#Rule 37
|
[#Rule 37
|
||||||
'opt_args', 0,
|
'opt_args', 0,
|
||||||
sub
|
sub
|
||||||
#line 65 "expr.yp"
|
#line 65 "pidl/expr.yp"
|
||||||
{ "" }
|
{ "" }
|
||||||
],
|
],
|
||||||
[#Rule 38
|
[#Rule 38
|
||||||
@ -1349,7 +1349,7 @@ sub
|
|||||||
[#Rule 42
|
[#Rule 42
|
||||||
'args', 3,
|
'args', 3,
|
||||||
sub
|
sub
|
||||||
#line 68 "expr.yp"
|
#line 68 "pidl/expr.yp"
|
||||||
{ "$_[1], $_[3]" }
|
{ "$_[1], $_[3]" }
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -1357,7 +1357,7 @@ sub
|
|||||||
bless($self,$class);
|
bless($self,$class);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 71 "expr.yp"
|
#line 71 "pidl/expr.yp"
|
||||||
|
|
||||||
|
|
||||||
package Parse::Pidl::Expr;
|
package Parse::Pidl::Expr;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -383,6 +383,7 @@ sub ParseStruct($$)
|
|||||||
my @elements = ();
|
my @elements = ();
|
||||||
my $surrounding = undef;
|
my $surrounding = undef;
|
||||||
|
|
||||||
|
|
||||||
foreach my $x (@{$struct->{ELEMENTS}})
|
foreach my $x (@{$struct->{ELEMENTS}})
|
||||||
{
|
{
|
||||||
my $e = ParseElement($x);
|
my $e = ParseElement($x);
|
||||||
@ -403,13 +404,20 @@ sub ParseStruct($$)
|
|||||||
&& property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) {
|
&& property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) {
|
||||||
$surrounding = $struct->{ELEMENTS}[-1];
|
$surrounding = $struct->{ELEMENTS}[-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $align = undef;
|
||||||
|
if ($struct->{NAME}) {
|
||||||
|
$align = align_type($struct->{NAME});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
TYPE => "STRUCT",
|
TYPE => "STRUCT",
|
||||||
|
NAME => $struct->{NAME},
|
||||||
SURROUNDING_ELEMENT => $surrounding,
|
SURROUNDING_ELEMENT => $surrounding,
|
||||||
ELEMENTS => \@elements,
|
ELEMENTS => \@elements,
|
||||||
PROPERTIES => $struct->{PROPERTIES},
|
PROPERTIES => $struct->{PROPERTIES},
|
||||||
ORIGINAL => $struct
|
ORIGINAL => $struct,
|
||||||
|
ALIGN => $align
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,6 +452,7 @@ sub ParseUnion($$)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
TYPE => "UNION",
|
TYPE => "UNION",
|
||||||
|
NAME => $e->{NAME},
|
||||||
SWITCH_TYPE => $switch_type,
|
SWITCH_TYPE => $switch_type,
|
||||||
ELEMENTS => \@elements,
|
ELEMENTS => \@elements,
|
||||||
PROPERTIES => $e->{PROPERTIES},
|
PROPERTIES => $e->{PROPERTIES},
|
||||||
@ -458,6 +467,7 @@ sub ParseEnum($$)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
TYPE => "ENUM",
|
TYPE => "ENUM",
|
||||||
|
NAME => $e->{NAME},
|
||||||
BASE_TYPE => Parse::Pidl::Typelist::enum_type_fn($e),
|
BASE_TYPE => Parse::Pidl::Typelist::enum_type_fn($e),
|
||||||
ELEMENTS => $e->{ELEMENTS},
|
ELEMENTS => $e->{ELEMENTS},
|
||||||
PROPERTIES => $e->{PROPERTIES},
|
PROPERTIES => $e->{PROPERTIES},
|
||||||
@ -471,6 +481,7 @@ sub ParseBitmap($$)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
TYPE => "BITMAP",
|
TYPE => "BITMAP",
|
||||||
|
NAME => $e->{NAME},
|
||||||
BASE_TYPE => Parse::Pidl::Typelist::bitmap_type_fn($e),
|
BASE_TYPE => Parse::Pidl::Typelist::bitmap_type_fn($e),
|
||||||
ELEMENTS => $e->{ELEMENTS},
|
ELEMENTS => $e->{ELEMENTS},
|
||||||
PROPERTIES => $e->{PROPERTIES},
|
PROPERTIES => $e->{PROPERTIES},
|
||||||
@ -501,8 +512,8 @@ sub ParseTypedef($$)
|
|||||||
{
|
{
|
||||||
my ($ndr,$d) = @_;
|
my ($ndr,$d) = @_;
|
||||||
|
|
||||||
if (defined($d->{PROPERTIES}) && !defined($d->{DATA}->{PROPERTIES})) {
|
if (defined($d->{DATA}->{PROPERTIES}) && !defined($d->{PROPERTIES})) {
|
||||||
$d->{DATA}->{PROPERTIES} = $d->{PROPERTIES};
|
$d->{PROPERTIES} = $d->{DATA}->{PROPERTIES};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $data = ParseType($ndr, $d->{DATA});
|
my $data = ParseType($ndr, $d->{DATA});
|
||||||
@ -865,7 +876,7 @@ sub mapToScalar($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a struct
|
# validate an element
|
||||||
sub ValidElement($)
|
sub ValidElement($)
|
||||||
{
|
{
|
||||||
my $e = shift;
|
my $e = shift;
|
||||||
@ -881,8 +892,8 @@ sub ValidElement($)
|
|||||||
fatal($e, el_name($e) . ": switch_is() used on non-union type $e->{TYPE} which is a $type->{DATA}->{TYPE}");
|
fatal($e, el_name($e) . ": switch_is() used on non-union type $e->{TYPE} which is a $type->{DATA}->{TYPE}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_property($type, "nodiscriminant") and defined($e2)) {
|
if (not has_property($type->{DATA}, "nodiscriminant") and defined($e2)) {
|
||||||
my $discriminator_type = has_property($type, "switch_type");
|
my $discriminator_type = has_property($type->{DATA}, "switch_type");
|
||||||
$discriminator_type = "uint32" unless defined ($discriminator_type);
|
$discriminator_type = "uint32" unless defined ($discriminator_type);
|
||||||
|
|
||||||
my $t1 = mapToScalar($discriminator_type);
|
my $t1 = mapToScalar($discriminator_type);
|
||||||
@ -940,12 +951,30 @@ sub ValidElement($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a struct
|
# validate an enum
|
||||||
|
sub ValidEnum($)
|
||||||
|
{
|
||||||
|
my ($enum) = @_;
|
||||||
|
|
||||||
|
ValidProperties($enum, "ENUM");
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# validate a bitmap
|
||||||
|
sub ValidBitmap($)
|
||||||
|
{
|
||||||
|
my ($bitmap) = @_;
|
||||||
|
|
||||||
|
ValidProperties($bitmap, "BITMAP");
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# validate a struct
|
||||||
sub ValidStruct($)
|
sub ValidStruct($)
|
||||||
{
|
{
|
||||||
my($struct) = shift;
|
my($struct) = shift;
|
||||||
|
|
||||||
ValidProperties($struct,"STRUCT");
|
ValidProperties($struct, "STRUCT");
|
||||||
|
|
||||||
foreach my $e (@{$struct->{ELEMENTS}}) {
|
foreach my $e (@{$struct->{ELEMENTS}}) {
|
||||||
$e->{PARENT} = $struct;
|
$e->{PARENT} = $struct;
|
||||||
@ -994,23 +1023,15 @@ sub ValidTypedef($)
|
|||||||
my($typedef) = shift;
|
my($typedef) = shift;
|
||||||
my $data = $typedef->{DATA};
|
my $data = $typedef->{DATA};
|
||||||
|
|
||||||
ValidProperties($typedef,"TYPEDEF");
|
ValidProperties($typedef, "TYPEDEF");
|
||||||
|
|
||||||
$data->{PARENT} = $typedef;
|
$data->{PARENT} = $typedef;
|
||||||
|
|
||||||
if (ref($data) eq "HASH") {
|
ValidType($data) if (ref($data) eq "HASH");
|
||||||
if ($data->{TYPE} eq "STRUCT") {
|
|
||||||
ValidStruct($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($data->{TYPE} eq "UNION") {
|
|
||||||
ValidUnion($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a function
|
# validate a function
|
||||||
sub ValidFunction($)
|
sub ValidFunction($)
|
||||||
{
|
{
|
||||||
my($fn) = shift;
|
my($fn) = shift;
|
||||||
@ -1026,6 +1047,21 @@ sub ValidFunction($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# validate a type
|
||||||
|
sub ValidType($)
|
||||||
|
{
|
||||||
|
my ($t) = @_;
|
||||||
|
|
||||||
|
{
|
||||||
|
TYPEDEF => \&ValidTypedef,
|
||||||
|
STRUCT => \&ValidStruct,
|
||||||
|
UNION => \&ValidUnion,
|
||||||
|
ENUM => \&ValidEnum,
|
||||||
|
BITMAP => \&ValidBitmap
|
||||||
|
}->{$t->{TYPE}}->($t);
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse the interface definitions
|
# parse the interface definitions
|
||||||
sub ValidInterface($)
|
sub ValidInterface($)
|
||||||
@ -1059,10 +1095,12 @@ sub ValidInterface($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $d (@{$data}) {
|
foreach my $d (@{$data}) {
|
||||||
($d->{TYPE} eq "TYPEDEF") &&
|
($d->{TYPE} eq "FUNCTION") && ValidFunction($d);
|
||||||
ValidTypedef($d);
|
($d->{TYPE} eq "TYPEDEF" or
|
||||||
($d->{TYPE} eq "FUNCTION") &&
|
$d->{TYPE} eq "STRUCT" or
|
||||||
ValidFunction($d);
|
$d->{TYPE} eq "UNION" or
|
||||||
|
$d->{TYPE} eq "ENUM" or
|
||||||
|
$d->{TYPE} eq "BITMAP") && ValidType($d);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -219,8 +219,6 @@ sub HeaderTypedef($)
|
|||||||
{
|
{
|
||||||
my($typedef) = shift;
|
my($typedef) = shift;
|
||||||
HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME});
|
HeaderType($typedef, $typedef->{DATA}, $typedef->{NAME});
|
||||||
pidl ";\n\n" unless ($typedef->{DATA}->{TYPE} eq "BITMAP" or
|
|
||||||
$typedef->{DATA}->{TYPE} eq "ENUM");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -354,8 +352,12 @@ sub HeaderInterface($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $d (@{$interface->{DATA}}) {
|
foreach my $d (@{$interface->{DATA}}) {
|
||||||
next if ($d->{TYPE} ne "TYPEDEF");
|
HeaderTypedef($d) if ($d->{TYPE} eq "TYPEDEF");
|
||||||
HeaderTypedef($d);
|
HeaderStruct($d, $d->{NAME}) if ($d->{TYPE} eq "STRUCT");
|
||||||
|
HeaderUnion($d, $d->{NAME}) if ($d->{TYPE} eq "UNION");
|
||||||
|
HeaderEnum($d, $d->{NAME}) if ($d->{TYPE} eq "ENUM");
|
||||||
|
HeaderBitmap($d, $d->{NAME}) if ($d->{TYPE} eq "BITMAP");
|
||||||
|
pidl ";\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $d (@{$interface->{DATA}}) {
|
foreach my $d (@{$interface->{DATA}}) {
|
||||||
|
@ -12,7 +12,7 @@ require Exporter;
|
|||||||
@EXPORT = qw(is_charset_array);
|
@EXPORT = qw(is_charset_array);
|
||||||
@EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv
|
@EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv
|
||||||
GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv NeededFunction
|
GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv NeededFunction
|
||||||
NeededElement NeededTypedef);
|
NeededElement NeededType);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Parse::Pidl::Typelist qw(hasType getType mapType);
|
use Parse::Pidl::Typelist qw(hasType getType mapType);
|
||||||
@ -1335,10 +1335,10 @@ sub ParseEnumPrint($$)
|
|||||||
end_flags($enum);
|
end_flags($enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub DeclEnum($)
|
sub DeclEnum($$$)
|
||||||
{
|
{
|
||||||
my ($e,$t) = @_;
|
my ($e,$t,$name) = @_;
|
||||||
return "enum $e->{NAME} " .
|
return "enum $name " .
|
||||||
($t eq "pull"?"*":"") . "r";
|
($t eq "pull"?"*":"") . "r";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1418,10 +1418,10 @@ sub ParseBitmapPrint($$)
|
|||||||
end_flags($bitmap);
|
end_flags($bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub DeclBitmap($$)
|
sub DeclBitmap($$$)
|
||||||
{
|
{
|
||||||
my ($e,$t) = @_;
|
my ($e,$t,$name) = @_;
|
||||||
return mapType(Parse::Pidl::Typelist::bitmap_type_fn($e->{DATA})) .
|
return mapType(Parse::Pidl::Typelist::bitmap_type_fn($e)) .
|
||||||
($t eq "pull"?" *":" ") . "r";
|
($t eq "pull"?" *":" ") . "r";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1581,27 +1581,27 @@ sub ParseStructPull($$)
|
|||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# calculate size of ndr struct
|
# calculate size of ndr struct
|
||||||
sub ParseStructNdrSize($)
|
sub ParseStructNdrSize($$)
|
||||||
{
|
{
|
||||||
my $t = shift;
|
my ($t, $name) = @_;
|
||||||
my $sizevar;
|
my $sizevar;
|
||||||
|
|
||||||
if (my $flags = has_property($t, "flag")) {
|
if (my $flags = has_property($t, "flag")) {
|
||||||
pidl "flags |= $flags;";
|
pidl "flags |= $flags;";
|
||||||
}
|
}
|
||||||
pidl "return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_$t->{NAME});";
|
pidl "return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_$name);";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub DeclStruct($)
|
sub DeclStruct($$$)
|
||||||
{
|
{
|
||||||
my ($e,$t) = @_;
|
my ($e,$t,$name) = @_;
|
||||||
return ($t ne "pull"?"const ":"") . "struct $e->{NAME} *r";
|
return ($t ne "pull"?"const ":"") . "struct $name *r";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ArgsStructNdrSize($)
|
sub ArgsStructNdrSize($$)
|
||||||
{
|
{
|
||||||
my $d = shift;
|
my ($d, $name) = @_;
|
||||||
return "const struct $d->{NAME} *r, int flags";
|
return "const struct $name *r, int flags";
|
||||||
}
|
}
|
||||||
|
|
||||||
$typefamily{STRUCT} = {
|
$typefamily{STRUCT} = {
|
||||||
@ -1615,16 +1615,16 @@ $typefamily{STRUCT} = {
|
|||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# calculate size of ndr struct
|
# calculate size of ndr struct
|
||||||
sub ParseUnionNdrSize($)
|
sub ParseUnionNdrSize($$)
|
||||||
{
|
{
|
||||||
my $t = shift;
|
my ($t, $name) = @_;
|
||||||
my $sizevar;
|
my $sizevar;
|
||||||
|
|
||||||
if (my $flags = has_property($t, "flag")) {
|
if (my $flags = has_property($t, "flag")) {
|
||||||
pidl "flags |= $flags;";
|
pidl "flags |= $flags;";
|
||||||
}
|
}
|
||||||
|
|
||||||
pidl "return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_$t->{NAME});";
|
pidl "return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);";
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -1864,16 +1864,16 @@ sub ParseUnionPull($$)
|
|||||||
pidl "ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);" if defined($e->{PROPERTIES}{relative_base});
|
pidl "ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);" if defined($e->{PROPERTIES}{relative_base});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub DeclUnion($$)
|
sub DeclUnion($$$)
|
||||||
{
|
{
|
||||||
my ($e,$t) = @_;
|
my ($e,$t,$name) = @_;
|
||||||
return ($t ne "pull"?"const ":"") . "union $e->{NAME} *r";
|
return ($t ne "pull"?"const ":"") . "union $name *r";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ArgsUnionNdrSize($)
|
sub ArgsUnionNdrSize($$)
|
||||||
{
|
{
|
||||||
my $d = shift;
|
my ($d,$name) = @_;
|
||||||
return "const union $d->{NAME} *r, uint32_t level, int flags";
|
return "const union $name *r, uint32_t level, int flags";
|
||||||
}
|
}
|
||||||
|
|
||||||
$typefamily{UNION} = {
|
$typefamily{UNION} = {
|
||||||
@ -1887,81 +1887,62 @@ $typefamily{UNION} = {
|
|||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a typedef - push side
|
# parse a typedef - push side
|
||||||
sub ParseTypedefPush($)
|
sub ParseTypedefPush($$)
|
||||||
{
|
{
|
||||||
my($e) = shift;
|
my($e,$name) = @_;
|
||||||
|
|
||||||
my $args = $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e,"push");
|
$typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($e->{DATA}, $name);
|
||||||
fn_declare("push", $e, "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, $args)") or return;
|
|
||||||
|
|
||||||
pidl "{";
|
|
||||||
indent;
|
|
||||||
$typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($e->{DATA}, $e->{NAME});
|
|
||||||
pidl "return NT_STATUS_OK;";
|
|
||||||
deindent;
|
|
||||||
pidl "}";
|
|
||||||
pidl "";;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a typedef - pull side
|
# parse a typedef - pull side
|
||||||
sub ParseTypedefPull($)
|
sub ParseTypedefPull($$)
|
||||||
{
|
{
|
||||||
my($e) = shift;
|
my($e,$name) = @_;
|
||||||
|
|
||||||
my $args = $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e,"pull");
|
$typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($e->{DATA}, $name);
|
||||||
|
|
||||||
fn_declare("pull", $e, "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, $args)") or return;
|
|
||||||
|
|
||||||
pidl "{";
|
|
||||||
indent;
|
|
||||||
$typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($e->{DATA}, $e->{NAME});
|
|
||||||
pidl "return NT_STATUS_OK;";
|
|
||||||
deindent;
|
|
||||||
pidl "}";
|
|
||||||
pidl "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a typedef - print side
|
# parse a typedef - print side
|
||||||
sub ParseTypedefPrint($)
|
sub ParseTypedefPrint($$)
|
||||||
{
|
{
|
||||||
my($e) = shift;
|
my($e,$name) = @_;
|
||||||
|
|
||||||
my $args = $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e,"print");
|
$typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($e->{DATA}, $name);
|
||||||
|
|
||||||
pidl_hdr "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args);";
|
|
||||||
|
|
||||||
return if (has_property($e, "noprint"));
|
|
||||||
|
|
||||||
pidl "_PUBLIC_ void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args)";
|
|
||||||
pidl "{";
|
|
||||||
indent;
|
|
||||||
$typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($e->{DATA}, $e->{NAME});
|
|
||||||
deindent;
|
|
||||||
pidl "}";
|
|
||||||
pidl "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
## calculate the size of a structure
|
## calculate the size of a structure
|
||||||
sub ParseTypedefNdrSize($)
|
sub ParseTypedefNdrSize($$)
|
||||||
{
|
{
|
||||||
my($t) = shift;
|
my($t,$name) = @_;
|
||||||
|
|
||||||
my $tf = $typefamily{$t->{DATA}->{TYPE}};
|
$typefamily{$t->{DATA}->{TYPE}}->{SIZE_FN_BODY}->($t->{DATA}, $name);
|
||||||
my $args = $tf->{SIZE_FN_ARGS}->($t);
|
|
||||||
|
|
||||||
fn_declare("size", $t, "size_t ndr_size_$t->{NAME}($args)") or return;
|
|
||||||
|
|
||||||
pidl "{";
|
|
||||||
indent;
|
|
||||||
$typefamily{$t->{DATA}->{TYPE}}->{SIZE_FN_BODY}->($t);
|
|
||||||
deindent;
|
|
||||||
pidl "}";
|
|
||||||
pidl "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub DeclTypedef($$$)
|
||||||
|
{
|
||||||
|
my ($e, $t, $name) = @_;
|
||||||
|
|
||||||
|
return $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e->{DATA}, $t, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ArgsTypedefNdrSize($$)
|
||||||
|
{
|
||||||
|
my ($d, $name) = @_;
|
||||||
|
return $typefamily{$d->{DATA}->{TYPE}}->{SIZE_FN_ARGS}->($d->{DATA}, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$typefamily{TYPEDEF} = {
|
||||||
|
PUSH_FN_BODY => \&ParseTypedefPush,
|
||||||
|
DECL => \&DeclTypedef,
|
||||||
|
PULL_FN_BODY => \&ParseTypedefPull,
|
||||||
|
PRINT_FN_BODY => \&ParseTypedefPrint,
|
||||||
|
SIZE_FN_ARGS => \&ArgsTypedefNdrSize,
|
||||||
|
SIZE_FN_BODY => \&ParseTypedefNdrSize,
|
||||||
|
};
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse a function - print side
|
# parse a function - print side
|
||||||
sub ParseFunctionPrint($)
|
sub ParseFunctionPrint($)
|
||||||
@ -2379,6 +2360,74 @@ sub HeaderInterface($)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ParseTypePush($)
|
||||||
|
{
|
||||||
|
my ($e) = @_;
|
||||||
|
|
||||||
|
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "push", $e->{NAME});
|
||||||
|
fn_declare("push", $e, "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, $args)") or return;
|
||||||
|
|
||||||
|
pidl "{";
|
||||||
|
indent;
|
||||||
|
$typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($e, $e->{NAME});
|
||||||
|
pidl "return NT_STATUS_OK;";
|
||||||
|
deindent;
|
||||||
|
pidl "}";
|
||||||
|
pidl "";;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ParseTypePull($)
|
||||||
|
{
|
||||||
|
my ($e) = @_;
|
||||||
|
|
||||||
|
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "pull", $e->{NAME});
|
||||||
|
|
||||||
|
fn_declare("pull", $e, "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, $args)") or return;
|
||||||
|
|
||||||
|
pidl "{";
|
||||||
|
indent;
|
||||||
|
$typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($e, $e->{NAME});
|
||||||
|
pidl "return NT_STATUS_OK;";
|
||||||
|
deindent;
|
||||||
|
pidl "}";
|
||||||
|
pidl "";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ParseTypePrint($)
|
||||||
|
{
|
||||||
|
my ($e) = @_;
|
||||||
|
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "print", $e->{NAME});
|
||||||
|
|
||||||
|
pidl_hdr "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args);";
|
||||||
|
|
||||||
|
return if (has_property($e, "noprint"));
|
||||||
|
|
||||||
|
pidl "_PUBLIC_ void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args)";
|
||||||
|
pidl "{";
|
||||||
|
indent;
|
||||||
|
$typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($e, $e->{NAME});
|
||||||
|
deindent;
|
||||||
|
pidl "}";
|
||||||
|
pidl "";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ParseTypeNdrSize($)
|
||||||
|
{
|
||||||
|
my ($t) = @_;
|
||||||
|
|
||||||
|
my $tf = $typefamily{$t->{TYPE}};
|
||||||
|
my $args = $tf->{SIZE_FN_ARGS}->($t, $t->{NAME});
|
||||||
|
|
||||||
|
fn_declare("size", $t, "size_t ndr_size_$t->{NAME}($args)") or return;
|
||||||
|
|
||||||
|
pidl "{";
|
||||||
|
indent;
|
||||||
|
$typefamily{$t->{TYPE}}->{SIZE_FN_BODY}->($t, $t->{NAME});
|
||||||
|
deindent;
|
||||||
|
pidl "}";
|
||||||
|
pidl "";
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# parse the interface definitions
|
# parse the interface definitions
|
||||||
sub ParseInterface($$)
|
sub ParseInterface($$)
|
||||||
@ -2398,15 +2447,15 @@ sub ParseInterface($$)
|
|||||||
|
|
||||||
# Typedefs
|
# Typedefs
|
||||||
foreach my $d (@{$interface->{TYPES}}) {
|
foreach my $d (@{$interface->{TYPES}}) {
|
||||||
($needed->{"push_$d->{NAME}"}) && ParseTypedefPush($d);
|
($needed->{"push_$d->{NAME}"}) && ParseTypePush($d);
|
||||||
($needed->{"pull_$d->{NAME}"}) && ParseTypedefPull($d);
|
($needed->{"pull_$d->{NAME}"}) && ParseTypePull($d);
|
||||||
($needed->{"print_$d->{NAME}"}) && ParseTypedefPrint($d);
|
($needed->{"print_$d->{NAME}"}) && ParseTypePrint($d);
|
||||||
|
|
||||||
# Make sure we don't generate a function twice...
|
# Make sure we don't generate a function twice...
|
||||||
$needed->{"push_$d->{NAME}"} = $needed->{"pull_$d->{NAME}"} =
|
$needed->{"push_$d->{NAME}"} = $needed->{"pull_$d->{NAME}"} =
|
||||||
$needed->{"print_$d->{NAME}"} = 0;
|
$needed->{"print_$d->{NAME}"} = 0;
|
||||||
|
|
||||||
($needed->{"ndr_size_$d->{NAME}"}) && ParseTypedefNdrSize($d);
|
($needed->{"ndr_size_$d->{NAME}"}) && ParseTypeNdrSize($d);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
@ -2524,7 +2573,7 @@ sub NeededFunction($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub NeededTypedef($$)
|
sub NeededType($$)
|
||||||
{
|
{
|
||||||
my ($t,$needed) = @_;
|
my ($t,$needed) = @_;
|
||||||
if (has_property($t, "public")) {
|
if (has_property($t, "public")) {
|
||||||
@ -2556,7 +2605,7 @@ sub NeededInterface($$)
|
|||||||
{
|
{
|
||||||
my ($interface,$needed) = @_;
|
my ($interface,$needed) = @_;
|
||||||
NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
|
NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
|
||||||
NeededTypedef($_, $needed) foreach (reverse @{$interface->{TYPES}});
|
NeededType($_, $needed) foreach (reverse @{$interface->{TYPES}});
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -91,7 +91,6 @@ SKIP: {
|
|||||||
|
|
||||||
my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags";
|
my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags";
|
||||||
$cmd =~ s/\n//g;
|
$cmd =~ s/\n//g;
|
||||||
print "$cmd\n";
|
|
||||||
open CC, "|$cmd";
|
open CC, "|$cmd";
|
||||||
print CC "#define uint_t unsigned int\n";
|
print CC "#define uint_t unsigned int\n";
|
||||||
print CC "#define _GNU_SOURCE\n";
|
print CC "#define _GNU_SOURCE\n";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 9;
|
use Test::More tests => 10;
|
||||||
use FindBin qw($RealBin);
|
use FindBin qw($RealBin);
|
||||||
use lib "$RealBin";
|
use lib "$RealBin";
|
||||||
use Util;
|
use Util;
|
||||||
@ -34,3 +34,5 @@ like(parse_idl("interface x { void foo ([out] uint32 x); };"),
|
|||||||
like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
|
like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
|
||||||
qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
|
qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
|
||||||
like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
|
like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
|
||||||
|
like(parse_idl("interface p { struct x { int y; }; };"),
|
||||||
|
qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly");
|
||||||
|
@ -24,5 +24,3 @@ my $e = {
|
|||||||
|
|
||||||
test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
|
test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
|
||||||
sub { ValidElement($e); });
|
sub { ValidElement($e); });
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,15 +8,7 @@ use FindBin qw($RealBin);
|
|||||||
use lib "$RealBin";
|
use lib "$RealBin";
|
||||||
use Util qw(test_samba4_ndr);
|
use Util qw(test_samba4_ndr);
|
||||||
|
|
||||||
SKIP: {
|
test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ',
|
||||||
skip "Tagged types without typedef are not supported yet", 8;
|
|
||||||
|
|
||||||
test_samba4_ndr('struct-notypedef',
|
|
||||||
'
|
|
||||||
struct bla {
|
|
||||||
uint8 x;
|
|
||||||
};
|
|
||||||
',
|
|
||||||
'
|
'
|
||||||
struct ndr_push *ndr = ndr_push_init_ctx(NULL);
|
struct ndr_push *ndr = ndr_push_init_ctx(NULL);
|
||||||
struct bla r;
|
struct bla r;
|
||||||
@ -33,5 +25,3 @@ test_samba4_ndr('struct-notypedef',
|
|||||||
if (!data_blob_equal(&result_blob, &expected_blob))
|
if (!data_blob_equal(&result_blob, &expected_blob))
|
||||||
return 2;
|
return 2;
|
||||||
');
|
');
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Published under the GNU General Public License
|
# Published under the GNU General Public License
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use Test::More tests => 59 * 2;
|
use Test::More tests => 62 * 2;
|
||||||
use FindBin qw($RealBin);
|
use FindBin qw($RealBin);
|
||||||
use lib "$RealBin";
|
use lib "$RealBin";
|
||||||
use Util qw(test_errors);
|
use Util qw(test_errors);
|
||||||
@ -83,8 +83,12 @@ testok "nested1", "interface test { struct x { struct { int a; } z; }; };";
|
|||||||
testok "nested2", "interface test { struct x { struct y { int a; } z; }; };";
|
testok "nested2", "interface test { struct x { struct y { int a; } z; }; };";
|
||||||
testok "bitmap1", "interface test { bitmap x { a=1 }; };";
|
testok "bitmap1", "interface test { bitmap x { a=1 }; };";
|
||||||
testok "unsigned", "interface test { struct x { unsigned short y; }; };";
|
testok "unsigned", "interface test { struct x { unsigned short y; }; };";
|
||||||
|
testok "struct-property", "interface test { [public] struct x { short y; }; };";
|
||||||
testok "signed", "interface test { struct x { signed short y; }; };";
|
testok "signed", "interface test { struct x { signed short y; }; };";
|
||||||
testok "declarg", "interface test { void test(struct { int x; } a); };";
|
testok "declarg", "interface test { void test(struct { int x; } a); };";
|
||||||
|
testok "structarg", "interface test { void test(struct a b); };";
|
||||||
|
testfail "structargmissing", "interface test { void test(struct a); };",
|
||||||
|
"<structargmissing>:0: Syntax error near ')'\n";
|
||||||
testok "structqual", "interface test { struct x { struct y z; }; };";
|
testok "structqual", "interface test { struct x { struct y z; }; };";
|
||||||
testok "unionqual", "interface test { struct x { union y z; }; };";
|
testok "unionqual", "interface test { struct x { union y z; }; };";
|
||||||
testok "enumqual", "interface test { struct x { enum y z; }; };";
|
testok "enumqual", "interface test { struct x { enum y z; }; };";
|
||||||
|
@ -11,7 +11,7 @@ use Util;
|
|||||||
use Parse::Pidl::Util qw(MyDumper);
|
use Parse::Pidl::Util qw(MyDumper);
|
||||||
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
|
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
|
||||||
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
|
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
|
||||||
EnvSubstituteValue NeededFunction NeededElement NeededTypedef);
|
EnvSubstituteValue NeededFunction NeededElement NeededType);
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
sub print_fn($) { my $x = shift; $output.=$x; }
|
sub print_fn($) { my $x = shift; $output.=$x; }
|
||||||
@ -202,19 +202,19 @@ is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
|
|||||||
|
|
||||||
# public structs are always needed
|
# public structs are always needed
|
||||||
$needed = {};
|
$needed = {};
|
||||||
NeededTypedef({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
|
NeededType({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
|
||||||
$needed);
|
$needed);
|
||||||
is_deeply($needed, { });
|
is_deeply($needed, { });
|
||||||
|
|
||||||
$needed = {};
|
$needed = {};
|
||||||
NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
|
NeededType({ PROPERTIES => { public => 1 }, NAME => "bla",
|
||||||
DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
|
DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
|
||||||
$needed);
|
$needed);
|
||||||
is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 });
|
is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 });
|
||||||
|
|
||||||
# make sure types for elements are set too
|
# make sure types for elements are set too
|
||||||
$needed = {};
|
$needed = {};
|
||||||
NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
|
NeededType({ PROPERTIES => { public => 1 }, NAME => "bla",
|
||||||
DATA => { TYPE => "STRUCT",
|
DATA => { TYPE => "STRUCT",
|
||||||
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
||||||
$needed);
|
$needed);
|
||||||
@ -222,7 +222,7 @@ is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1,
|
|||||||
pull_bar => 1, print_bar => 1, push_bar => 1});
|
pull_bar => 1, print_bar => 1, push_bar => 1});
|
||||||
|
|
||||||
$needed = {};
|
$needed = {};
|
||||||
NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla",
|
NeededType({ PROPERTIES => { gensize => 1}, NAME => "bla",
|
||||||
DATA => { TYPE => "STRUCT",
|
DATA => { TYPE => "STRUCT",
|
||||||
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
||||||
$needed);
|
$needed);
|
||||||
@ -230,14 +230,14 @@ is_deeply($needed, { ndr_size_bla => 1 });
|
|||||||
|
|
||||||
# make sure types for elements are set too
|
# make sure types for elements are set too
|
||||||
$needed = { pull_bla => 1 };
|
$needed = { pull_bla => 1 };
|
||||||
NeededTypedef({ NAME => "bla",
|
NeededType({ NAME => "bla",
|
||||||
DATA => { TYPE => "STRUCT",
|
DATA => { TYPE => "STRUCT",
|
||||||
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
|
||||||
$needed);
|
$needed);
|
||||||
is_deeply($needed, { pull_bla => 1, pull_bar => 1 });
|
is_deeply($needed, { pull_bla => 1, pull_bar => 1 });
|
||||||
|
|
||||||
$needed = {};
|
$needed = {};
|
||||||
NeededTypedef({ PROPERTIES => { public => 1},
|
NeededType({ PROPERTIES => { public => 1},
|
||||||
NAME => "bla",
|
NAME => "bla",
|
||||||
DATA => { TYPE => "STRUCT",
|
DATA => { TYPE => "STRUCT",
|
||||||
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } },
|
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user