diff --git a/ChangeLog b/ChangeLog index b09fe4322e..9efa9ed03c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-04-04 Jan Schmidt + + * gst/common.h: + * gst/gst.override: + * gst/gstbuffer.override: + * gst/gstcaps.override: + * gst/gststructure.override: + * gst/gsttaglist.override: + * gst/interfaces.override: + + Fix the build for x86_64 when compiling against Python 2.5. + Keeps backwards compatibility with Python 2.4. Tested on Ubuntu + Edgy 32-bit with python 2.4 & Feisty 64-bit with Python 2.4 & 2.5 + Fixes #415003. + 2007-03-25 Tim-Philipp Müller * gst/interfaces.defs: diff --git a/gst/common.h b/gst/common.h index 528e86b19b..bf4676cb09 100644 --- a/gst/common.h +++ b/gst/common.h @@ -36,8 +36,11 @@ #endif #if PY_VERSION_HEX < 0x02050000 +#define lenfunc inquiry #define ssizeargfunc intargfunc #define ssizessizeargfunc intintargfunc +#define ssizeobjargproc intobjargproc +#define ssizessizeobjargproc intintobjargproc #endif typedef struct { diff --git a/gst/gst.override b/gst/gst.override index c5b265f288..77699e6149 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -58,6 +58,11 @@ headers #include #include +/* Boonky define that allows for backwards compatibility with Python 2.4 */ +#if PY_VERSION_HEX < 0x02050000 +#define Py_ssize_t int +#endif + GST_DEBUG_CATEGORY_EXTERN (python_debug); GST_DEBUG_CATEGORY_EXTERN (pygst_debug); #define GST_CAT_DEFAULT pygst_debug @@ -1030,7 +1035,7 @@ gst_type_find_peek_handler (gpointer data, gint64 offset, guint size) goto beach; } else { gchar *str; - int len; + Py_ssize_t len; if ((PyString_AsStringAndSize(py_ret, &str, &len)) == -1) { Py_DECREF (py_ret); diff --git a/gst/gstbuffer.override b/gst/gstbuffer.override index 92003f49a7..cd5d7acd75 100644 --- a/gst/gstbuffer.override +++ b/gst/gstbuffer.override @@ -23,17 +23,20 @@ %% headers -static int gst_buffer_getreadbuffer (PyGstMiniObject *self, - int index, - const void **ptr); -static int gst_buffer_getwritebuf (PyGstMiniObject *self, - int index, - const void **ptr); -static int gst_buffer_getsegcount (PyGstMiniObject *self, - int *lenp); -static int gst_buffer_getcharbuf (PyGstMiniObject *self, - int index, - const char **ptr); +static Py_ssize_t gst_buffer_getreadbuffer (PyObject *self, + Py_ssize_t index, void **ptr); +static Py_ssize_t gst_buffer_getwritebuf (PyObject *self, + Py_ssize_t index, void **ptr); +static Py_ssize_t gst_buffer_getsegcount (PyObject *self, + Py_ssize_t *lenp); + +#if PY_VERSION_HEX >= 0x02050000 +static Py_ssize_t gst_buffer_getcharbuf (PyObject *self, + Py_ssize_t index, char **ptr); +#else +static Py_ssize_t gst_buffer_getcharbuf (PyObject *self, + Py_ssize_t index, const char **ptr); +#endif %% override gst_buffer_new kwargs static int @@ -130,14 +133,15 @@ _wrap_gst_buffer_tp_repr (PyGstMiniObject *self) %% override-slot GstBuffer.tp_as_buffer static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = { - (getreadbufferproc)gst_buffer_getreadbuffer, /* bf_getreadbuffer */ - (getwritebufferproc)gst_buffer_getwritebuf, /* bf_getwritebuffer */ - (getsegcountproc)gst_buffer_getsegcount, /* bf_getsegcount */ - (getcharbufferproc)gst_buffer_getcharbuf, /* bf_getcharbuffer */ + gst_buffer_getreadbuffer, /* bf_getreadbuffer */ + gst_buffer_getwritebuf, /* bf_getwritebuffer */ + gst_buffer_getsegcount, /* bf_getsegcount */ + gst_buffer_getcharbuf, /* bf_getcharbuffer */ }; -static int -gst_buffer_getreadbuffer(PyGstMiniObject *self, int index, const void **ptr) +static Py_ssize_t +gst_buffer_getreadbuffer(PyObject *self, Py_ssize_t index, + void **ptr) { GstBuffer *buf = pyg_boxed_get(self, GstBuffer); @@ -151,8 +155,8 @@ gst_buffer_getreadbuffer(PyGstMiniObject *self, int index, const void **ptr) return GST_BUFFER_SIZE(buf); } -static int -gst_buffer_getsegcount(PyGstMiniObject *self, int *lenp) +static Py_ssize_t +gst_buffer_getsegcount(PyObject *self, Py_ssize_t *lenp) { GstBuffer *buf = pyg_boxed_get(self, GstBuffer); @@ -161,14 +165,20 @@ gst_buffer_getsegcount(PyGstMiniObject *self, int *lenp) return 1; } -static int -gst_buffer_getcharbuf(PyGstMiniObject *self, int index, const char **ptr) +/* Need a version that has const char ** for Python 2.4 */ +#if PY_VERSION_HEX >= 0x02050000 +static Py_ssize_t gst_buffer_getcharbuf (PyObject *self, + Py_ssize_t index, char **ptr) +#else +static Py_ssize_t gst_buffer_getcharbuf (PyObject *self, + Py_ssize_t index, const char **ptr) +#endif { - return gst_buffer_getreadbuffer (self, index, (const void **) ptr); + return gst_buffer_getreadbuffer (self, index, (void **) ptr); } -static int -gst_buffer_getwritebuf(PyGstMiniObject *self, int index, const void **ptr) +static Py_ssize_t +gst_buffer_getwritebuf(PyObject *self, Py_ssize_t index, void **ptr) { GstBuffer *buf = pyg_boxed_get(self, GstBuffer); @@ -192,14 +202,14 @@ gst_buffer_getwritebuf(PyGstMiniObject *self, int index, const void **ptr) override-slot GstBuffer.tp_as_sequence /* FIXME: should buffer parts be buffers or strings? */ -static int +static Py_ssize_t pygst_buffer_length(PyObject *self) { return GST_BUFFER_SIZE(pygobject_get (self)); } static PyObject * -pygst_buffer_slice(PyObject *self, int start, int end) +pygst_buffer_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end) { GstBuffer *buf = GST_BUFFER (pygobject_get (self)); if (start < 0) @@ -217,17 +227,18 @@ pygst_buffer_slice(PyObject *self, int start, int end) } static PyObject * -pygst_buffer_item(PyObject *self, int index) +pygst_buffer_item(PyObject *self, Py_ssize_t index) { return pygst_buffer_slice (self, index, index + 1); } static int -pygst_buffer_ass_slice (PyObject *self, int start, int end, PyObject *val) +pygst_buffer_ass_slice (PyObject *self, Py_ssize_t start, + Py_ssize_t end, PyObject *val) { GstBuffer *buf = GST_BUFFER (pygobject_get (self)); const void *data; - int len; + Py_ssize_t len; if (!gst_buffer_is_writable (buf)) { PyErr_SetString(PyExc_TypeError, "buffer is not writable"); @@ -248,11 +259,11 @@ pygst_buffer_ass_slice (PyObject *self, int start, int end, PyObject *val) } static int -pygst_buffer_ass_item (PyObject *self, int index, PyObject *val) +pygst_buffer_ass_item (PyObject *self, Py_ssize_t index, PyObject *val) { GstBuffer *buf = GST_BUFFER (pygobject_get (self)); const void *data; - int len; + Py_ssize_t len; if (!gst_buffer_is_writable (buf)) { PyErr_SetString(PyExc_TypeError, "buffer is not writable"); diff --git a/gst/gstcaps.override b/gst/gstcaps.override index 0c5f37f909..6765624c8b 100644 --- a/gst/gstcaps.override +++ b/gst/gstcaps.override @@ -77,7 +77,7 @@ ignore gst_caps_set_simple %% override gst_caps_get_structure kwargs -static PyObject *pygst_caps_sq_item(PyObject *self, int i); +static PyObject *pygst_caps_sq_item(PyObject *self, Py_ssize_t i); static PyObject * _wrap_gst_caps_get_structure(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -349,7 +349,7 @@ static PyNumberMethods _wrap_gst_caps_tp_as_number = { }; %% override-slot GstCaps.tp_as_sequence -static int +static Py_ssize_t pygst_caps_sq_length(PyObject *self) { GstCaps *caps = pyg_boxed_get (self, GstCaps); @@ -357,7 +357,7 @@ pygst_caps_sq_length(PyObject *self) } static PyObject * -pygst_caps_sq_item(PyObject *self, int i) +pygst_caps_sq_item(PyObject *self, Py_ssize_t i) { GstCaps *caps = pyg_boxed_get (self, GstCaps); GstStructure *structure; @@ -381,7 +381,7 @@ pygst_caps_sq_item(PyObject *self, int i) /* FIXME: This syntax sucks */ static PyObject * -pygst_caps_sq_slice(PyObject *self, int start, int end) +pygst_caps_sq_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end) { GstCaps *caps = pyg_boxed_get (self, GstCaps); GstCaps *ret = gst_caps_new_empty (); diff --git a/gst/gststructure.override b/gst/gststructure.override index 68bedbea51..453a216725 100644 --- a/gst/gststructure.override +++ b/gst/gststructure.override @@ -172,10 +172,11 @@ _wrap_gst_structure_keys (PyObject *self) %% override-slot GstStructure.tp_as_mapping -static int -_wrap_gst_structure_length(PyGObject *self) +static Py_ssize_t +_wrap_gst_structure_length(PyObject *self) { - return gst_structure_n_fields((GstStructure*)self->obj); + PyGObject *gself = (PyGObject *)self; + return gst_structure_n_fields((GstStructure*)gself->obj); } static PyObject * @@ -222,7 +223,7 @@ _wrap_gst_structure_ass_subscript(PyGObject *self, } static PyMappingMethods _wrap_gst_structure_tp_as_mapping = { - (inquiry)_wrap_gst_structure_length, /* mp_length */ + _wrap_gst_structure_length, /* mp_length */ (binaryfunc)_wrap_gst_structure_subscript, /* mp_subscript */ (objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */ }; diff --git a/gst/gsttaglist.override b/gst/gsttaglist.override index 9d65440d4e..93c902f9fe 100644 --- a/gst/gsttaglist.override +++ b/gst/gsttaglist.override @@ -63,10 +63,11 @@ _wrap_gst_tag_list_keys(PyGObject *self) } %% override-slot GstTagList.tp_as_mapping -static int -_wrap_gst_tag_list_length(PyGObject *self) +static Py_ssize_t +_wrap_gst_tag_list_length(PyObject *self) { - return gst_structure_n_fields((GstStructure*)self->obj); + PyGObject *gself = (PyGObject *)self; + return gst_structure_n_fields((GstStructure*)gself->obj); } static PyObject * @@ -113,7 +114,7 @@ _wrap_gst_tag_list_ass_subscript(PyGObject *self, } static PyMappingMethods _wrap_gst_tag_list_tp_as_mapping = { - (inquiry)_wrap_gst_tag_list_length, /* mp_length */ + _wrap_gst_tag_list_length, /* mp_length */ (binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */ (objobjargproc)_wrap_gst_tag_list_ass_subscript /* mp_ass_subscript */ }; @@ -127,13 +128,13 @@ _wrap_gst_tag_list_contains(PyGObject *self, PyObject *py_key) } static PySequenceMethods _wrap_gst_tag_list_tp_as_sequence = { - (inquiry)NULL, + (lenfunc)NULL, (binaryfunc)NULL, (ssizeargfunc)NULL, (ssizeargfunc)NULL, (ssizessizeargfunc)NULL, - (intobjargproc)NULL, - (intintobjargproc)NULL, + (ssizeobjargproc)NULL, + (ssizessizeobjargproc)NULL, (objobjproc)_wrap_gst_tag_list_contains, (binaryfunc)NULL, (ssizeargfunc)NULL, diff --git a/gst/interfaces.override b/gst/interfaces.override index d5edf8611b..c16680d6f0 100644 --- a/gst/interfaces.override +++ b/gst/interfaces.override @@ -188,7 +188,7 @@ _wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs) if (channels != PyTuple_Size (py_tuple)) { PyErr_Format (PyExc_TypeError, "Track channel count %d != volume tuple size %d", - channels, PyTuple_Size (py_tuple)); + channels, (gint) PyTuple_Size (py_tuple)); return NULL; }