[foreign-memaccess+abi] RFR: Add an internal MemoryInspection class [v3]
Athijegannathan Sundararajan
sundar at openjdk.org
Thu Sep 22 10:26:18 UTC 2022
On Thu, 22 Sep 2022 07:30:37 GMT, Per Minborg <duke at openjdk.org> wrote:
>> This PR adds a way of inspecting a `MemoryLayout` through a `MemoryLayout`.
>>
>>
>> /**
>> * Returns a human-readable view of the provided {@linkplain MemorySegment memory} viewed
>> * through the provided {@linkplain MemoryLayout layout} using the provided {@linkplain ValueLayoutRenderer renderer}.
>> * <p>
>> * The exact format of the returned view is unspecified and should not
>> * be acted upon programmatically.
>> * <p>
>> * As an example, a MemorySegment viewed though the following memory layout
>> * {@snippet lang = java:
>> * var layout = MemoryLayout.structLayout(
>> * ValueLayout.JAVA_INT.withName("x"),
>> * ValueLayout.JAVA_INT.withName("y")
>> * ).withName("Point");
>> *
>> * MemoryInspection.inspect(segment, layout, ValueLayoutRenderer.standard())
>> * .forEach(System.out::println);
>> *
>> *}
>> * might be rendered to something like this:
>> * {@snippet lang = text:
>> * Point {
>> * x=1,
>> * y=2
>> * }
>> *}
>> * <p>
>> * This method is intended to view memory segments through small and medium-sized memory layouts.
>> *
>> * @param segment to be viewed
>> * @param layout to use as a layout when viewing the memory segment
>> * @param renderer to apply when rendering value layouts
>> * @return a view of the memory abstraction viewed through the memory layout
>> */
>> public static Stream<String> inspect(MemorySegment segment,
>> MemoryLayout layout,
>> ValueLayoutRenderer renderer) {
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix copyright and javadoc issues
LGTM
-------------
Marked as reviewed by sundar (Committer).
PR: https://git.openjdk.org/panama-foreign/pull/715
More information about the panama-dev
mailing list