[Pen-commits] SF.net SVN: pen:[111] pygame/src/mask.h
Brought to you by:
mdgeorge
From: <mdg...@us...> - 2008-12-03 04:07:13
|
Revision: 111 http://pen.svn.sourceforge.net/pen/?rev=111&view=rev Author: mdgeorge Date: 2008-12-03 04:07:11 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Added initmask macro to mask.h Modified Paths: -------------- pygame/src/mask.h Modified: pygame/src/mask.h =================================================================== --- pygame/src/mask.h 2008-12-03 03:09:49 UTC (rev 110) +++ pygame/src/mask.h 2008-12-03 04:07:11 UTC (rev 111) @@ -2,6 +2,7 @@ #include "bitmask.h" #define PYGAMEAPI_MASK_NUMSLOTS +#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API" typedef struct { PyObject_HEAD @@ -15,8 +16,18 @@ #define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0]) #define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) +#define import_pygame_mask() { \ + PyObject *module = PyImport_ImportModule("pygame.mask"); \ + if (module != NULL) { \ + PyObject *dict = PyModule_GetDict(module); \ + 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); \ + } Py_DECREF(module); \ + } \ +} - #endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */ static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |