summaryrefslogtreecommitdiff
path: root/source4/pidl/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-04 03:44:32 -0600
committerStefan Metzmacher <metze@samba.org>2008-01-03 21:51:01 -0600
commitc9afddd42c916328980390251938508165ad130f (patch)
tree034b3e9ea63aa146982533936333e4f0f6e51813 /source4/pidl/lib
parent0d6dbcabe9c90f211c356155d21f9d3d630333a6 (diff)
downloadsamba-c9afddd42c916328980390251938508165ad130f.tar.gz
samba-c9afddd42c916328980390251938508165ad130f.tar.bz2
samba-c9afddd42c916328980390251938508165ad130f.zip
r26661: pidl/python: More generic handling of NTSTATUS, add stubs for types.
(This used to be commit 336dae6d429f122f7f38a6c78d28b848ebfa3c67)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm51
1 files changed, 41 insertions, 10 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 0a2fb0b0f3..7e2ded1ff7 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -84,23 +84,48 @@ sub TypeConstructor($$)
{
my ($self, $type) = @_;
+ $self->pidl("static PyObject *py_$type->{NAME}(PyObject *self, PyObject *args)");
+ $self->pidl("{");
+ $self->indent;
#FIXME
+
+ $self->pidl("return Py_None;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
}
-sub PythonFunction($$)
+sub PythonFunction($$$)
{
- my ($self, $fn) = @_;
+ my ($self, $fn, $iface) = @_;
$self->pidl("static PyObject *py_$fn->{NAME}(PyObject *self, PyObject *args)");
$self->pidl("{");
$self->indent;
+ $self->pidl("$iface\_InterfaceObject *iface = ($iface\_InterfaceObject *)self;");
+ $self->pidl("NTSTATUS status;");
+ $self->pidl("");
# FIXME
+ $self->handle_ntstatus("status", "NULL");
$self->pidl("return Py_None;");
$self->deindent;
$self->pidl("}");
$self->pidl("");
}
+sub handle_ntstatus($$$)
+{
+ my ($self, $var, $retval) = @_;
+
+ $self->pidl("if (NT_STATUS_IS_ERR($var)) {");
+ $self->indent;
+ $self->pidl("PyErr_SetString(PyExc_RuntimeError, nt_errstr($var));");
+ $self->pidl("return $retval;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+}
+
sub Interface($$)
{
my($self,$interface) = @_;
@@ -155,7 +180,7 @@ sub Interface($$)
$self->pidl("static void interface_$interface->{NAME}_dealloc(PyObject* self)");
$self->pidl("{");
$self->indent;
- $self->pidl("$interface->{NAME}_InterfaceObject *interface;");
+ $self->pidl("$interface->{NAME}_InterfaceObject *interface = ($interface->{NAME}_InterfaceObject *)self;");
$self->pidl("talloc_free(interface->pipe);");
$self->pidl("PyObject_Del(self);");
$self->deindent;
@@ -199,13 +224,7 @@ sub Interface($$)
$self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
$self->pidl(" &ndr_table_$interface->{NAME}, credentials, NULL, lp_ctx);");
- $self->pidl("if (NT_STATUS_IS_ERR(status)) {");
- $self->indent;
- $self->pidl("PyErr_SetString(PyExc_RuntimeError, nt_errstr(status));");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
+ $self->handle_ntstatus("status", "NULL");
$self->pidl("return (PyObject *)ret;");
$self->deindent;
@@ -246,6 +265,18 @@ sub Parse($$$$)
foreach my $x (@$ndr) {
next if ($x->{TYPE} ne "INTERFACE");
$self->pidl("{ (char *)\"$x->{NAME}\", (PyCFunction)interface_$x->{NAME}, METH_VARARGS|METH_KEYWORDS, NULL },");
+
+ foreach my $d (@{$x->{TYPES}}) {
+ next if has_property($d, "nopython");
+ next if ($d->{TYPE} eq "ENUM" or $d->{TYPE} eq "BITMAP");
+
+ my $fn_name = $d->{NAME};
+
+ $fn_name =~ s/^$x->{NAME}_//;
+ $fn_name =~ s/^$basename\_//;
+
+ $self->pidl("{ (char *)\"$fn_name\", (PyCFunction)py_$d->{NAME}, METH_VARARGS|METH_KEYWORDS, NULL },");
+ }
}
$self->pidl("{ NULL, NULL, 0, NULL }");