summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/pidl/TODO3
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm23
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm1
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm15
-rwxr-xr-xsource4/pidl/pidl5
-rw-r--r--source4/pidl/tests/Util.pm7
-rw-r--r--source4/pidl/tests/ndr_represent.pl40
7 files changed, 85 insertions, 9 deletions
diff --git a/source4/pidl/TODO b/source4/pidl/TODO
index db64df3dd9..6203bd412f 100644
--- a/source4/pidl/TODO
+++ b/source4/pidl/TODO
@@ -12,6 +12,9 @@
- auto-alloc [ref] pointers for Samba4 during pull if they were NULL
- replace subcontext() with represent_as()
+ - NTSTATUS FROM_to_TO (const FROM *f, TO **t); /* FIXME: t needs to be allocated using talloc */
+ - NTSTATUS TO_to_FROM (const TO *t, FROM **f); /* FIXME: f needs to be allocated using talloc */
+ - `
- --explain-ndr option that dumps out parse tree ?
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index a709abba10..1d5059bfb5 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -2,7 +2,7 @@
# Samba4 NDR info tree generator
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001
-# Copyright jelmer@samba.org 2004-2005
+# Copyright jelmer@samba.org 2004-2006
# released under the GNU GPL
=pod
@@ -258,6 +258,8 @@ sub GetElementLevelTable($)
push (@$order, {
TYPE => "DATA",
+ CONVERT_TO => has_property($e, ""),
+ CONVERT_FROM => has_property($e, ""),
DATA_TYPE => $e->{TYPE},
IS_DEFERRED => $is_deferred,
CONTAINS_DEFERRED => can_contain_deferred($e),
@@ -319,8 +321,8 @@ sub find_largest_alignment($)
$a = 4;
} elsif (has_property($e, "subcontext")) {
$a = 1;
- } elsif (has_property($e, "represent_as")) {
- $a = align_type($e->{PROPERTIES}->{represent_as});
+ } elsif (has_property($e, "transmit_as")) {
+ $a = align_type($e->{PROPERTIES}->{transmit_as});
} else {
$a = align_type($e->{TYPE});
}
@@ -368,6 +370,7 @@ sub ParseElement($)
TYPE => $e->{TYPE},
PROPERTIES => $e->{PROPERTIES},
LEVELS => GetElementLevelTable($e),
+ REPRESENTATION_TYPE => $e->{PROPERTIES}->{represent_as},
ALIGN => align_type($e->{TYPE}),
ORIGINAL => $e
};
@@ -796,6 +799,7 @@ my %property_list = (
"default" => ["ELEMENT"],
"represent_as" => ["ELEMENT"],
+ "transmit_as" => ["ELEMENT"],
# subcontext
"subcontext" => ["ELEMENT"],
@@ -900,6 +904,19 @@ sub ValidElement($)
}
}
+
+ if (has_property($e, "subcontext") and has_property($e, "represent_as")) {
+ fatal($e, el_name($e) . " : subcontext() and represent_as() can not be used on the same element");
+ }
+
+ if (has_property($e, "subcontext") and has_property($e, "transmit_as")) {
+ fatal($e, el_name($e) . " : subcontext() and transmit_as() can not be used on the same element");
+ }
+
+ if (has_property($e, "represent_as") and has_property($e, "transmit_as")) {
+ fatal($e, el_name($e) . " : represent_as() and transmit_as() can not be used on the same element");
+ }
+
if (defined (has_property($e, "subcontext_size")) and not defined(has_property($e, "subcontext"))) {
fatal($e, el_name($e) . " : subcontext_size() on non-subcontext element");
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index f19f4df319..ace1e79672 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -1,6 +1,7 @@
###################################################
# client calls generator
# Copyright tridge@samba.org 2003
+# Copyright jelmer@samba.org 2005-2006
# released under the GNU GPL
package Parse::Pidl::Samba4::NDR::Client;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index bc7e4ce545..81e30e1053 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -2,7 +2,7 @@
# Samba4 NDR parser generator for IDL structures
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001
-# Copyright jelmer@samba.org 2004-2005
+# Copyright jelmer@samba.org 2004-2006
# released under the GNU GPL
package Parse::Pidl::Samba4::NDR::Parser;
@@ -674,6 +674,12 @@ sub ParseElementPush($$$$$$)
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
+ # Representation type is different from transmit_as
+ if ($e->{REPRESENTATION_TYPE}) {
+ pidl "/* FIXME: Convert from $e->{REPRESENTATION_TYPE} to $e->{TYPE} */";
+ pidl "NDR_CHECK(ndr_$e->{REPRESENTATION_TYPE}_to_$e->{TYPE}(FIXME, FIXME));";
+ }
+
start_flags($e);
if (my $value = has_property($e, "value")) {
@@ -683,6 +689,7 @@ sub ParseElementPush($$$$$$)
ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred);
end_flags($e);
+
}
#####################################################################
@@ -1067,6 +1074,12 @@ sub ParseElementPull($$$$$$)
ParseElementPullLevel($e,$e->{LEVELS}[0],$ndr,$var_name,$env,$primitives,$deferred);
end_flags($e);
+
+ # Representation type is different from transmit_as
+ if ($e->{REPRESENTATION_TYPE}) {
+ pidl "/* FIXME: Convert from $e->{TYPE} to $e->{REPRESENTATION_TYPE} */";
+ pidl "NDR_CHECK(ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}(FIXME, FIXME));";
+ }
}
#####################################################################
diff --git a/source4/pidl/pidl b/source4/pidl/pidl
index d913e84e7d..314ab7c60b 100755
--- a/source4/pidl/pidl
+++ b/source4/pidl/pidl
@@ -279,7 +279,8 @@ Datagram support (ncadg_*)
in, out, ref, length_is, switch_is, size_is, uuid, case, default, string,
unique, ptr, pointer_default, v1_enum, object, helpstring, range, local,
-call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as.
+call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as,
+transmit_as.
=head2 PIDL Specific properties
@@ -357,7 +358,7 @@ helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib,
import, include, includelib, last_is, lcid, licensed, max_is, module,
ms_union, no_injected_text, nonbrowsable, noncreatable, nonextensible, odl,
oleautomation, optional, pragma, propget, propputref, propput, readonly,
-requestedit, restricted, retval, source, transmit_as, uidefault,
+requestedit, restricted, retval, source, uidefault,
usesgetlasterror, vararg, vi_progid, wire_marshal.
=head1 EXAMPLES
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
index 3e0f214854..bb633f6e32 100644
--- a/source4/pidl/tests/Util.pm
+++ b/source4/pidl/tests/Util.pm
@@ -1,5 +1,5 @@
# Some simple utility functions for pidl tests
-# Copyright (C) 2005 Jelmer Vernooij
+# Copyright (C) 2005-2006 Jelmer Vernooij
# Published under the GNU General Public License
package Util;
@@ -18,9 +18,9 @@ use Parse::Pidl::Samba4::Header;
# Generate a Samba4 parser for an IDL fragment and run it with a specified
# piece of code to check whether the parser works as expected
-sub test_samba4_ndr($$$)
+sub test_samba4_ndr
{
- my ($name,$idl,$c) = @_;
+ my ($name,$idl,$c,$extra) = @_;
my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>");
ok(defined($pidl), "($name) parse idl");
@@ -58,6 +58,7 @@ SKIP: {
print CC $header;
print CC $ndrheader;
print CC $ndrparser;
+ print CC $extra if ($extra);
print CC "int main(int argc, const char **argv)
{
TALLOC_CTX *mem_ctx = talloc_init(NULL);
diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl
new file mode 100644
index 0000000000..772df2b94e
--- /dev/null
+++ b/source4/pidl/tests/ndr_represent.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+# NDR represent_as() / transmit_as() tests
+# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
+use strict;
+
+use Test::More tests => 1 * 8;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+use lib "$RealBin";
+use Util qw(test_samba4_ndr);
+
+SKIP: {
+ skip "represent_as() is not finished yet", 8;
+
+test_samba4_ndr('represent_as-simple',
+'
+ void bla([in,represent_as(foo)] uint8 x);
+',
+'
+ uint8_t expected[] = { 0x0D };
+ DATA_BLOB in_blob = { expected, 1 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL);
+ struct bla r;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
+ return 1;
+
+ if (r != 13)
+ return 2;
+',
+'
+NTSTATUS ndr_uint8_to_foo(uint8 from, foo *to)
+{
+ *to = from;
+ return NT_STATUS_OK;
+}
+'
+);
+
+}