Source

pygame / src / mouse.c

Diff from to

src/mouse.c

  *  pygame mouse module
  */
 #include "pygame.h"
-#include "pygamedocs.h"
+#include "pgcompat.h"
+#include "doc/mouse_doc.h"
 
 /* mouse module functions */
 static PyObject*
     return Py_BuildValue ("((ii)(ii)NN)", w, h, spotx, spoty, xordata, anddata);
 }
 
-static PyMethodDef mouse_builtins[] =
+static PyMethodDef _mouse_methods[] =
 {
     { "set_pos", mouse_set_pos, METH_VARARGS, DOC_PYGAMEMOUSESETPOS },
     { "get_pos", (PyCFunction) mouse_get_pos, METH_VARARGS,
 };
 
 
-PYGAME_EXPORT
-void initmouse (void)
+MODINIT_DEFINE (mouse)
 {
     PyObject *module;
 
+#if PY3
+    static struct PyModuleDef _module = {
+        PyModuleDef_HEAD_INIT,
+        "mouse",
+        DOC_PYGAMEMOUSE,
+        -1,
+        _mouse_methods,
+        NULL, NULL, NULL, NULL
+    };
+#endif
+
     /* imported needed apis; Do this first so if there is an error
        the module is not loaded.
     */
     import_pygame_base ();
     if (PyErr_Occurred ()) {
-	return;
+        MODINIT_ERROR;
     }
 
     /* create the module */
-    module = Py_InitModule3 ("mouse", mouse_builtins, DOC_PYGAMEMOUSE);
+#if PY3
+    module = PyModule_Create (&_module);
+#else
+    module = Py_InitModule3 ("mouse", _mouse_methods, DOC_PYGAMEMOUSE);
+#endif
+    if (module == NULL) {
+        MODINIT_ERROR;
+    }
+    MODINIT_RETURN (module);
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.