From 122c067f12f853ad8dfe55d997cc046493419e9d Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Tue, 30 Oct 2012 13:28:26 +0000 Subject: Bucket implementation fixed to work in 32bit The last commit worked in 64bit arch but not in 32bit. This fix works only in 32bit, then do not update the binaries already compiled to 64bit. Signed-off-by: Gonzalo Odiard --- diff --git a/fill/armv7l_27/__init__.py b/fill/armv7l_27/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fill/armv7l_27/__init__.py diff --git a/fill/armv7l_27/_fill.so b/fill/armv7l_27/_fill.so new file mode 100644 index 0000000..5445d0f --- /dev/null +++ b/fill/armv7l_27/_fill.so Binary files differ diff --git a/fill/eggfill.c b/fill/eggfill.c index 318879c..50af76f 100644 --- a/fill/eggfill.c +++ b/fill/eggfill.c @@ -122,7 +122,7 @@ void queue_dequeue(queue *q){ }/* end of queue*/ void -floodfill(unsigned int* pixels, int x, int y, int width, int height, unsigned int color) { +floodfill(unsigned long * pixels, int x, int y, int width, int height,unsigned long color) { printf("\nEntrando to floodfill\n"); queue *lista_xy; diff --git a/fill/eggfill.h b/fill/eggfill.h index 6cba20d..bc7dd07 100644 --- a/fill/eggfill.h +++ b/fill/eggfill.h @@ -73,4 +73,4 @@ void queue_enqueue(int element, queue *q); void queue_dequeue(queue *q); /*end of queue*/ -void floodfill(unsigned int * pixels, int x, int y, int width, int height, unsigned int color); +void floodfill(unsigned long * pixels, int x, int y, int width, int height, unsigned long color); diff --git a/fill/fillmodule.c b/fill/fillmodule.c index 9a1c0e1..e9b461c 100644 --- a/fill/fillmodule.c +++ b/fill/fillmodule.c @@ -58,28 +58,28 @@ static PyObject* fill(PyObject* self, PyObject* args) return NULL; /* from http://mail.python.org/pipermail/tutor/1999-November/000758.html */ - unsigned int *intarr, arrsize, index; + unsigned long *intarr, arrsize, index; PyObject *item; PyObject *pylist; /* how many elements are in the Python object */ arrsize = PyObject_Length(mylist); /* create a dynamic C array of integers */ - intarr = (int *)malloc(sizeof(int)*arrsize); + intarr = (unsigned long *)malloc(sizeof(unsigned long)*arrsize); for (index = 0; index < arrsize; index++) { /* get the element from the list/tuple */ item = PySequence_GetItem(mylist, index); /* assign to the C array */ - intarr[index] = PyInt_AsUnsignedLongMask(item); + intarr[index] = PyLong_AsUnsignedLong(item); } /* now use intarr and arrsize in you extension */ - //printf("x %u y %u width %u height %u color %u", x, y, width, height, color); + printf("x %u y %u width %u height %u color %u", x, y, width, height, color); floodfill(intarr, x, y, width, height, color); pylist = PyTuple_New(arrsize); for (index = 0; index < arrsize; index++) { - PyTuple_SetItem(pylist, index, PyInt_FromLong(intarr[index])); + PyTuple_SetItem(pylist, index, PyLong_FromUnsignedLong(intarr[index])); } return Py_BuildValue("O", pylist); diff --git a/fill/linux32_27/__init__.py b/fill/linux32_27/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fill/linux32_27/__init__.py diff --git a/fill/linux32_27/_fill.so b/fill/linux32_27/_fill.so new file mode 100644 index 0000000..c1317d2 --- /dev/null +++ b/fill/linux32_27/_fill.so Binary files differ diff --git a/test_fill.py b/test_fill.py new file mode 100644 index 0000000..9f85f01 --- /dev/null +++ b/test_fill.py @@ -0,0 +1,20 @@ +import fill +import array +a = array.array('I') +a.append(1) +a.append(1) +a.append(3) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +a.append(2) +print "before", a +b = fill.fill(a,2,2,3,3,4278190080) +print "after", b + +print "after 2", array.array('I', b) -- cgit v0.9.1