From e5aa9f7e8dbb5b66a5ce25f50ed67dfcae7a1809 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 8 Apr 2008 02:58:18 +0200 Subject: Raise NotImplementedError from functions that don't have complete IDL. (This used to be commit 685aab0c99c87386fee64c07d8b68c75652713c6) --- source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 43 +++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'source4/pidl/lib') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index 40c0cd51cb..c04324e992 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -253,17 +253,10 @@ sub PythonStruct($$$$$$) return "&$typeobject"; } -sub PythonFunction($$$) +sub PythonFunctionBody($$$) { my ($self, $fn, $iface, $prettyname) = @_; - my $docstring = $self->DocString($fn, $fn->{NAME}); - - my $fnname = "py_$fn->{NAME}"; - - $self->pidl("static PyObject *$fnname(PyObject *self, PyObject *args, PyObject *kwargs)"); - $self->pidl("{"); - $self->indent; $self->pidl("$iface\_InterfaceObject *iface = ($iface\_InterfaceObject *)self;"); $self->pidl("NTSTATUS status;"); $self->pidl("TALLOC_CTX *mem_ctx = talloc_new(NULL);"); @@ -370,16 +363,38 @@ sub PythonFunction($$$) $self->pidl("talloc_free(mem_ctx);"); $self->pidl("return result;"); - $self->deindent; - $self->pidl("}"); - $self->pidl(""); - if ($docstring) { - $docstring = "\"$signature\\n\\n\"$docstring"; + return $signature; +} + +sub PythonFunction($$$) +{ + my ($self, $fn, $iface, $prettyname) = @_; + + my $fnname = "py_$fn->{NAME}"; + my $docstring = $self->DocString($fn, $fn->{NAME}); + + $self->pidl("static PyObject *$fnname(PyObject *self, PyObject *args, PyObject *kwargs)"); + $self->pidl("{"); + $self->indent; + if (has_property($fn, "todo")) { + $self->pidl("PyErr_SetString(PyExc_NotImplementedError, \"No marshalling code available yet for $prettyname\");"); + $self->pidl("return NULL;"); + unless ($docstring) { $docstring = "NULL"; } } else { - $docstring = "\"$signature\""; + my $signature = $self->PythonFunctionBody($fn, $iface, $prettyname); + + if ($docstring) { + $docstring = "\"$signature\\n\\n\"$docstring"; + } else { + $docstring = "\"$signature\""; + } } + $self->deindent; + $self->pidl("}"); + $self->pidl(""); + return ($fnname, $docstring); } -- cgit