Rev 11387: Deprecate subcontext(). in
file:///home/jelmer/bzr.samba/SAMBA_4_0/
Jelmer Vernooij
jelmer at samba.org
Wed Feb 7 17:58:02 GMT 2007
At file:///home/jelmer/bzr.samba/SAMBA_4_0/
------------------------------------------------------------
revno: 11387
revision-id: jelmer at samba.org-20070207175747-p9n4fspman7yyrw4
parent: jelmer at samba.org-20070207175511-dgqr6231chj5tw6d
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Wed 2007-02-07 18:57:47 +0100
message:
Deprecate subcontext().
added:
source/pidl/tests/ndr_deprecations.pl ndr_deprecations.pl-20070207141838-38btwf0hx7cwmnhp-1
modified:
source/pidl/TODO svn-v2:9459 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2fTODO
source/pidl/lib/Parse/Pidl/NDR.pm svn-v2:9460 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fNDR.pm
source/pidl/pidl svn-v2:9459 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2fpidl
source/pidl/tests/ndr_represent.pl* svn-v2:14687 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fndr_represent.pl
=== added file 'source/pidl/tests/ndr_deprecations.pl'
--- a/source/pidl/tests/ndr_deprecations.pl 1970-01-01 00:00:00 +0000
+++ b/source/pidl/tests/ndr_deprecations.pl 2007-02-07 17:57:47 +0000
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU General Public License
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util;
+use Parse::Pidl::Util qw(MyDumper);
+use Parse::Pidl::NDR qw(ValidElement);
+
+# Case 1
+
+my $e = {
+ 'FILE' => 'foo.idl',
+ 'NAME' => 'v',
+ 'PROPERTIES' => {"subcontext" => 1},
+ 'POINTERS' => 0,
+ 'TYPE' => 'uint8',
+ 'PARENT' => { TYPE => 'STRUCT' },
+ 'LINE' => 42 };
+
+test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
+ sub { ValidElement($e); });
+
+
=== modified file 'source/pidl/TODO'
--- a/source/pidl/TODO 2006-09-15 20:07:55 +0000
+++ b/source/pidl/TODO 2007-02-07 17:57:47 +0000
@@ -1,8 +1,6 @@
- EJS output backend shouldn't use the NDR levels stuff but instead
as the "C levels" and NDR levels don't necessarily match.
-- warn about [out] attributes on pointers (midl/samba3 compatibility)
-
- true multiple dimension array / strings in arrays support
- compatibility mode for generating MIDL-readable data:
@@ -21,3 +19,5 @@
- allow data structures outside of interfaces
- mem_ctx in the interface rather than as struct ndr member.
+
+- real typelibs
=== modified file 'source/pidl/lib/Parse/Pidl/NDR.pm'
--- a/source/pidl/lib/Parse/Pidl/NDR.pm 2007-01-09 15:50:36 +0000
+++ b/source/pidl/lib/Parse/Pidl/NDR.pm 2007-02-07 17:57:47 +0000
@@ -35,7 +35,7 @@
$VERSION = '0.01';
@ISA = qw(Exporter);
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
- at EXPORT_OK = qw(GetElementLevelTable ParseElement);
+ at EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement);
use strict;
use Parse::Pidl qw(warning fatal);
@@ -902,7 +902,6 @@
}
}
-
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");
}
@@ -919,6 +918,10 @@
fatal($e, el_name($e) . " : represent_as() and value() can not be used on the same element");
}
+ if (has_property($e, "subcontext")) {
+ warning($e, "subcontext() is deprecated. Use represent_as() or transmit_as() instead");
+ }
+
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");
}
=== modified file 'source/pidl/pidl'
--- a/source/pidl/pidl 2007-01-22 00:04:59 +0000
+++ b/source/pidl/pidl 2007-02-07 17:57:47 +0000
@@ -4,7 +4,7 @@
# package to parse IDL files and generate code for
# rpc functions in Samba
# Copyright tridge at samba.org 2000-2003
-# Copyright jelmer at samba.org 2005
+# Copyright jelmer at samba.org 2005-2007
# released under the GNU GPL
=pod
@@ -319,6 +319,9 @@
bytes should be read, followed by a blob of that size,
which will be parsed as NDR.
+subcontext() is deprecated now, and should not be used in new code.
+Instead, use represent_as() or transmit_as().
+
=item flag
Specify boolean options, mostly used for
=== modified file 'source/pidl/tests/ndr_represent.pl' (properties changed)
--- a/source/pidl/tests/ndr_represent.pl 2007-01-05 15:03:21 +0000
+++ b/source/pidl/tests/ndr_represent.pl 2007-02-07 17:57:47 +0000
@@ -3,7 +3,7 @@
# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
use strict;
-use Test::More tests => 1 * 8;
+use Test::More tests => 3 * 8;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_samba4_ndr);
@@ -40,3 +40,75 @@
}
'
);
+
+test_samba4_ndr('transmit_as-simple',
+'
+ void bla([in,transmit_as(uint32)] 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.in.x != 13)
+ return 2;
+',
+'
+#include <libcli/util/nterr.h>
+
+NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
+{
+ *to = from;
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
+{
+ *to = from;
+ return NT_STATUS_OK;
+}
+'
+);
+
+test_samba4_ndr('represent_as-custom-type',
+'
+ void bla([in,represent_as(mytype)] 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.in.x.header != 42)
+ return 2;
+
+ if (r.in.x.data != 13)
+ return 3;
+',
+'
+#include <libcli/util/nterr.h>
+
+NTSTATUS ndr_uint8_to_mytype(uint8_t from, struct mytype *to)
+{
+ to->header = 42;
+ to->data = from;
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_uint32_to_uint8(struct mytype from, uint8_t *to)
+{
+ *to = from->data;
+ return NT_STATUS_OK;
+}
+'
+);
+
+
More information about the samba-cvs
mailing list