Author: tack
Date: Tue Mar 13 13:51:27 2007
New Revision: 2556
Added:
trunk/imlib2/src/imlib2.h
Modified:
trunk/imlib2/src/font.c
trunk/imlib2/src/image.c
trunk/imlib2/src/imlib2.c
Log:
Py_ssize_t support for python 2.5
Modified: trunk/imlib2/src/font.c
==============================================================================
--- trunk/imlib2/src/font.c (original)
+++ trunk/imlib2/src/font.c Tue Mar 13 13:51:27 2007
@@ -34,6 +34,7 @@
#define X_DISPLAY_MISSING
#include <Imlib2.h>
+#include "imlib2.h"
#include "font.h"
PyTypeObject Font_PyObject_Type = {
Modified: trunk/imlib2/src/image.c
==============================================================================
--- trunk/imlib2/src/image.c (original)
+++ trunk/imlib2/src/image.c Tue Mar 13 13:51:27 2007
@@ -35,6 +35,7 @@
#define X_DISPLAY_MISSING
#include <Imlib2.h>
+#include "imlib2.h"
#include "image.h"
#include "rawformats.h"
#include "font.h"
@@ -43,9 +44,9 @@
#include <fcntl.h>
#include "config.h"
-int Image_PyObject_Buffer__get_read_buffer(PyObject *, int, void **);
-int Image_PyObject_Buffer__get_readwrite_buffer(PyObject *, int, void **);
-int Image_PyObject_Buffer__get_seg_count(PyObject *, int *);
+int Image_PyObject_Buffer__get_read_buffer(PyObject *, Py_ssize_t, void **);
+int Image_PyObject_Buffer__get_readwrite_buffer(PyObject *, Py_ssize_t, void
**);
+int Image_PyObject_Buffer__get_seg_count(PyObject *, Py_ssize_t *);
PyBufferProcs buffer_procs = {
Image_PyObject_Buffer__get_read_buffer,
@@ -102,7 +103,7 @@
return pyimg->image;
}
-int Image_PyObject_Buffer__get_read_buffer(PyObject *self, int segment, void
**ptr)
+int Image_PyObject_Buffer__get_read_buffer(PyObject *self, Py_ssize_t segment,
void **ptr)
{
imlib_context_set_image(((Image_PyObject *)self)->image);
if (ptr)
@@ -110,7 +111,7 @@
return imlib_image_get_width() * imlib_image_get_height() * 4;
}
-int Image_PyObject_Buffer__get_readwrite_buffer(PyObject *self, int segment,
void **ptr)
+int Image_PyObject_Buffer__get_readwrite_buffer(PyObject *self, Py_ssize_t
segment, void **ptr)
{
Image_PyObject *o = (Image_PyObject *)self;
imlib_context_set_image(o->image);
@@ -127,11 +128,11 @@
return imlib_image_get_width() * imlib_image_get_height() * 4;
}
-int Image_PyObject_Buffer__get_seg_count(PyObject *self, int *lenp)
+int Image_PyObject_Buffer__get_seg_count(PyObject *self, Py_ssize_t *lenp)
{
if (lenp) {
imlib_context_set_image(((Image_PyObject *)self)->image);
- *lenp = imlib_image_get_width() * imlib_image_get_height() * 4;
+ *lenp = (Py_ssize_t)(imlib_image_get_width() *
imlib_image_get_height() * 4);
}
return 1;
}
@@ -643,7 +644,8 @@
PyObject *Image_PyObject__get_raw_data(PyObject *self, PyObject *args)
{
char *format;
- int len, write;
+ int write;
+ Py_ssize_t len;
Image_PyObject *o = (Image_PyObject *)self;
@@ -676,7 +678,7 @@
Image_PyObject *o = (Image_PyObject *)self;
PyObject *buffer_object;
unsigned char *buffer;
- int len;
+ Py_ssize_t len;
if (!PyArg_ParseTuple(args, "O!", &PyBuffer_Type, &buffer_object))
return NULL;
Modified: trunk/imlib2/src/imlib2.c
==============================================================================
--- trunk/imlib2/src/imlib2.c (original)
+++ trunk/imlib2/src/imlib2.c Tue Mar 13 13:51:27 2007
@@ -42,13 +42,15 @@
#include <sys/mman.h>
#endif
+#include "imlib2.h"
#include "image.h"
#include "rawformats.h"
#include "font.h"
PyObject *imlib2_create(PyObject *self, PyObject *args)
{
- int w, h, len, copy;
+ int w, h, copy;
+ Py_ssize_t len;
void *bytes = NULL;
char *from_format = "BGRA";
PyObject *data = NULL;
@@ -175,7 +177,8 @@
Image_PyObject *image = NULL;
PyObject *buffer;
void *data;
- int len, fd;
+ int fd;
+ Py_ssize_t len;
static int prng_seeded = 0;
char filename[30], path[PATH_MAX];
@@ -273,7 +276,7 @@
};
-void init_Imlib2()
+void init_Imlib2(void)
{
PyObject *m, *c_api;
static void *api_ptrs[2];
Added: trunk/imlib2/src/imlib2.h
==============================================================================
--- (empty file)
+++ trunk/imlib2/src/imlib2.h Tue Mar 13 13:51:27 2007
@@ -0,0 +1,37 @@
+/*
+ * ----------------------------------------------------------------------------
+ * Imlib2 wrapper for Python
+ * ----------------------------------------------------------------------------
+ * $Id: imlib2.h 1942 2006-10-30 09:54:47Z dmeyer $
+ *
+ * ----------------------------------------------------------------------------
+ * kaa.imlib2 - An imlib2 wrapper for Python
+ * Copyright (C) 2004-2006 Jason Tackaberry <[EMAIL PROTECTED]>
+ *
+ * First Edition: Jason Tackaberry <[EMAIL PROTECTED]>
+ * Maintainer: Jason Tackaberry <[EMAIL PROTECTED]>
+ *
+ * Please see the file AUTHORS for a complete list of authors.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version
+ * 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ * ----------------------------------------------------------------------------
+ */
+
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog