gst/: Fix the build for x86_64 when compiling against Python 2.5.

Original commit message from CVS:
* 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.
This commit is contained in:
Jan Schmidt 2007-04-04 12:22:03 +00:00
parent 6baee7881d
commit c0f3f0d55f
8 changed files with 84 additions and 48 deletions

View file

@ -1,3 +1,18 @@
2007-04-04 Jan Schmidt <thaytan@mad.scientist.com>
* 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 <tim at centricular dot net> 2007-03-25 Tim-Philipp Müller <tim at centricular dot net>
* gst/interfaces.defs: * gst/interfaces.defs:

View file

@ -36,8 +36,11 @@
#endif #endif
#if PY_VERSION_HEX < 0x02050000 #if PY_VERSION_HEX < 0x02050000
#define lenfunc inquiry
#define ssizeargfunc intargfunc #define ssizeargfunc intargfunc
#define ssizessizeargfunc intintargfunc #define ssizessizeargfunc intintargfunc
#define ssizeobjargproc intobjargproc
#define ssizessizeobjargproc intintobjargproc
#endif #endif
typedef struct { typedef struct {

View file

@ -58,6 +58,11 @@ headers
#include <compile.h> #include <compile.h>
#include <frameobject.h> #include <frameobject.h>
/* 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 (python_debug);
GST_DEBUG_CATEGORY_EXTERN (pygst_debug); GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
#define GST_CAT_DEFAULT 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; goto beach;
} else { } else {
gchar *str; gchar *str;
int len; Py_ssize_t len;
if ((PyString_AsStringAndSize(py_ret, &str, &len)) == -1) { if ((PyString_AsStringAndSize(py_ret, &str, &len)) == -1) {
Py_DECREF (py_ret); Py_DECREF (py_ret);

View file

@ -23,17 +23,20 @@
%% %%
headers headers
static int gst_buffer_getreadbuffer (PyGstMiniObject *self, static Py_ssize_t gst_buffer_getreadbuffer (PyObject *self,
int index, Py_ssize_t index, void **ptr);
const void **ptr); static Py_ssize_t gst_buffer_getwritebuf (PyObject *self,
static int gst_buffer_getwritebuf (PyGstMiniObject *self, Py_ssize_t index, void **ptr);
int index, static Py_ssize_t gst_buffer_getsegcount (PyObject *self,
const void **ptr); Py_ssize_t *lenp);
static int gst_buffer_getsegcount (PyGstMiniObject *self,
int *lenp); #if PY_VERSION_HEX >= 0x02050000
static int gst_buffer_getcharbuf (PyGstMiniObject *self, static Py_ssize_t gst_buffer_getcharbuf (PyObject *self,
int index, Py_ssize_t index, char **ptr);
const 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 override gst_buffer_new kwargs
static int static int
@ -130,14 +133,15 @@ _wrap_gst_buffer_tp_repr (PyGstMiniObject *self)
%% %%
override-slot GstBuffer.tp_as_buffer override-slot GstBuffer.tp_as_buffer
static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = { static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = {
(getreadbufferproc)gst_buffer_getreadbuffer, /* bf_getreadbuffer */ gst_buffer_getreadbuffer, /* bf_getreadbuffer */
(getwritebufferproc)gst_buffer_getwritebuf, /* bf_getwritebuffer */ gst_buffer_getwritebuf, /* bf_getwritebuffer */
(getsegcountproc)gst_buffer_getsegcount, /* bf_getsegcount */ gst_buffer_getsegcount, /* bf_getsegcount */
(getcharbufferproc)gst_buffer_getcharbuf, /* bf_getcharbuffer */ gst_buffer_getcharbuf, /* bf_getcharbuffer */
}; };
static int static Py_ssize_t
gst_buffer_getreadbuffer(PyGstMiniObject *self, int index, const void **ptr) gst_buffer_getreadbuffer(PyObject *self, Py_ssize_t index,
void **ptr)
{ {
GstBuffer *buf = pyg_boxed_get(self, GstBuffer); 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); return GST_BUFFER_SIZE(buf);
} }
static int static Py_ssize_t
gst_buffer_getsegcount(PyGstMiniObject *self, int *lenp) gst_buffer_getsegcount(PyObject *self, Py_ssize_t *lenp)
{ {
GstBuffer *buf = pyg_boxed_get(self, GstBuffer); GstBuffer *buf = pyg_boxed_get(self, GstBuffer);
@ -161,14 +165,20 @@ gst_buffer_getsegcount(PyGstMiniObject *self, int *lenp)
return 1; return 1;
} }
static int /* Need a version that has const char ** for Python 2.4 */
gst_buffer_getcharbuf(PyGstMiniObject *self, int index, const char **ptr) #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 static Py_ssize_t
gst_buffer_getwritebuf(PyGstMiniObject *self, int index, const void **ptr) gst_buffer_getwritebuf(PyObject *self, Py_ssize_t index, void **ptr)
{ {
GstBuffer *buf = pyg_boxed_get(self, GstBuffer); 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 override-slot GstBuffer.tp_as_sequence
/* FIXME: should buffer parts be buffers or strings? */ /* FIXME: should buffer parts be buffers or strings? */
static int static Py_ssize_t
pygst_buffer_length(PyObject *self) pygst_buffer_length(PyObject *self)
{ {
return GST_BUFFER_SIZE(pygobject_get (self)); return GST_BUFFER_SIZE(pygobject_get (self));
} }
static PyObject * 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)); GstBuffer *buf = GST_BUFFER (pygobject_get (self));
if (start < 0) if (start < 0)
@ -217,17 +227,18 @@ pygst_buffer_slice(PyObject *self, int start, int end)
} }
static PyObject * 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); return pygst_buffer_slice (self, index, index + 1);
} }
static int 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)); GstBuffer *buf = GST_BUFFER (pygobject_get (self));
const void *data; const void *data;
int len; Py_ssize_t len;
if (!gst_buffer_is_writable (buf)) { if (!gst_buffer_is_writable (buf)) {
PyErr_SetString(PyExc_TypeError, "buffer is not writable"); 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 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)); GstBuffer *buf = GST_BUFFER (pygobject_get (self));
const void *data; const void *data;
int len; Py_ssize_t len;
if (!gst_buffer_is_writable (buf)) { if (!gst_buffer_is_writable (buf)) {
PyErr_SetString(PyExc_TypeError, "buffer is not writable"); PyErr_SetString(PyExc_TypeError, "buffer is not writable");

View file

@ -77,7 +77,7 @@ ignore
gst_caps_set_simple gst_caps_set_simple
%% %%
override gst_caps_get_structure kwargs 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 * static PyObject *
_wrap_gst_caps_get_structure(PyObject *self, PyObject *args, PyObject *kwargs) _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 override-slot GstCaps.tp_as_sequence
static int static Py_ssize_t
pygst_caps_sq_length(PyObject *self) pygst_caps_sq_length(PyObject *self)
{ {
GstCaps *caps = pyg_boxed_get (self, GstCaps); GstCaps *caps = pyg_boxed_get (self, GstCaps);
@ -357,7 +357,7 @@ pygst_caps_sq_length(PyObject *self)
} }
static PyObject * 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); GstCaps *caps = pyg_boxed_get (self, GstCaps);
GstStructure *structure; GstStructure *structure;
@ -381,7 +381,7 @@ pygst_caps_sq_item(PyObject *self, int i)
/* FIXME: This syntax sucks */ /* FIXME: This syntax sucks */
static PyObject * 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 *caps = pyg_boxed_get (self, GstCaps);
GstCaps *ret = gst_caps_new_empty (); GstCaps *ret = gst_caps_new_empty ();

View file

@ -172,10 +172,11 @@ _wrap_gst_structure_keys (PyObject *self)
%% %%
override-slot GstStructure.tp_as_mapping override-slot GstStructure.tp_as_mapping
static int static Py_ssize_t
_wrap_gst_structure_length(PyGObject *self) _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 * static PyObject *
@ -222,7 +223,7 @@ _wrap_gst_structure_ass_subscript(PyGObject *self,
} }
static PyMappingMethods _wrap_gst_structure_tp_as_mapping = { 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 */ (binaryfunc)_wrap_gst_structure_subscript, /* mp_subscript */
(objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */ (objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */
}; };

View file

@ -63,10 +63,11 @@ _wrap_gst_tag_list_keys(PyGObject *self)
} }
%% %%
override-slot GstTagList.tp_as_mapping override-slot GstTagList.tp_as_mapping
static int static Py_ssize_t
_wrap_gst_tag_list_length(PyGObject *self) _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 * static PyObject *
@ -113,7 +114,7 @@ _wrap_gst_tag_list_ass_subscript(PyGObject *self,
} }
static PyMappingMethods _wrap_gst_tag_list_tp_as_mapping = { 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 */ (binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
(objobjargproc)_wrap_gst_tag_list_ass_subscript /* mp_ass_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 = { static PySequenceMethods _wrap_gst_tag_list_tp_as_sequence = {
(inquiry)NULL, (lenfunc)NULL,
(binaryfunc)NULL, (binaryfunc)NULL,
(ssizeargfunc)NULL, (ssizeargfunc)NULL,
(ssizeargfunc)NULL, (ssizeargfunc)NULL,
(ssizessizeargfunc)NULL, (ssizessizeargfunc)NULL,
(intobjargproc)NULL, (ssizeobjargproc)NULL,
(intintobjargproc)NULL, (ssizessizeobjargproc)NULL,
(objobjproc)_wrap_gst_tag_list_contains, (objobjproc)_wrap_gst_tag_list_contains,
(binaryfunc)NULL, (binaryfunc)NULL,
(ssizeargfunc)NULL, (ssizeargfunc)NULL,

View file

@ -188,7 +188,7 @@ _wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
if (channels != PyTuple_Size (py_tuple)) { if (channels != PyTuple_Size (py_tuple)) {
PyErr_Format (PyExc_TypeError, PyErr_Format (PyExc_TypeError,
"Track channel count %d != volume tuple size %d", "Track channel count %d != volume tuple size %d",
channels, PyTuple_Size (py_tuple)); channels, (gint) PyTuple_Size (py_tuple));
return NULL; return NULL;
} }