Author: tpot Date: 2004-10-15 12:21:49 +0000 (Fri, 15 Oct 2004) New Revision: 2994
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2994&nolog=1 Log: More cleanups. Move the generation of NTSTATUS and WERROR exceptions from inside a swig %exception block and into the argout typemap. This will allow us to wrap functions that don't require exception handling, and also get rid of some ugly code in dcerpc.i Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm branches/SAMBA_4_0/source/scripting/swig/dcerpc.i Changeset: Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm =================================================================== --- branches/SAMBA_4_0/source/build/pidl/swig.pm 2004-10-15 11:11:02 UTC (rev 2993) +++ branches/SAMBA_4_0/source/build/pidl/swig.pm 2004-10-15 12:21:49 UTC (rev 2994) @@ -346,9 +346,26 @@ } else { $result .= "\tPyDict_SetItemString(temp, \"result\", PyLong_FromLong(W_ERROR_V(arg3->out.result)));\n"; } - $result .= "\tresultobj = temp;\n"; - $result .= "\ttalloc_free(mem_ctx);\n"; + $result .= "\n"; + + $result .= "\tresultobj = temp;\n\n"; + + + + $result .= "\tif (NT_STATUS_IS_ERR(result)) {\n"; + $result .= "\t\tset_ntstatus_exception(NT_STATUS_V(result));\n"; + $result .= "\t\tgoto fail;\n"; + $result .= "\t}\n"; + + if (!($fn->{RETURN_TYPE} eq "NTSTATUS")) { + $result .= "\tif (!W_ERROR_IS_OK(arg3->out.result) && \n"; + $result .= "\t\t!(W_ERROR_EQUAL(arg3->out.result, WERR_INSUFFICIENT_BUFFER))) {\n"; + $result .= "\t\tset_werror_exception(W_ERROR_V(arg3->out.result));\n"; + $result .= "\t\tgoto fail;\n"; + $result .= "\t}\n"; + } + $result .= "}\n\n"; # Function definitions Modified: branches/SAMBA_4_0/source/scripting/swig/dcerpc.i =================================================================== --- branches/SAMBA_4_0/source/scripting/swig/dcerpc.i 2004-10-15 11:11:02 UTC (rev 2993) +++ branches/SAMBA_4_0/source/scripting/swig/dcerpc.i 2004-10-15 12:21:49 UTC (rev 2994) @@ -347,40 +347,8 @@ const char *password); %include "librpc/gen_ndr/misc.i" - -/* Wrapped functions returning NTSTATUS */ - -%exception { - $action - - if (NT_STATUS_IS_ERR(result)) { - set_ntstatus_exception(NT_STATUS_V(result)); - return NULL; - } -} - %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" - -/* Wrapped functions returning WERROR */ - -%exception { - $action - - if (NT_STATUS_IS_ERR(result)) { - set_ntstatus_exception(NT_STATUS_V(result)); - return NULL; - } - - /* Emulate NT_STATUS_IS_ERR() */ - - if (!W_ERROR_IS_OK(arg3->out.result) && - !(W_ERROR_EQUAL(arg3->out.result, WERR_INSUFFICIENT_BUFFER))) { - set_werror_exception(W_ERROR_V(arg3->out.result)); - return NULL; - } -} - %include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i"