pidl/python: Fix compilation of py_echo.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 01:48:50 +0000 (02:48 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 18:53:06 +0000 (19:53 +0100)
source/foo.py [new file with mode: 0644]
source/librpc/config.mk
source/pidl/lib/Parse/Pidl/Samba4/Python.pm
source/scripting/python/config.mk
source/scripting/python/pytalloc.c

diff --git a/source/foo.py b/source/foo.py
new file mode 100644 (file)
index 0000000..0e2d35f
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+#   
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#   
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#   
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from echo import rpcecho
+
+x = rpcecho("ncalrpc:")
index debfbb68692097d6849cb9fda5684bf386d98b60..e491f69b34415a6ebbf8b78335a82c9f98778d5c 100644 (file)
@@ -597,4 +597,4 @@ PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-CONFIG dcerpc_s
 
 [PYTHON::python_echo]
 OBJ_FILES = gen_ndr/py_echo.o
-PRIVATE_DEPENDENCIES = NDR_ECHO
+PRIVATE_DEPENDENCIES = RPC_NDR_ECHO
index a7e17917936f33d51a4b8ec1fb5453ef430fe432..f569f013dc6eb572b898a9c9604b00e5bc162ac3 100644 (file)
@@ -384,7 +384,7 @@ sub PythonType($$$)
                $self->EnumAndBitmapConsts($d->{NAME}, $d->{DATA});
        }
 
-       if ($actual_ctype->{TYPE} eq "UNION") {
+       if ($actual_ctype->{TYPE} eq "UNION" and defined($actual_ctype->{ELEMENTS})) {
                $self->pidl("PyObject *py_import_$d->{NAME}(int level, " .mapTypeName($d) . " *in)");
                $self->pidl("{");
                $self->indent;
@@ -486,7 +486,7 @@ sub Interface($$$)
        $self->pidl("");
 
        $self->register_module_method($interface->{NAME}, "interface_$interface->{NAME}", "METH_VARARGS|METH_KEYWORDS", "NULL");
-       $self->pidl("static PyObject *interface_$interface->{NAME}(PyObject *self, PyObject *args)");
+       $self->pidl("static PyObject *interface_$interface->{NAME}(PyObject *self, PyObject *args, PyObject *kwargs)");
        $self->pidl("{");
        $self->indent;
        $self->pidl("$interface->{NAME}_InterfaceObject *ret;");
@@ -496,6 +496,18 @@ sub Interface($$$)
        $self->pidl("TALLOC_CTX *mem_ctx = NULL;");
        $self->pidl("NTSTATUS status;");
        $self->pidl("");
+       $self->pidl("const char *kwnames[] = {");
+       $self->indent;
+       $self->pidl("\"binding\", NULL");
+       $self->deindent;
+       $self->pidl("};");
+       $self->pidl("");
+       $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string)) {");
+       $self->indent;
+       $self->pidl("return NULL;");
+       $self->deindent;
+       $self->pidl("}");
+       $self->pidl("");
 
        # FIXME: Arguments: binding string, credentials, loadparm context
        $self->pidl("ret = PyObject_New($interface->{NAME}_InterfaceObject, &$interface->{NAME}_InterfaceType);");
index cfd179aff5c957df544e6634a29452f2b6bb54c3..f00b4779199a0d6b00b7a607329e51b6c1b73ebd 100644 (file)
@@ -5,7 +5,7 @@ OBJ_FILES = smbpython.o
 [SUBSYSTEM::LIBPYTHON]
 PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON
 INIT_FUNCTION_SENTINEL = { NULL, NULL }
-OBJ_FILES = modules.o
+OBJ_FILES = modules.o pytalloc.o
 
 [PYTHON::python_uuid]
 PRIVATE_DEPENDENCIES = LIBNDR 
index d0b8cb83f20369a638cbded3168e24b7a6506370..dc61a0a13d70a8bbb48bd2088e78eb915b358ff5 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "scripting/python/pytalloc.h"
 
 void py_talloc_dealloc(PyObject* self)
 {
@@ -26,13 +27,13 @@ void py_talloc_dealloc(PyObject* self)
        PyObject_Del(self);
 }
 
-PyObject *py_talloc_import(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
+PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
                                                   void *ptr)
 {
-       PyObject *ret = PyObject_New(py_talloc_Object, &py_type);
+       py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
        ret->talloc_ctx = talloc_reference(mem_ctx, ptr); 
        ret->ptr = ptr;
-       return ret;
+       return (PyObject *)ret;
 }
 
 PyObject *py_talloc_default_repr(PyObject *py_obj)