Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8252800

Generate a method to convert a MemoryAddress to a MemorySegment on struct classes

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: repo-panama
    • Fix Version/s: None
    • Component/s: tools

      Description

      It can be useful to convert a MemoryAddress obtained from a native function call to a MemorySegment, so that fields can be read and written to.

      We can help users doing this by adding a factory method such as:

          MemorySegment asSegmentRestricted(MemoryAddress addr) {...}

      To the struct classes generated by jextract, and the implementation can use the MemoryLayout associated with the struct to do the conversion.

      As a side note: currently RuntimeHelper has:

          MemorySegment asArrayRestricted(MemoryAddress addr, MemoryLayout layout, int numElements) {...}

      To do something similar for arrays. This method could be moved to the CSupport class as well, since it is generally useful.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: