mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r14690: Support represent_as in headers, enable represent_as() test (which works now)
This commit is contained in:
parent
b199f5345c
commit
31e847a084
@ -55,19 +55,23 @@ sub HeaderElement($)
|
|||||||
my($element) = shift;
|
my($element) = shift;
|
||||||
|
|
||||||
pidl tabs();
|
pidl tabs();
|
||||||
HeaderType($element, $element->{TYPE}, "");
|
if (has_property($element, "represent_as")) {
|
||||||
pidl " ";
|
pidl mapType($element->{PROPERTIES}->{represent_as})." ";
|
||||||
my $numstar = $element->{POINTERS};
|
} else {
|
||||||
if ($numstar >= 1) {
|
HeaderType($element, $element->{TYPE}, "");
|
||||||
$numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE});
|
pidl " ";
|
||||||
|
my $numstar = $element->{POINTERS};
|
||||||
|
if ($numstar >= 1) {
|
||||||
|
$numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE});
|
||||||
|
}
|
||||||
|
foreach (@{$element->{ARRAY_LEN}})
|
||||||
|
{
|
||||||
|
next if is_constant($_) and
|
||||||
|
not has_property($element, "charset");
|
||||||
|
$numstar++;
|
||||||
|
}
|
||||||
|
pidl "*" foreach (1..$numstar);
|
||||||
}
|
}
|
||||||
foreach (@{$element->{ARRAY_LEN}})
|
|
||||||
{
|
|
||||||
next if is_constant($_) and
|
|
||||||
not has_property($element, "charset");
|
|
||||||
$numstar++;
|
|
||||||
}
|
|
||||||
pidl "*" foreach (1..$numstar);
|
|
||||||
pidl $element->{NAME};
|
pidl $element->{NAME};
|
||||||
foreach (@{$element->{ARRAY_LEN}}) {
|
foreach (@{$element->{ARRAY_LEN}}) {
|
||||||
next unless (is_constant($_) and
|
next unless (is_constant($_) and
|
||||||
@ -91,8 +95,8 @@ sub HeaderStruct($$)
|
|||||||
$tab_depth++;
|
$tab_depth++;
|
||||||
my $el_count=0;
|
my $el_count=0;
|
||||||
if (defined $struct->{ELEMENTS}) {
|
if (defined $struct->{ELEMENTS}) {
|
||||||
foreach my $e (@{$struct->{ELEMENTS}}) {
|
foreach (@{$struct->{ELEMENTS}}) {
|
||||||
HeaderElement($e);
|
HeaderElement($_);
|
||||||
$el_count++;
|
$el_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,10 +241,8 @@ sub HeaderFunctionInOut($$)
|
|||||||
{
|
{
|
||||||
my($fn,$prop) = @_;
|
my($fn,$prop) = @_;
|
||||||
|
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach (@{$fn->{ELEMENTS}}) {
|
||||||
if (has_property($e, $prop)) {
|
HeaderElement($_) if (has_property($_, $prop));
|
||||||
HeaderElement($e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,8 +670,6 @@ sub ParseElementPush($$$$$$)
|
|||||||
|
|
||||||
my $var_name = $var_prefix.$e->{NAME};
|
my $var_name = $var_prefix.$e->{NAME};
|
||||||
|
|
||||||
$var_name = append_prefix($e, $var_name);
|
|
||||||
|
|
||||||
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
|
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
|
||||||
|
|
||||||
# Representation type is different from transmit_as
|
# Representation type is different from transmit_as
|
||||||
@ -680,10 +678,12 @@ sub ParseElementPush($$$$$$)
|
|||||||
indent;
|
indent;
|
||||||
my $transmit_name = "_transmit_$e->{NAME}";
|
my $transmit_name = "_transmit_$e->{NAME}";
|
||||||
pidl mapType($e->{TYPE}) ." $transmit_name;";
|
pidl mapType($e->{TYPE}) ." $transmit_name;";
|
||||||
pidl "NDR_CHECK(ndr_$e->{REPRESENTATION_TYPE}_to_$e->{TYPE}($var_name, $transmit_name));";
|
pidl "NDR_CHECK(ndr_$e->{REPRESENTATION_TYPE}_to_$e->{TYPE}($var_name, " . get_pointer_to($transmit_name) . "));";
|
||||||
$var_name = $transmit_name;
|
$var_name = $transmit_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$var_name = append_prefix($e, $var_name);
|
||||||
|
|
||||||
start_flags($e);
|
start_flags($e);
|
||||||
|
|
||||||
if (my $value = has_property($e, "value")) {
|
if (my $value = has_property($e, "value")) {
|
||||||
@ -1073,6 +1073,7 @@ sub ParseElementPull($$$$$$)
|
|||||||
|
|
||||||
my $var_name = $var_prefix.$e->{NAME};
|
my $var_name = $var_prefix.$e->{NAME};
|
||||||
my $represent_name;
|
my $represent_name;
|
||||||
|
my $transmit_name;
|
||||||
|
|
||||||
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
|
return unless $primitives or ($deferred and ContainsDeferred($e, $e->{LEVELS}[0]));
|
||||||
|
|
||||||
@ -1080,7 +1081,8 @@ sub ParseElementPull($$$$$$)
|
|||||||
pidl "{";
|
pidl "{";
|
||||||
indent;
|
indent;
|
||||||
$represent_name = $var_name;
|
$represent_name = $var_name;
|
||||||
$var_name = "_transmit_$e->{NAME}";
|
$transmit_name = "_transmit_$e->{NAME}";
|
||||||
|
$var_name = $transmit_name;
|
||||||
pidl mapType($e->{TYPE})." $var_name;";
|
pidl mapType($e->{TYPE})." $var_name;";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1096,7 @@ sub ParseElementPull($$$$$$)
|
|||||||
|
|
||||||
# Representation type is different from transmit_as
|
# Representation type is different from transmit_as
|
||||||
if ($e->{REPRESENTATION_TYPE}) {
|
if ($e->{REPRESENTATION_TYPE}) {
|
||||||
pidl "NDR_CHECK(ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}($var_name, $represent_name));";
|
pidl "NDR_CHECK(ndr_$e->{TYPE}_to_$e->{REPRESENTATION_TYPE}($transmit_name, ".get_pointer_to($represent_name)."));";
|
||||||
deindent;
|
deindent;
|
||||||
pidl "}";
|
pidl "}";
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,9 @@ use lib "$RealBin/../lib";
|
|||||||
use lib "$RealBin";
|
use lib "$RealBin";
|
||||||
use Util qw(test_samba4_ndr);
|
use Util qw(test_samba4_ndr);
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
skip "represent_as() is not finished yet", 8;
|
|
||||||
|
|
||||||
test_samba4_ndr('represent_as-simple',
|
test_samba4_ndr('represent_as-simple',
|
||||||
'
|
'
|
||||||
void bla([in,represent_as(foo)] uint8 x);
|
void bla([in,represent_as(uint32)] uint8 x);
|
||||||
',
|
',
|
||||||
'
|
'
|
||||||
uint8_t expected[] = { 0x0D };
|
uint8_t expected[] = { 0x0D };
|
||||||
@ -25,25 +22,22 @@ test_samba4_ndr('represent_as-simple',
|
|||||||
if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
|
if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (r != 13)
|
if (r.in.x != 13)
|
||||||
return 2;
|
return 2;
|
||||||
',
|
',
|
||||||
'
|
'
|
||||||
#include <core/nterr.h>
|
#include <core/nterr.h>
|
||||||
typedef int foo;
|
|
||||||
|
|
||||||
NTSTATUS ndr_uint8_to_foo(uint8_t from, foo *to)
|
NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
|
||||||
{
|
{
|
||||||
*to = from;
|
*to = from;
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ndr_foo_to_uint8(foo from, uint8_t *to)
|
NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
|
||||||
{
|
{
|
||||||
*to = from;
|
*to = from;
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user