Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903628

Replace ofAddress method in FI classes with a static invoke method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • None
    • tools
    • None

      We can pull the string on our current 'all-static' approach for jextract further by replacing the `ofAddress` factory in the functional interface classes we generate with a static invoke method.

      This would avoid clients having to create an intermediate instance of the FI in order to invoke a function pointer they got back from native code.

          MemorySegment ptr = ...
          FP.ofAddress(ptr, someArena).apply(42);

      ->

          MemorySegment ptr = ...
          FP.invoke(ptr, 42);

      It would also make it easier to deal with function pointers which return by-value structs, since the proposed 'invoke' method could just accept an additional SegmentAllocator argument.

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: