Skip to content

Commit

Permalink
Add a test for function pointer text wrapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Nov 10, 2022
1 parent d8660bb commit 66bc17f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/expectations/function_ptr.c
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions tests/expectations/function_ptr.compat.c
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/expectations/function_ptr.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions tests/expectations/function_ptr.pyx
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions tests/rust/function_ptr.rs
Original file line number Diff line number Diff line change
@@ -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) {}

0 comments on commit 66bc17f

Please sign in to comment.