summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-16 11:09:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:44 -0500
commita0667e11ae2c92850919a1568ca47fa83d29af6f (patch)
tree58fea153339373c6f629a0380a00690a17d6270a
parent97dcee677e4fda03bed2ace3151e329e340ca313 (diff)
downloadsamba-a0667e11ae2c92850919a1568ca47fa83d29af6f.tar.gz
samba-a0667e11ae2c92850919a1568ca47fa83d29af6f.tar.bz2
samba-a0667e11ae2c92850919a1568ca47fa83d29af6f.zip
r5417: Add wrapper function for typedefs hash rather then using the "our" keyword,
move pointer parsing to seperate function. (This used to be commit ea872b9a2b9a51ba9f6c2842303d067e9e85d11a)
-rw-r--r--source4/build/pidl/dump.pm4
-rw-r--r--source4/build/pidl/header.pm5
-rw-r--r--source4/build/pidl/ndr.pm63
3 files changed, 49 insertions, 23 deletions
diff --git a/source4/build/pidl/dump.pm b/source4/build/pidl/dump.pm
index 00a57b10b4..9e896cd256 100644
--- a/source4/build/pidl/dump.pm
+++ b/source4/build/pidl/dump.pm
@@ -47,10 +47,8 @@ sub DumpElement($)
($res .= DumpProperties($element->{PROPERTIES}));
$res .= DumpType($element->{TYPE});
$res .= " ";
- if ($element->{POINTERS}) {
- for (my($i)=0; $i < $element->{POINTERS}; $i++) {
+ for my $i (1..$element->{POINTERS}) {
$res .= "*";
- }
}
$res .= "$element->{NAME}";
(defined $element->{ARRAY_LEN}) && ($res .= "[$element->{ARRAY_LEN}]");
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index c49f60ce8b..00321fef93 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -185,7 +185,10 @@ sub HeaderType($$$)
return;
}
- my $dt = $NdrParser::typedefs{$e->{TYPE}}->{DATA};
+ my $dt;
+ if (my $t = NdrParser::get_typedef($e->{TYPE})) {
+ $dt = $t->{DATA};
+ }
if ($data =~ "string") {
pidl "const char *";
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 81a909c472..961f32e333 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -11,8 +11,14 @@ use strict;
use needed;
# list of known types
-our %typedefs;
-our %typefamily;
+my %typedefs;
+my %typefamily;
+
+sub get_typedef($)
+{
+ my $n = shift;
+ return $typedefs{$n};
+}
sub RegisterPrimitives()
{
@@ -534,7 +540,7 @@ sub ParseElementPushScalar($$$)
} elsif (util::is_inline_array($e)) {
ParseArrayPush($e, "r->", "NDR_SCALARS");
} elsif (need_wire_pointer($e)) {
- pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_prefix$e->{NAME}));";
+ ParseElementPushPtr($e, $var_prefix, $ndr_flags);
} elsif (need_alloc($e)) {
# no scalar component
} elsif (my $switch = util::has_property($e, "switch_is")) {
@@ -549,6 +555,18 @@ sub ParseElementPushScalar($$$)
}
#####################################################################
+# parse a pointer in a struct element or function
+sub ParseElementPushPtr($$$)
+{
+ my $e = shift;
+ my $var_prefix = shift;
+ my $ndr_flags = shift;
+
+ pidl "NDR_CHECK(ndr_push_unique_ptr(ndr, $var_prefix$e->{NAME}));";
+}
+
+
+#####################################################################
# print scalars in a structure element
sub ParseElementPrintScalar($$)
{
@@ -710,19 +728,7 @@ sub ParseElementPullScalar($$$)
if (util::is_inline_array($e)) {
ParseArrayPull($e, "r->", "NDR_SCALARS");
} elsif (need_wire_pointer($e)) {
- pidl "NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_$e->{NAME}));";
- pidl "if (_ptr_$e->{NAME}) {";
- indent;
- pidl "NDR_ALLOC(ndr, $var_prefix$e->{NAME});";
- if (util::has_property($e, "relative")) {
- pidl "NDR_CHECK(ndr_pull_relative_ptr1(ndr, $var_prefix$e->{NAME}, _ptr_$e->{NAME}));";
- }
- deindent;
- pidl "} else {";
- indent;
- pidl "$var_prefix$e->{NAME} = NULL;";
- deindent;
- pidl "}";
+ ParseElementPullPtr($e, $var_prefix, $ndr_flags);
} elsif (need_alloc($e)) {
# no scalar component
} elsif (my $switch = util::has_property($e, "switch_is")) {
@@ -735,9 +741,7 @@ sub ParseElementPullScalar($$$)
if (my $range = util::has_property($e, "range")) {
my ($low, $high) = split(/ /, $range, 2);
pidl "if ($var_prefix$e->{NAME} < $low || $var_prefix$e->{NAME} > $high) {";
- indent;
- pidl "return ndr_pull_error(ndr, NDR_ERR_RANGE, \"value out of range\");";
- deindent;
+ pidl "\treturn ndr_pull_error(ndr, NDR_ERR_RANGE, \"value out of range\");";
pidl "}";
}
@@ -745,6 +749,27 @@ sub ParseElementPullScalar($$$)
}
#####################################################################
+# parse a pointer in a struct element or function
+sub ParseElementPullPtr($$$)
+{
+ my($e) = shift;
+ my($var_prefix) = shift;
+ my($ndr_flags) = shift;
+
+ pidl "NDR_CHECK(ndr_pull_unique_ptr(ndr, &_ptr_$e->{NAME}));";
+ pidl "if (_ptr_$e->{NAME}) {";
+ indent;
+ pidl "NDR_ALLOC(ndr, $var_prefix$e->{NAME});";
+ if (util::has_property($e, "relative")) {
+ pidl "NDR_CHECK(ndr_pull_relative_ptr1(ndr, $var_prefix$e->{NAME}, _ptr_$e->{NAME}));";
+ }
+ deindent;
+ pidl "} else {";
+ pidl "\t$var_prefix$e->{NAME} = NULL;";
+ pidl "}";
+}
+
+#####################################################################
# parse buffers in a structure element
sub ParseElementPushBuffer($$$)
{