diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-09 00:57:27 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-09 00:57:27 +0000 |
commit | 2430e941d748beebd1297c83d176982e7ff89be7 (patch) | |
tree | 4b6e526724a654b93fae48b8453217a86c3c2096 /source4/build | |
parent | 574a11bd3720b4d9fd66b386ff32bdcfaf259478 (diff) | |
download | samba-2430e941d748beebd1297c83d176982e7ff89be7.tar.gz samba-2430e941d748beebd1297c83d176982e7ff89be7.tar.bz2 samba-2430e941d748beebd1297c83d176982e7ff89be7.zip |
added fixes for the pushing of arrays and handling non-ref pointers in
function arguments
(This used to be commit 25be8dafdae65d9b6cbd04514290f1402e882f4e)
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/pidl/idl.gram | 3 | ||||
-rw-r--r-- | source4/build/pidl/parser.pm | 35 |
2 files changed, 29 insertions, 9 deletions
diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram index 4ebd8fabe1..a5e89aadf4 100644 --- a/source4/build/pidl/idl.gram +++ b/source4/build/pidl/idl.gram @@ -25,7 +25,8 @@ interface: 'interface' <commit> identifier '{' definition(s?) '}' }} | <error?> -definition : typedef { $item[1] } +definition : cpp_prefix + | typedef { $item[1] } | function { $item[1] } typedef : 'typedef' <commit> type identifier array_len(?) ';' diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index e83d9391b6..86837dbc3b 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -74,7 +74,12 @@ sub ParseElementPushScalar($$$) $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"; + if (util::is_scalar_type($e->{TYPE}) || + $e->{POINTERS}) { + $res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}));\n"; + } else { + $res .= "\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, $ndr_flags, &$var_prefix$e->{NAME}));\n"; + } } } @@ -141,7 +146,7 @@ sub ParseElementPushBuffer($$) if (util::is_scalar_type($e->{TYPE})) { $res .= "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, *$var_prefix$e->{NAME}));\n"; } elsif (!$e->{POINTERS}) { - $res .= "\t\tNDR_CHECK(ndr_push_$e->{TYPE}(ndr, ndr_flags, *$var_prefix$e->{NAME}));\n"; + $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"; } else { @@ -157,10 +162,11 @@ sub ParseElementPushBuffer($$) ##################################################################### # parse buffers in a structure element - pull side -sub ParseElementPullBuffer($$) +sub ParseElementPullBuffer($$$) { my($e) = shift; my($var_prefix) = shift; + my($ndr_flags) = shift; if (util::has_property($e->{PROPERTIES}, "ref")) { return; @@ -179,11 +185,15 @@ sub ParseElementPullBuffer($$) } else { if (!$e->{POINTERS} || $e->{TYPE} =~ "unistr") { - $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, &$var_prefix$e->{NAME}));\n"; + if (util::is_builtin_type($e->{TYPE})) { + $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, &$var_prefix$e->{NAME}));\n"; + } else { + $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, &$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 { - $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, ndr_flags, $var_prefix$e->{NAME}));\n"; + $res .= "\t\tNDR_CHECK(ndr_pull_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}));\n"; } } @@ -292,7 +302,7 @@ sub ParseStructPull($) $res .= "buffers:\n"; $res .= "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n"; foreach my $e (@{$struct->{ELEMENTS}}) { - ParseElementPullBuffer($e, "r->"); + ParseElementPullBuffer($e, "r->", "ndr_flags"); } if (defined $struct_len) { @@ -411,6 +421,16 @@ sub ParseFunctionPull($) # pull function args $res .= "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, struct $fn->{NAME} *r)\n{\n"; + # declare any internal pointers we need + foreach my $e (@{$fn->{DATA}}) { + if (util::has_property($e->{PROPERTIES}, "out") && + $e->{POINTERS} && + !util::is_scalar_type($e->{TYPE}) && + !util::has_property($e->{PROPERTIES}, "ref")) { + $res .= "\tuint32 _ptr_$e->{NAME};\n"; + } + } + foreach my $arg (@{$fn->{DATA}}) { if (util::has_property($arg->{PROPERTIES}, "out")) { if ($arg->{POINTERS} && @@ -418,8 +438,7 @@ sub ParseFunctionPull($) $res .= "\tNDR_ALLOC(ndr, r->out.$arg->{NAME});\n"; } ParseElementPullScalar($arg, "r->out.", "NDR_SCALARS|NDR_BUFFERS"); - ParseElementPullBuffer($arg, "r->out."); - + ParseElementPullBuffer($arg, "r->out.", "NDR_SCALARS|NDR_BUFFERS"); } } |