< prev index next >

test/micro/org/openjdk/bench/java/lang/foreign/points/support/PanamaPoint.java

Print this page

 51                 loaderLibs.find("distance").get(),
 52                 FunctionDescriptor.of(C_DOUBLE, LAYOUT, LAYOUT)
 53         );
 54         MH_distance_ptrs = abi.downcallHandle(
 55                 loaderLibs.find("distance_ptrs").get(),
 56                 FunctionDescriptor.of(C_DOUBLE, C_POINTER, C_POINTER)
 57         );
 58     }
 59 
 60     Arena arena;
 61     private final MemorySegment segment;
 62 
 63     public PanamaPoint(int x, int y) {
 64         this.arena = Arena.ofConfined();
 65         this.segment = arena.allocate(LAYOUT);
 66         setX(x);
 67         setY(y);
 68     }
 69 
 70     public void setX(int x) {
 71         VH_x.set(segment, x);
 72     }
 73 
 74     public int getX() {
 75         return (int) VH_x.get(segment);
 76     }
 77 
 78     public void setY(int y) {
 79         VH_y.set(segment, y);
 80     }
 81 
 82     public int getY() {
 83         return (int) VH_y.get(segment);
 84     }
 85 
 86     public double distanceTo(PanamaPoint other) {
 87         try {
 88             return (double) MH_distance.invokeExact(segment, other.segment);
 89         } catch (Throwable throwable) {
 90             throw new InternalError(throwable);
 91         }
 92     }
 93 
 94     public double distanceToPtrs(PanamaPoint other) {
 95         try {
 96             return (double) MH_distance_ptrs.invokeExact(segment, other.segment);
 97         } catch (Throwable throwable) {
 98             throw new InternalError(throwable);
 99         }
100     }
101 
102     @Override
103     public void close() {

 51                 loaderLibs.find("distance").get(),
 52                 FunctionDescriptor.of(C_DOUBLE, LAYOUT, LAYOUT)
 53         );
 54         MH_distance_ptrs = abi.downcallHandle(
 55                 loaderLibs.find("distance_ptrs").get(),
 56                 FunctionDescriptor.of(C_DOUBLE, C_POINTER, C_POINTER)
 57         );
 58     }
 59 
 60     Arena arena;
 61     private final MemorySegment segment;
 62 
 63     public PanamaPoint(int x, int y) {
 64         this.arena = Arena.ofConfined();
 65         this.segment = arena.allocate(LAYOUT);
 66         setX(x);
 67         setY(y);
 68     }
 69 
 70     public void setX(int x) {
 71         VH_x.set(segment, 0L, x);
 72     }
 73 
 74     public int getX() {
 75         return (int) VH_x.get(segment, 0L);
 76     }
 77 
 78     public void setY(int y) {
 79         VH_y.set(segment, 0L, y);
 80     }
 81 
 82     public int getY() {
 83         return (int) VH_y.get(segment, 0L);
 84     }
 85 
 86     public double distanceTo(PanamaPoint other) {
 87         try {
 88             return (double) MH_distance.invokeExact(segment, other.segment);
 89         } catch (Throwable throwable) {
 90             throw new InternalError(throwable);
 91         }
 92     }
 93 
 94     public double distanceToPtrs(PanamaPoint other) {
 95         try {
 96             return (double) MH_distance_ptrs.invokeExact(segment, other.segment);
 97         } catch (Throwable throwable) {
 98             throw new InternalError(throwable);
 99         }
100     }
101 
102     @Override
103     public void close() {
< prev index next >