summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-18 10:08:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:49 -0500
commit6d00d88f94f410bffe7058786f17abd58c2de23f (patch)
treedc77ed018789e3b81d726519dfb516a05287f1ff /source4/build/pidl
parentb02b2fa3473a8249a8a69eb5cc08ab207503ecd0 (diff)
downloadsamba-6d00d88f94f410bffe7058786f17abd58c2de23f.tar.gz
samba-6d00d88f94f410bffe7058786f17abd58c2de23f.tar.bz2
samba-6d00d88f94f410bffe7058786f17abd58c2de23f.zip
r2409: Convert NULL pointers to Py_None, and vice versa.
This gets samr_QuerySecurity() working again. (This used to be commit 810bce2fe517969e62d87497bbe4ae645badfdf6)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/swig.pm20
1 files changed, 18 insertions, 2 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index dcd3efa698..e43454a2fc 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -231,7 +231,13 @@ sub ParseStruct($)
$res .= "struct $s->{NAME} *$s->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)\n";
$res .= "{\n";
- $res .= "\tstruct $s->{NAME} *s = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n";
+ $res .= "\tstruct $s->{NAME} *s;\n\n";
+
+ $res .= "\tif (obj == Py_None) {\n";
+ $res .= "\t\treturn NULL;\n";
+ $res .= "\t}\n\n";
+
+ $res .= "\ts = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n";
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
$res .= XFromPython($e, "");
@@ -259,6 +265,11 @@ sub ParseStruct($)
$res .= "\tPyObject *obj = PyDict_New();\n\n";
+ $res .= "\tif (s == NULL) {\n";
+ $res .= "\t\tPy_INCREF(Py_None);\n";
+ $res .= "\t\treturn Py_None;\n";
+ $res .= "\t}\n\n";
+
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
$res .= XToPython($e, "");
}
@@ -282,7 +293,6 @@ sub ParseUnion($)
$res .= "\tunion $u->{NAME} *u = talloc(mem_ctx, sizeof(union $u->{NAME}));\n";
$res .= "\tPyObject *dict;\n\n";
-
for my $e (@{$u->{DATA}{DATA}}) {
$res .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n";
@@ -305,6 +315,12 @@ sub ParseUnion($)
$res .= "PyObject *$u->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u)\n";
$res .= "{\n";
+
+ $res .= "\tif (u == NULL) {\n";
+ $res .= "\t\tPy_INCREF(Py_None);\n";
+ $res .= "\t\treturn Py_None;\n";
+ $res .= "\t}\n\n";
+
$res .= "\treturn PyDict_New();\n";
$res .= "}\n\n";