mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-15 17:20:07 +01:00
Update siplib
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The implementation of the supprt for setting API versions.
|
||||
*
|
||||
* Copyright (c) 2016 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
* Copyright (c) 2019 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
*
|
||||
* This file is part of SIP.
|
||||
*
|
||||
@@ -124,7 +124,7 @@ int sipInitAPI(sipExportedModuleDef *em, PyObject *mod_dict)
|
||||
if ((pmd = sip_api_malloc(sizeof (PyMethodDef))) == NULL)
|
||||
return -1;
|
||||
|
||||
pmd->ml_name = SIP_MLNAME_CAST(func_name);
|
||||
pmd->ml_name = func_name;
|
||||
pmd->ml_meth = vf->vf_function;
|
||||
pmd->ml_flags = vf->vf_flags;
|
||||
pmd->ml_doc = vf->vf_docstring;
|
||||
@@ -186,6 +186,9 @@ PyObject *sipGetAPI(PyObject *self, PyObject *args)
|
||||
|
||||
(void)self;
|
||||
|
||||
if (sip_api_deprecated(NULL, "getapi") < 0)
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getapi", &api))
|
||||
return NULL;
|
||||
|
||||
@@ -195,11 +198,7 @@ PyObject *sipGetAPI(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyLong_FromLong(avd->version_nr);
|
||||
#else
|
||||
return PyInt_FromLong(avd->version_nr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +213,9 @@ PyObject *sipSetAPI(PyObject *self, PyObject *args)
|
||||
|
||||
(void)self;
|
||||
|
||||
if (sip_api_deprecated(NULL, "setapi") < 0)
|
||||
return NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:setapi", &api, &version_nr))
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -34,33 +34,27 @@ typedef struct {
|
||||
const sipTypeDef *td;
|
||||
const char *format;
|
||||
size_t stride;
|
||||
SIP_SSIZE_T len;
|
||||
Py_ssize_t len;
|
||||
int flags;
|
||||
PyObject *owner;
|
||||
} sipArrayObject;
|
||||
|
||||
|
||||
static int check_writable(sipArrayObject *array);
|
||||
static int check_index(sipArrayObject *array, SIP_SSIZE_T idx);
|
||||
static int check_index(sipArrayObject *array, Py_ssize_t idx);
|
||||
static void *get_value(sipArrayObject *array, PyObject *value);
|
||||
static void *get_slice(sipArrayObject *array, PyObject *value,
|
||||
SIP_SSIZE_T len);
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
static void fix_bounds(int len, int *left, int *right);
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
static void *get_slice(sipArrayObject *array, PyObject *value, Py_ssize_t len);
|
||||
static void bad_key(PyObject *key);
|
||||
#endif
|
||||
static void *element(sipArrayObject *array, SIP_SSIZE_T idx);
|
||||
static void *element(sipArrayObject *array, Py_ssize_t idx);
|
||||
static PyObject *make_array(void *data, const sipTypeDef *td,
|
||||
const char *format, size_t stride, SIP_SSIZE_T len, int flags,
|
||||
const char *format, size_t stride, Py_ssize_t len, int flags,
|
||||
PyObject *owner);
|
||||
|
||||
|
||||
/*
|
||||
* Implement len() for the type.
|
||||
*/
|
||||
static SIP_SSIZE_T sipArray_length(PyObject *self)
|
||||
static Py_ssize_t sipArray_length(PyObject *self)
|
||||
{
|
||||
return ((sipArrayObject *)self)->len;
|
||||
}
|
||||
@@ -69,7 +63,7 @@ static SIP_SSIZE_T sipArray_length(PyObject *self)
|
||||
/*
|
||||
* Implement sequence item sub-script for the type.
|
||||
*/
|
||||
static PyObject *sipArray_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
static PyObject *sipArray_item(PyObject *self, Py_ssize_t idx)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
PyObject *py_item;
|
||||
@@ -89,7 +83,7 @@ static PyObject *sipArray_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
switch (*array->format)
|
||||
{
|
||||
case 'b':
|
||||
py_item = SIPLong_FromLong(*(char *)data);
|
||||
py_item = PyLong_FromLong(*(char *)data);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
@@ -97,7 +91,7 @@ static PyObject *sipArray_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
py_item = SIPLong_FromLong(*(short *)data);
|
||||
py_item = PyLong_FromLong(*(short *)data);
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
@@ -105,7 +99,7 @@ static PyObject *sipArray_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
py_item = SIPLong_FromLong(*(int *)data);
|
||||
py_item = PyLong_FromLong(*(int *)data);
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
@@ -129,91 +123,21 @@ static PyObject *sipArray_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
}
|
||||
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
/*
|
||||
* Implement sequence slice sub-script for the type.
|
||||
*/
|
||||
static PyObject *sipArray_slice(PyObject *self, int left, int right)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
|
||||
fix_bounds(array->len, &left, &right);
|
||||
|
||||
if (left == right)
|
||||
left = right = 0;
|
||||
|
||||
return make_array(element(array, left), array->td, array->format,
|
||||
array->stride, right - left, (array->flags & ~SIP_OWNS_MEMORY),
|
||||
array->owner);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implement sequence assignment item sub-script for the type.
|
||||
*/
|
||||
static int sipArray_ass_item(PyObject *self, int idx, PyObject *value)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
void *value_data;
|
||||
|
||||
if (check_writable(array) < 0 || check_index(array, idx) < 0)
|
||||
return -1;
|
||||
|
||||
if ((value_data = get_value(array, value)) == NULL)
|
||||
return -1;
|
||||
|
||||
memmove(element(array, idx), value_data, array->stride);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implement sequence assignment slice sub-script for the type.
|
||||
*/
|
||||
static int sipArray_ass_slice(PyObject *self, int left, int right,
|
||||
PyObject *value)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
void *value_data;
|
||||
|
||||
if (check_writable(array) < 0)
|
||||
return -1;
|
||||
|
||||
fix_bounds(array->len, &left, &right);
|
||||
|
||||
if ((value_data = get_slice(array, value, right - left)) == NULL)
|
||||
return -1;
|
||||
|
||||
memmove(element(array, left), value_data, (right - left) * array->stride);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The sequence methods data structure. */
|
||||
static PySequenceMethods sipArray_SequenceMethods = {
|
||||
sipArray_length, /* sq_length */
|
||||
0, /* sq_concat */
|
||||
0, /* sq_repeat */
|
||||
sipArray_item, /* sq_item */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
0, /* sq_slice */
|
||||
0, /* sq_ass_item */
|
||||
0, /* sq_ass_slice */
|
||||
#else
|
||||
sipArray_slice, /* sq_slice */
|
||||
sipArray_ass_item, /* sq_ass_item */
|
||||
sipArray_ass_slice, /* sq_ass_slice */
|
||||
#endif
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
};
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
/*
|
||||
* Implement mapping sub-script for the type.
|
||||
*/
|
||||
@@ -265,7 +189,7 @@ static int sipArray_ass_subscript(PyObject *self, PyObject *key,
|
||||
PyObject *value)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
SIP_SSIZE_T start, len;
|
||||
Py_ssize_t start, len;
|
||||
void *value_data;
|
||||
|
||||
if (check_writable(array) < 0)
|
||||
@@ -324,10 +248,8 @@ static PyMappingMethods sipArray_MappingMethods = {
|
||||
sipArray_subscript, /* mp_subscript */
|
||||
sipArray_ass_subscript, /* mp_ass_subscript */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
/*
|
||||
* The buffer implementation for Python v2.6.3 and later.
|
||||
*/
|
||||
@@ -371,84 +293,12 @@ static int sipArray_getbuffer(PyObject *self, Py_buffer *view, int flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The read buffer implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipArray_getreadbuffer(PyObject *self, SIP_SSIZE_T seg,
|
||||
void **ptr)
|
||||
{
|
||||
sipArrayObject *array = (sipArrayObject *)self;
|
||||
|
||||
if (seg != 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, "invalid buffer segment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*ptr = array->data;
|
||||
|
||||
return array->len;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The write buffer implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipArray_getwritebuffer(PyObject *self, SIP_SSIZE_T seg,
|
||||
void **ptr)
|
||||
{
|
||||
if (check_writable((sipArrayObject *)self) < 0)
|
||||
return -1;
|
||||
|
||||
return sipArray_getreadbuffer(self, seg, ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The segment count implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipArray_getsegcount(PyObject *self, SIP_SSIZE_T *lenp)
|
||||
{
|
||||
SIP_SSIZE_T segs, len;
|
||||
|
||||
len = ((sipArrayObject *)self)->len;
|
||||
segs = (len < 0 ? 0 : 1);
|
||||
|
||||
if (lenp != NULL)
|
||||
*lenp = len;
|
||||
|
||||
return segs;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The buffer methods data structure. */
|
||||
static PyBufferProcs sipArray_BufferProcs = {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
sipArray_getbuffer, /* bf_getbuffer */
|
||||
0 /* bf_releasebuffer */
|
||||
#else
|
||||
sipArray_getreadbuffer, /* bf_getreadbuffer */
|
||||
sipArray_getwritebuffer, /* bf_getwritebuffer */
|
||||
sipArray_getsegcount, /* bf_getsegcount */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
(charbufferproc)sipArray_getreadbuffer, /* bf_getcharbuffer */
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
sipArray_getbuffer, /* bf_getbuffer */
|
||||
0 /* bf_releasebuffer */
|
||||
#endif
|
||||
#else
|
||||
(getcharbufferproc)sipArray_getreadbuffer /* bf_getcharbuffer */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -474,15 +324,11 @@ PyTypeObject sipArray_Type = {
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved (Python v3), tp_compare (Python v2) */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
&sipArray_SequenceMethods, /* tp_as_sequence */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
&sipArray_MappingMethods, /* tp_as_mapping */
|
||||
#else
|
||||
0, /* tp_as_mapping */
|
||||
#endif
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
@@ -520,12 +366,8 @@ PyTypeObject sipArray_Type = {
|
||||
0, /* tp_subclasses */
|
||||
0, /* tp_weaklist */
|
||||
0, /* tp_del */
|
||||
#if PY_VERSION_HEX >= 0x02060000
|
||||
0, /* tp_version_tag */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03040000
|
||||
0, /* tp_finalize */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
0, /* tp_vectorcall */
|
||||
#endif
|
||||
@@ -550,7 +392,7 @@ static int check_writable(sipArrayObject *array)
|
||||
/*
|
||||
* Check that an index is valid for an array.
|
||||
*/
|
||||
static int check_index(sipArrayObject *array, SIP_SSIZE_T idx)
|
||||
static int check_index(sipArrayObject *array, Py_ssize_t idx)
|
||||
{
|
||||
if (idx >= 0 && idx < array->len)
|
||||
return 0;
|
||||
@@ -561,27 +403,6 @@ static int check_index(sipArrayObject *array, SIP_SSIZE_T idx)
|
||||
}
|
||||
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
/*
|
||||
* Fix the bounds of a slice in the same way that the Python buffer object
|
||||
* does.
|
||||
*/
|
||||
static void fix_bounds(int len, int *left, int *right)
|
||||
{
|
||||
if (*left < 0)
|
||||
*left = 0;
|
||||
else if (*left > len)
|
||||
*left = len;
|
||||
|
||||
if (*right < *left)
|
||||
*right = *left;
|
||||
else if (*right > len)
|
||||
*right = len;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
/*
|
||||
* Raise an exception about a bad sub-script key.
|
||||
*/
|
||||
@@ -591,13 +412,12 @@ static void bad_key(PyObject *key)
|
||||
"cannot index a sip.array object using '%s'",
|
||||
Py_TYPE(key)->tp_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Get the address of an element of an array.
|
||||
*/
|
||||
static void *element(sipArrayObject *array, SIP_SSIZE_T idx)
|
||||
static void *element(sipArrayObject *array, Py_ssize_t idx)
|
||||
{
|
||||
return (unsigned char *)(array->data) + idx * array->stride;
|
||||
}
|
||||
@@ -689,7 +509,7 @@ static void *get_value(sipArrayObject *array, PyObject *value)
|
||||
/*
|
||||
* Get the address of an value that will be copied to an array slice.
|
||||
*/
|
||||
static void *get_slice(sipArrayObject *array, PyObject *value, SIP_SSIZE_T len)
|
||||
static void *get_slice(sipArrayObject *array, PyObject *value, Py_ssize_t len)
|
||||
{
|
||||
sipArrayObject *other = (sipArrayObject *)value;
|
||||
|
||||
@@ -751,8 +571,7 @@ static void *get_slice(sipArrayObject *array, PyObject *value, SIP_SSIZE_T len)
|
||||
if (other->len != len)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"the array being assigned must have length " SIP_SSIZE_T_FORMAT,
|
||||
len);
|
||||
"the array being assigned must have length %zd", len);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -760,13 +579,8 @@ static void *get_slice(sipArrayObject *array, PyObject *value, SIP_SSIZE_T len)
|
||||
if (other->stride == array->stride)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
"the array being assigned must have stride %zu",
|
||||
array->stride);
|
||||
#else
|
||||
"the array being assigned must have stride %ld",
|
||||
(unsigned long)array->stride);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -779,7 +593,7 @@ static void *get_slice(sipArrayObject *array, PyObject *value, SIP_SSIZE_T len)
|
||||
* Do the work of creating an array.
|
||||
*/
|
||||
static PyObject *make_array(void *data, const sipTypeDef *td,
|
||||
const char *format, size_t stride, SIP_SSIZE_T len, int flags,
|
||||
const char *format, size_t stride, Py_ssize_t len, int flags,
|
||||
PyObject *owner)
|
||||
{
|
||||
sipArrayObject *array;
|
||||
@@ -815,7 +629,7 @@ static PyObject *make_array(void *data, const sipTypeDef *td,
|
||||
* short), "i" (int), "I" (unsigned int), "f" (float) or "d" (double).
|
||||
*/
|
||||
PyObject *sip_api_convert_to_array(void *data, const char *format,
|
||||
SIP_SSIZE_T len, int flags)
|
||||
Py_ssize_t len, int flags)
|
||||
{
|
||||
size_t stride;
|
||||
|
||||
@@ -874,7 +688,7 @@ PyObject *sip_api_convert_to_array(void *data, const char *format,
|
||||
* Wrap an array of instances of a defined type.
|
||||
*/
|
||||
PyObject *sip_api_convert_to_typed_array(void *data, const sipTypeDef *td,
|
||||
const char *format, size_t stride, SIP_SSIZE_T len, int flags)
|
||||
const char *format, size_t stride, Py_ssize_t len, int flags)
|
||||
{
|
||||
if (data == NULL)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file defines the API for the array type.
|
||||
*
|
||||
* Copyright (c) 2016 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
* Copyright (c) 2019 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
*
|
||||
* This file is part of SIP.
|
||||
*
|
||||
@@ -34,9 +34,9 @@ extern "C" {
|
||||
extern PyTypeObject sipArray_Type;
|
||||
|
||||
PyObject *sip_api_convert_to_array(void *data, const char *format,
|
||||
SIP_SSIZE_T len, int flags);
|
||||
Py_ssize_t len, int flags);
|
||||
PyObject *sip_api_convert_to_typed_array(void *data, const sipTypeDef *td,
|
||||
const char *format, size_t stride, SIP_SSIZE_T len, int flags);
|
||||
const char *format, size_t stride, Py_ssize_t len, int flags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
// Set a C++ bool for the main C implementation of the module.
|
||||
extern "C" void sipSetBool(void *ptr, int val)
|
||||
{
|
||||
*reinterpret_cast<bool *>(ptr) = !!val;
|
||||
*reinterpret_cast<bool *>(ptr) = !!val;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,8 @@ PyTypeObject sipMethodDescr_Type = {
|
||||
0, /* tp_subclasses */
|
||||
0, /* tp_weaklist */
|
||||
0, /* tp_del */
|
||||
#if PY_VERSION_HEX >= 0x02060000
|
||||
0, /* tp_version_tag */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03040000
|
||||
0, /* tp_finalize */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
0, /* tp_vectorcall */
|
||||
#endif
|
||||
@@ -176,13 +172,7 @@ static PyObject *sipMethodDescr_repr(PyObject *self)
|
||||
{
|
||||
sipMethodDescr *md = (sipMethodDescr *)self;
|
||||
|
||||
return
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyUnicode_FromFormat
|
||||
#else
|
||||
PyString_FromFormat
|
||||
#endif
|
||||
("<built-in method %s>", md->pmd->ml_name);
|
||||
return PyUnicode_FromFormat("<built-in method %s>", md->pmd->ml_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -314,12 +304,8 @@ PyTypeObject sipVariableDescr_Type = {
|
||||
0, /* tp_subclasses */
|
||||
0, /* tp_weaklist */
|
||||
0, /* tp_del */
|
||||
#if PY_VERSION_HEX >= 0x02060000
|
||||
0, /* tp_version_tag */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03040000
|
||||
0, /* tp_finalize */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
0, /* tp_vectorcall */
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The implementation of the Python object to C/C++ integer convertors.
|
||||
*
|
||||
* Copyright (c) 2018 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
* Copyright (c) 2019 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
*
|
||||
* This file is part of SIP.
|
||||
*
|
||||
@@ -329,26 +329,6 @@ static unsigned long long_as_unsigned_long(PyObject *o, unsigned long max)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PY_VERSION_HEX < 0x02040000
|
||||
/*
|
||||
* Work around a bug in Python versions prior to v2.4 where an integer
|
||||
* (or a named enum) causes an error.
|
||||
*/
|
||||
if (!PyLong_Check(o) && PyInt_Check(o))
|
||||
{
|
||||
long v = PyInt_AsLong(o);
|
||||
|
||||
if (v < 0)
|
||||
{
|
||||
raise_unsigned_overflow(max);
|
||||
|
||||
return (unsigned long)-1;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
value = PyLong_AsUnsignedLongMask(o);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,13 +169,7 @@ PyObject *sip_api_invoke_slot_ex(const sipSlot *slot, PyObject *sigargs,
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
sfunc = PyMethod_New(slot->meth.mfunc, self);
|
||||
#else
|
||||
sfunc = PyMethod_New(slot->meth.mfunc, self, slot->meth.mclass);
|
||||
#endif
|
||||
|
||||
if (sfunc == NULL)
|
||||
if ((sfunc = PyMethod_New(slot->meth.mfunc, self)) == NULL)
|
||||
{
|
||||
Py_XDECREF(sref);
|
||||
return NULL;
|
||||
@@ -344,11 +338,7 @@ int sip_api_same_slot(const sipSlot *sp, PyObject *rxObj, const char *slot)
|
||||
return 0;
|
||||
|
||||
return (sp->meth.mfunc == PyMethod_GET_FUNCTION(rxObj)
|
||||
&& sp->meth.mself == PyMethod_GET_SELF(rxObj)
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
&& sp->meth.mclass == PyMethod_GET_CLASS(rxObj)
|
||||
#endif
|
||||
);
|
||||
&& sp->meth.mself == PyMethod_GET_SELF(rxObj));
|
||||
}
|
||||
|
||||
/* See if they are wrapped C++ methods. */
|
||||
|
||||
463
sip/siplib/sip.h
463
sip/siplib/sip.h
@@ -21,22 +21,11 @@
|
||||
#define _SIP_H
|
||||
|
||||
|
||||
/*
|
||||
* This gets round a problem with Qt's moc and Python v2.3. Strictly speaking
|
||||
* it's a Qt problem but later versions of Python include a fix for it so we
|
||||
* might as well too.
|
||||
*/
|
||||
#undef slots
|
||||
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/*
|
||||
* There is a mis-feature somewhere with the Borland compiler. This works
|
||||
* around it.
|
||||
*/
|
||||
#if defined(__BORLANDC__)
|
||||
#include <rpc.h>
|
||||
/* Sanity check on the Python version. */
|
||||
#if PY_VERSION_HEX < 0x03050000
|
||||
#error "This version of SIP requires Python v3.5 or later"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -45,238 +34,35 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Sanity check on the Python version. */
|
||||
#if PY_VERSION_HEX < 0x02030000
|
||||
#error "This version of SIP requires Python v2.3 or later"
|
||||
#endif
|
||||
/* The patch version of this implementation of the ABI. */
|
||||
#define SIP_MODULE_PATCH_VERSION 1
|
||||
|
||||
|
||||
/*
|
||||
* Define the SIP version number.
|
||||
* The changes to this version of the ABI.
|
||||
*
|
||||
* Preserve any current exception in the wrapper tp_dealloc functions.
|
||||
*/
|
||||
#define SIP_VERSION 0x041318
|
||||
#define SIP_VERSION_STR "4.19.24"
|
||||
|
||||
|
||||
/*
|
||||
* Define the current API version number. SIP must handle modules with the
|
||||
* same major number and with the same or earlier minor number. Whenever
|
||||
* members are added to non-embedded data structures they must be appended and
|
||||
* the minor number incremented. Whenever data structure members are removed
|
||||
* or their offset changed then the major number must be incremented and the
|
||||
* minor number set * to 0.
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* 12.7 Added sip_api_visit_wrappers() to the public API.
|
||||
* Added sip_api_register_exit_notifier() to the public API.
|
||||
* sip_api_is_owned_by_python() is now part of the public API.
|
||||
*
|
||||
* 12.6 Added sip_api_long_as_size_t() to the public API.
|
||||
* Added the '=' format character to sip_api_build_result().
|
||||
* Added the '=' format character to sip_api_parse_result_ex().
|
||||
*
|
||||
* 12.5 Replaced the sipConvertFromSliceObject() macro with
|
||||
* sip_api_convert_from_slice_object() in the public API.
|
||||
*
|
||||
* 12.4 Added sip_api_instance_destroyed_ex() to the private API.
|
||||
*
|
||||
* 12.3 Added SIP_TYPE_SCOPED_ENUM to the sipTypeDef flags.
|
||||
* Added sip_api_convert_to_enum() to the public API.
|
||||
* Added sip_api_convert_to_bool() to the public API.
|
||||
* Added sip_api_long_as_char(), sip_api_long_as_signed_char(),
|
||||
* sip_api_long_as_unsigned_char(), sip_api_long_as_short(),
|
||||
* sip_api_long_as_unsigned_short(), sip_api_long_as_int(),
|
||||
* sip_api_long_as_unsigned_int(), sip_api_long_as_long(),
|
||||
* sip_api_long_as_unsigned_long(), sip_api_long_as_long_long(),
|
||||
* sip_api_long_as_unsigned_long_long() to the public API.
|
||||
* Deprecated sip_api_can_convert_to_enum().
|
||||
*
|
||||
* 12.2 Added sip_api_print_object() to the public API.
|
||||
* Renamed sip_api_common_dtor() to sip_api_instance_destroyed() and added
|
||||
* it to the public API.
|
||||
* Added sipEventType and sip_api_register_event_handler() to the public
|
||||
* API.
|
||||
*
|
||||
* 12.1 Added sip_api_enable_gc() to the public API.
|
||||
*
|
||||
* 12.0 Added SIP_TYPE_LIMITED_API to the sipTypeDef flags.
|
||||
* Added sip_api_py_type_dict() and sip_api_py_type_name() to the public
|
||||
* API.
|
||||
* Added sip_api_set_new_user_type_handler() to the public API.
|
||||
* Added sip_api_is_user_type() to the public API.
|
||||
* Added sip_api_set_type_user_data() and sip_api_get_type_user_data() to
|
||||
* the public API.
|
||||
* Added sip_api_set_user_object() and sip_api_get_user_object() to the
|
||||
* public API.
|
||||
* Added sip_api_get_method() and sip_api_from_method() to the public API.
|
||||
* Added sip_api_get_c_function() to the public API.
|
||||
* Added sip_api_get_date() and sip_api_from_date() to the public API.
|
||||
* Added sip_api_get_datetime() and sip_api_from_datetime() to the public
|
||||
* API.
|
||||
* Added sip_api_get_time() and sip_api_from_time() to the public API.
|
||||
* Added sip_api_get_frame() to the public API.
|
||||
* Added sip_api_check_plugin_for_type() to the public API.
|
||||
* Added sip_api_unicode_new(), sip_api_unicode_write() and
|
||||
* sip_api_unicode_data() to the public API.
|
||||
* Added sip_api_get_buffer_info() and sip_api_relese_buffer_info() to the
|
||||
* public API.
|
||||
* Added sip_api_call_procedure_method() to the public API.
|
||||
* Added sip_api_is_owned_by_python() to the private API.
|
||||
* Added sip_api_is_derived_class() to the private API.
|
||||
* Removed the im_version member from sipImportedModuleDef.
|
||||
* Removed the im_module member from sipImportedModuleDef.
|
||||
* Removed the em_version member from sipExportedModuleDef.
|
||||
* Removed the em_virthandlers member from sipExportedModuleDef.
|
||||
* Re-ordered the API functions.
|
||||
*
|
||||
* 11.3 Added sip_api_get_interpreter() to the public API.
|
||||
*
|
||||
* 11.2 Added sip_api_get_reference() to the private API.
|
||||
*
|
||||
* 11.1 Added sip_api_invoke_slot_ex().
|
||||
*
|
||||
* 11.0 Added the pyqt5QtSignal and pyqt5ClassTypeDef structures.
|
||||
* Removed qt_interface from pyqt4ClassTypeDef.
|
||||
* Added hack to pyqt4QtSignal.
|
||||
*
|
||||
* 10.1 Added ctd_final to sipClassTypeDef.
|
||||
* Added ctd_init_mixin to sipClassTypeDef.
|
||||
* Added sip_api_get_mixin_address() to the public API.
|
||||
* Added sip_api_convert_from_new_pytype() to the public API.
|
||||
* Added sip_api_convert_to_array() to the public API.
|
||||
* Added sip_api_convert_to_typed_array() to the public API.
|
||||
* Added sip_api_register_proxy_resolver() to the public API.
|
||||
* Added sip_api_init_mixin() to the private API.
|
||||
* Added qt_interface to pyqt4ClassTypeDef.
|
||||
*
|
||||
* 10.0 Added sip_api_set_destroy_on_exit().
|
||||
* Added sip_api_enable_autoconversion().
|
||||
* Removed sip_api_call_error_handler_old().
|
||||
* Removed sip_api_start_thread().
|
||||
*
|
||||
* 9.2 Added sip_gilstate_t and SIP_RELEASE_GIL to the public API.
|
||||
* Renamed sip_api_call_error_handler() to
|
||||
* sip_api_call_error_handler_old().
|
||||
* Added the new sip_api_call_error_handler() to the private API.
|
||||
*
|
||||
* 9.1 Added the capsule type.
|
||||
* Added the 'z' format character to sip_api_build_result().
|
||||
* Added the 'z', '!' and '$' format characters to
|
||||
* sip_api_parse_result_ex().
|
||||
*
|
||||
* 9.0 Changed the sipVariableGetterFunc signature.
|
||||
* Added sip_api_parse_result_ex() to the private API.
|
||||
* Added sip_api_call_error_handler() to the private API.
|
||||
* Added em_virterrorhandlers to sipExportedModuleDef.
|
||||
* Re-ordered the API functions.
|
||||
*
|
||||
* 8.1 Revised the sipVariableDef structure.
|
||||
* sip_api_get_address() is now part of the public API.
|
||||
*
|
||||
* 8.0 Changed the size of the sipSimpleWrapper structure.
|
||||
* Added sip_api_get_address().
|
||||
*
|
||||
* 7.1 Added the 'H' format character to sip_api_parse_result().
|
||||
* Deprecated the 'D' format character of sip_api_parse_result().
|
||||
*
|
||||
* 7.0 Added sip_api_parse_kwd_args().
|
||||
* Added sipErrorState, sip_api_add_exception().
|
||||
* The type initialisation function is now passed a dictionary of keyword
|
||||
* arguments.
|
||||
* All argument parsers now update a set of error messages rather than an
|
||||
* argument count.
|
||||
* The signatures of sip_api_no_function() and sip_api_no_method() have
|
||||
* changed.
|
||||
* Added ctd_docstring to sipClassTypeDef.
|
||||
* Added vf_docstring to sipVersionedFunctionDef.
|
||||
*
|
||||
* 6.0 Added the sipContainerDef structure to define the contents of a class
|
||||
* or mapped type. Restructured sipClassDef and sipMappedTypeDef
|
||||
* accordingly.
|
||||
* Added the 'r' format character to sip_api_parse_args().
|
||||
* Added the 'r' format character to sip_api_call_method() and
|
||||
* sip_api_build_result().
|
||||
* Added the assignment, array and copy allocation helpers.
|
||||
*
|
||||
* 5.0 Added sip_api_is_api_enabled().
|
||||
* Renamed the td_version_nr member of sipTypeDef to be int and where -1
|
||||
* indicates it is not versioned.
|
||||
* Added the em_versions member to sipExportedModuleDef.
|
||||
* Added the em_versioned_functions member to sipExportedModuleDef.
|
||||
*
|
||||
* 4.0 Much refactoring.
|
||||
*
|
||||
* 3.8 Added sip_api_register_qt_metatype() and sip_api_deprecated().
|
||||
* Added qt_register_meta_type() to the Qt support API.
|
||||
* The C/C++ names of enums and types are now always defined in the
|
||||
* relevant structures and don't default to the Python name.
|
||||
* Added the 'XE' format characters to sip_api_parse_args().
|
||||
*
|
||||
* 3.7 Added sip_api_convert_from_const_void_ptr(),
|
||||
* sip_api_convert_from_void_ptr_and_size() and
|
||||
* sip_api_convert_from_const_void_ptr_and_size().
|
||||
* Added the 'g' and 'G' format characters (to replace the now deprecated
|
||||
* 'a' and 'A' format characters) to sip_api_build_result(),
|
||||
* sip_api_call_method() and sip_api_parse_result().
|
||||
* Added the 'k' and 'K' format characters (to replace the now deprecated
|
||||
* 'a' and 'A' format characters) to sip_api_parse_args().
|
||||
* Added sip_api_invoke_slot().
|
||||
* Added sip_api_parse_type().
|
||||
* Added sip_api_is_exact_wrapped_type().
|
||||
* Added the td_assign and td_qt fields to the sipTypeDef structure.
|
||||
* Added the mt_assign field to the sipMappedType structure.
|
||||
*
|
||||
* 3.6 Added the 'g' format character to sip_api_parse_args().
|
||||
*
|
||||
* 3.5 Added the td_pickle field to the sipTypeDef structure.
|
||||
* Added sip_api_transfer_break().
|
||||
*
|
||||
* 3.4 Added qt_find_connection() to the Qt support API.
|
||||
* Added sip_api_string_as_char(), sip_api_unicode_as_wchar(),
|
||||
* sip_api_unicode_as_wstring(), sip_api_find_class(),
|
||||
* sip_api_find_named_enum() and sip_api_parse_signature().
|
||||
* Added the 'A', 'w' and 'x' format characters to sip_api_parse_args(),
|
||||
* sip_api_parse_result(), sip_api_build_result() and
|
||||
* sip_api_call_method().
|
||||
*
|
||||
* 3.3 Added sip_api_register_int_types().
|
||||
*
|
||||
* 3.2 Added sip_api_export_symbol() and sip_api_import_symbol().
|
||||
*
|
||||
* 3.1 Added sip_api_add_mapped_type_instance().
|
||||
*
|
||||
* 3.0 Moved the Qt support out of the sip module and into PyQt. This is
|
||||
* such a dramatic change that there is no point in attempting to maintain
|
||||
* backwards compatibility.
|
||||
*
|
||||
* 2.0 Added the td_flags field to the sipTypeDef structure.
|
||||
* Added the first_child, sibling_next, sibling_prev and parent fields to
|
||||
* the sipWrapper structure.
|
||||
* Added the td_traverse and td_clear fields to the sipTypeDef structure.
|
||||
* Added the em_api_minor field to the sipExportedModuleDef structure.
|
||||
* Added sip_api_bad_operator_arg().
|
||||
* Added sip_api_wrapper_check().
|
||||
*
|
||||
* 1.1 Added support for __pos__ and __abs__.
|
||||
*
|
||||
* 1.0 Removed all deprecated parts of the API.
|
||||
* Removed the td_proxy field from the sipTypeDef structure.
|
||||
* Removed the create proxy function from the 'q' and 'y' format
|
||||
* characters to sip_api_parse_args().
|
||||
* Removed sip_api_emit_to_slot().
|
||||
* Reworked the enum related structures.
|
||||
*
|
||||
* 0.2 Added the 'H' format character to sip_api_parse_args().
|
||||
*
|
||||
* 0.1 Added sip_api_add_class_instance().
|
||||
* Added the 't' format character to sip_api_parse_args().
|
||||
* Deprecated the 'J' and 'K' format characters to sip_api_parse_result().
|
||||
*
|
||||
* 0.0 Original version.
|
||||
*/
|
||||
#define SIP_API_MAJOR_NR 12
|
||||
#define SIP_API_MINOR_NR 7
|
||||
/* The ABI version implemented. */
|
||||
#define SIP_ABI_MAJOR_VERSION 12
|
||||
#define SIP_ABI_MINOR_VERSION 8
|
||||
|
||||
/* The version of the code generator. */
|
||||
#define SIP_VERSION 0x50500
|
||||
#define SIP_VERSION_STR "5.5.0"
|
||||
|
||||
/* These are all dependent on the user-specified name of the sip module. */
|
||||
#define _SIP_MODULE_FQ_NAME "wx.siplib"
|
||||
#define _SIP_MODULE_NAME "siplib"
|
||||
#define _SIP_MODULE_SHARED 1
|
||||
#define _SIP_MODULE_ENTRY PyInit_siplib
|
||||
#define _SIP_MODULE_LEGACY 0
|
||||
|
||||
/* Support the historical names. */
|
||||
#define SIP_API_MAJOR_NR SIP_ABI_MAJOR_VERSION
|
||||
#define SIP_API_MINOR_NR SIP_ABI_MINOR_VERSION
|
||||
|
||||
|
||||
/*
|
||||
@@ -324,29 +110,16 @@ typedef unsigned int uint;
|
||||
#endif
|
||||
|
||||
|
||||
/* Some Python compatibility stuff. */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
|
||||
#define SIP_SSIZE_T Py_ssize_t
|
||||
#define SIP_SSIZE_T_FORMAT "%zd"
|
||||
|
||||
#define SIP_MLNAME_CAST(s) (s)
|
||||
#define SIP_MLDOC_CAST(s) (s)
|
||||
#define SIP_TPNAME_CAST(s) (s)
|
||||
|
||||
#else
|
||||
|
||||
#define SIP_SSIZE_T int
|
||||
#define SIP_SSIZE_T_FORMAT "%d"
|
||||
|
||||
#define SIP_MLNAME_CAST(s) ((char *)(s))
|
||||
#define SIP_MLDOC_CAST(s) ((char *)(s))
|
||||
#define SIP_TPNAME_CAST(s) ((char *)(s))
|
||||
|
||||
#endif
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
/* Remove in v5.1. */
|
||||
#define SIP_SSIZE_T Py_ssize_t
|
||||
#define SIP_SSIZE_T_FORMAT "%zd"
|
||||
#define SIP_USE_PYCAPSULE
|
||||
#define SIP_MODULE_RETURN(v) return (v)
|
||||
|
||||
/*
|
||||
* Remove in v5.1. These are undocumented and can be removed when PyQt5 drops
|
||||
* support for Python v2.
|
||||
*/
|
||||
#define SIPLong_Check PyLong_Check
|
||||
#define SIPLong_FromLong PyLong_FromLong
|
||||
#define SIPLong_AsLong PyLong_AsLong
|
||||
@@ -359,57 +132,6 @@ typedef unsigned int uint;
|
||||
#define SIPBytes_AS_STRING PyBytes_AS_STRING
|
||||
#define SIPBytes_GET_SIZE PyBytes_GET_SIZE
|
||||
|
||||
#if PY_MINOR_VERSION >= 1
|
||||
#define SIP_USE_PYCAPSULE
|
||||
#endif
|
||||
|
||||
#if PY_MINOR_VERSION < 2
|
||||
#define SIP_SUPPORT_PYCOBJECT
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define SIPLong_Check PyInt_Check
|
||||
#define SIPLong_FromLong PyInt_FromLong
|
||||
#define SIPLong_AsLong PyInt_AsLong
|
||||
|
||||
#define SIPBytes_Check PyString_Check
|
||||
#define SIPBytes_FromString PyString_FromString
|
||||
#define SIPBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
#define SIPBytes_AsString PyString_AsString
|
||||
#define SIPBytes_Size PyString_Size
|
||||
#define SIPBytes_AS_STRING PyString_AS_STRING
|
||||
#define SIPBytes_GET_SIZE PyString_GET_SIZE
|
||||
|
||||
#if PY_MINOR_VERSION >= 7
|
||||
#define SIP_USE_PYCAPSULE
|
||||
#endif
|
||||
|
||||
#define SIP_SUPPORT_PYCOBJECT
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(Py_REFCNT)
|
||||
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
|
||||
#endif
|
||||
|
||||
#if !defined(Py_TYPE)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#endif
|
||||
|
||||
#if !defined(PyVarObject_HEAD_INIT)
|
||||
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(SIP_USE_PYCAPSULE)
|
||||
#define SIPCapsule_FromVoidPtr(p, n) PyCapsule_New((p), (n), NULL)
|
||||
#define SIPCapsule_AsVoidPtr(p, n) PyCapsule_GetPointer((p), (n))
|
||||
#else
|
||||
#define SIPCapsule_FromVoidPtr(p, n) sipConvertFromVoidPtr((p))
|
||||
#define SIPCapsule_AsVoidPtr(p, n) sipConvertToVoidPtr((p))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The mask that can be passed to sipTrace().
|
||||
@@ -512,17 +234,12 @@ typedef int (*sipFinalFunc)(PyObject *, void *, PyObject *, PyObject **);
|
||||
typedef void *(*sipAccessFunc)(sipSimpleWrapper *, AccessFuncOp);
|
||||
typedef int (*sipTraverseFunc)(void *, visitproc, void *);
|
||||
typedef int (*sipClearFunc)(void *);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
typedef int (*sipGetBufferFuncLimited)(PyObject *, void *, sipBufferDef *);
|
||||
typedef void (*sipReleaseBufferFuncLimited)(PyObject *, void *);
|
||||
#if !defined(Py_LIMITED_API)
|
||||
typedef int (*sipGetBufferFunc)(PyObject *, void *, Py_buffer *, int);
|
||||
typedef void (*sipReleaseBufferFunc)(PyObject *, void *, Py_buffer *);
|
||||
#endif
|
||||
#else
|
||||
typedef SIP_SSIZE_T (*sipBufferFunc)(PyObject *, void *, SIP_SSIZE_T, void **);
|
||||
typedef SIP_SSIZE_T (*sipSegCountFunc)(PyObject *, void *, SIP_SSIZE_T *);
|
||||
#endif
|
||||
typedef void (*sipDeallocFunc)(sipSimpleWrapper *);
|
||||
typedef void *(*sipCastFunc)(void *, const sipTypeDef *);
|
||||
typedef const sipTypeDef *(*sipSubClassConvertFunc)(void **);
|
||||
@@ -531,9 +248,9 @@ typedef PyObject *(*sipConvertFromFunc)(void *, PyObject *);
|
||||
typedef void (*sipVirtErrorHandlerFunc)(sipSimpleWrapper *, sip_gilstate_t);
|
||||
typedef int (*sipVirtHandlerFunc)(sip_gilstate_t, sipVirtErrorHandlerFunc,
|
||||
sipSimpleWrapper *, PyObject *, ...);
|
||||
typedef void (*sipAssignFunc)(void *, SIP_SSIZE_T, void *);
|
||||
typedef void *(*sipArrayFunc)(SIP_SSIZE_T);
|
||||
typedef void *(*sipCopyFunc)(const void *, SIP_SSIZE_T);
|
||||
typedef void (*sipAssignFunc)(void *, Py_ssize_t, void *);
|
||||
typedef void *(*sipArrayFunc)(Py_ssize_t);
|
||||
typedef void *(*sipCopyFunc)(const void *, Py_ssize_t);
|
||||
typedef void (*sipReleaseFunc)(void *, int);
|
||||
typedef PyObject *(*sipPickleFunc)(void *);
|
||||
typedef int (*sipAttrGetterFunc)(const sipTypeDef *, PyObject *);
|
||||
@@ -544,7 +261,7 @@ typedef int (*sipNewUserTypeFunc)(sipWrapperType *);
|
||||
typedef void (*sipWrapperVisitorFunc)(sipSimpleWrapper *, void *);
|
||||
|
||||
|
||||
#if !defined(Py_LIMITED_API) || PY_VERSION_HEX < 0x03020000
|
||||
#if !defined(Py_LIMITED_API)
|
||||
/*
|
||||
* The meta-type of a wrapper type.
|
||||
*/
|
||||
@@ -638,6 +355,7 @@ struct _sipWrapper {
|
||||
|
||||
|
||||
/*
|
||||
* Removed in v5.1.
|
||||
* The meta-type of an enum type. (This is exposed only to support the
|
||||
* deprecated sipConvertFromNamedEnum() macro.)
|
||||
*/
|
||||
@@ -761,7 +479,7 @@ struct _sipBufferDef {
|
||||
void *bd_buffer;
|
||||
|
||||
/* The length of the buffer. */
|
||||
SIP_SSIZE_T bd_length;
|
||||
Py_ssize_t bd_length;
|
||||
|
||||
/* Set if the buffer is read-only. */
|
||||
int bd_readonly;
|
||||
@@ -782,7 +500,7 @@ struct _sipBufferInfoDef {
|
||||
PyObject *bi_obj;
|
||||
|
||||
/* The length of the buffer in bytes. */
|
||||
SIP_SSIZE_T bi_len;
|
||||
Py_ssize_t bi_len;
|
||||
|
||||
/* The number of dimensions. */
|
||||
int bi_ndim;
|
||||
@@ -813,11 +531,6 @@ struct _sipMethodDef {
|
||||
|
||||
/* The bound object. */
|
||||
PyObject *pm_self;
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/* The class. */
|
||||
PyObject *pm_class;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -871,9 +584,6 @@ typedef enum {
|
||||
typedef enum {
|
||||
str_slot, /* __str__ */
|
||||
int_slot, /* __int__ */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
long_slot, /* __long__ */
|
||||
#endif
|
||||
float_slot, /* __float__ */
|
||||
len_slot, /* __len__ */
|
||||
contains_slot, /* __contains__ */
|
||||
@@ -916,18 +626,13 @@ typedef enum {
|
||||
ne_slot, /* __ne__ */
|
||||
gt_slot, /* __gt__ */
|
||||
ge_slot, /* __ge__ */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
cmp_slot, /* __cmp__ */
|
||||
#endif
|
||||
bool_slot, /* __bool__, __nonzero__ */
|
||||
neg_slot, /* __neg__ */
|
||||
repr_slot, /* __repr__ */
|
||||
hash_slot, /* __hash__ */
|
||||
pos_slot, /* __pos__ */
|
||||
abs_slot, /* __abs__ */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
index_slot, /* __index__ */
|
||||
#endif
|
||||
iter_slot, /* __iter__ */
|
||||
next_slot, /* __next__ */
|
||||
setattr_slot, /* __setattr__, __delattr__ */
|
||||
@@ -1039,14 +744,8 @@ struct _sipTypeDef {
|
||||
/* The C/C++ name of the type. */
|
||||
int td_cname;
|
||||
|
||||
/*
|
||||
* The Python type object. This needs to be a union until we remove the
|
||||
* deprecated sipClass_* macros.
|
||||
*/
|
||||
union {
|
||||
PyTypeObject *td_py_type;
|
||||
sipWrapperType *td_wrapper_type;
|
||||
} u;
|
||||
/* The Python type object. */
|
||||
PyTypeObject *td_py_type;
|
||||
|
||||
/* Any additional fixed data generated by a plugin. */
|
||||
void *td_plugin_data;
|
||||
@@ -1130,7 +829,6 @@ typedef struct _sipClassTypeDef {
|
||||
/* The clear function. */
|
||||
sipClearFunc ctd_clear;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
/* The get buffer function. */
|
||||
#if defined(Py_LIMITED_API)
|
||||
sipGetBufferFuncLimited ctd_getbuffer;
|
||||
@@ -1144,19 +842,6 @@ typedef struct _sipClassTypeDef {
|
||||
#else
|
||||
sipReleaseBufferFunc ctd_releasebuffer;
|
||||
#endif
|
||||
#else
|
||||
/* The read buffer function. */
|
||||
sipBufferFunc ctd_readbuffer;
|
||||
|
||||
/* The write buffer function. */
|
||||
sipBufferFunc ctd_writebuffer;
|
||||
|
||||
/* The segment count function. */
|
||||
sipSegCountFunc ctd_segcount;
|
||||
|
||||
/* The char buffer function. */
|
||||
sipBufferFunc ctd_charbuffer;
|
||||
#endif
|
||||
|
||||
/* The deallocation function. */
|
||||
sipDeallocFunc ctd_dealloc;
|
||||
@@ -1257,6 +942,7 @@ typedef struct _sipExternalTypeDef {
|
||||
|
||||
|
||||
/*
|
||||
* Remove in v5.1.
|
||||
* The information describing a mapped class. This (and anything that uses it)
|
||||
* is deprecated.
|
||||
*/
|
||||
@@ -1625,8 +1311,9 @@ typedef struct _sipTypeInstanceDef {
|
||||
|
||||
|
||||
/*
|
||||
* Remove in v5.1.
|
||||
* Define a mapping between a wrapped type identified by a string and the
|
||||
* corresponding Python type. This is deprecated.
|
||||
* corresponding Python type.
|
||||
*/
|
||||
typedef struct _sipStringTypeClassMap {
|
||||
/* The type as a string. */
|
||||
@@ -1638,8 +1325,9 @@ typedef struct _sipStringTypeClassMap {
|
||||
|
||||
|
||||
/*
|
||||
* Remove in v5.1.
|
||||
* Define a mapping between a wrapped type identified by an integer and the
|
||||
* corresponding Python type. This is deprecated.
|
||||
* corresponding Python type.
|
||||
*/
|
||||
typedef struct _sipIntTypeClassMap {
|
||||
/* The type as an integer. */
|
||||
@@ -1660,11 +1348,6 @@ typedef struct _sipPyMethod {
|
||||
|
||||
/* Self if it is a bound method. */
|
||||
PyObject *mself;
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/* The class. */
|
||||
PyObject *mclass;
|
||||
#endif
|
||||
} sipPyMethod;
|
||||
|
||||
|
||||
@@ -1707,7 +1390,7 @@ typedef struct _sipAPIDef {
|
||||
PyTypeObject *api_voidptr_type;
|
||||
|
||||
void (*api_bad_catcher_result)(PyObject *method);
|
||||
void (*api_bad_length_for_slice)(SIP_SSIZE_T seqlen, SIP_SSIZE_T slicelen);
|
||||
void (*api_bad_length_for_slice)(Py_ssize_t seqlen, Py_ssize_t slicelen);
|
||||
PyObject *(*api_build_result)(int *isErr, const char *fmt, ...);
|
||||
PyObject *(*api_call_method)(int *isErr, PyObject *method, const char *fmt,
|
||||
...);
|
||||
@@ -1715,8 +1398,8 @@ typedef struct _sipAPIDef {
|
||||
sipSimpleWrapper *, PyObject *, const char *, ...);
|
||||
PyObject *(*api_connect_rx)(PyObject *txObj, const char *sig,
|
||||
PyObject *rxObj, const char *slot, int type);
|
||||
SIP_SSIZE_T (*api_convert_from_sequence_index)(SIP_SSIZE_T idx,
|
||||
SIP_SSIZE_T len);
|
||||
Py_ssize_t (*api_convert_from_sequence_index)(Py_ssize_t idx,
|
||||
Py_ssize_t len);
|
||||
int (*api_can_convert_to_type)(PyObject *pyObj, const sipTypeDef *td,
|
||||
int flags);
|
||||
void *(*api_convert_to_type)(PyObject *pyObj, const sipTypeDef *td,
|
||||
@@ -1754,9 +1437,9 @@ typedef struct _sipAPIDef {
|
||||
PyObject *(*api_convert_from_void_ptr)(void *val);
|
||||
PyObject *(*api_convert_from_const_void_ptr)(const void *val);
|
||||
PyObject *(*api_convert_from_void_ptr_and_size)(void *val,
|
||||
SIP_SSIZE_T size);
|
||||
Py_ssize_t size);
|
||||
PyObject *(*api_convert_from_const_void_ptr_and_size)(const void *val,
|
||||
SIP_SSIZE_T size);
|
||||
Py_ssize_t size);
|
||||
void *(*api_convert_to_void_ptr)(PyObject *obj);
|
||||
int (*api_export_symbol)(const char *name, void *sym);
|
||||
void *(*api_import_symbol)(const char *name);
|
||||
@@ -1777,12 +1460,12 @@ typedef struct _sipAPIDef {
|
||||
PyObject *(*api_convert_from_new_pytype)(void *cpp, PyTypeObject *py_type,
|
||||
sipWrapper *owner, sipSimpleWrapper **selfp, const char *fmt, ...);
|
||||
PyObject *(*api_convert_to_typed_array)(void *data, const sipTypeDef *td,
|
||||
const char *format, size_t stride, SIP_SSIZE_T len, int flags);
|
||||
const char *format, size_t stride, Py_ssize_t len, int flags);
|
||||
PyObject *(*api_convert_to_array)(void *data, const char *format,
|
||||
SIP_SSIZE_T len, int flags);
|
||||
Py_ssize_t len, int flags);
|
||||
int (*api_register_proxy_resolver)(const sipTypeDef *td,
|
||||
sipProxyResolverFunc resolver);
|
||||
PyInterpreterState *(*api_get_interpreter)();
|
||||
PyInterpreterState *(*api_get_interpreter)(void);
|
||||
sipNewUserTypeFunc (*api_set_new_user_type_handler)(const sipTypeDef *,
|
||||
sipNewUserTypeFunc);
|
||||
void (*api_set_type_user_data)(sipWrapperType *, void *);
|
||||
@@ -1801,9 +1484,9 @@ typedef struct _sipAPIDef {
|
||||
int (*api_is_user_type)(const sipWrapperType *);
|
||||
struct _frame *(*api_get_frame)(int);
|
||||
int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
|
||||
PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
|
||||
PyObject *(*api_unicode_new)(Py_ssize_t, unsigned, int *, void **);
|
||||
void (*api_unicode_write)(int, void *, int, unsigned);
|
||||
void *(*api_unicode_data)(PyObject *, int *, SIP_SSIZE_T *);
|
||||
void *(*api_unicode_data)(PyObject *, int *, Py_ssize_t *);
|
||||
int (*api_get_buffer_info)(PyObject *, sipBufferInfoDef *);
|
||||
void (*api_release_buffer_info)(sipBufferInfoDef *);
|
||||
PyObject *(*api_get_user_object)(const sipSimpleWrapper *);
|
||||
@@ -1948,14 +1631,22 @@ typedef struct _sipAPIDef {
|
||||
/*
|
||||
* The following are part of the public API.
|
||||
*/
|
||||
int (*api_convert_from_slice_object)(PyObject *slice, SIP_SSIZE_T length,
|
||||
SIP_SSIZE_T *start, SIP_SSIZE_T *stop, SIP_SSIZE_T *step,
|
||||
SIP_SSIZE_T *slicelength);
|
||||
int (*api_convert_from_slice_object)(PyObject *slice, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
|
||||
Py_ssize_t *slicelength);
|
||||
size_t (*api_long_as_size_t)(PyObject *o);
|
||||
void (*api_visit_wrappers)(sipWrapperVisitorFunc visitor, void *closure);
|
||||
int (*api_register_exit_notifier)(PyMethodDef *md);
|
||||
|
||||
/*
|
||||
* The following are not part of the public API.
|
||||
*/
|
||||
PyObject *(*api_is_py_method_12_8)(sip_gilstate_t *gil, char *pymc,
|
||||
sipSimpleWrapper **sipSelfp, const char *cname, const char *mname);
|
||||
} sipAPIDef;
|
||||
|
||||
const sipAPIDef *sip_init_library(PyObject *mod_dict);
|
||||
|
||||
|
||||
/*
|
||||
* The API implementing the optional Qt support.
|
||||
@@ -2020,7 +1711,7 @@ typedef struct _sipQtAPI {
|
||||
#define SIP_ACCFUNC 0x0008 /* If there is an access function. */
|
||||
#define SIP_NOT_IN_MAP 0x0010 /* If Python object is not in the map. */
|
||||
|
||||
#if !defined(Py_LIMITED_API) || PY_VERSION_HEX < 0x03020000
|
||||
#if !defined(Py_LIMITED_API)
|
||||
#define SIP_PY_OWNED 0x0020 /* If owned by Python. */
|
||||
#define SIP_SHARE_MAP 0x0040 /* If the map slot might be occupied. */
|
||||
#define SIP_CPP_HAS_REF 0x0080 /* If C/C++ has a reference. */
|
||||
@@ -2068,22 +1759,16 @@ typedef struct _sipQtAPI {
|
||||
#define sipTypeIsMapped(td) (((td)->td_flags & SIP_TYPE_TYPE_MASK) == SIP_TYPE_MAPPED)
|
||||
#define sipTypeIsEnum(td) (((td)->td_flags & SIP_TYPE_TYPE_MASK) == SIP_TYPE_ENUM)
|
||||
#define sipTypeIsScopedEnum(td) (((td)->td_flags & SIP_TYPE_TYPE_MASK) == SIP_TYPE_SCOPED_ENUM)
|
||||
#define sipTypeAsPyTypeObject(td) ((td)->u.td_py_type)
|
||||
#define sipTypeAsPyTypeObject(td) ((td)->td_py_type)
|
||||
#define sipTypeName(td) sipNameFromPool((td)->td_module, (td)->td_cname)
|
||||
#define sipTypePluginData(td) ((td)->td_plugin_data)
|
||||
|
||||
|
||||
/*
|
||||
* Note that this was never actually documented as being part of the public
|
||||
* API. It is now deprecated. sipIsUserType() should be used instead.
|
||||
*/
|
||||
#define sipIsExactWrappedType(wt) (sipTypeAsPyTypeObject((wt)->wt_td) == (PyTypeObject *)(wt))
|
||||
|
||||
|
||||
/*
|
||||
* The following are deprecated parts of the public API.
|
||||
* Remove in v5.1.
|
||||
*/
|
||||
#define sipClassName(w) PyString_FromString(Py_TYPE(w)->tp_name)
|
||||
#define sipIsExactWrappedType(wt) (sipTypeAsPyTypeObject((wt)->wt_td) == (PyTypeObject *)(wt))
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file defines the SIP library internal interfaces.
|
||||
*
|
||||
* Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
* Copyright (c) 2020 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
*
|
||||
* This file is part of SIP.
|
||||
*
|
||||
@@ -91,9 +91,9 @@ extern PyTypeObject sipVoidPtr_Type;
|
||||
void *sip_api_convert_to_void_ptr(PyObject *obj);
|
||||
PyObject *sip_api_convert_from_void_ptr(void *val);
|
||||
PyObject *sip_api_convert_from_const_void_ptr(const void *val);
|
||||
PyObject *sip_api_convert_from_void_ptr_and_size(void *val, SIP_SSIZE_T size);
|
||||
PyObject *sip_api_convert_from_void_ptr_and_size(void *val, Py_ssize_t size);
|
||||
PyObject *sip_api_convert_from_const_void_ptr_and_size(const void *val,
|
||||
SIP_SSIZE_T size);
|
||||
Py_ssize_t size);
|
||||
|
||||
|
||||
/*
|
||||
@@ -151,9 +151,10 @@ PyObject *sip_api_invoke_slot_ex(const sipSlot *slot, PyObject *sigargs,
|
||||
void *sip_api_convert_rx(sipWrapper *txSelf, const char *sigargs,
|
||||
PyObject *rxObj, const char *slot, const char **memberp, int flags);
|
||||
int sip_api_save_slot(sipSlot *sp, PyObject *rxObj, const char *slot);
|
||||
int sip_api_convert_from_slice_object(PyObject *slice, SIP_SSIZE_T length,
|
||||
SIP_SSIZE_T *start, SIP_SSIZE_T *stop, SIP_SSIZE_T *step,
|
||||
SIP_SSIZE_T *slicelength);
|
||||
int sip_api_convert_from_slice_object(PyObject *slice, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
|
||||
Py_ssize_t *slicelength);
|
||||
int sip_api_deprecated(const char *classname, const char *method);
|
||||
|
||||
|
||||
/*
|
||||
@@ -163,7 +164,7 @@ sipClassTypeDef *sipGetGeneratedClassType(const sipEncodedTypeDef *enc,
|
||||
const sipClassTypeDef *ctd);
|
||||
void sipSaveMethod(sipPyMethod *pm,PyObject *meth);
|
||||
int sipGetPending(void **pp, sipWrapper **op, int *fp);
|
||||
int sipIsPending();
|
||||
int sipIsPending(void);
|
||||
PyObject *sipWrapInstance(void *cpp, PyTypeObject *py_type, PyObject *args,
|
||||
sipWrapper *owner, int flags);
|
||||
void *sipConvertRxEx(sipWrapper *txSelf, const char *sigargs,
|
||||
@@ -176,7 +177,9 @@ sipSimpleWrapper *sipOMFindObject(sipObjectMap *om, void *key,
|
||||
void sipOMAddObject(sipObjectMap *om, sipSimpleWrapper *val);
|
||||
int sipOMRemoveObject(sipObjectMap *om, sipSimpleWrapper *val);
|
||||
|
||||
void sipSetBool(void *ptr,int val);
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#define sipSetBool(p, v) (*(_Bool *)(p) = (v))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
1798
sip/siplib/siplib.c
1798
sip/siplib/siplib.c
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
* C++ classes that provide a thread interface to interact properly with the
|
||||
* Python threading infrastructure.
|
||||
*
|
||||
* Copyright (c) 2016 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
* Copyright (c) 2020 Riverbank Computing Limited <info@riverbankcomputing.com>
|
||||
*
|
||||
* This file is part of SIP.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ int sipGetPending(void **pp, sipWrapper **op, int *fp)
|
||||
/*
|
||||
* Return TRUE if anything is pending.
|
||||
*/
|
||||
int sipIsPending()
|
||||
int sipIsPending(void)
|
||||
{
|
||||
pendingDef *pd;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void *voidptr;
|
||||
SIP_SSIZE_T size;
|
||||
Py_ssize_t size;
|
||||
int rw;
|
||||
} sipVoidPtrObject;
|
||||
|
||||
@@ -38,30 +38,21 @@ typedef struct {
|
||||
/* The structure used to hold the results of a voidptr conversion. */
|
||||
struct vp_values {
|
||||
void *voidptr;
|
||||
SIP_SSIZE_T size;
|
||||
Py_ssize_t size;
|
||||
int rw;
|
||||
};
|
||||
|
||||
|
||||
static int check_size(PyObject *self);
|
||||
static int check_rw(PyObject *self);
|
||||
static int check_index(PyObject *self, SIP_SSIZE_T idx);
|
||||
#if PY_VERSION_HEX < 0x02060300
|
||||
static SIP_SSIZE_T get_value_data(PyObject *value, void **value_ptr);
|
||||
#endif
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
static void fix_bounds(int size, int *left, int *right);
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
static int check_index(PyObject *self, Py_ssize_t idx);
|
||||
static void bad_key(PyObject *key);
|
||||
#endif
|
||||
static int check_slice_size(SIP_SSIZE_T size, SIP_SSIZE_T value_size);
|
||||
static PyObject *make_voidptr(void *voidptr, SIP_SSIZE_T size, int rw);
|
||||
static int check_slice_size(Py_ssize_t size, Py_ssize_t value_size);
|
||||
static PyObject *make_voidptr(void *voidptr, Py_ssize_t size, int rw);
|
||||
static int vp_convertor(PyObject *arg, struct vp_values *vp);
|
||||
static SIP_SSIZE_T get_size_from_arg(sipVoidPtrObject *v, SIP_SSIZE_T size);
|
||||
static Py_ssize_t get_size_from_arg(sipVoidPtrObject *v, Py_ssize_t size);
|
||||
|
||||
|
||||
#if defined(SIP_USE_PYCAPSULE)
|
||||
/*
|
||||
* Implement ascapsule() for the type.
|
||||
*/
|
||||
@@ -71,20 +62,6 @@ static PyObject *sipVoidPtr_ascapsule(sipVoidPtrObject *v, PyObject *arg)
|
||||
|
||||
return PyCapsule_New(v->voidptr, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(SIP_SUPPORT_PYCOBJECT)
|
||||
/*
|
||||
* Implement ascobject() for the type.
|
||||
*/
|
||||
static PyObject *sipVoidPtr_ascobject(sipVoidPtrObject *v, PyObject *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
return PyCObject_FromVoidPtr(v->voidptr, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -95,15 +72,9 @@ static PyObject *sipVoidPtr_asarray(sipVoidPtrObject *v, PyObject *args,
|
||||
{
|
||||
static char *kwlist[] = {"size", NULL};
|
||||
|
||||
SIP_SSIZE_T size = -1;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw,
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
"|n:asarray",
|
||||
#else
|
||||
"|i:asarray",
|
||||
#endif
|
||||
kwlist, &size))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|n:asarray", kwlist, &size))
|
||||
return NULL;
|
||||
|
||||
if ((size = get_size_from_arg(v, size)) < 0)
|
||||
@@ -122,21 +93,15 @@ static PyObject *sipVoidPtr_asstring(sipVoidPtrObject *v, PyObject *args,
|
||||
{
|
||||
static char *kwlist[] = {"size", NULL};
|
||||
|
||||
SIP_SSIZE_T size = -1;
|
||||
Py_ssize_t size = -1;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw,
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
"|n:asstring",
|
||||
#else
|
||||
"|i:asstring",
|
||||
#endif
|
||||
kwlist, &size))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "|n:asstring", kwlist, &size))
|
||||
return NULL;
|
||||
|
||||
if ((size = get_size_from_arg(v, size)) < 0)
|
||||
return NULL;
|
||||
|
||||
return SIPBytes_FromStringAndSize(v->voidptr, size);
|
||||
return PyBytes_FromStringAndSize(v->voidptr, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,13 +112,7 @@ static PyObject *sipVoidPtr_getsize(sipVoidPtrObject *v, PyObject *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyLong_FromSsize_t(v->size);
|
||||
#elif PY_VERSION_HEX >= 0x02050000
|
||||
return PyInt_FromSsize_t(v->size);
|
||||
#else
|
||||
return PyInt_FromLong(v->size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -162,15 +121,7 @@ static PyObject *sipVoidPtr_getsize(sipVoidPtrObject *v, PyObject *arg)
|
||||
*/
|
||||
static PyObject *sipVoidPtr_setsize(sipVoidPtrObject *v, PyObject *arg)
|
||||
{
|
||||
SIP_SSIZE_T size;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
size = PyLong_AsSsize_t(arg);
|
||||
#elif PY_VERSION_HEX >= 0x02050000
|
||||
size = PyInt_AsSsize_t(arg);
|
||||
#else
|
||||
size = (int)PyInt_AsLong(arg);
|
||||
#endif
|
||||
Py_ssize_t size = PyLong_AsSsize_t(arg);
|
||||
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
@@ -213,12 +164,7 @@ static PyObject *sipVoidPtr_setwriteable(sipVoidPtrObject *v, PyObject *arg)
|
||||
/* The methods data structure. */
|
||||
static PyMethodDef sipVoidPtr_Methods[] = {
|
||||
{"asarray", (PyCFunction)sipVoidPtr_asarray, METH_VARARGS|METH_KEYWORDS, NULL},
|
||||
#if defined(SIP_USE_PYCAPSULE)
|
||||
{"ascapsule", (PyCFunction)sipVoidPtr_ascapsule, METH_NOARGS, NULL},
|
||||
#endif
|
||||
#if defined(SIP_SUPPORT_PYCOBJECT)
|
||||
{"ascobject", (PyCFunction)sipVoidPtr_ascobject, METH_NOARGS, NULL},
|
||||
#endif
|
||||
{"asstring", (PyCFunction)sipVoidPtr_asstring, METH_VARARGS|METH_KEYWORDS, NULL},
|
||||
{"getsize", (PyCFunction)sipVoidPtr_getsize, METH_NOARGS, NULL},
|
||||
{"setsize", (PyCFunction)sipVoidPtr_setsize, METH_O, NULL},
|
||||
@@ -246,59 +192,30 @@ static PyObject *sipVoidPtr_int(PyObject *self)
|
||||
}
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* Implement hex() for the type.
|
||||
*/
|
||||
static PyObject *sipVoidPtr_hex(PyObject *self)
|
||||
{
|
||||
char buf[2 + 16 + 1];
|
||||
|
||||
PyOS_snprintf(buf, sizeof (buf), "0x%.*lx", (int)(sizeof (void *) * 2),
|
||||
(unsigned long)((sipVoidPtrObject *)self)->voidptr);
|
||||
|
||||
return PyString_FromString(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The number methods data structure. */
|
||||
static PyNumberMethods sipVoidPtr_NumberMethods = {
|
||||
0, /* nb_add */
|
||||
0, /* nb_subtract */
|
||||
0, /* nb_multiply */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /* nb_divide */
|
||||
#endif
|
||||
0, /* nb_remainder */
|
||||
0, /* nb_divmod */
|
||||
0, /* nb_power */
|
||||
0, /* nb_negative */
|
||||
0, /* nb_positive */
|
||||
0, /* nb_absolute */
|
||||
sipVoidPtr_bool, /* nb_bool (Python v3), nb_nonzero (Python v2) */
|
||||
sipVoidPtr_bool, /* nb_bool */
|
||||
0, /* nb_invert */
|
||||
0, /* nb_lshift */
|
||||
0, /* nb_rshift */
|
||||
0, /* nb_and */
|
||||
0, /* nb_xor */
|
||||
0, /* nb_or */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /* nb_coerce */
|
||||
#endif
|
||||
sipVoidPtr_int, /* nb_int */
|
||||
0, /* nb_reserved (Python v3), nb_long (Python v2) */
|
||||
0, /* nb_reserved */
|
||||
0, /* nb_float */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /* nb_oct */
|
||||
sipVoidPtr_hex, /* nb_hex */
|
||||
#endif
|
||||
0, /* nb_inplace_add */
|
||||
0, /* nb_inplace_subtract */
|
||||
0, /* nb_inplace_multiply */
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
0, /* nb_inplace_divide */
|
||||
#endif
|
||||
0, /* nb_inplace_remainder */
|
||||
0, /* nb_inplace_power */
|
||||
0, /* nb_inplace_lshift */
|
||||
@@ -310,20 +227,16 @@ static PyNumberMethods sipVoidPtr_NumberMethods = {
|
||||
0, /* nb_true_divide */
|
||||
0, /* nb_inplace_floor_divide */
|
||||
0, /* nb_inplace_true_divide */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
0, /* nb_index */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03050000
|
||||
0, /* nb_matrix_multiply */
|
||||
0, /* nb_inplace_matrix_multiply */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Implement len() for the type.
|
||||
*/
|
||||
static SIP_SSIZE_T sipVoidPtr_length(PyObject *self)
|
||||
static Py_ssize_t sipVoidPtr_length(PyObject *self)
|
||||
{
|
||||
if (check_size(self) < 0)
|
||||
return -1;
|
||||
@@ -335,118 +248,31 @@ static SIP_SSIZE_T sipVoidPtr_length(PyObject *self)
|
||||
/*
|
||||
* Implement sequence item sub-script for the type.
|
||||
*/
|
||||
static PyObject *sipVoidPtr_item(PyObject *self, SIP_SSIZE_T idx)
|
||||
static PyObject *sipVoidPtr_item(PyObject *self, Py_ssize_t idx)
|
||||
{
|
||||
if (check_size(self) < 0 || check_index(self, idx) < 0)
|
||||
return NULL;
|
||||
|
||||
return SIPBytes_FromStringAndSize(
|
||||
return PyBytes_FromStringAndSize(
|
||||
(char *)((sipVoidPtrObject *)self)->voidptr + idx, 1);
|
||||
}
|
||||
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
/*
|
||||
* Implement sequence slice sub-script for the type.
|
||||
*/
|
||||
static PyObject *sipVoidPtr_slice(PyObject *self, int left, int right)
|
||||
{
|
||||
sipVoidPtrObject *v;
|
||||
|
||||
if (check_size(self) < 0)
|
||||
return NULL;
|
||||
|
||||
v = (sipVoidPtrObject *)self;
|
||||
|
||||
fix_bounds(v->size, &left, &right);
|
||||
|
||||
if (left == right)
|
||||
left = right = 0;
|
||||
|
||||
return make_voidptr((char *)(v->voidptr) + left, right - left, v->rw);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implement sequence assignment item sub-script for the type.
|
||||
*/
|
||||
static int sipVoidPtr_ass_item(PyObject *self, int idx, PyObject *value)
|
||||
{
|
||||
int value_size;
|
||||
void *value_ptr;
|
||||
|
||||
if (check_rw(self) < 0 || check_size(self) < 0 || check_index(self, idx) < 0)
|
||||
return -1;
|
||||
|
||||
if ((value_size = get_value_data(value, &value_ptr)) < 0)
|
||||
return -1;
|
||||
|
||||
if (value_size != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"right operand must be a single byte");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
((char *)((sipVoidPtrObject *)self)->voidptr)[idx] = *(char *)value_ptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implement sequence assignment slice sub-script for the type.
|
||||
*/
|
||||
static int sipVoidPtr_ass_slice(PyObject *self, int left, int right,
|
||||
PyObject *value)
|
||||
{
|
||||
sipVoidPtrObject *v;
|
||||
int value_size;
|
||||
void *value_ptr;
|
||||
|
||||
if (check_rw(self) < 0 || check_size(self) < 0)
|
||||
return -1;
|
||||
|
||||
if ((value_size = get_value_data(value, &value_ptr)) < 0)
|
||||
return -1;
|
||||
|
||||
v = (sipVoidPtrObject *)self;
|
||||
|
||||
fix_bounds(v->size, &left, &right);
|
||||
|
||||
if (check_slice_size(right - left, value_size) < 0)
|
||||
return -1;
|
||||
|
||||
memmove((char *)(v->voidptr) + left, value_ptr, right - left);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The sequence methods data structure. */
|
||||
static PySequenceMethods sipVoidPtr_SequenceMethods = {
|
||||
sipVoidPtr_length, /* sq_length */
|
||||
0, /* sq_concat */
|
||||
0, /* sq_repeat */
|
||||
sipVoidPtr_item, /* sq_item */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
0, /* sq_slice */
|
||||
0, /* sq_ass_item */
|
||||
0, /* sq_ass_slice */
|
||||
#else
|
||||
sipVoidPtr_slice, /* sq_slice */
|
||||
sipVoidPtr_ass_item, /* sq_ass_item */
|
||||
sipVoidPtr_ass_slice, /* sq_ass_slice */
|
||||
#endif
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
};
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
/*
|
||||
* Implement mapping sub-script for the type.
|
||||
*/
|
||||
@@ -502,12 +328,7 @@ static int sipVoidPtr_ass_subscript(PyObject *self, PyObject *key,
|
||||
{
|
||||
sipVoidPtrObject *v;
|
||||
Py_ssize_t start, size;
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
Py_buffer value_view;
|
||||
#else
|
||||
Py_ssize_t value_size;
|
||||
void *value_ptr;
|
||||
#endif
|
||||
|
||||
if (check_rw(self) < 0 || check_size(self) < 0)
|
||||
return -1;
|
||||
@@ -549,7 +370,6 @@ static int sipVoidPtr_ass_subscript(PyObject *self, PyObject *key,
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
if (PyObject_GetBuffer(value, &value_view, PyBUF_CONTIG_RO) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -572,15 +392,6 @@ static int sipVoidPtr_ass_subscript(PyObject *self, PyObject *key,
|
||||
memmove((char *)v->voidptr + start, value_view.buf, size);
|
||||
|
||||
PyBuffer_Release(&value_view);
|
||||
#else
|
||||
if ((value_size = get_value_data(value, &value_ptr)) < 0)
|
||||
return -1;
|
||||
|
||||
if (check_slice_size(size, value_size) < 0)
|
||||
return -1;
|
||||
|
||||
memmove((char *)v->voidptr + start, value_ptr, size);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -592,10 +403,8 @@ static PyMappingMethods sipVoidPtr_MappingMethods = {
|
||||
sipVoidPtr_subscript, /* mp_subscript */
|
||||
sipVoidPtr_ass_subscript, /* mp_ass_subscript */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
/*
|
||||
* The buffer implementation for Python v2.6.3 and later.
|
||||
*/
|
||||
@@ -610,90 +419,12 @@ static int sipVoidPtr_getbuffer(PyObject *self, Py_buffer *buf, int flags)
|
||||
|
||||
return PyBuffer_FillInfo(buf, self, v->voidptr, v->size, !v->rw, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The read buffer implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipVoidPtr_getreadbuffer(PyObject *self, SIP_SSIZE_T seg,
|
||||
void **ptr)
|
||||
{
|
||||
sipVoidPtrObject *v;
|
||||
|
||||
if (seg != 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, "invalid buffer segment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (check_size(self) < 0)
|
||||
return -1;
|
||||
|
||||
v = (sipVoidPtrObject *)self;
|
||||
|
||||
*ptr = v->voidptr;
|
||||
|
||||
return v->size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The write buffer implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipVoidPtr_getwritebuffer(PyObject *self, SIP_SSIZE_T seg,
|
||||
void **ptr)
|
||||
{
|
||||
if (((sipVoidPtrObject *)self)->rw)
|
||||
return sipVoidPtr_getreadbuffer(self, seg, ptr);
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "sip.voidptr object is not writeable");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/*
|
||||
* The segment count implementation for Python v2.
|
||||
*/
|
||||
static SIP_SSIZE_T sipVoidPtr_getsegcount(PyObject *self, SIP_SSIZE_T *lenp)
|
||||
{
|
||||
SIP_SSIZE_T segs, len;
|
||||
|
||||
len = ((sipVoidPtrObject *)self)->size;
|
||||
segs = (len < 0 ? 0 : 1);
|
||||
|
||||
if (lenp != NULL)
|
||||
*lenp = len;
|
||||
|
||||
return segs;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The buffer methods data structure. */
|
||||
static PyBufferProcs sipVoidPtr_BufferProcs = {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
sipVoidPtr_getbuffer, /* bf_getbuffer */
|
||||
0 /* bf_releasebuffer */
|
||||
#else
|
||||
sipVoidPtr_getreadbuffer, /* bf_getreadbuffer */
|
||||
sipVoidPtr_getwritebuffer, /* bf_getwritebuffer */
|
||||
sipVoidPtr_getsegcount, /* bf_getsegcount */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
(charbufferproc)sipVoidPtr_getreadbuffer, /* bf_getcharbuffer */
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
sipVoidPtr_getbuffer, /* bf_getbuffer */
|
||||
0 /* bf_releasebuffer */
|
||||
#endif
|
||||
#else
|
||||
(getcharbufferproc)sipVoidPtr_getreadbuffer /* bf_getcharbuffer */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -706,17 +437,11 @@ static PyObject *sipVoidPtr_new(PyTypeObject *subtype, PyObject *args,
|
||||
static char *kwlist[] = {"address", "size", "writeable", NULL};
|
||||
|
||||
struct vp_values vp_conversion;
|
||||
SIP_SSIZE_T size = -1;
|
||||
Py_ssize_t size = -1;
|
||||
int rw = -1;
|
||||
PyObject *obj;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw,
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
"O&|ni:voidptr",
|
||||
#else
|
||||
"O&|ii:voidptr",
|
||||
#endif
|
||||
kwlist, vp_convertor, &vp_conversion, &size, &rw))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "O&|ni:voidptr", kwlist, vp_convertor, &vp_conversion, &size, &rw))
|
||||
return NULL;
|
||||
|
||||
/* Use the explicit size if one was given. */
|
||||
@@ -754,11 +479,7 @@ PyTypeObject sipVoidPtr_Type = {
|
||||
0, /* tp_repr */
|
||||
&sipVoidPtr_NumberMethods, /* tp_as_number */
|
||||
&sipVoidPtr_SequenceMethods, /* tp_as_sequence */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
&sipVoidPtr_MappingMethods, /* tp_as_mapping */
|
||||
#else
|
||||
0, /* tp_as_mapping */
|
||||
#endif
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
@@ -796,12 +517,8 @@ PyTypeObject sipVoidPtr_Type = {
|
||||
0, /* tp_subclasses */
|
||||
0, /* tp_weaklist */
|
||||
0, /* tp_del */
|
||||
#if PY_VERSION_HEX >= 0x02060000
|
||||
0, /* tp_version_tag */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03040000
|
||||
0, /* tp_finalize */
|
||||
#endif
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
0, /* tp_vectorcall */
|
||||
#endif
|
||||
@@ -849,7 +566,7 @@ PyObject *sip_api_convert_from_const_void_ptr(const void *val)
|
||||
/*
|
||||
* Convert a sized C/C++ void pointer to a sip.voidptr object.
|
||||
*/
|
||||
PyObject *sip_api_convert_from_void_ptr_and_size(void *val, SIP_SSIZE_T size)
|
||||
PyObject *sip_api_convert_from_void_ptr_and_size(void *val, Py_ssize_t size)
|
||||
{
|
||||
return make_voidptr(val, size, TRUE);
|
||||
}
|
||||
@@ -859,7 +576,7 @@ PyObject *sip_api_convert_from_void_ptr_and_size(void *val, SIP_SSIZE_T size)
|
||||
* Convert a sized C/C++ const void pointer to a sip.voidptr object.
|
||||
*/
|
||||
PyObject *sip_api_convert_from_const_void_ptr_and_size(const void *val,
|
||||
SIP_SSIZE_T size)
|
||||
Py_ssize_t size)
|
||||
{
|
||||
return make_voidptr((void *)val, size, FALSE);
|
||||
}
|
||||
@@ -899,7 +616,7 @@ static int check_rw(PyObject *self)
|
||||
/*
|
||||
* Check that an index is valid for a void pointer.
|
||||
*/
|
||||
static int check_index(PyObject *self, SIP_SSIZE_T idx)
|
||||
static int check_index(PyObject *self, Py_ssize_t idx)
|
||||
{
|
||||
if (idx >= 0 && idx < ((sipVoidPtrObject *)self)->size)
|
||||
return 0;
|
||||
@@ -910,58 +627,6 @@ static int check_index(PyObject *self, SIP_SSIZE_T idx)
|
||||
}
|
||||
|
||||
|
||||
#if PY_VERSION_HEX < 0x02060300
|
||||
/*
|
||||
* Get the address and size of the data from a value that supports the buffer
|
||||
* interface.
|
||||
*/
|
||||
static SIP_SSIZE_T get_value_data(PyObject *value, void **value_ptr)
|
||||
{
|
||||
PyBufferProcs *bf = Py_TYPE(value)->tp_as_buffer;
|
||||
|
||||
if (bf == NULL || bf->bf_getreadbuffer == NULL || bf->bf_getsegcount == NULL)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"'%s' does not support the buffer interface",
|
||||
Py_TYPE(value)->tp_name);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((*bf->bf_getsegcount)(value, NULL) != 1)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"single-segment buffer object expected");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (*bf->bf_getreadbuffer)(value, 0, value_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
/*
|
||||
* Fix the bounds of a slice in the same way that the Python buffer object
|
||||
* does.
|
||||
*/
|
||||
static void fix_bounds(int size, int *left, int *right)
|
||||
{
|
||||
if (*left < 0)
|
||||
*left = 0;
|
||||
else if (*left > size)
|
||||
*left = size;
|
||||
|
||||
if (*right < *left)
|
||||
*right = *left;
|
||||
else if (*right > size)
|
||||
*right = size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
/*
|
||||
* Raise an exception about a bad sub-script key.
|
||||
*/
|
||||
@@ -971,14 +636,13 @@ static void bad_key(PyObject *key)
|
||||
"cannot index a sip.voidptr object using '%s'",
|
||||
Py_TYPE(key)->tp_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Check that the size of a value is the same as the size of the slice it is
|
||||
* replacing.
|
||||
*/
|
||||
static int check_slice_size(SIP_SSIZE_T size, SIP_SSIZE_T value_size)
|
||||
static int check_slice_size(Py_ssize_t size, Py_ssize_t value_size)
|
||||
{
|
||||
if (value_size == size)
|
||||
return 0;
|
||||
@@ -993,7 +657,7 @@ static int check_slice_size(SIP_SSIZE_T size, SIP_SSIZE_T value_size)
|
||||
/*
|
||||
* Do the work of converting a void pointer.
|
||||
*/
|
||||
static PyObject *make_voidptr(void *voidptr, SIP_SSIZE_T size, int rw)
|
||||
static PyObject *make_voidptr(void *voidptr, Py_ssize_t size, int rw)
|
||||
{
|
||||
sipVoidPtrObject *self;
|
||||
|
||||
@@ -1020,26 +684,23 @@ static PyObject *make_voidptr(void *voidptr, SIP_SSIZE_T size, int rw)
|
||||
static int vp_convertor(PyObject *arg, struct vp_values *vp)
|
||||
{
|
||||
void *ptr;
|
||||
SIP_SSIZE_T size = -1;
|
||||
Py_ssize_t size = -1;
|
||||
int rw = TRUE;
|
||||
|
||||
if (arg == Py_None)
|
||||
{
|
||||
ptr = NULL;
|
||||
#if defined(SIP_USE_PYCAPSULE)
|
||||
}
|
||||
else if (PyCapsule_CheckExact(arg))
|
||||
{
|
||||
ptr = PyCapsule_GetPointer(arg, NULL);
|
||||
#endif
|
||||
#if defined(SIP_SUPPORT_PYCOBJECT)
|
||||
else if (PyCObject_Check(arg))
|
||||
ptr = PyCObject_AsVoidPtr(arg);
|
||||
#endif
|
||||
}
|
||||
else if (PyObject_TypeCheck(arg, &sipVoidPtr_Type))
|
||||
{
|
||||
ptr = ((sipVoidPtrObject *)arg)->voidptr;
|
||||
size = ((sipVoidPtrObject *)arg)->size;
|
||||
rw = ((sipVoidPtrObject *)arg)->rw;
|
||||
}
|
||||
#if PY_VERSION_HEX >= 0x02060300
|
||||
else if (PyObject_CheckBuffer(arg))
|
||||
{
|
||||
Py_buffer view;
|
||||
@@ -1053,13 +714,6 @@ static int vp_convertor(PyObject *arg, struct vp_values *vp)
|
||||
|
||||
PyBuffer_Release(&view);
|
||||
}
|
||||
#endif
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
else if (PyObject_AsReadBuffer(arg, (const void **)&ptr, &size) >= 0)
|
||||
{
|
||||
rw = (Py_TYPE(arg)->tp_as_buffer->bf_getwritebuffer != NULL);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
PyErr_Clear();
|
||||
@@ -1067,15 +721,7 @@ static int vp_convertor(PyObject *arg, struct vp_values *vp)
|
||||
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
#if defined(SIP_USE_PYCAPSULE)
|
||||
#if defined(SIP_SUPPORT_PYCOBJECT)
|
||||
PyErr_SetString(PyExc_TypeError, "a single integer, Capsule, CObject, None, bytes-like object or another sip.voidptr object is required");
|
||||
#else
|
||||
PyErr_SetString(PyExc_TypeError, "a single integer, Capsule, None, bytes-like object or another sip.voidptr object is required");
|
||||
#endif
|
||||
#else
|
||||
PyErr_SetString(PyExc_TypeError, "a single integer, CObject, None, bytes-like object or another sip.voidptr object is required");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1092,7 +738,7 @@ static int vp_convertor(PyObject *arg, struct vp_values *vp)
|
||||
* Get a size possibly supplied as an argument, otherwise get it from the
|
||||
* object. Raise an exception if there was no size specified.
|
||||
*/
|
||||
static SIP_SSIZE_T get_size_from_arg(sipVoidPtrObject *v, SIP_SSIZE_T size)
|
||||
static Py_ssize_t get_size_from_arg(sipVoidPtrObject *v, Py_ssize_t size)
|
||||
{
|
||||
/* Use the current size if one wasn't explicitly given. */
|
||||
if (size < 0)
|
||||
|
||||
Reference in New Issue
Block a user