summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-02-01 09:49:54 +0100
committerStefan Metzmacher <metze@samba.org>2008-02-01 21:29:33 +0100
commitc94ee074998a623dd9e47ca35b73ba2a83fbfeca (patch)
tree9b9586047cec8afc82d62c1b0f40e9517ac8a5ef /source4
parenta4571e661f662eabf4ab15d5302b576333fd6371 (diff)
downloadsamba-c94ee074998a623dd9e47ca35b73ba2a83fbfeca.tar.gz
samba-c94ee074998a623dd9e47ca35b73ba2a83fbfeca.tar.bz2
samba-c94ee074998a623dd9e47ca35b73ba2a83fbfeca.zip
CHECKED... pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a function
metze (This used to be commit 3369015f5d8c425e1a9f9d861471028f03f163bb)
Diffstat (limited to 'source4')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm59
1 files changed, 34 insertions, 25 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 8326ce5fb6..81e8a21625 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/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);
}