Commits

Anonymous committed 87e55ba

Added IMPPREFIX to be used when importing pygame module.

  • Participants
  • Parent commits dfabe36
  • Branches symbian_s60

Comments (0)

Files changed (8)

     PyModule_AddObject (module, "Color", (PyObject *) &PyColor_Type);
     dict = PyModule_GetDict (module);
 
-    colordict = PyImport_ImportModule (MODPREFIX "colordict");
+    colordict = PyImport_ImportModule (IMPPREFIX "colordict");
     if (colordict)
     {
         PyObject *_dict = PyModule_GetDict (colordict);

File src/fastevent.c

     PyObject *module, *eventmodule, *dict;
 
     /* create the module */
-    module = Py_InitModule3 ("fastevent", fastevent_builtins,
+    module = Py_InitModule3 ( MODPREFIX "fastevent", fastevent_builtins,
                              doc_fastevent_MODULE);
     dict = PyModule_GetDict (module);
 
     /* imported needed apis */
     import_pygame_base ();
     import_pygame_event ();
-    eventmodule = PyImport_ImportModule (MODPREFIX "event");
+    eventmodule = PyImport_ImportModule (IMPPREFIX "event");
     if (eventmodule)
     {
         char *NAMES[] = {"Event", "event_name", NULL};
             {
                 /* If it is .png .jpg .jpeg use the extended module. */
                 /* try to get extended formats */
-                imgext = PyImport_ImportModule (MODPREFIX "imageext");
+                imgext = PyImport_ImportModule (IMPPREFIX "imageext");
                 if (imgext)
                 {
                     PyObject *extdict = PyModule_GetDict (imgext);
 
 
     /* try to get extended formats */
-    extmodule = PyImport_ImportModule (MODPREFIX "imageext");
+    extmodule = PyImport_ImportModule (IMPPREFIX "imageext");
     if (extmodule)
     {
         PyObject *extdict = PyModule_GetDict (extmodule);
 #define PyMask_Check(x) ((x)->ob_type == &PyMask_Type)
 
 #define import_pygame_mask() {                                                                 \
-	PyObject *module = PyImport_ImportModule("pygame.mask");                               \
+	PyObject *module = PyImport_ImportModule(IMPPREFIX "mask");                               \
 	if (module != NULL) {                                                                  \
 		PyObject *dict  = PyModule_GetDict(module);                                    \
 		PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY);           \
     import_pygame_rwobject ();
     import_pygame_bufferproxy ();
 
-    music = PyImport_ImportModule (MODPREFIX "mixer_music");
+    music = PyImport_ImportModule (IMPPREFIX "mixer_music");
     if (!music) {
         /* try loading it under this name...
         */
 #define PyMixer_AutoInit (*(PyObject*(*)(PyObject*, PyObject*))PyMIXER_C_API[5])
 #define PyMixer_AutoQuit (*(void(*)(void))PyMIXER_C_API[6])
 #define import_pygame_mixer() { \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "mixer"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "mixer"); \
 	if (_module != NULL) { \
 		PyObject *_dict = PyModule_GetDict(_module); \
 		PyObject *_c_api = PyDict_GetItemString(_dict, PYGAMEAPI_LOCAL_ENTRY); \

File src/pygame.h

 #endif
 
 
-#define MODPREFIX "pygame."
+/// Prefix when initializing module
+#define MODPREFIX ""
+/// Prefix when importing module
+#define IMPPREFIX "pygame."
 
 #ifdef __SYMBIAN32__
 #undef MODPREFIX
+// On Symbian there is no pygame package. The extensions are built-in or in sys\bin.
 #define MODPREFIX "pygame_"
+#define IMPPREFIX "pygame_"
 #endif
 
 #include <SDL.h>
     (*(int(*)(PyObject*, Uint8*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 12])
 
 #define import_pygame_base() {                                          \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "base");        \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "base");        \
 	if (_module != NULL) {                                           \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
      PyGAME_C_API[PYGAMEAPI_RECT_FIRSTSLOT + 3])
 
 #define import_pygame_rect() {                                          \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "rect");        \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "rect");        \
 	if (_module != NULL) {                                         \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
     (*(PyObject*(*)(int))PyGAME_C_API[PYGAMEAPI_CDROM_FIRSTSLOT + 1])
 
 #define import_pygame_cd() {                                      \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "cdrom"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "cdrom"); \
 	if (_module != NULL) {                                     \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
     (*(PyObject*(*)(int))PyGAME_C_API[PYGAMEAPI_JOYSTICK_FIRSTSLOT + 1])
 
 #define import_pygame_joystick() {                                      \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "joystick");    \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "joystick");    \
 	if (_module != NULL) {                                           \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
     (*(PyObject*(*)(SDL_VideoInfo*))                    \
      PyGAME_C_API[PYGAMEAPI_DISPLAY_FIRSTSLOT + 1])
 #define import_pygame_display() {                                   \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "display"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "display"); \
 	if (_module != NULL) {                                       \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
      PyGAME_C_API[PYGAMEAPI_SURFACE_FIRSTSLOT + 2])
 
 #define import_pygame_surface() {                                   \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "surface"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "surface"); \
 	if (_module != NULL) {                                       \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
             }                                                           \
             Py_DECREF(_module);                                          \
         }                                                               \
-	_module = PyImport_ImportModule(MODPREFIX "surflock");              \
+	_module = PyImport_ImportModule(IMPPREFIX "surflock");              \
 	if (_module != NULL) {                                           \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
     (*(int (*)(PyEventObject*, SDL_Event*))             \
      PyGAME_C_API[PYGAMEAPI_EVENT_FIRSTSLOT + 3])
 #define import_pygame_event() {                                   \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "event"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "event"); \
 	if (_module != NULL) {                                     \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
 #define RWopsCheckPythonThreaded                                        \
     (*(int(*)(SDL_RWops*))PyGAME_C_API[PYGAMEAPI_RWOBJECT_FIRSTSLOT + 3])
 #define import_pygame_rwobject() {                                   \
-	PyObject *_module = PyImport_ImportModule(MODPREFIX "rwobject"); \
+	PyObject *_module = PyImport_ImportModule(IMPPREFIX "rwobject"); \
 	if (_module != NULL) {                                        \
             PyObject *_dict = PyModule_GetDict(_module);                  \
             PyObject *_c_api = PyDict_GetItemString(_dict,                \
     PyGAME_C_API[PYGAMEAPI_BUFFERPROXY_FIRSTSLOT + 1])
 #define import_pygame_bufferproxy()                                      \
     {                                                                    \
-	PyObject *_module = PyImport_ImportModule (MODPREFIX "bufferproxy");\
+	PyObject *_module = PyImport_ImportModule (IMPPREFIX "bufferproxy");\
 	if (_module != NULL)                                             \
         {                                                                \
             PyObject *_dict = PyModule_GetDict (_module);                \
     (*(PyObject*(*)) PyGAME_C_API[PYGAMEAPI_PIXELARRAY_FIRSTSLOT + 1])
 #define import_pygame_pixelarray()                                       \
     {                                                                    \
-	PyObject *_module = PyImport_ImportModule (MODPREFIX "pixelarray"); \
+	PyObject *_module = PyImport_ImportModule (IMPPREFIX "pixelarray"); \
 	if (_module != NULL)                                             \
         {                                                                \
             PyObject *_dict = PyModule_GetDict (_module);                \
     (*(int(*)(PyObject*, Uint8*)) PyGAME_C_API[PYGAMEAPI_COLOR_FIRSTSLOT + 2])
 #define import_pygame_color()                                           \
     {                                                                   \
-	PyObject *_module = PyImport_ImportModule (MODPREFIX "color");     \
+	PyObject *_module = PyImport_ImportModule (IMPPREFIX "color");     \
 	if (_module != NULL)                                            \
         {                                                               \
             PyObject *_dict = PyModule_GetDict (_module);               \
 #define PYGAME_EXPORT
 #endif
 
-// Redifined as empty for the rest of the code
-#undef MODPREFIX
-#define MODPREFIX ""
-
 #ifdef __SYMBIAN32__
 
-#undef MODPREFIX
-#define MODPREFIX "pygame_"
-
 // These are missing from Python 2.2
 #ifndef Py_RETURN_NONE
 

File src/surface.c

     import_pygame_bufferproxy();
 
     /* import the surflock module manually */
-    lockmodule = PyImport_ImportModule (MODPREFIX "surflock");
+    lockmodule = PyImport_ImportModule (IMPPREFIX "surflock");
     if (lockmodule != NULL)
     {
         PyObject *_dict = PyModule_GetDict (lockmodule);