Raise NotImplementedError from functions that don't have complete IDL.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 8 Apr 2008 00:58:18 +0000 (02:58 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 8 Apr 2008 00:58:18 +0000 (02:58 +0200)
(This used to be commit 685aab0c99c87386fee64c07d8b68c75652713c6)

source4/pidl/lib/Parse/Pidl/Samba4/Python.pm

index 40c0cd51cbf54439d91cb7a93641465c1f15ebd7..c04324e99290d2302cb54242e51741d870bbcc0f 100644 (file)
@@ -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);
 }