summaryrefslogtreecommitdiff
path: root/source4/build/pidl/parser.pm
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/pidl/parser.pm')
-rw-r--r--source4/build/pidl/parser.pm60
1 files changed, 52 insertions, 8 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 0029aef603..e83d9391b6 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -67,7 +67,12 @@ sub ParseElementPushScalar($$$)
!util::has_property($e->{PROPERTIES}, "ref")) {
$res .= "\tNDR_CHECK(ndr_push_ptr(ndr, $var_prefix$e->{NAME}));\n";
} elsif (util::is_builtin_type($e->{TYPE})) {
- $res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
+ if (util::is_scalar_type($e->{TYPE}) &&
+ util::has_property($e->{PROPERTIES}, "ref")) {
+ $res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, *$var_prefix$e->{NAME}));\n";
+ } else {
+ $res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
+ }
} else {
$res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}));\n";
}
@@ -75,10 +80,11 @@ sub ParseElementPushScalar($$$)
#####################################################################
# parse scalars in a structure element - pull size
-sub ParseElementPullScalar($$)
+sub ParseElementPullScalar($$$)
{
my($e) = shift;
my($var_prefix) = shift;
+ my($ndr_flags) = shift;
if (defined $e->{VALUE}) {
$res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $e->{VALUE}));\n";
@@ -90,8 +96,23 @@ sub ParseElementPullScalar($$)
$res .= "\t} else {\n";
$res .= "\t\t$var_prefix$e->{NAME} = NULL;\n";
$res .= "\t}\n";
+ } elsif (!util::is_scalar_type($e->{TYPE}) &&
+ util::has_property($e->{PROPERTIES}, "ref")) {
+ if (util::is_builtin_type($e->{TYPE})) {
+ $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
+ } else {
+ $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}));\n";
+ }
} else {
- $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, &$var_prefix$e->{NAME}));\n";
+ if (util::is_builtin_type($e->{TYPE})) {
+ if (!util::has_property($e->{PROPERTIES}, "ref")) {
+ $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, &$var_prefix$e->{NAME}));\n";
+ } else {
+ $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
+ }
+ } else {
+ $res .= "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, &$var_prefix$e->{NAME}));\n";
+ }
}
}
@@ -119,7 +140,7 @@ sub ParseElementPushBuffer($$)
} else {
if (util::is_scalar_type($e->{TYPE})) {
$res .= "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, *$var_prefix$e->{NAME}));\n";
- } elsif (util::has_property($e->{PROPERTIES}, "ref") || !$e->{POINTERS}) {
+ } elsif (!$e->{POINTERS}) {
$res .= "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, ndr_flags, *$var_prefix$e->{NAME}));\n";
} elsif (util::is_builtin_type($e->{TYPE})) {
$res .= "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
@@ -156,10 +177,9 @@ sub ParseElementPullBuffer($$)
if (util::has_property($e->{PROPERTIES}, "size_is")) {
ParseArrayPull($e);
} else {
- if (util::has_property($e->{PROPERTIES}, "ref") ||
- !$e->{POINTERS} ||
+ if (!$e->{POINTERS} ||
$e->{TYPE} =~ "unistr") {
- $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, \&$var_prefix$e->{NAME}));\n";
+ $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, &$var_prefix$e->{NAME}));\n";
} elsif (util::is_builtin_type($e->{TYPE})) {
$res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $var_prefix$e->{NAME}));\n";
} else {
@@ -263,7 +283,7 @@ sub ParseStructPull($)
$res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n";
foreach my $e (@{$struct->{ELEMENTS}}) {
- ParseElementPullScalar($e, "r->");
+ ParseElementPullScalar($e, "r->", "NDR_SCALARS");
if (defined($struct_len) && $e == $struct_len) {
$res .= "\tNDR_CHECK(ndr_pull_limit_size(ndr, _size, 4));\n";
}
@@ -386,6 +406,29 @@ sub ParseFunctionPush($)
# parse a function
sub ParseFunctionPull($)
{
+ my($fn) = shift;
+
+ # pull function args
+ $res .= "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, struct $fn->{NAME} *r)\n{\n";
+
+ foreach my $arg (@{$fn->{DATA}}) {
+ if (util::has_property($arg->{PROPERTIES}, "out")) {
+ if ($arg->{POINTERS} &&
+ !util::has_property($arg->{PROPERTIES}, "ref")) {
+ $res .= "\tNDR_ALLOC(ndr, r->out.$arg->{NAME});\n";
+ }
+ ParseElementPullScalar($arg, "r->out.", "NDR_SCALARS|NDR_BUFFERS");
+ ParseElementPullBuffer($arg, "r->out.");
+
+ }
+ }
+
+ if ($fn->{RETURN_TYPE}) {
+ $res .= "\tNDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}(ndr, &r->out.result));\n";
+ }
+
+
+ $res .= "\n\treturn NT_STATUS_OK;\n}\n\n";
}
#####################################################################
@@ -427,6 +470,7 @@ sub Parse($)
{
my($idl) = shift;
$res = "/* parser auto-generated by pidl */\n\n";
+ $res .= "#include \"includes.h\"\n\n";
foreach my $x (@{$idl}) {
($x->{TYPE} eq "INTERFACE") &&
ParseInterface($x);