From 6d82eaa7e9597ebaf292e21e00345be0c50287bf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 20 Sep 2004 00:55:53 +0000 Subject: r2424: Refactor handling of non-OK NTSTATUS returns to be more swiggish. (This used to be commit aaef6eaf6e0c38fb277d1be0617dfdff559a0115) --- source4/build/pidl/swig.pm | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'source4/build/pidl') diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 6c0fb0f194..9736c56eb1 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -241,7 +241,7 @@ sub ParseFunction($) $result .= "\tif (!PyDict_Check(obj)) {\n"; $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $result .= "\t\treturn NULL;\n"; + $result .= "\t\t\treturn NULL;\n"; $result .= "\t}\n\n"; $result .= "\ts = talloc(mem_ctx, sizeof(struct $fn->{NAME}));\n\n"; @@ -282,8 +282,7 @@ sub ParseFunction($) $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(int) $fn->{NAME}\");\n\n"; $result .= "\t\$1 = $fn->{NAME}_ptr_from_python(mem_ctx, \$input, \"\");\n\n"; - $result .= "\tif (PyErr_Occurred())\n"; - $result .= "\t\t\treturn NULL;\n\n"; + $result .= "\tif (PyErr_Occurred()) return NULL;\n\n"; $result .= "}\n\n"; @@ -291,18 +290,8 @@ sub ParseFunction($) $result .= "%typemap(argout) struct $fn->{NAME} * {\n"; $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $fn->{NAME}\");\n\n"; - $result .= "\tlong status = PyLong_AsLong(resultobj);\n"; - $result .= "\tPyObject *dict;\n"; - $result .= "\n"; - - $result .= "\tif (status != 0) {\n"; - $result .= "\t\tset_ntstatus_exception(status);\n"; - $result .= "\t\treturn NULL;\n"; - $result .= "\t}\n"; - $result .= "\n"; - $result .= "\tdict = $fn->{NAME}_ptr_to_python(mem_ctx, \$1);\n"; - - $result .= "\tresultobj = dict;\n"; + $result .= "\tresultobj = $fn->{NAME}_ptr_to_python(mem_ctx, \$1);\n\n"; + $result .= "\ttalloc_free(mem_ctx);\n"; $result .= "}\n\n"; # Function definitions @@ -337,8 +326,7 @@ sub ParseStruct($) $result .= "\t\treturn NULL;\n"; $result .= "\t}\n\n"; - $result .= "\tif (obj == Py_None) {\n"; - $result .= "\t\treturn NULL;\n"; + $result .= "\tif (obj == Py_None) return NULL;\n"; $result .= "\t}\n\n"; $result .= "\tif (!PyDict_Check(obj)) {\n"; @@ -575,8 +563,7 @@ sub Parse($) # Generate interface - $result = "/* Auto-generated by pidl */\n\n"; - $result = "/* Tastes like -*- C -*- */\n\n"; + $result .= "/* Auto-generated by pidl. Tastes like -*- C -*-. */\n\n"; foreach my $x (@{$idl}) { $result .= ParseHeader($x) if ($x->{TYPE} eq "INTERFACE"); -- cgit