return retval;
}
+static int
+_parse_voidp(PyObject *obj, void **address)
+{
+ *address = PyLong_AsVoidPtr(obj);
+ if (*address == NULL)
+ return 0;
+ return 1;
+}
+
#ifdef MS_WIN32
#ifdef _UNICODE
static PyObject *free_library(PyObject *self, PyObject *args)
{
void *hMod;
- if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":FreeLibrary", &hMod))
+ if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod))
return NULL;
if (!FreeLibrary((HMODULE)hMod))
return PyErr_SetFromWindowsErr(GetLastError());
{
void *handle;
- if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":dlclose", &handle))
+ if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle))
return NULL;
if (dlclose(handle)) {
PyErr_SetString(PyExc_OSError,
void *handle;
void *ptr;
- if (!PyArg_ParseTuple(args, PY_VOID_P_CODE "s:dlsym", &handle, &name))
+ if (!PyArg_ParseTuple(args, "O&s:dlsym",
+ &_parse_voidp, &handle, &name))
return NULL;
ptr = ctypes_dlsym(handle, name);
if (!ptr) {
PyObject *result;
if (!PyArg_ParseTuple(args,
- PY_VOID_P_CODE "O!",
- &func,
+ "O&O!",
+ &_parse_voidp, &func,
&PyTuple_Type, &arguments))
return NULL;
PyObject *result;
if (!PyArg_ParseTuple(args,
- PY_VOID_P_CODE "O!",
- &func,
+ "O&O!",
+ &_parse_voidp, &func,
&PyTuple_Type, &arguments))
return NULL;
#define PY_LONG_LONG LONG_LONG
#endif
-#if SIZEOF_VOID_P == SIZEOF_LONG
-#define PY_VOID_P_CODE "k"
-#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P == SIZEOF_LONG_LONG)
-#define PY_VOID_P_CODE "K"
-#endif
-
typedef struct tagPyCArgObject PyCArgObject;
typedef struct tagCDataObject CDataObject;
typedef PyObject *(* GETFUNC)(void *, unsigned size);