pidl - Remove "Py_RETURN_NONE" compatibility code
[ira/wip.git] / pidl / lib / Parse / Pidl / Samba4 / Python.pm
index 3baaa6765582a121a55598860d34bb0547cde588..781d640cabdc69e51d074651a5aaa6e77285bf05 100644 (file)
@@ -275,24 +275,7 @@ sub PythonStruct($$$$$$)
                $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
                $self->pidl("\treturn NULL;");
                $self->pidl("");
-
-               # This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers.  
-                # So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this
-               my $got_relative = 0;
-               if ($#{$d->{ELEMENTS}} > -1) {
-                       foreach my $e (@{$d->{ELEMENTS}}) {
-                               my $l = $e->{LEVELS}[0];
-                               if ($l->{TYPE} eq "POINTER" and ($l->{POINTER_TYPE} eq "relative")) {
-                                       $got_relative = 1;
-                                       last;
-                               }
-                       }
-               }
-               if ($got_relative == 0) {
-                       $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
-               } else {
-                       $self->pidl("err = ndr_pull_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
-               }
+               $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
                $self->pidl("if (err != NDR_ERR_SUCCESS) {");
                $self->indent;
                $self->pidl("PyErr_SetNdrError(err);");
@@ -998,10 +981,10 @@ sub ConvertScalarToPython($$$)
        }
 
        # Not yet supported
-       if ($ctypename eq "string_array") { return "PyCObject_FromVoidPtr($cvar)"; }
+       if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
        if ($ctypename eq "ipv4address") { return "PyString_FromString($cvar)"; }
        if ($ctypename eq "pointer") {
-               return "PyCObject_FromVoidPtr($cvar, talloc_free)";
+               return "PyCObject_FromTallocPtr($cvar)";
        }
 
        die("Unknown scalar type $ctypename");
@@ -1141,18 +1124,14 @@ sub Parse($$$$$)
 
     $self->pidl_hdr("
 /* Python wrapper functions auto-generated by pidl */
-#include \"includes.h\"
 #include <Python.h>
+#include \"includes.h\"
 #include \"librpc/rpc/dcerpc.h\"
 #include \"lib/talloc/pytalloc.h\"
 #include \"librpc/rpc/pyrpc.h\"
 #include \"$hdr\"
 #include \"$ndr_hdr\"
 
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-#endif
-
 ");
 
        foreach my $x (@$ndr) {