[Pen-commits] SF.net SVN: pen:[119]
Brought to you by:
mdgeorge
From: <mdg...@us...> - 2008-12-04 04:13:59
|
Revision: 119 http://pen.svn.sourceforge.net/pen/?rev=119&view=rev Author: mdgeorge Date: 2008-12-04 04:13:55 +0000 (Thu, 04 Dec 2008) Log Message: ----------- It seems to run! Modified Paths: -------------- pygame/src/mask.c pygame/src/mask.h src/maskutils.c Modified: pygame/src/mask.c =================================================================== --- pygame/src/mask.c 2008-12-04 01:24:33 UTC (rev 118) +++ pygame/src/mask.c 2008-12-04 04:13:55 UTC (rev 119) @@ -1383,13 +1383,24 @@ void initmask(void) { - PyObject *module, *dict; + PyObject *module, *dict, *apiobj; + static void* c_api[PYGAMEAPI_MASK_NUMSLOTS]; + + /* create the mask type */ PyType_Init(PyMask_Type); /* create the module */ module = Py_InitModule3("mask", mask_builtins, DOC_PYGAMEMASK); dict = PyModule_GetDict(module); PyDict_SetItemString(dict, "MaskType", (PyObject *)&PyMask_Type); + + /* export the c api */ + Py_INCREF((PyObject*) &PyMask_Type); + c_api[0] = &PyMask_Type; + apiobj = PyCObject_FromVoidPtr (c_api, NULL); + PyModule_AddObject (module, PYGAMEAPI_LOCAL_ENTRY, apiobj); + + /* import other modules */ import_pygame_base (); import_pygame_color (); import_pygame_surface (); Modified: pygame/src/mask.h =================================================================== --- pygame/src/mask.h 2008-12-04 01:24:33 UTC (rev 118) +++ pygame/src/mask.h 2008-12-04 04:13:55 UTC (rev 119) @@ -1,7 +1,7 @@ #include <Python.h> #include "bitmask.h" -#define PYGAMEAPI_MASK_NUMSLOTS +#define PYGAMEAPI_MASK_NUMSLOTS 1 #define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API" typedef struct { @@ -23,7 +23,7 @@ PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \ if(PyCObject_Check(c_api)) { \ void** localptr = (void**) PyCObject_AsVoidPtr(c_api); \ - memcpy(PyMASK_C_API, localptr, sizeof(void*)*PYGAMEAPI_FONT_NUMSLOTS); \ + memcpy(PyMASK_C_API, localptr, sizeof(void*)*PYGAMEAPI_MASK_NUMSLOTS); \ } Py_DECREF(module); \ } \ } Modified: src/maskutils.c =================================================================== --- src/maskutils.c 2008-12-04 01:24:33 UTC (rev 118) +++ src/maskutils.c 2008-12-04 04:13:55 UTC (rev 119) @@ -6,10 +6,10 @@ */ static const char DOC_CONVOLVE[] = -"Return the convolution of self with another mask. \n" +"Return the convolution of two masks. \n" " \n" "convolve(a, b, outputmask = None, offset = (0,0)): return Mask \n" -" Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting a \n" +" Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting b \n" " so that it's lower right corner pixel is at (i,j) would cause it to overlap \n" " with a. \n" " \n" @@ -37,6 +37,7 @@ void initmaskutils(void) { + import_pygame_mask(); Py_InitModule ("maskutils", maskutils_methods); } @@ -148,7 +149,7 @@ if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &mobj, &x, &y)) return NULL; - mask = PyMask_AsBitmap (self); + mask = PyMask_AsBitmap (mobj); bitmask_find_closest (mask, &x, &y); return Py_BuildValue ("(ii)", x, y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |