Fix SBProcess::ReadMemory's typemap to handle PyLongObjects.

llvm-svn: 156638
This commit is contained in:
Filipe Cabecinhas 2012-05-11 20:38:28 +00:00
parent 0c543ea186
commit 0bfed4bc7a
1 changed files with 8 additions and 5 deletions

View File

@ -116,11 +116,14 @@
// typemap for an incoming buffer
// See also SBProcess::ReadMemory.
%typemap(in) (void *buf, size_t size) {
if (!PyInt_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Expecting an integer");
return NULL;
if (PyInt_Check($input)) {
$2 = PyInt_AsLong($input);
} else if (PyLong_Check($input)) {
$2 = PyLong_AsLong($input);
} else {
PyErr_SetString(PyExc_ValueError, "Expecting an integer or long object");
return NULL;
}
$2 = PyInt_AsLong($input);
if ($2 <= 0) {
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
return NULL;
@ -329,4 +332,4 @@
%typemap(freearg) (uint32_t *versions) {
free($1);
}
}