File ocaml-ctypes.patch of Package ocaml-ctypes

From fe4be538e389d5caf6c0a562cd02e58fda9361cb Mon Sep 17 00:00:00 2001
From: Jeremy Yallop <yallop@gmail.com>
Date: Tue, 13 Aug 2024 06:41:53 +0100
Subject: [PATCH] Add an explicit upcast in the OO-style test.

---
 tests/clib/test_functions.c            | 5 +++++
 tests/clib/test_functions.h            | 2 ++
 tests/test-oo_style/stubs/functions.ml | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/clib/test_functions.c b/tests/clib/test_functions.c
index cf81c5a40..44d0f57d8 100644
--- a/tests/clib/test_functions.c
+++ b/tests/clib/test_functions.c
@@ -293,6 +293,11 @@ struct chorse *new_chorse(int colour)
   h->colour = (enum colour)colour;
   return h;
 }
+
+struct animal *new_chorse_as_animal(int colour)
+{
+  return (struct animal *)new_chorse(colour);
+}
 /* (End of OO-style example) */
 
 int accept_pointers(float *float_p,
diff --git a/tests/clib/test_functions.h b/tests/clib/test_functions.h
index eae2e176a..011cc9369 100644
--- a/tests/clib/test_functions.h
+++ b/tests/clib/test_functions.h
@@ -79,6 +79,8 @@ extern char *chorse_colour(struct chorse *);
 extern char *chorse_say(struct animal *);
 extern char *chorse_identify(struct animal *);
 extern struct chorse *new_chorse(int);
+extern struct animal *new_chorse_as_animal(int);
+
 extern int accept_pointers(float *,
                            double *,
                            short *,
diff --git a/tests/test-oo_style/stubs/functions.ml b/tests/test-oo_style/stubs/functions.ml
index 84ded6f6f..a35fa2cda 100644
--- a/tests/test-oo_style/stubs/functions.ml
+++ b/tests/test-oo_style/stubs/functions.ml
@@ -81,6 +81,6 @@ struct
   let check_name = foreign "check_name"
     (ptr animal @-> string @-> returning int)
 
-    let new_chorse = foreign "new_chorse"
+  let new_chorse = foreign "new_chorse_as_animal"
       (int @-> returning (ptr animal))
 end
openSUSE Build Service is sponsored by