mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r14687: Start working on support for represent_as() and transmit_as() as
an alternative to subcontext()
This commit is contained in:
parent
a7279f13f0
commit
744402160d
@ -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 ?
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));";
|
||||
}
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
40
source/pidl/tests/ndr_represent.pl
Normal file
40
source/pidl/tests/ndr_represent.pl
Normal file
@ -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;
|
||||
}
|
||||
'
|
||||
);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user