Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pygame/mask.h
diff options
context:
space:
mode:
authorolpc <olpc@xo-0D-2D-97.localdomain>2009-01-17 18:41:32 (GMT)
committer olpc <olpc@xo-0D-2D-97.localdomain>2009-01-17 18:41:32 (GMT)
commit9e64dbd7cd3093353f87e5a69006d8c449a58313 (patch)
tree8f9aa1da589d22956f59d05a2bbf4a34a7efa775 /pygame/mask.h
parentb30efd562477d84c2820e1f18987b2a1516c6d40 (diff)
adding trimmed pygame from SVN
Diffstat (limited to 'pygame/mask.h')
-rwxr-xr-xpygame/mask.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/pygame/mask.h b/pygame/mask.h
new file mode 100755
index 0000000..169615f
--- /dev/null
+++ b/pygame/mask.h
@@ -0,0 +1,34 @@
+#include <Python.h>
+#include "bitmask.h"
+
+#define PYGAMEAPI_MASK_NUMSLOTS 1
+#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
+
+typedef struct {
+ PyObject_HEAD
+ bitmask_t *mask;
+} PyMaskObject;
+
+#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask)
+
+#ifndef PYGAMEAPI_MASK_INTERNAL
+
+#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_MASK_NUMSLOTS); \
+ } Py_DECREF(module); \
+ } \
+}
+
+#endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */
+
+static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL};
+