1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

r2986: Add correct value to dict when generating wrapper for functions that

return WERROR values.

Clean up WERROR vs NTSTATUS handling a bit.
(This used to be commit e6756e3ee0af3e7e98f6deaf9dc83af9aac1b586)
This commit is contained in:
Tim Potter 2004-10-15 07:17:51 +00:00 committed by Gerald (Jerry) Carter
parent 83928ac670
commit dc2df2530f
3 changed files with 27 additions and 6 deletions

View File

@ -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;

View File

@ -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"

View File

@ -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));
}