-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Variadic annotation to specify fixed args
When calling a variadic function with a non-varargs Java signature users must provide the Variadic annotation to indicate how many fixed arguments the target function takes. This is required to support platforms where variadic args are passed differently than fixed args, such as on Apple Silicon.
- Loading branch information
Showing
4 changed files
with
56 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jnr.ffi.annotations; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
/** | ||
* Specifies that a non-varargs function binding will call a variadic C function with the specified number of fixed | ||
* arguments. | ||
* | ||
* Platforms that pass variadic arguments differently than fixed arguments will need this annotation if the Java binding | ||
* does not itself use varargs. Without Java varargs or this annotation, there's no way for jnr-ffi to know where fixed | ||
* args end and variadic arguments begin, causing them all to be passed the way fixed arguments get passed on the given | ||
* platform. | ||
* | ||
* See https://github.com/jnr/jnr-ffi/pull/292 | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Variadic { | ||
int fixedCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters