summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-09 21:10:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:36 -0500
commit632acd9bc7704ac3d326354808c3d12f4f0a9f8f (patch)
treeb801c24612751b65c3af360e6842396f0e96d85b /source4/build/pidl
parent73d317e0dae5d9dd30300da9dd19abaaef5db03f (diff)
downloadsamba-632acd9bc7704ac3d326354808c3d12f4f0a9f8f.tar.gz
samba-632acd9bc7704ac3d326354808c3d12f4f0a9f8f.tar.bz2
samba-632acd9bc7704ac3d326354808c3d12f4f0a9f8f.zip
r5286: Some first steps in making the pidl code somewhat more generic for the
various data types: Add ndr_flags argument to all ndr push/pull scalar functions (This used to be commit ab490c0c882bb13de190546c50a0631ecb8255ad)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/header.pm8
-rw-r--r--source4/build/pidl/parser.pm76
-rw-r--r--source4/build/pidl/util.pm11
3 files changed, 29 insertions, 66 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm
index c1fb5e6619..21c86bd8b0 100644
--- a/source4/build/pidl/header.pm
+++ b/source4/build/pidl/header.pm
@@ -257,8 +257,8 @@ sub HeaderTypedefProto($)
}
if ($d->{DATA}{TYPE} eq "ENUM") {
- $res .= "NTSTATUS ndr_push_$d->{NAME}(struct ndr_push *ndr, enum $d->{NAME} r);\n";
- $res .= "NTSTATUS ndr_pull_$d->{NAME}(struct ndr_pull *ndr, enum $d->{NAME} *r);\n";
+ $res .= "NTSTATUS ndr_push_$d->{NAME}(struct ndr_push *ndr, int ndr_flags, enum $d->{NAME} r);\n";
+ $res .= "NTSTATUS ndr_pull_$d->{NAME}(struct ndr_pull *ndr, int ndr_flags, enum $d->{NAME} *r);\n";
if (!util::has_property($d, "noprint")) {
$res .= "void ndr_print_$d->{NAME}(struct ndr_print *ndr, const char *name, enum $d->{NAME} r);\n";
}
@@ -266,8 +266,8 @@ sub HeaderTypedefProto($)
if ($d->{DATA}{TYPE} eq "BITMAP") {
my $type_decl = util::bitmap_type_decl($d->{DATA});
- $res .= "NTSTATUS ndr_push_$d->{NAME}(struct ndr_push *ndr, $type_decl r);\n";
- $res .= "NTSTATUS ndr_pull_$d->{NAME}(struct ndr_pull *ndr, $type_decl *r);\n";
+ $res .= "NTSTATUS ndr_push_$d->{NAME}(struct ndr_push *ndr, int ndr_flags, $type_decl r);\n";
+ $res .= "NTSTATUS ndr_pull_$d->{NAME}(struct ndr_pull *ndr, int ndr_flags, $type_decl *r);\n";
if (!util::has_property($d, "noprint")) {
$res .= "void ndr_print_$d->{NAME}(struct ndr_print *ndr, const char *name, $type_decl r);\n";
}
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 092ac0b297..f1942cef73 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -256,13 +256,13 @@ sub ParseArrayPush($$$)
# the conformant size has already been pushed
} elsif (!util::is_inline_array($e)) {
# we need to emit the array size
- pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, $size));\n";
+ pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));\n";
}
if (my $length = util::has_property($e, "length_is")) {
$length = find_size_var($e, $length, $var_prefix);
- pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, 0));\n";
- pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, $length));\n";
+ pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));\n";
+ pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $length));\n";
$size = $length;
}
@@ -405,13 +405,7 @@ sub ParseElementPushScalar($$$)
} elsif (my $switch = util::has_property($e, "switch_is")) {
ParseElementPushSwitch($e, $var_prefix, $ndr_flags, $switch);
} elsif (defined $sub_size) {
- if (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_push_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_fn_t) ndr_push_$e->{TYPE}));\n";
- } else {
- pidl "\tNDR_CHECK(ndr_push_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_flags_fn_t) ndr_push_$e->{TYPE}));\n";
- }
- } elsif (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME}));\n";
+ pidl "\tNDR_CHECK(ndr_push_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_flags_fn_t) ndr_push_$e->{TYPE}));\n";
} else {
pidl "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix$e->{NAME}));\n";
}
@@ -478,7 +472,7 @@ sub ParseElementPullSwitch($$$$)
$type_decl = util::bitmap_type_decl($e2);
}
pidl "\t\t$type_decl _level;\n";
- pidl "\t\tNDR_CHECK(ndr_pull_$e2->{TYPE}(ndr, &_level));\n";
+ pidl "\t\tNDR_CHECK(ndr_pull_$e2->{TYPE}(ndr, NDR_SCALARS, &_level));\n";
if ($switch_var =~ /r->in/) {
pidl "\t\tif (!(ndr->flags & LIBNDR_FLAG_REF_ALLOC) && _level != $switch_var) {\n";
} else {
@@ -522,7 +516,7 @@ sub ParseElementPushSwitch($$$$)
!util::has_property($utype, "nodiscriminant")) {
my $e2 = find_sibling($e, $switch);
pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n";
- pidl "\t\tNDR_CHECK(ndr_push_$e2->{TYPE}(ndr, $switch_var));\n";
+ pidl "\t\tNDR_CHECK(ndr_push_$e2->{TYPE}(ndr, NDR_SCALARS, $switch_var));\n";
pidl "\t}\n";
}
@@ -581,13 +575,7 @@ sub ParseElementPullScalar($$$)
} elsif (my $switch = util::has_property($e, "switch_is")) {
ParseElementPullSwitch($e, $var_prefix, $ndr_flags, $switch);
} elsif (defined $sub_size) {
- if (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) ndr_pull_$e->{TYPE}));\n";
- } else {
- pidl "\tNDR_CHECK(ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE}));\n";
- }
- } elsif (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME}));\n";
+ pidl "\tNDR_CHECK(ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE}));\n";
} else {
pidl "\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix$e->{NAME}));\n";
}
@@ -635,14 +623,8 @@ sub ParseElementPushBuffer($$$)
}
} elsif (defined $sub_size) {
if ($e->{POINTERS}) {
- if (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_push_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_fn_t) ndr_push_$e->{TYPE}));\n";
- } else {
- pidl "\tNDR_CHECK(ndr_push_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_flags_fn_t) ndr_push_$e->{TYPE}));\n";
- }
+ pidl "\tNDR_CHECK(ndr_push_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_push_flags_fn_t) ndr_push_$e->{TYPE}));\n";
}
- } elsif (util::is_builtin_type($e->{TYPE})) {
- pidl "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME}));\n";
} elsif ($e->{POINTERS}) {
pidl "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, NDR_SCALARS|NDR_BUFFERS, $cprefix$var_prefix$e->{NAME}));\n";
} else {
@@ -719,14 +701,8 @@ sub ParseElementPullBuffer($$$)
}
} elsif (defined $sub_size) {
if ($e->{POINTERS}) {
- if (util::is_builtin_type($e->{TYPE})) {
- pidl "\tNDR_CHECK(ndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) ndr_pull_$e->{TYPE}));\n";
- } else {
- pidl "\tNDR_CHECK(ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE}));\n";
- }
+ pidl "\tNDR_CHECK(ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE}));\n";
}
- } elsif (util::is_builtin_type($e->{TYPE})) {
- pidl "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME}));\n";
} elsif ($e->{POINTERS}) {
pidl "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, NDR_SCALARS|NDR_BUFFERS, $cprefix$var_prefix$e->{NAME}));\n";
} else {
@@ -765,12 +741,12 @@ sub ParseStructPush($)
my $size = find_size_var($e, util::array_size($e), "r->");
$e->{CONFORMANT_SIZE} = $size;
check_null_pointer($size);
- pidl "\tNDR_CHECK(ndr_push_uint32(ndr, $size));\n";
+ pidl "\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));\n";
}
if (defined $e->{TYPE} && $e->{TYPE} eq "string"
&& util::property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*")) {
- pidl "\tNDR_CHECK(ndr_push_uint32(ndr, ndr_string_array_size(ndr, r->$e->{NAME})));\n";
+ pidl "\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, r->$e->{NAME})));\n";
}
pidl "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n";
@@ -807,7 +783,7 @@ sub ParseEnumPush($)
start_flags($enum);
- pidl "\tNDR_CHECK(ndr_push_$type_fn(ndr, r));\n";
+ pidl "\tNDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, r));\n";
end_flags($enum);
}
@@ -822,7 +798,7 @@ sub ParseEnumPull($)
pidl "\t$type_v_decl v;\n";
start_flags($enum);
- pidl "\tNDR_CHECK(ndr_pull_$type_fn(ndr, &v));\n";
+ pidl "\tNDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));\n";
pidl "\t*r = v;\n";
end_flags($enum);
@@ -864,7 +840,7 @@ sub ParseBitmapPush($)
start_flags($bitmap);
- pidl "\tNDR_CHECK(ndr_push_$type_fn(ndr, r));\n";
+ pidl "\tNDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, r));\n";
end_flags($bitmap);
}
@@ -879,7 +855,7 @@ sub ParseBitmapPull($)
pidl "\t$type_decl v;\n";
start_flags($bitmap);
- pidl "\tNDR_CHECK(ndr_pull_$type_fn(ndr, &v));\n";
+ pidl "\tNDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));\n";
pidl "\t*r = v;\n";
end_flags($bitmap);
@@ -993,7 +969,7 @@ sub ParseStructPull($)
pidl "\tNDR_CHECK(ndr_pull_struct_start(ndr));\n";
if (defined $conform_e) {
- pidl "\tNDR_CHECK(ndr_pull_uint32(ndr, &$conform_e->{CONFORMANT_SIZE}));\n";
+ pidl "\tNDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &$conform_e->{CONFORMANT_SIZE}));\n";
}
my $align = struct_alignment($struct);
@@ -1292,7 +1268,7 @@ sub ParseTypedefPush($)
}
if ($e->{DATA}->{TYPE} eq "ENUM") {
- pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, enum $e->{NAME} r)";
+ pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, enum $e->{NAME} r)";
pidl "\n{\n";
ParseTypePush($e->{DATA});
pidl "\treturn NT_STATUS_OK;\n";
@@ -1301,7 +1277,7 @@ sub ParseTypedefPush($)
if ($e->{DATA}->{TYPE} eq "BITMAP") {
my $type_decl = util::bitmap_type_decl($e->{DATA});
- pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, $type_decl r)";
+ pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, $type_decl r)";
pidl "\n{\n";
ParseTypePush($e->{DATA});
pidl "\treturn NT_STATUS_OK;\n";
@@ -1343,7 +1319,7 @@ sub ParseTypedefPull($)
}
if ($e->{DATA}->{TYPE} eq "ENUM") {
- pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, enum $e->{NAME} *r)";
+ pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, enum $e->{NAME} *r)";
pidl "\n{\n";
ParseTypePull($e->{DATA});
pidl "\treturn NT_STATUS_OK;\n";
@@ -1352,7 +1328,7 @@ sub ParseTypedefPull($)
if ($e->{DATA}->{TYPE} eq "BITMAP") {
my $type_decl = util::bitmap_type_decl($e->{DATA});
- pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, $type_decl *r)";
+ pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, $type_decl *r)";
pidl "\n{\n";
ParseTypePull($e->{DATA});
pidl "\treturn NT_STATUS_OK;\n";
@@ -1454,11 +1430,9 @@ sub ParseFunctionPrint($)
}
}
if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
- if (util::is_scalar_type($fn->{RETURN_TYPE})) {
- pidl "\tndr_print_$fn->{RETURN_TYPE}(ndr, \"result\", r->out.result);\n";
- } else {
- pidl "\tndr_print_$fn->{RETURN_TYPE}(ndr, \"result\", &r->out.result);\n";
- }
+ my $cprefix = "&";
+ $cprefix = "" if (util::is_scalar_type($fn->{RETURN_TYPE})) ; # FIXME: Should really use util::c_push_prefix here
+ pidl "\tndr_print_$fn->{RETURN_TYPE}(ndr, \"result\", $cprefix"."r->out.result);\n";
}
pidl "\tndr->depth--;\n";
pidl "\t}\n";
@@ -1519,7 +1493,7 @@ sub ParseFunctionPush($)
}
if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
- pidl "\tNDR_CHECK(ndr_push_$fn->{RETURN_TYPE}(ndr, r->out.result));\n";
+ pidl "\tNDR_CHECK(ndr_push_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, r->out.result));\n";
}
pidl "\ndone:\n";
@@ -1660,7 +1634,7 @@ sub ParseFunctionPull($)
}
if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
- pidl "\tNDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}(ndr, &r->out.result));\n";
+ pidl "\tNDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, &r->out.result));\n";
}
pidl "\ndone:\n";
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 112b617806..bb5de2a8ed 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -346,17 +346,6 @@ sub type_align($)
return 4;
}
-# this is used to determine if the ndr push/pull functions will need
-# a ndr_flags field to split by buffers/scalars
-sub is_builtin_type($)
-{
- my($type) = shift;
-
- return 1, if (is_scalar_type($type));
-
- return 0;
-}
-
# determine if an element needs a reference pointer on the wire
# in its NDR representation
sub need_wire_pointer($)