summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba4
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba4')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Header.pm31
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm46
2 files changed, 46 insertions, 31 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
index 96f695d1cd..2b5b9c9e01 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -9,7 +9,6 @@ package Parse::Pidl::Samba4::Header;
use strict;
use Parse::Pidl::Typelist qw(mapType);
use Parse::Pidl::Util qw(has_property is_constant);
-use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel);
use Parse::Pidl::Samba4 qw(is_intree);
use vars qw($VERSION);
@@ -236,15 +235,25 @@ sub HeaderConst($)
}
}
+sub ElementDirection($)
+{
+ my ($e) = @_;
+
+ return "inout" if (has_property($e, "in") and has_property($e, "out"));
+ return "in" if (has_property($e, "in"));
+ return "out" if (has_property($e, "out"));
+ return "inout";
+}
+
#####################################################################
# parse a function
sub HeaderFunctionInOut($$)
{
my($fn,$prop) = @_;
- foreach (@{$fn->{ELEMENTS}}) {
- HeaderElement($_) if (has_property($_, $prop));
- }
+ foreach (@{$fn->{ELEMENTS}}) {
+ HeaderElement($_) if (ElementDirection($_) eq $prop);
+ }
}
#####################################################################
@@ -255,8 +264,8 @@ sub HeaderFunctionInOut_needed($$)
return 1 if ($prop eq "out" && $fn->{RETURN_TYPE} ne "void");
- foreach (@{$fn->{ELEMENTS}}) {
- return 1 if (has_property($_, $prop));
+ foreach (@{$fn->{ELEMENTS}}) {
+ return 1 if (ElementDirection($_) eq $prop);
}
return undef;
@@ -278,19 +287,23 @@ sub HeaderFunction($)
$tab_depth++;
my $needed = 0;
- if (HeaderFunctionInOut_needed($fn, "in")) {
+ if (HeaderFunctionInOut_needed($fn, "in") or
+ HeaderFunctionInOut_needed($fn, "inout")) {
pidl tabs()."struct {\n";
$tab_depth++;
HeaderFunctionInOut($fn, "in");
+ HeaderFunctionInOut($fn, "inout");
$tab_depth--;
pidl tabs()."} in;\n\n";
$needed++;
}
- if (HeaderFunctionInOut_needed($fn, "out")) {
+ if (HeaderFunctionInOut_needed($fn, "out") or
+ HeaderFunctionInOut_needed($fn, "inout")) {
pidl tabs()."struct {\n";
$tab_depth++;
HeaderFunctionInOut($fn, "out");
+ HeaderFunctionInOut($fn, "inout");
if ($fn->{RETURN_TYPE} ne "void") {
pidl tabs().mapType($fn->{RETURN_TYPE}) . " result;\n";
}
@@ -299,7 +312,7 @@ sub HeaderFunction($)
$needed++;
}
- if (! $needed) {
+ if (!$needed) {
# sigh - some compilers don't like empty structures
pidl tabs()."int _dummy_element;\n";
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 1e199ba62b..3b1bc726ff 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -10,7 +10,7 @@ package Parse::Pidl::Samba4::NDR::Parser;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(is_charset_array);
-@EXPORT_OK = qw(check_null_pointer);
+@EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv);
use strict;
use Parse::Pidl::Typelist qw(hasType getType mapType);
@@ -451,7 +451,9 @@ sub ParseArrayPullHeader($$$$$)
if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
defer "if ($var_name) {";
defer_indent;
- my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env));
+ my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL},
+ check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"),
+ check_fully_dereferenced($e, $env));
defer "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));";
defer_deindent;
defer "}"
@@ -689,12 +691,12 @@ sub ParseElementPushLevel
#####################################################################
# parse scalars in a structure element
-sub ParseElementPush($$$$$$)
+sub ParseElementPush($$$$$)
{
- my ($e,$ndr,$var_prefix,$env,$primitives,$deferred) = @_;
+ my ($e,$ndr,$env,$primitives,$deferred) = @_;
my $subndr = undef;
- my $var_name = $var_prefix.$e->{NAME};
+ my $var_name = $env->{$e->{NAME}};
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
@@ -1096,11 +1098,11 @@ sub ParseElementPullLevel
#####################################################################
# parse scalars in a structure element - pull size
-sub ParseElementPull($$$$$$)
+sub ParseElementPull($$$$$)
{
- my($e,$ndr,$var_prefix,$env,$primitives,$deferred) = @_;
+ my($e,$ndr,$env,$primitives,$deferred) = @_;
- my $var_name = $var_prefix.$e->{NAME};
+ my $var_name = $env->{$e->{NAME}};
my $represent_name;
my $transmit_name;
@@ -1247,7 +1249,7 @@ sub ParseStructPush($$)
}
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPush($e, "ndr", "r->", $env, 1, 0);
+ ParseElementPush($e, "ndr", $env, 1, 0);
}
deindent;
@@ -1261,7 +1263,7 @@ sub ParseStructPush($$)
pidl "NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r));";
}
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPush($e, "ndr", "r->", $env, 0, 1);
+ ParseElementPush($e, "ndr", $env, 0, 1);
}
deindent;
@@ -1547,7 +1549,7 @@ sub ParseStructPull($$)
}
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPull($e, "ndr", "r->", $env, 1, 0);
+ ParseElementPull($e, "ndr", $env, 1, 0);
}
add_deferred();
@@ -1562,7 +1564,7 @@ sub ParseStructPull($$)
pidl "NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r));";
}
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPull($e, "ndr", "r->", $env, 0, 1);
+ ParseElementPull($e, "ndr", $env, 0, 1);
}
add_deferred();
@@ -1662,7 +1664,7 @@ sub ParseUnionPush($$)
pidl "NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));";
}
DeclareArrayVariables($el);
- ParseElementPush($el, "ndr", "r->", {}, 1, 0);
+ ParseElementPush($el, "ndr", {$el->{NAME} => "r->$el->{NAME}"}, 1, 0);
deindent;
}
pidl "break;";
@@ -1689,7 +1691,7 @@ sub ParseUnionPush($$)
pidl "$el->{CASE}:";
if ($el->{TYPE} ne "EMPTY") {
indent;
- ParseElementPush($el, "ndr", "r->", {}, 0, 1);
+ ParseElementPush($el, "ndr", {$el->{NAME} => "r->$el->{NAME}"}, 0, 1);
deindent;
}
pidl "break;";
@@ -1810,7 +1812,7 @@ sub ParseUnionPull($$)
# and store it based on the toplevel struct/union
pidl "NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));";
}
- ParseElementPull($el, "ndr", "r->", {}, 1, 0);
+ ParseElementPull($el, "ndr", {$el->{NAME} => "r->$el->{NAME}"}, 1, 0);
deindent;
}
pidl "break; }";
@@ -1837,7 +1839,7 @@ sub ParseUnionPull($$)
pidl "$el->{CASE}:";
if ($el->{TYPE} ne "EMPTY") {
indent;
- ParseElementPull($el, "ndr", "r->", {}, 0, 1);
+ ParseElementPull($el, "ndr", {$el->{NAME} => "r->$el->{NAME}"}, 0, 1);
deindent;
}
pidl "break;";
@@ -1993,7 +1995,7 @@ sub ParseFunctionPrint($)
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
- ParseElementPrint($e, "r->in.$e->{NAME}", $env);
+ ParseElementPrint($e, $env->{$e->{NAME}}, $env);
}
}
pidl "ndr->depth--;";
@@ -2008,7 +2010,7 @@ sub ParseFunctionPrint($)
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
- ParseElementPrint($e, "r->out.$e->{NAME}", $env);
+ ParseElementPrint($e, $env->{$e->{NAME}}, $env);
}
}
if ($fn->{RETURN_TYPE}) {
@@ -2050,7 +2052,7 @@ sub ParseFunctionPush($)
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
- ParseElementPush($e, "ndr", "r->in.", $env, 1, 1);
+ ParseElementPush($e, "ndr", $env, 1, 1);
}
}
@@ -2063,7 +2065,7 @@ sub ParseFunctionPush($)
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
- ParseElementPush($e, "ndr", "r->out.", $env, 1, 1);
+ ParseElementPush($e, "ndr", $env, 1, 1);
}
}
@@ -2147,7 +2149,7 @@ sub ParseFunctionPull($)
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/in/, @{$e->{DIRECTION}}));
- ParseElementPull($e, "ndr", "r->in.", $env, 1, 1);
+ ParseElementPull($e, "ndr", $env, 1, 1);
}
# allocate the "simple" out ref variables. FIXME: Shouldn't this have it's
@@ -2194,7 +2196,7 @@ sub ParseFunctionPull($)
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless grep(/out/, @{$e->{DIRECTION}});
- ParseElementPull($e, "ndr", "r->out.", $env, 1, 1);
+ ParseElementPull($e, "ndr", $env, 1, 1);
}
if ($fn->{RETURN_TYPE}) {