flathub / shared-modules

Common Flatpak modules that can be used as a git submodule
108 stars 87 forks source link

Update pygame's portmidi to 2.0.4 #317

Closed MateusRodCosta closed 3 days ago

MateusRodCosta commented 6 days ago

Fixes #316

Tested as working when building against fdo 23.08

bbhtt commented 6 days ago

More work is needed to get pygame building on 24.08:

src_c/font.c:584:12: error: assignment to ‘Uint16 *’ {aka ‘short unsigned int *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
  584 |     buffer = Bytes_AS_STRING(obj);
      |            ^
In file included from src_c/pygame.h:32,
                 from src_c/font.c:32:
src_c/font.c: In function ‘font_init’:

And this is only one, there are several other errors that need to be fixed.

diff --git a/src_c/font.c b/src_c/font.c
index a6b6cd5..62ebc44 100644
--- a/src_c/font.c
+++ b/src_c/font.c
@@ -581,7 +581,7 @@ font_metrics(PyObject *self, PyObject *args)
         Py_DECREF(obj);
         return NULL;
     }
-    buffer = Bytes_AS_STRING(obj);
+    buffer = (Uint16 *)Bytes_AS_STRING(obj);
     length = Bytes_GET_SIZE(obj) / sizeof(Uint16);
     for (i = 1 /* skip BOM */; i < length; i++) {
         ch = buffer[i];
diff --git a/src_c/pypm.pyx b/src_c/pypm.pyx
index d66e7a1..5b1cfe0 100644
--- a/src_c/pypm.pyx
+++ b/src_c/pypm.pyx
@@ -103,7 +103,7 @@ cdef extern from "portmidi.h":
                          PmDeviceID inputDevice,
                          void *inputDriverInfo,
                          long bufferSize,
-                         long (*PmPtr) (), # long = PtTimestamp
+                         PmTimeProcPtr time_proc, # long = PtTimestamp
                          void *time_info)

     PmError Pm_OpenOutput(PortMidiStream** stream,
@@ -522,11 +522,14 @@ cdef class Input:
         """Instantiate MIDI input stream object."""

         cdef PmError err
+        cdef PmTimeProcPtr PmPtr
         self.device = input_device
         self.debug = 0

+        PmPtr = <PmTimeProcPtr>&Pt_Time
+
         err = Pm_OpenInput(&(self.midi), input_device, NULL, buffersize,
-                           &Pt_Time, NULL)
+                           PmPtr, NULL)
         if err < 0:
             raise Exception(Pm_GetErrorText(err))

diff --git a/src_c/scrap_x11.c b/src_c/scrap_x11.c
index e9a982a..039453b 100644
--- a/src_c/scrap_x11.c
+++ b/src_c/scrap_x11.c
@@ -795,7 +795,7 @@ pygame_scrap_get_types(void)
 #if PY3
         PyObject *chars;
 #endif
-        int pos = 0;
+        Py_ssize_t pos = 0;
         int i = 0;
         PyObject *dict =
             (_currentmode == SCRAP_SELECTION) ? _selectiondata : _clipdata;

will handle some of them

MateusRodCosta commented 3 days ago

Well, I believe I will build dtipbijays with my own fork of shared-modules and fdo runtime. Sorry, but I am not that good at C to contribute with patches for the compilation errors.