mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
(This used to be commit 66327b8bd8
)
This commit is contained in:
commit
dfedfae1cd
@ -9,7 +9,7 @@ package Parse::Pidl::Samba3::ClientNDR;
|
|||||||
|
|
||||||
use Exporter;
|
use Exporter;
|
||||||
@ISA = qw(Exporter);
|
@ISA = qw(Exporter);
|
||||||
@EXPORT_OK = qw(ParseFunction $res $res_hdr);
|
@EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Parse::Pidl qw(fatal warning);
|
use Parse::Pidl qw(fatal warning);
|
||||||
@ -73,6 +73,40 @@ sub HeaderProperties($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ParseOutputArgument($$$)
|
||||||
|
{
|
||||||
|
my ($self, $fn, $e) = @_;
|
||||||
|
my $level = 0;
|
||||||
|
|
||||||
|
fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
|
||||||
|
|
||||||
|
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
||||||
|
$level = 1;
|
||||||
|
if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
|
||||||
|
$self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
|
||||||
|
$self->indent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
|
||||||
|
# This is a call to GenerateFunctionInEnv intentionally.
|
||||||
|
# Since the data is being copied into a user-provided data
|
||||||
|
# structure, the user should be able to know the size beforehand
|
||||||
|
# to allocate a structure of the right size.
|
||||||
|
my $env = GenerateFunctionInEnv($fn, "r.");
|
||||||
|
my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
|
||||||
|
$self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
|
||||||
|
} else {
|
||||||
|
$self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
||||||
|
if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
|
||||||
|
$self->deindent;
|
||||||
|
$self->pidl("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub ParseFunction($$$)
|
sub ParseFunction($$$)
|
||||||
{
|
{
|
||||||
@ -147,36 +181,9 @@ sub ParseFunction($$$)
|
|||||||
$self->pidl("/* Return variables */");
|
$self->pidl("/* Return variables */");
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||||
next unless (grep(/out/, @{$e->{DIRECTION}}));
|
next unless (grep(/out/, @{$e->{DIRECTION}}));
|
||||||
my $level = 0;
|
|
||||||
|
|
||||||
fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
|
$self->ParseOutputArgument($fn, $e);
|
||||||
|
|
||||||
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
|
||||||
$level = 1;
|
|
||||||
if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
|
|
||||||
$self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
|
|
||||||
$self->indent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
|
|
||||||
# This is a call to GenerateFunctionInEnv intentionally.
|
|
||||||
# Since the data is being copied into a user-provided data
|
|
||||||
# structure, the user should be able to know the size beforehand
|
|
||||||
# to allocate a structure of the right size.
|
|
||||||
my $env = GenerateFunctionInEnv($fn, "r.");
|
|
||||||
my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
|
|
||||||
$self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is);");
|
|
||||||
} else {
|
|
||||||
$self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
|
||||||
if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
|
|
||||||
$self->deindent;
|
|
||||||
$self->pidl("}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->pidl("");
|
$self->pidl("");
|
||||||
|
@ -952,16 +952,15 @@ sub ConvertObjectToPythonLevel($$$$$)
|
|||||||
$self->pidl("}");
|
$self->pidl("}");
|
||||||
}
|
}
|
||||||
} elsif ($l->{TYPE} eq "ARRAY") {
|
} elsif ($l->{TYPE} eq "ARRAY") {
|
||||||
if (is_charset_array($e, $l)) {
|
my $pl = GetPrevLevel($e, $l);
|
||||||
|
if ($pl && $pl->{TYPE} eq "POINTER") {
|
||||||
$var_name = get_pointer_to($var_name);
|
$var_name = get_pointer_to($var_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_charset_array($e, $l)) {
|
||||||
# FIXME: Use Unix charset setting rather than utf-8
|
# FIXME: Use Unix charset setting rather than utf-8
|
||||||
$self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
|
$self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
|
||||||
} else {
|
} else {
|
||||||
my $pl = GetPrevLevel($e, $l);
|
|
||||||
if ($pl && $pl->{TYPE} eq "POINTER") {
|
|
||||||
$var_name = get_pointer_to($var_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
|
die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
|
||||||
my $length = $l->{SIZE_IS};
|
my $length = $l->{SIZE_IS};
|
||||||
if (defined($l->{LENGTH_IS})) {
|
if (defined($l->{LENGTH_IS})) {
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 8;
|
use Test::More tests => 9;
|
||||||
use FindBin qw($RealBin);
|
use FindBin qw($RealBin);
|
||||||
use lib "$RealBin";
|
use lib "$RealBin";
|
||||||
use Util;
|
use Util;
|
||||||
use Parse::Pidl::Util qw(MyDumper);
|
use Parse::Pidl::Util qw(MyDumper);
|
||||||
use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction);
|
use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument);
|
||||||
use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
|
use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
|
||||||
|
|
||||||
# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
|
# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
|
||||||
@ -117,3 +117,12 @@ is($x->{res},
|
|||||||
}
|
}
|
||||||
|
|
||||||
");
|
");
|
||||||
|
|
||||||
|
$x = new Parse::Pidl::Samba3::ClientNDR();
|
||||||
|
|
||||||
|
$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
|
||||||
|
my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },
|
||||||
|
LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};
|
||||||
|
|
||||||
|
$x->ParseOutputArgument($fn, $e);
|
||||||
|
is($x->{res}, "memcpy(foo, r.out.foo, mysize * sizeof(*foo));\n");
|
||||||
|
@ -39,7 +39,7 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
|
|||||||
PyObject *py_talloc_default_repr(PyObject *py_obj)
|
PyObject *py_talloc_default_repr(PyObject *py_obj)
|
||||||
{
|
{
|
||||||
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
|
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
|
||||||
|
PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
|
||||||
|
|
||||||
return PyString_FromFormat("<talloc: %s>",
|
return PyString_FromFormat("<%s>", type->tp_name);
|
||||||
talloc_get_name(obj->talloc_ctx));
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ class UnixinfoTests(RpcInterfaceTestCase):
|
|||||||
def test_getpwuid(self):
|
def test_getpwuid(self):
|
||||||
infos = self.conn.GetPWUid(range(512))
|
infos = self.conn.GetPWUid(range(512))
|
||||||
self.assertEquals(512, len(infos))
|
self.assertEquals(512, len(infos))
|
||||||
|
self.assertEquals("", infos[0].shell)
|
||||||
|
self.assertEquals("", infos[0].homedir)
|
||||||
|
|
||||||
def test_gidtosid(self):
|
def test_gidtosid(self):
|
||||||
self.conn.GidToSid(1000)
|
self.conn.GidToSid(1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user