diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/swig.pm | 21 | ||||
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 8 | ||||
-rw-r--r-- | source4/scripting/swig/samba.i | 4 |
3 files changed, 27 insertions, 6 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index e9b2d220b8..3694cfdec9 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -341,7 +341,11 @@ sub ParseFunction($) $result .= ");\n\n"; - $result .= "\tPyDict_SetItemString(temp, \"result\", resultobj);\n"; + if ($fn->{RETURN_TYPE} eq "NTSTATUS") { + $result .= "\tPyDict_SetItemString(temp, \"result\", resultobj);\n"; + } 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"; @@ -350,7 +354,7 @@ sub ParseFunction($) # Function definitions $result .= "%rename($fn->{NAME}) dcerpc_$fn->{NAME};\n"; - $result .= "$fn->{RETURN_TYPE} dcerpc_$fn->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $fn->{NAME} *r);\n\n"; + $result .= "NTSTATUS dcerpc_$fn->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $fn->{NAME} *r);\n\n"; return $result; } @@ -443,6 +447,19 @@ sub ParseStruct($) $result .= "\treturn obj;\n"; $result .= "}\n"; + # Generate function to convert DATA_BLOB to Python dict + + if (util::has_property($s, "public")) { + $result .= "/* Convert DATA_BLOB to python dict of struct $s->{NAME} */\n\n"; + + $result .= "NTSTATUS DATA_BLOB_to_python_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, PyObject **obj)\n"; + $result .= "{\n"; + $result .= "\tstruct $s->{NAME} s;\n"; + $result .= "\tNTSTATUS result = ndr_pull_struct_blob(blob, mem_ctx, &s, ndr_pull_$s->{NAME});\n\n"; + $result .= "\treturn NT_STATUS_OK;\n"; + $result .= "}\n"; + } + $result .= "\n%}\n\n"; return $result; diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index f91f664820..5248164881 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -352,6 +352,7 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %exception { $action + if (NT_STATUS_IS_ERR(result)) { set_ntstatus_exception(NT_STATUS_V(result)); return NULL; @@ -365,10 +366,14 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %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)); @@ -379,4 +384,7 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, %include "librpc/gen_ndr/winreg.i" %include "librpc/gen_ndr/spoolss.i" +/* The status codes must be included last otherwise the automatically + generated .i files get confused. This is kind of yucky. */ + %include "status_codes.i" diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i index faa46dc348..6a34f9b148 100644 --- a/source4/scripting/swig/samba.i +++ b/source4/scripting/swig/samba.i @@ -32,10 +32,6 @@ $1 = (uint32_t)PyInt_AsLong($input); } -/* For the moment treat NTSTATUS as an integer */ - -#define WERROR NTSTATUS - %typemap(out) NTSTATUS { $result = PyInt_FromLong(NT_STATUS_V($1)); } |