Create and use convenience function for creating new talloc-wrapping Python Objects...
authorJelmer Vernooij <jelmer@samba.org>
Sat, 20 Dec 2008 23:37:31 +0000 (00:37 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 20 Dec 2008 23:37:31 +0000 (00:37 +0100)
lib/talloc/pytalloc.h
pidl/lib/Parse/Pidl/Samba4/Python.pm

index bff6f31d27105c724abc75b79676034c89c1848a..e6745f937d05928aa55bc0425e47ed9e3d1f2057 100644 (file)
@@ -48,4 +48,6 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *
 /* Sane default implementation of reprfunc. */
 PyObject *py_talloc_default_repr(PyObject *py_obj);
 
+#define py_talloc_new(type, typeobj) py_talloc_import(typeobj, talloc_zero(NULL, type))
+
 #endif /* _PY_TALLOC_H_ */
index 15dbd67b7cfa009cc75ad143054d1cff977b109b..120a35a1cf49c5864f753bf0cc9f312b5f7f7178 100644 (file)
@@ -224,8 +224,7 @@ sub PythonStruct($$$$$$)
        $self->pidl("static PyObject *py_$name\_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
        $self->pidl("{");
        $self->indent;
-       $self->pidl("$cname *ret = talloc_zero(NULL, $cname);");
-       $self->pidl("return py_talloc_import(type, ret);");
+       $self->pidl("return py_talloc_new($cname, type);");
        $self->deindent;
        $self->pidl("}");
        $self->pidl("");
@@ -677,7 +676,7 @@ sub Interface($$$)
                $self->pidl("};");
                $self->pidl("");
 
-               $self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
+               $self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
                $self->pidl("{");
                $self->indent;
                $self->pidl("dcerpc_InterfaceObject *ret;");
@@ -728,7 +727,7 @@ sub Interface($$$)
                $self->deindent;
                $self->pidl("}");
 
-               $self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, &$interface->{NAME}_InterfaceType);");
+               $self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, type);");
                $self->pidl("");
                $self->pidl("event_ctx = event_context_init(mem_ctx);");
                $self->pidl("");