summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-02-06 00:34:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:33 -0500
commita36c43bc2161086a229b620a01eb071f05eda878 (patch)
treebf574efad5046d25cc7f366e47e1e2c5e54f3c31 /source4/scripting
parente2e8db3a6562f75f1f495de9617ba020a82d666b (diff)
downloadsamba-a36c43bc2161086a229b620a01eb071f05eda878.tar.gz
samba-a36c43bc2161086a229b620a01eb071f05eda878.tar.bz2
samba-a36c43bc2161086a229b620a01eb071f05eda878.zip
r5242: Check that argument is an integer or a long for uint32_t input
typemap. The uint32_t output typemap must return a Python long as an unsigned uint32_t cannot be fully represented by a Python int. Likewise for the NTSTATUS typemap. (This used to be commit 6dba5d6fb43f87bedc380c4f82b1d5f90b70325a)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/swig/samba.i19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/scripting/swig/samba.i b/source4/scripting/swig/samba.i
index 6cdf424095..db48b3c4ba 100644
--- a/source4/scripting/swig/samba.i
+++ b/source4/scripting/swig/samba.i
@@ -28,11 +28,24 @@
%apply char { int8_t };
%apply unsigned int { uint16_t };
%apply int { int16_t };
-%apply unsigned long { uint32_t };
-%apply long { int32_t };
%apply unsigned long long { uint64_t };
%apply long long { int64_t };
+%typemap(in) uint32_t {
+ if (PyLong_Check($input))
+ $1 = PyLong_AsUnsignedLong($input);
+ else if (PyInt_Check($input))
+ $1 = PyInt_AsLong($input);
+ else {
+ PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
+ return NULL;
+ }
+}
+
+%typemap(out) uint32_t {
+ $result = PyLong_FromUnsignedLong($1);
+}
+
%typemap(out) NTSTATUS {
- $result = PyLong_FromLong(NT_STATUS_V($1));
+ $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
}