summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-07-10 01:16:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:29 -0500
commit514ce32a894585b66d7dc276d10fe6f4b525e02b (patch)
treec8d5f194aba2ba1ca2738ca9d6d14dfbe51c2433 /source4/build
parent76ecf81428c161a98a5621b55a64cb8515f80585 (diff)
downloadsamba-514ce32a894585b66d7dc276d10fe6f4b525e02b.tar.gz
samba-514ce32a894585b66d7dc276d10fe6f4b525e02b.tar.bz2
samba-514ce32a894585b66d7dc276d10fe6f4b525e02b.zip
r8274: Export some more symbols.
(This used to be commit d1f754a0a34c5938579a605b4f113100e14bac3d)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/Parse/Pidl/Ethereal/NDR/Header.pm8
-rw-r--r--source4/build/pidl/Parse/Pidl/Ethereal/NDR/Parser.pm39
-rw-r--r--source4/build/pidl/Parse/Pidl/IDL.pm147
-rw-r--r--source4/build/pidl/Parse/Pidl/NDR.pm13
-rw-r--r--source4/build/pidl/Parse/Pidl/ODL.pm5
-rw-r--r--source4/build/pidl/Parse/Pidl/Samba/NDR/Header.pm7
-rw-r--r--source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm44
-rw-r--r--source4/build/pidl/Parse/Pidl/Typelist.pm3
-rw-r--r--source4/build/pidl/Parse/Pidl/Util.pm29
-rw-r--r--source4/build/pidl/Parse/Pidl/Validator.pm5
-rw-r--r--source4/build/pidl/idl.yp29
11 files changed, 184 insertions, 145 deletions
diff --git a/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Header.pm b/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Header.pm
index c4d983e793..6fcf949811 100644
--- a/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Header.pm
+++ b/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Header.pm
@@ -8,6 +8,8 @@ package Parse::Pidl::Ethereal::NDR::Header;
use strict;
+use Parse::Pidl::Util qw(has_property);
+
my($res);
my($tab_depth);
@@ -29,11 +31,11 @@ sub HeaderTypedefProto($)
{
my($d) = shift;
- my $tf = EthParser::get_typefamily($d->{DATA}{TYPE});
+ my $tf = Parse::Pidl::Ethereal::NDR::Parser::get_typefamily($d->{DATA}{TYPE});
- return unless util::has_property($d, "public");
+ return unless has_property($d, "public");
- unless (util::has_property($d, "nopull")) {
+ unless (has_property($d, "nopull")) {
pidl "dcerpc_dissect_fnct_t $d->{NAME};\n";
}
}
diff --git a/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Parser.pm b/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Parser.pm
index 96eafc0b57..1038a64b42 100644
--- a/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Parser.pm
+++ b/source4/build/pidl/Parse/Pidl/Ethereal/NDR/Parser.pm
@@ -9,6 +9,7 @@ package Parse::Pidl::Ethereal::NDR::Parser;
use strict;
use Parse::Pidl::Typelist;
+use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::NDR;
# the list of needed functions
@@ -60,9 +61,9 @@ sub NeededTypedef($$)
my $t = shift;
my $needed = shift;
- if (util::has_property($t, "public")) {
- $needed->{"pull_$t->{NAME}"} = not util::has_property($t, "nopull");
- $needed->{"decl_$t->{NAME}"} = not util::has_property($t, "nopull");
+ if (has_property($t, "public")) {
+ $needed->{"pull_$t->{NAME}"} = not has_property($t, "nopull");
+ $needed->{"decl_$t->{NAME}"} = not has_property($t, "nopull");
}
if ($t->{DATA}->{TYPE} eq "STRUCT" or $t->{DATA}->{TYPE} eq "UNION") {
@@ -156,7 +157,7 @@ sub elementbase($)
{
my($e) = shift;
- if (my $base = util::has_property($e, "display")) {
+ if (my $base = has_property($e, "display")) {
return "BASE_" . uc($base);
}
@@ -186,8 +187,8 @@ sub bitmapbase($)
{
my $e = shift;
- return "16", if util::has_property($e->{DATA}, "bitmap16bit");
- return "8", if util::has_property($e->{DATA}, "bitmap8bit");
+ return "16", if has_property($e->{DATA}, "bitmap16bit");
+ return "8", if has_property($e->{DATA}, "bitmap8bit");
return "32";
}
@@ -307,7 +308,7 @@ sub fn_prefix($)
{
my $fn = shift;
- return "" if (util::has_property($fn, "public"));
+ return "" if (has_property($fn, "public"));
return "static ";
}
@@ -316,7 +317,7 @@ sub fn_prefix($)
sub start_flags($)
{
my $e = shift;
- my $flags = util::has_property($e, "flag");
+ my $flags = has_property($e, "flag");
if (defined $flags) {
pidl "{ uint32_t _flags_save_$e->{TYPE} = ndr->flags;";
pidl "ndr_set_flags(&ndr->flags, $flags);";
@@ -329,7 +330,7 @@ sub start_flags($)
sub end_flags($)
{
my $e = shift;
- my $flags = util::has_property($e, "flag");
+ my $flags = has_property($e, "flag");
if (defined $flags) {
pidl "ndr->flags = _flags_save_$e->{TYPE};\n\t}";
deindent;
@@ -398,7 +399,7 @@ sub compression_clen($$$)
my $compression = $l->{COMPRESSION};
my ($alg, $clen, $dlen) = split(/ /, $compression);
- return util::ParseExpr($clen, $env);
+ return ParseExpr($clen, $env);
}
sub compression_dlen($$$)
@@ -409,7 +410,7 @@ sub compression_dlen($$$)
my $compression = $l->{COMPRESSION};
my ($alg, $clen, $dlen) = split(/ /, $compression);
- return util::ParseExpr($dlen, $env);
+ return ParseExpr($dlen, $env);
}
sub ParseCompressionStart($$$$)
@@ -446,7 +447,7 @@ sub ParseObfuscationStart($$)
{
my $e = shift;
my $ndr = shift;
- my $obfuscation = util::has_property($e, "obfuscation");
+ my $obfuscation = has_property($e, "obfuscation");
pidl "ndr_pull_obfuscation($ndr, $obfuscation);";
@@ -526,7 +527,7 @@ sub ParseSwitch($$$$$$)
my($var_name) = shift;
my($ndr_flags) = shift;
my $env = shift;
- my $switch_var = util::ParseExpr($l->{SWITCH_IS}, $env);
+ my $switch_var = ParseExpr($l->{SWITCH_IS}, $env);
check_null_pointer($switch_var);
@@ -556,7 +557,7 @@ sub ParseData($$$$$)
pidl "offset += dissect_$l->{DATA_TYPE}(tvb, offset, pinfo, tree, drep, hf_FIXME, NULL);";
- if (my $range = util::has_property($e, "range")) {
+ if (my $range = has_property($e, "range")) {
$var_name = get_value_of($var_name);
my ($low, $high) = split(/ /, $range, 2);
if (($l->{DATA_TYPE} =~ /^uint/) and ($low eq "0")) {
@@ -650,7 +651,7 @@ sub ParseElementLevel
pidl "}";
}
} elsif ($l->{TYPE} eq "ARRAY") {
- my $length = util::ParseExpr($l->{LENGTH_IS}, $env);
+ my $length = ParseExpr($l->{LENGTH_IS}, $env);
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
$var_name = $var_name . "[$counter]";
@@ -935,7 +936,7 @@ sub ParseArrayHeader($$$$$)
# $var_name contains the name of the first argument here
- my $length = util::ParseExpr($l->{SIZE_IS}, $env);
+ my $length = ParseExpr($l->{SIZE_IS}, $env);
my $size = $length;
if ($l->{IS_CONFORMANT}) {
@@ -965,13 +966,13 @@ sub ParseArrayHeader($$$$$)
}
if ($l->{IS_CONFORMANT}) {
- my $size = util::ParseExpr($l->{SIZE_IS}, $env);
+ my $size = ParseExpr($l->{SIZE_IS}, $env);
check_null_pointer($size);
pidl "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));";
}
if ($l->{IS_VARYING}) {
- my $length = util::ParseExpr($l->{LENGTH_IS}, $env);
+ my $length = ParseExpr($l->{LENGTH_IS}, $env);
check_null_pointer($length);
pidl "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));";
}
@@ -1203,7 +1204,7 @@ sub RegisterInterface($$)
# in epan/dissctors are deleted.
my $name = "\"" . uc($x->{NAME}) . " (pidl)\"";
- if (util::has_property($x, "helpstring")) {
+ if (has_property($x, "helpstring")) {
$name = $x->{PROPERTIES}->{helpstring};
}
my $short_name = "pidl_$x->{NAME}";
diff --git a/source4/build/pidl/Parse/Pidl/IDL.pm b/source4/build/pidl/Parse/Pidl/IDL.pm
index bd46921abe..900e368ce8 100644
--- a/source4/build/pidl/Parse/Pidl/IDL.pm
+++ b/source4/build/pidl/Parse/Pidl/IDL.pm
@@ -1859,19 +1859,19 @@ sub new {
[#Rule 2
'idl', 2,
sub
-#line 19 "idl.yp"
+#line 19 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 3
'idl', 2,
sub
-#line 20 "idl.yp"
+#line 20 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 4
'coclass', 7,
sub
-#line 24 "idl.yp"
+#line 24 "build/pidl/idl.yp"
{$_[3] => {
"TYPE" => "COCLASS",
"PROPERTIES" => $_[1],
@@ -1887,13 +1887,13 @@ sub
[#Rule 6
'interface_names', 4,
sub
-#line 36 "idl.yp"
+#line 36 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 7
'interface', 8,
sub
-#line 40 "idl.yp"
+#line 40 "build/pidl/idl.yp"
{$_[3] => {
"TYPE" => "INTERFACE",
"PROPERTIES" => $_[1],
@@ -1910,19 +1910,19 @@ sub
[#Rule 9
'base_interface', 2,
sub
-#line 53 "idl.yp"
+#line 53 "build/pidl/idl.yp"
{ $_[2] }
],
[#Rule 10
'definitions', 1,
sub
-#line 57 "idl.yp"
+#line 57 "build/pidl/idl.yp"
{ [ $_[1] ] }
],
[#Rule 11
'definitions', 2,
sub
-#line 58 "idl.yp"
+#line 58 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 12
@@ -1940,7 +1940,7 @@ sub
[#Rule 16
'const', 6,
sub
-#line 66 "idl.yp"
+#line 66 "build/pidl/idl.yp"
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
@@ -1953,7 +1953,7 @@ sub
[#Rule 17
'const', 7,
sub
-#line 75 "idl.yp"
+#line 75 "build/pidl/idl.yp"
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
@@ -1967,7 +1967,7 @@ sub
[#Rule 18
'function', 7,
sub
-#line 88 "idl.yp"
+#line 88 "build/pidl/idl.yp"
{{
"TYPE" => "FUNCTION",
"NAME" => $_[3],
@@ -1981,7 +1981,7 @@ sub
[#Rule 19
'declare', 5,
sub
-#line 100 "idl.yp"
+#line 100 "build/pidl/idl.yp"
{{
"TYPE" => "DECLARE",
"PROPERTIES" => $_[2],
@@ -2000,7 +2000,7 @@ sub
[#Rule 22
'decl_enum', 1,
sub
-#line 114 "idl.yp"
+#line 114 "build/pidl/idl.yp"
{{
"TYPE" => "ENUM"
}}
@@ -2008,7 +2008,7 @@ sub
[#Rule 23
'decl_bitmap', 1,
sub
-#line 120 "idl.yp"
+#line 120 "build/pidl/idl.yp"
{{
"TYPE" => "BITMAP"
}}
@@ -2016,7 +2016,7 @@ sub
[#Rule 24
'typedef', 6,
sub
-#line 126 "idl.yp"
+#line 126 "build/pidl/idl.yp"
{{
"TYPE" => "TYPEDEF",
"PROPERTIES" => $_[2],
@@ -2045,13 +2045,13 @@ sub
[#Rule 30
'type', 1,
sub
-#line 138 "idl.yp"
+#line 138 "build/pidl/idl.yp"
{ "void" }
],
[#Rule 31
'enum', 4,
sub
-#line 143 "idl.yp"
+#line 143 "build/pidl/idl.yp"
{{
"TYPE" => "ENUM",
"ELEMENTS" => $_[3]
@@ -2060,13 +2060,13 @@ sub
[#Rule 32
'enum_elements', 1,
sub
-#line 150 "idl.yp"
+#line 150 "build/pidl/idl.yp"
{ [ $_[1] ] }
],
[#Rule 33
'enum_elements', 3,
sub
-#line 151 "idl.yp"
+#line 151 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[3]); $_[1] }
],
[#Rule 34
@@ -2075,13 +2075,13 @@ sub
[#Rule 35
'enum_element', 3,
sub
-#line 155 "idl.yp"
+#line 155 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 36
'bitmap', 4,
sub
-#line 159 "idl.yp"
+#line 159 "build/pidl/idl.yp"
{{
"TYPE" => "BITMAP",
"ELEMENTS" => $_[3]
@@ -2090,25 +2090,25 @@ sub
[#Rule 37
'bitmap_elements', 1,
sub
-#line 166 "idl.yp"
+#line 166 "build/pidl/idl.yp"
{ [ $_[1] ] }
],
[#Rule 38
'bitmap_elements', 3,
sub
-#line 167 "idl.yp"
+#line 167 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[3]); $_[1] }
],
[#Rule 39
'bitmap_element', 3,
sub
-#line 170 "idl.yp"
+#line 170 "build/pidl/idl.yp"
{ "$_[1] ( $_[3] )" }
],
[#Rule 40
'struct', 4,
sub
-#line 174 "idl.yp"
+#line 174 "build/pidl/idl.yp"
{{
"TYPE" => "STRUCT",
"ELEMENTS" => $_[3]
@@ -2117,7 +2117,7 @@ sub
[#Rule 41
'empty_element', 2,
sub
-#line 181 "idl.yp"
+#line 181 "build/pidl/idl.yp"
{{
"NAME" => "",
"TYPE" => "EMPTY",
@@ -2137,7 +2137,7 @@ sub
[#Rule 44
'optional_base_element', 2,
sub
-#line 195 "idl.yp"
+#line 195 "build/pidl/idl.yp"
{ $_[2]->{PROPERTIES} = Parse::Pidl::Util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
],
[#Rule 45
@@ -2146,13 +2146,13 @@ sub
[#Rule 46
'union_elements', 2,
sub
-#line 200 "idl.yp"
+#line 200 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 47
'union', 4,
sub
-#line 204 "idl.yp"
+#line 204 "build/pidl/idl.yp"
{{
"TYPE" => "UNION",
"ELEMENTS" => $_[3]
@@ -2161,7 +2161,7 @@ sub
[#Rule 48
'base_element', 5,
sub
-#line 211 "idl.yp"
+#line 211 "build/pidl/idl.yp"
{{
"NAME" => $_[4],
"TYPE" => $_[2],
@@ -2175,13 +2175,13 @@ sub
[#Rule 49
'pointers', 0,
sub
-#line 225 "idl.yp"
+#line 225 "build/pidl/idl.yp"
{ 0 }
],
[#Rule 50
'pointers', 2,
sub
-#line 226 "idl.yp"
+#line 226 "build/pidl/idl.yp"
{ $_[1]+1 }
],
[#Rule 51
@@ -2190,7 +2190,7 @@ sub
[#Rule 52
'element_list1', 3,
sub
-#line 231 "idl.yp"
+#line 231 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[2]); $_[1] }
],
[#Rule 53
@@ -2202,13 +2202,13 @@ sub
[#Rule 55
'element_list2', 1,
sub
-#line 237 "idl.yp"
+#line 237 "build/pidl/idl.yp"
{ [ $_[1] ] }
],
[#Rule 56
'element_list2', 3,
sub
-#line 238 "idl.yp"
+#line 238 "build/pidl/idl.yp"
{ push(@{$_[1]}, $_[3]); $_[1] }
],
[#Rule 57
@@ -2217,13 +2217,13 @@ sub
[#Rule 58
'array_len', 3,
sub
-#line 243 "idl.yp"
+#line 243 "build/pidl/idl.yp"
{ push(@{$_[3]}, "*"); $_[3] }
],
[#Rule 59
'array_len', 4,
sub
-#line 244 "idl.yp"
+#line 244 "build/pidl/idl.yp"
{ push(@{$_[4]}, "$_[2]"); $_[4] }
],
[#Rule 60
@@ -2232,31 +2232,31 @@ sub
[#Rule 61
'property_list', 4,
sub
-#line 250 "idl.yp"
+#line 250 "build/pidl/idl.yp"
{ Parse::Pidl::Util::FlattenHash([$_[1],$_[3]]); }
],
[#Rule 62
'properties', 1,
sub
-#line 253 "idl.yp"
+#line 253 "build/pidl/idl.yp"
{ $_[1] }
],
[#Rule 63
'properties', 3,
sub
-#line 254 "idl.yp"
+#line 254 "build/pidl/idl.yp"
{ Parse::Pidl::Util::FlattenHash([$_[1], $_[3]]); }
],
[#Rule 64
'property', 1,
sub
-#line 257 "idl.yp"
+#line 257 "build/pidl/idl.yp"
{{ "$_[1]" => "1" }}
],
[#Rule 65
'property', 4,
sub
-#line 258 "idl.yp"
+#line 258 "build/pidl/idl.yp"
{{ "$_[1]" => "$_[3]" }}
],
[#Rule 66
@@ -2265,7 +2265,7 @@ sub
[#Rule 67
'listtext', 3,
sub
-#line 263 "idl.yp"
+#line 263 "build/pidl/idl.yp"
{ "$_[1] $_[3]" }
],
[#Rule 68
@@ -2274,13 +2274,13 @@ sub
[#Rule 69
'commalisttext', 3,
sub
-#line 268 "idl.yp"
+#line 268 "build/pidl/idl.yp"
{ "$_[1],$_[3]" }
],
[#Rule 70
'anytext', 0,
sub
-#line 272 "idl.yp"
+#line 272 "build/pidl/idl.yp"
{ "" }
],
[#Rule 71
@@ -2295,73 +2295,73 @@ sub
[#Rule 74
'anytext', 3,
sub
-#line 274 "idl.yp"
+#line 274 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 75
'anytext', 3,
sub
-#line 275 "idl.yp"
+#line 275 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 76
'anytext', 3,
sub
-#line 276 "idl.yp"
+#line 276 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 77
'anytext', 3,
sub
-#line 277 "idl.yp"
+#line 277 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 78
'anytext', 3,
sub
-#line 278 "idl.yp"
+#line 278 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 79
'anytext', 3,
sub
-#line 279 "idl.yp"
+#line 279 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 80
'anytext', 3,
sub
-#line 280 "idl.yp"
+#line 280 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 81
'anytext', 3,
sub
-#line 281 "idl.yp"
+#line 281 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 82
'anytext', 3,
sub
-#line 282 "idl.yp"
+#line 282 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 83
'anytext', 3,
sub
-#line 283 "idl.yp"
+#line 283 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]" }
],
[#Rule 84
'anytext', 5,
sub
-#line 284 "idl.yp"
+#line 284 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
],
[#Rule 85
'anytext', 5,
sub
-#line 285 "idl.yp"
+#line 285 "build/pidl/idl.yp"
{ "$_[1]$_[2]$_[3]$_[4]$_[5]" }
],
[#Rule 86
@@ -2373,7 +2373,7 @@ sub
[#Rule 88
'text', 1,
sub
-#line 294 "idl.yp"
+#line 294 "build/pidl/idl.yp"
{ "\"$_[1]\"" }
],
[#Rule 89
@@ -2387,11 +2387,38 @@ sub
bless($self,$class);
}
-#line 305 "idl.yp"
+#line 305 "build/pidl/idl.yp"
use Parse::Pidl::Util;
+#####################################################################
+# traverse a perl data structure removing any empty arrays or
+# hashes and any hash elements that map to undef
+sub CleanData($)
+{
+ sub CleanData($);
+ my($v) = shift;
+ 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};
+ } elsif (ref($v) eq "HASH") {
+ 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;
+}
+
sub _Error {
if (exists $_[0]->YYData->{ERRMSG}) {
print $_[0]->YYData->{ERRMSG};
@@ -2479,7 +2506,7 @@ sub parse_idl($$)
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
- return Parse::Pidl::Util::CleanData($idl);
+ return CleanData($idl);
}
1;
diff --git a/source4/build/pidl/Parse/Pidl/NDR.pm b/source4/build/pidl/Parse/Pidl/NDR.pm
index e330bcec3b..1ab17e014b 100644
--- a/source4/build/pidl/Parse/Pidl/NDR.pm
+++ b/source4/build/pidl/Parse/Pidl/NDR.pm
@@ -7,8 +7,11 @@
package Parse::Pidl::NDR;
+use Exporter 'import';
+@EXPORT_OK = qw(GetPrevLevel GetNextLevel);
+
use strict;
-use Parse::Pidl::Typelist;
+use Parse::Pidl::Typelist qw(hasType getType);
use Parse::Pidl::Util qw(has_property property_matches);
sub nonfatal($$)
@@ -214,9 +217,9 @@ sub can_contain_deferred
return 1 if ($e->{POINTERS});
return 0 if (Parse::Pidl::Typelist::is_scalar($e->{TYPE}));
- return 1 unless (Parse::Pidl::Typelist::hasType($e->{TYPE})); # assume the worst
+ return 1 unless (hasType($e->{TYPE})); # assume the worst
- my $type = Parse::Pidl::Typelist::getType($e->{TYPE});
+ my $type = getType($e->{TYPE});
foreach my $x (@{$type->{DATA}->{ELEMENTS}}) {
return 1 if (can_contain_deferred ($x));
@@ -269,13 +272,13 @@ sub align_type
{
my $e = shift;
- unless (Parse::Pidl::Typelist::hasType($e)) {
+ unless (hasType($e)) {
# it must be an external type - all we can do is guess
# print "Warning: assuming alignment of unknown type '$e' is 4\n";
return 4;
}
- my $dt = Parse::Pidl::Typelist::getType($e)->{DATA};
+ my $dt = getType($e)->{DATA};
if ($dt->{TYPE} eq "ENUM") {
return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
diff --git a/source4/build/pidl/Parse/Pidl/ODL.pm b/source4/build/pidl/Parse/Pidl/ODL.pm
index fadb77f15d..9bf94b78b4 100644
--- a/source4/build/pidl/Parse/Pidl/ODL.pm
+++ b/source4/build/pidl/Parse/Pidl/ODL.pm
@@ -5,6 +5,7 @@
package Parse::Pidl::ODL;
use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Typelist qw(hasType getType);
use strict;
#####################################################################
@@ -44,8 +45,8 @@ sub ReplaceInterfacePointers($)
my $e = shift;
foreach my $x (@{$e->{ELEMENTS}}) {
- next unless (Parse::Pidl::Typelist::hasType($x->{TYPE}));
- next unless Parse::Pidl::Typelist::getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
+ next unless (hasType($x->{TYPE}));
+ next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
$x->{TYPE} = "MInterfacePointer";
}
diff --git a/source4/build/pidl/Parse/Pidl/Samba/NDR/Header.pm b/source4/build/pidl/Parse/Pidl/Samba/NDR/Header.pm
index 09e4bb5050..05982488c9 100644
--- a/source4/build/pidl/Parse/Pidl/Samba/NDR/Header.pm
+++ b/source4/build/pidl/Parse/Pidl/Samba/NDR/Header.pm
@@ -9,6 +9,7 @@ package Parse::Pidl::Samba::NDR::Header;
use strict;
use Parse::Pidl::Typelist;
use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel);
use Parse::Pidl::Samba::NDR::Parser;
my($res);
@@ -61,12 +62,12 @@ sub HeaderElement($)
foreach my $l (@{$element->{LEVELS}})
{
if (($l->{TYPE} eq "POINTER")) {
- my $nl = Parse::Pidl::NDR::GetNextLevel($element, $l);
- $nl = Parse::Pidl::NDR::GetNextLevel($element, $nl) if ($nl->{TYPE} eq "SUBCONTEXT");
+ my $nl = GetNextLevel($element, $l);
+ $nl = GetNextLevel($element, $nl) if ($nl->{TYPE} eq "SUBCONTEXT");
next if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}));
$prefix .= "*";
} elsif ($l->{TYPE} eq "ARRAY") {
- my $pl = Parse::Pidl::NDR::GetPrevLevel($element, $l);
+ my $pl = GetPrevLevel($element, $l);
next if ($pl and $pl->{TYPE} eq "POINTER");
if ($l->{IS_FIXED}) {
diff --git a/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm b/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm
index 421f854e3e..b281dae9e7 100644
--- a/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm
+++ b/source4/build/pidl/Parse/Pidl/Samba/NDR/Parser.pm
@@ -9,7 +9,7 @@ package Parse::Pidl::Samba::NDR::Parser;
use strict;
use Parse::Pidl::Typelist;
-use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::NDR;
# list of known types
@@ -222,8 +222,8 @@ sub ParseArrayPushHeader($$$$$)
if ($l->{IS_ZERO_TERMINATED}) {
$size = $length = "ndr_string_length($var_name, sizeof(*$var_name))";
} else {
- $size = Parse::Pidl::Util::ParseExpr($l->{SIZE_IS}, $env);
- $length = Parse::Pidl::Util::ParseExpr($l->{LENGTH_IS}, $env);
+ $size = ParseExpr($l->{SIZE_IS}, $env);
+ $length = ParseExpr($l->{LENGTH_IS}, $env);
}
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
@@ -256,7 +256,7 @@ sub ParseArrayPullHeader($$$$$)
} elsif ($l->{IS_ZERO_TERMINATED}) { # Noheader arrays
$length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
} else {
- $length = $size = Parse::Pidl::Util::ParseExpr($l->{SIZE_IS}, $env);
+ $length = $size = ParseExpr($l->{SIZE_IS}, $env);
}
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
@@ -280,13 +280,13 @@ sub ParseArrayPullHeader($$$$$)
}
if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
- my $size = Parse::Pidl::Util::ParseExpr($l->{SIZE_IS}, $env);
+ my $size = ParseExpr($l->{SIZE_IS}, $env);
check_null_pointer($size);
pidl "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));";
}
if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
- my $length = Parse::Pidl::Util::ParseExpr($l->{LENGTH_IS}, $env);
+ my $length = ParseExpr($l->{LENGTH_IS}, $env);
check_null_pointer($length);
pidl "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));";
}
@@ -313,7 +313,7 @@ sub compression_clen($$$)
my $compression = $l->{COMPRESSION};
my ($alg, $clen, $dlen) = split(/ /, $compression);
- return Parse::Pidl::Util::ParseExpr($clen, $env);
+ return ParseExpr($clen, $env);
}
sub compression_dlen($$$)
@@ -322,7 +322,7 @@ sub compression_dlen($$$)
my $compression = $l->{COMPRESSION};
my ($alg, $clen, $dlen) = split(/ /, $compression);
- return Parse::Pidl::Util::ParseExpr($dlen, $env);
+ return ParseExpr($dlen, $env);
}
sub ParseCompressionPushStart($$$)
@@ -441,7 +441,7 @@ sub ParseSubcontextPushEnd($$$$)
{
my ($e,$l,$ndr_flags,$env) = @_;
my $ndr = "_ndr_$e->{NAME}";
- my $subcontext_size = Parse::Pidl::Util::ParseExpr($l->{SUBCONTEXT_SIZE},$env);
+ my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env);
if (defined $l->{COMPRESSION}) {
ParseCompressionPushEnd($e, $l, $ndr);
@@ -461,7 +461,7 @@ sub ParseSubcontextPullStart($$$$$$)
{
my ($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_;
my $retndr = "_ndr_$e->{NAME}";
- my $subcontext_size = Parse::Pidl::Util::ParseExpr($l->{SUBCONTEXT_SIZE},$env);
+ my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env);
pidl "{";
indent;
@@ -495,7 +495,7 @@ sub ParseSubcontextPullEnd($$$)
my $advance;
if (defined($l->{SUBCONTEXT_SIZE}) and ($l->{SUBCONTEXT_SIZE} ne "-1")) {
- $advance = Parse::Pidl::Util::ParseExpr($l->{SUBCONTEXT_SIZE},$env);
+ $advance = ParseExpr($l->{SUBCONTEXT_SIZE},$env);
} elsif ($l->{HEADER_SIZE}) {
$advance = "$ndr->data_size";
} else {
@@ -559,7 +559,7 @@ sub ParseElementPushLevel
pidl "}";
}
} elsif ($l->{TYPE} eq "ARRAY" and not is_scalar_array($e,$l)) {
- my $length = Parse::Pidl::Util::ParseExpr($l->{LENGTH_IS}, $env);
+ my $length = ParseExpr($l->{LENGTH_IS}, $env);
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
$var_name = $var_name . "[$counter]";
@@ -604,7 +604,7 @@ sub ParseElementPush($$$$$$)
start_flags($e);
if (my $value = has_property($e, "value")) {
- $var_name = Parse::Pidl::Util::ParseExpr($value, $env);
+ $var_name = ParseExpr($value, $env);
}
ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred);
@@ -645,7 +645,7 @@ sub ParseElementPrint($$$)
return if (has_property($e, "noprint"));
if (my $value = has_property($e, "value")) {
- $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . Parse::Pidl::Util::ParseExpr($value,$env) . ":$var_name";
+ $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env) . ":$var_name";
}
foreach my $l (@{$e->{LEVELS}}) {
@@ -667,7 +667,7 @@ sub ParseElementPrint($$$)
if ($l->{IS_ZERO_TERMINATED}) {
$length = "ndr_string_length($var_name, sizeof(*$var_name))";
} else {
- $length = Parse::Pidl::Util::ParseExpr($l->{LENGTH_IS}, $env);
+ $length = ParseExpr($l->{LENGTH_IS}, $env);
}
if (is_scalar_array($e, $l)) {
@@ -701,7 +701,7 @@ sub ParseElementPrint($$$)
}
pidl "ndr_print_$l->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name);";
} elsif ($l->{TYPE} eq "SWITCH") {
- my $switch_var = Parse::Pidl::Util::ParseExpr($l->{SWITCH_IS}, $env);
+ my $switch_var = ParseExpr($l->{SWITCH_IS}, $env);
check_null_pointer_void($switch_var);
pidl "ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);";
}
@@ -730,7 +730,7 @@ sub ParseElementPrint($$$)
sub ParseSwitchPull($$$$$$)
{
my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_;
- my $switch_var = Parse::Pidl::Util::ParseExpr($l->{SWITCH_IS}, $env);
+ my $switch_var = ParseExpr($l->{SWITCH_IS}, $env);
check_null_pointer($switch_var);
@@ -743,7 +743,7 @@ sub ParseSwitchPull($$$$$$)
sub ParseSwitchPush($$$$$$)
{
my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_;
- my $switch_var = Parse::Pidl::Util::ParseExpr($l->{SWITCH_IS}, $env);
+ my $switch_var = ParseExpr($l->{SWITCH_IS}, $env);
check_null_pointer($switch_var);
$var_name = get_pointer_to($var_name);
@@ -875,7 +875,7 @@ sub ParseElementPullLevel
pidl "}";
}
} elsif ($l->{TYPE} eq "ARRAY" and not is_scalar_array($e,$l)) {
- my $length = Parse::Pidl::Util::ParseExpr($l->{LENGTH_IS}, $env);
+ my $length = ParseExpr($l->{LENGTH_IS}, $env);
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
$var_name = $var_name . "[$counter]";
@@ -1008,7 +1008,7 @@ sub ParseStructPush($$)
if (defined($e->{LEVELS}[0]) and
$e->{LEVELS}[0]->{TYPE} eq "ARRAY") {
- my $size = Parse::Pidl::Util::ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env);
+ my $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env);
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));";
} else {
@@ -1864,7 +1864,7 @@ sub AllocateArrayLevel($$$$$)
return if (has_property($e, "charset"));
- my $var = Parse::Pidl::Util::ParseExpr($e->{NAME}, $env);
+ my $var = ParseExpr($e->{NAME}, $env);
check_null_pointer($size);
my $pl = Parse::Pidl::NDR::GetPrevLevel($e, $l);
@@ -1938,7 +1938,7 @@ sub ParseFunctionPull($)
and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED});
if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") {
- my $size = Parse::Pidl::Util::ParseExpr($e->{LEVELS}[1]->{SIZE_IS}, $env);
+ my $size = ParseExpr($e->{LEVELS}[1]->{SIZE_IS}, $env);
check_null_pointer($size);
pidl "NDR_ALLOC_N(ndr, r->out.$e->{NAME}, $size);";
diff --git a/source4/build/pidl/Parse/Pidl/Typelist.pm b/source4/build/pidl/Parse/Pidl/Typelist.pm
index d8934bfbce..f107dfdd82 100644
--- a/source4/build/pidl/Parse/Pidl/Typelist.pm
+++ b/source4/build/pidl/Parse/Pidl/Typelist.pm
@@ -5,6 +5,9 @@
package Parse::Pidl::Typelist;
+use Exporter 'import';
+@EXPORT_OK = qw(hasType getType);
+
use Parse::Pidl::Util qw(has_property);
use strict;
diff --git a/source4/build/pidl/Parse/Pidl/Util.pm b/source4/build/pidl/Parse/Pidl/Util.pm
index fec18e6aeb..5e9544d40b 100644
--- a/source4/build/pidl/Parse/Pidl/Util.pm
+++ b/source4/build/pidl/Parse/Pidl/Util.pm
@@ -5,7 +5,7 @@
package Parse::Pidl::Util;
use Exporter 'import';
-@EXPORT_OK = qw(has_property property_matches);
+@EXPORT_OK = qw(has_property property_matches ParseExpr);
use strict;
@@ -52,33 +52,6 @@ sub FlattenHash($)
}
#####################################################################
-# traverse a perl data structure removing any empty arrays or
-# hashes and any hash elements that map to undef
-sub CleanData($)
-{
- sub CleanData($);
- my($v) = shift;
- 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};
- } elsif (ref($v) eq "HASH") {
- 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;
-}
-
-#####################################################################
# return the modification time of a file
sub FileModtime($)
{
diff --git a/source4/build/pidl/Parse/Pidl/Validator.pm b/source4/build/pidl/Parse/Pidl/Validator.pm
index 606d14e08b..1a551c562a 100644
--- a/source4/build/pidl/Parse/Pidl/Validator.pm
+++ b/source4/build/pidl/Parse/Pidl/Validator.pm
@@ -6,6 +6,7 @@
package Parse::Pidl::Validator;
use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Typelist qw(hasType getType);
use strict;
@@ -155,7 +156,7 @@ sub ValidProperties($$)
sub mapToScalar($)
{
my $t = shift;
- my $ti = Parse::Pidl::Typelist::getType($t);
+ my $ti = getType($t);
if (not defined ($ti)) {
return undef;
@@ -185,7 +186,7 @@ sub ValidElement($)
# Check whether switches are used correctly.
if (my $switch = has_property($e, "switch_is")) {
my $e2 = find_sibling($e, $switch);
- my $type = Parse::Pidl::Typelist::getType($e->{TYPE});
+ my $type = getType($e->{TYPE});
if (defined($type) and $type->{DATA}->{TYPE} ne "UNION") {
fatal($e, el_name($e) . ": switch_is() used on non-union type $e->{TYPE} which is a $type->{DATA}->{TYPE}");
diff --git a/source4/build/pidl/idl.yp b/source4/build/pidl/idl.yp
index acf926dd40..0e505b81fb 100644
--- a/source4/build/pidl/idl.yp
+++ b/source4/build/pidl/idl.yp
@@ -306,6 +306,33 @@ optional_semicolon:
use Parse::Pidl::Util;
+#####################################################################
+# traverse a perl data structure removing any empty arrays or
+# hashes and any hash elements that map to undef
+sub CleanData($)
+{
+ sub CleanData($);
+ my($v) = shift;
+ 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};
+ } elsif (ref($v) eq "HASH") {
+ 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;
+}
+
sub _Error {
if (exists $_[0]->YYData->{ERRMSG}) {
print $_[0]->YYData->{ERRMSG};
@@ -393,5 +420,5 @@ sub parse_idl($$)
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
- return Parse::Pidl::Util::CleanData($idl);
+ return CleanData($idl);
}