Add a test for function pointer text wrapping.

This commit is contained in:
Emilio Cobos Álvarez
2022-11-10 14:21:06 +01:00
parent d8660bb01f
commit 66bc17facf
5 changed files with 78 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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);
+22
View File
@@ -0,0 +1,22 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
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
+19
View File
@@ -0,0 +1,19 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
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"
+17
View File
@@ -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);
+6
View File
@@ -0,0 +1,6 @@
pub type MyCallback = Option<unsafe extern "C" fn(a: usize, b: usize)>;
pub type MyOtherCallback = Option<unsafe extern "C" fn(a: usize, lot: usize, of: usize, args: usize, and_then_some: usize)>;
#[no_mangle]
pub extern "C" fn my_function(a: MyCallback, b: MyOtherCallback) {}