From 66bc17facfeba395482ba7202a460290283f78b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 10 Nov 2022 14:21:06 +0100 Subject: [PATCH] Add a test for function pointer text wrapping. --- tests/expectations/function_ptr.c | 14 ++++++++++++++ tests/expectations/function_ptr.compat.c | 22 ++++++++++++++++++++++ tests/expectations/function_ptr.cpp | 19 +++++++++++++++++++ tests/expectations/function_ptr.pyx | 17 +++++++++++++++++ tests/rust/function_ptr.rs | 6 ++++++ 5 files changed, 78 insertions(+) create mode 100644 tests/expectations/function_ptr.c create mode 100644 tests/expectations/function_ptr.compat.c create mode 100644 tests/expectations/function_ptr.cpp create mode 100644 tests/expectations/function_ptr.pyx create mode 100644 tests/rust/function_ptr.rs diff --git a/tests/expectations/function_ptr.c b/tests/expectations/function_ptr.c new file mode 100644 index 000000000..1041a6b34 --- /dev/null +++ b/tests/expectations/function_ptr.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +typedef void (*MyCallback)(uintptr_t a, uintptr_t b); + +typedef void (*MyOtherCallback)(uintptr_t a, + uintptr_t lot, + uintptr_t of, + uintptr_t args, + uintptr_t and_then_some); + +void my_function(MyCallback a, MyOtherCallback b); diff --git a/tests/expectations/function_ptr.compat.c b/tests/expectations/function_ptr.compat.c new file mode 100644 index 000000000..be3870ce1 --- /dev/null +++ b/tests/expectations/function_ptr.compat.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +typedef void (*MyCallback)(uintptr_t a, uintptr_t b); + +typedef void (*MyOtherCallback)(uintptr_t a, + uintptr_t lot, + uintptr_t of, + uintptr_t args, + uintptr_t and_then_some); + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void my_function(MyCallback a, MyOtherCallback b); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/function_ptr.cpp b/tests/expectations/function_ptr.cpp new file mode 100644 index 000000000..217a16081 --- /dev/null +++ b/tests/expectations/function_ptr.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +#include +#include + +using MyCallback = void(*)(uintptr_t a, uintptr_t b); + +using MyOtherCallback = void(*)(uintptr_t a, + uintptr_t lot, + uintptr_t of, + uintptr_t args, + uintptr_t and_then_some); + +extern "C" { + +void my_function(MyCallback a, MyOtherCallback b); + +} // extern "C" diff --git a/tests/expectations/function_ptr.pyx b/tests/expectations/function_ptr.pyx new file mode 100644 index 000000000..371774209 --- /dev/null +++ b/tests/expectations/function_ptr.pyx @@ -0,0 +1,17 @@ +from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t +from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t +cdef extern from *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + ctypedef void (*MyCallback)(uintptr_t a, uintptr_t b); + + ctypedef void (*MyOtherCallback)(uintptr_t a, + uintptr_t lot, + uintptr_t of, + uintptr_t args, + uintptr_t and_then_some); + + void my_function(MyCallback a, MyOtherCallback b); diff --git a/tests/rust/function_ptr.rs b/tests/rust/function_ptr.rs new file mode 100644 index 000000000..59adb52b3 --- /dev/null +++ b/tests/rust/function_ptr.rs @@ -0,0 +1,6 @@ +pub type MyCallback = Option; + +pub type MyOtherCallback = Option; + +#[no_mangle] +pub extern "C" fn my_function(a: MyCallback, b: MyOtherCallback) {}