summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba4/NDR
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-02-02 11:13:03 +0100
committerStefan Metzmacher <metze@samba.org>2008-02-02 11:13:03 +0100
commite22c627ea1e700c30568399cf94df5b88b05f216 (patch)
tree0e81ec21588b62e66abc9ca8bd934e82fa557b36 /source4/pidl/lib/Parse/Pidl/Samba4/NDR
parent4117839d7725a814c76c3869a23b6bd65cedf079 (diff)
downloadsamba-e22c627ea1e700c30568399cf94df5b88b05f216.tar.gz
samba-e22c627ea1e700c30568399cf94df5b88b05f216.tar.bz2
samba-e22c627ea1e700c30568399cf94df5b88b05f216.zip
pidl: revert changes it didn't want to push...sorry!
8ebf16c0741085fa769fcc2929f275ab49b1ea5d Works!!!...pidl/Samba4::NDR::Parser: fix support for embedded "ref" pointers 6fcf2456d0e81898b5779ef1650f38b4c5363a80 WORKS!!!...pidl/NDR: fix handling of multilevel pointers in function elements 0569139ca2960ec5478829c3e66f7ff69bdb55cd LOOKS OK... pidl: get the pointer types correct when an element has multiple pointe rs 13afc89a87716063180723f0e9cb4f76daca837e CHECKED... pidl/Samba4::NDR::Parser: correctly get the name of an array element 29c104944bcad30c6a2a3fa70d527bf0ee8969de CHECKED... TODO:MSG pidl/Samba4::NDR::Parser: fix ... 3369015f5d8c425e1a9f9d861471028f03f163bb CHECKED... pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a f unction metze (This used to be commit 0bcc8e53d1470ba9dfe93e5d6925b8f4c20c7c66)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/NDR')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm96
1 files changed, 38 insertions, 58 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 6e6d227681..8326ce5fb6 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -14,7 +14,7 @@ require Exporter;
use strict;
use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody);
use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid);
-use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element);
+use Parse::Pidl::CUtil qw(get_pointer_to get_value_of);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array);
use Parse::Pidl::Samba4 qw(is_intree choose_header);
use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
@@ -42,21 +42,19 @@ sub append_prefix($$)
{
my ($e, $var_name) = @_;
my $pointers = 0;
- my $arrays = 0;
foreach my $l (@{$e->{LEVELS}}) {
if ($l->{TYPE} eq "POINTER") {
$pointers++;
} elsif ($l->{TYPE} eq "ARRAY") {
- $arrays++;
if (($pointers == 0) and
(not $l->{IS_FIXED}) and
(not $l->{IS_INLINE})) {
- return get_value_of($var_name);
+ return get_value_of($var_name);
}
} elsif ($l->{TYPE} eq "DATA") {
if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
- return get_value_of($var_name) unless ($pointers or $arrays);
+ return get_value_of($var_name) unless ($pointers);
}
}
}
@@ -584,7 +582,7 @@ sub ParseElementPushLevel
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
- $var_name = get_array_element($var_name, $counter);
+ $var_name = $var_name . "[$counter]";
if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
@@ -671,48 +669,23 @@ 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;
- }
-
- my $arrays = 0;
-
- foreach my $tl (@{$e->{LEVELS}}) {
- last if $l == $tl;
- if ($tl->{TYPE} eq "ARRAY") {
- $arrays++;
- }
- }
-
- if (Parse::Pidl::Typelist::scalar_is_reference($t)) {
- return 1 unless $arrays;
- }
-
- return 0;
-}
-
sub ParseDataPrint($$$$)
{
my ($self, $e, $l, $var_name) = @_;
- if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
-
- if (need_pointer_to($e, $l, 1)) {
+ 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)) {
$var_name = get_pointer_to($var_name);
}
-
- $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);");
+ $self->pidl("ndr_print_$t(ndr, \"$e->{NAME}\", $var_name);");
} else {
$self->ParseTypePrint($l->{DATA_TYPE}, $var_name);
}
@@ -779,7 +752,7 @@ sub ParseElementPrint($$$$)
$self->pidl("if (idx_$l->{LEVEL_INDEX}) {");
$self->indent;
- $var_name = get_array_element($var_name, $counter);
+ $var_name = $var_name . "[$counter]";
}
} elsif ($l->{TYPE} eq "DATA") {
$self->ParseDataPrint($e, $l, $var_name);
@@ -842,11 +815,12 @@ 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 (need_pointer_to($e, $l, 0)) {
+ if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
$var_name = get_pointer_to($var_name);
}
@@ -871,15 +845,21 @@ sub ParseDataPush($$$$$$$)
my ($self,$e,$l,$ndr,$var_name,$primitives,$deferred) = @_;
if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
-
- my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
-
+ my $t;
+ if (ref($l->{DATA_TYPE}) eq "HASH") {
+ $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}";
+ } else {
+ $t = $l->{DATA_TYPE};
+ }
+
# strings are passed by value rather than reference
- if (need_pointer_to($e, $l, 1)) {
+ if (not Parse::Pidl::Typelist::is_scalar($t) or
+ Parse::Pidl::Typelist::scalar_is_reference($t)) {
$var_name = get_pointer_to($var_name);
}
- $self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
+ my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
+ $self->pidl("NDR_CHECK(ndr_push_$t($ndr, $ndr_flags, $var_name));");
} else {
$self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred);
}
@@ -929,7 +909,7 @@ sub ParseMemCtxPullFlags($$$$)
($nl->{DATA_TYPE} eq "string"));
if ($next_is_array or $next_is_string) {
return undef;
- } elsif ($l->{LEVEL} eq "TOP") {
+ } else {
$mem_flags = "LIBNDR_FLAG_REF_ALLOC";
}
}
@@ -1048,7 +1028,7 @@ sub ParseElementPullLevel
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
my $array_name = $var_name;
- $var_name = get_array_element($var_name, $counter);
+ $var_name = $var_name . "[$counter]";
$self->ParseMemCtxPullStart($e, $l, $array_name);
@@ -1129,7 +1109,10 @@ sub ParsePtrPull($$$$$)
my $next_is_string = (($nl->{TYPE} eq "DATA") and
($nl->{DATA_TYPE} eq "string"));
- if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") {
+ if ($l->{POINTER_TYPE} eq "ref") {
+ if ($l->{LEVEL} eq "EMBEDDED") {
+ $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));");
+ }
if (!$next_is_array and !$next_is_string) {
$self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
@@ -1138,19 +1121,16 @@ sub ParsePtrPull($$$$$)
}
return;
- } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") {
- $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));");
} elsif (($l->{POINTER_TYPE} eq "unique") or
($l->{POINTER_TYPE} eq "relative") or
($l->{POINTER_TYPE} eq "full")) {
$self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));");
+ $self->pidl("if (_ptr_$e->{NAME}) {");
+ $self->indent;
} else {
die("Unhandled pointer type $l->{POINTER_TYPE}");
}
- $self->pidl("if (_ptr_$e->{NAME}) {");
- $self->indent;
-
# Don't do this for arrays, they're allocated at the actual level
# of the array
unless ($next_is_array or $next_is_string) {