diff options
author | Tim Potter <tpot@samba.org> | 2004-10-15 12:21:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:55 -0500 |
commit | 8f00427136cd52e0e1cd1b12267515d872798c56 (patch) | |
tree | 655446e40cc858a7f2259c5f98342d25889637f1 | |
parent | a8ce1303832b46ff0c976e2d443d4f3ef293f6df (diff) | |
download | samba-8f00427136cd52e0e1cd1b12267515d872798c56.tar.gz samba-8f00427136cd52e0e1cd1b12267515d872798c56.tar.bz2 samba-8f00427136cd52e0e1cd1b12267515d872798c56.zip |
r2994: 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
(This used to be commit 558076cc8ddbdb563869f7d35150310217f30c31)
-rw-r--r-- | source4/build/pidl/swig.pm | 21 | ||||
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 32 |
2 files changed, 19 insertions, 34 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 3694cfdec9..cdfe90450d 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -346,9 +346,26 @@ sub ParseFunction($) } 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 diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 5248164881..ab53a1dc51 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -347,40 +347,8 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, 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" |