[foreign-memaccess+abi] RFR: Add an internal MemoryInspection class [v2]
Per Minborg
duke at openjdk.org
Mon Sep 19 09:02:27 UTC 2022
> 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:
Update after review
-------------
Changes:
- all: https://git.openjdk.org/panama-foreign/pull/715/files
- new: https://git.openjdk.org/panama-foreign/pull/715/files/0174c0ed..29dc714b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=panama-foreign&pr=715&range=01
- incr: https://webrevs.openjdk.org/?repo=panama-foreign&pr=715&range=00-01
Stats: 281 lines in 3 files changed: 34 ins; 174 del; 73 mod
Patch: https://git.openjdk.org/panama-foreign/pull/715.diff
Fetch: git fetch https://git.openjdk.org/panama-foreign pull/715/head:pull/715
PR: https://git.openjdk.org/panama-foreign/pull/715
More information about the panama-dev
mailing list