Annotation Interface FFMReturn


@Target(METHOD) @Retention(RUNTIME) public @interface FFMReturn
Transforms a native function such that it returns the value of an output parameter.

Supports the following transformations:

  • From void function(..., type *paramOut, ...) to type function(...). The method will return a single value only, of the same type as the element type of the output parameter.
  • From sizeT function(..., sizeT paramSize, type *paramOut, ...) to MemorySegment function(..., sizeT paramSize, ...). The method will allocate a buffer of size equal to the paramSize parameter, which must be annotated with FFMReturn.Size. The returned MemorySegment will have a size equal to the value returned by the native function. The return type can also be a String, in which case the output buffer will be decoded and returned as a string.
  • From void function(..., sizeT paramSize, sizeT *length, type *paramOut, ...) to MemorySegment function(..., sizeT paramSize, ...). The method will allocate a buffer of size equal to the paramSize parameter, which must be annotated with FFMReturn.Size. It will also allocate storage for the output length parameter. The returned MemorySegment will have a size equal to the value returned in the length parameter. The return type can also be a String, in which case the output buffer will be decoded and returned as a string.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    When specified, the parameter will be used as the size of the internally allocated return buffer.
    static @interface 
    Specifies the output parameter that receives the actual buffer size.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    int
    Index of the buffer parameter that has been transformed to a return value.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    When true, the actual string size includes the null-termination character.
  • Element Details

    • value

      int value
      Index of the buffer parameter that has been transformed to a return value.

      It should be the native parameter index, ignoring any virtual parameters before the actual parameters.

    • includesNT

      boolean includesNT
      When true, the actual string size includes the null-termination character.
      Default:
      false