Skip to content

Commit ab98ede

Browse files
committed
Extend arity of function arguments
1 parent 2bb3063 commit ab98ede

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎libcc2rs/src/fn_ptr.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) trait FnSig: Copy + 'static {
2121

2222
macro_rules! impl_fn_sig {
2323
() => {
24-
impl_fn_sig!(@gen A B C D E F G H I J K L M N O P);
24+
impl_fn_sig!(@gen A B C D E F G H I J K L M N O P Q S T U V W X Y);
2525
};
2626
(@gen $($a:ident)*) => {
2727
impl<R: FnPtrArg $(, $a: FnPtrArg)*> FnSig for fn($($a,)*) -> R {
@@ -252,7 +252,7 @@ impl<T: FnSig> FnPtr<T> {
252252
// invokes, e.g. `fn_ptr.call(a0, a1)`.
253253
macro_rules! impl_fn_ptr_call {
254254
() => {
255-
impl_fn_ptr_call!(@gen A B C D E F G H I J K L M N O P);
255+
impl_fn_ptr_call!(@gen A B C D E F G H I J K L M N O P Q S T U V W X Y);
256256
};
257257
(@gen $($a:ident)*) => {
258258
impl<R: FnPtrArg $(, $a: FnPtrArg)*> FnPtr<fn($($a,)*) -> R> {

‎libcc2rs/src/fn_ptr_arg.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<T: ?Sized + 'static> FnPtrArg for *const T {
148148

149149
macro_rules! impl_fn_ptr_arg_unsafe_fn {
150150
() => {
151-
impl_fn_ptr_arg_unsafe_fn!(@gen A B C D E F G H I J K L M N O P);
151+
impl_fn_ptr_arg_unsafe_fn!(@gen A B C D E F G H I J K L M N O P Q S T U V W X Y);
152152
};
153153
(@gen $($a:ident)*) => {
154154
impl<R: 'static $(, $a: 'static)*> FnPtrArg for Option<unsafe fn($($a,)*) -> R> {
@@ -224,7 +224,7 @@ pub(crate) trait FnPtrArgs: Sized + 'static {
224224

225225
macro_rules! impl_fn_ptr_args {
226226
() => {
227-
impl_fn_ptr_args!(@gen A B C D E F G H I J K L M N O P);
227+
impl_fn_ptr_args!(@gen A B C D E F G H I J K L M N O P Q S T U V W X Y);
228228
};
229229
(@gen $($a:ident)*) => {
230230
impl_fn_ptr_args!(@arity $($a)*);

‎tests/unit/fn_ptr_arity.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,23 @@ int foo(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9,
55
return 22;
66
}
77

8+
int wide(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8,
9+
int a9, int a10, int a11, int a12, int a13, int a14, int a15,
10+
int a16, int a17, int a18, int a19, int a20, int a21, int a22) {
11+
return a1 + a22;
12+
}
13+
814
int main() {
915
auto f = &foo;
1016
assert(f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) == 22);
17+
18+
auto w = &wide;
19+
assert(w(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20+
20, 21, 22) == 23);
21+
22+
auto l = [](int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8,
23+
int a9, int a10, int a11, int a12, int a13, int a14, int a15,
24+
int a16, int a17, int a18) { return a1 * a18; };
25+
assert(l(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9) == 18);
1126
return 0;
1227
}

0 commit comments

Comments
 (0)