1 /* 2 * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 // Generated by jextract 27 28 package jdk.internal.clang.libclang; 29 30 import java.lang.invoke.MethodHandle; 31 import java.lang.invoke.VarHandle; 32 import java.nio.ByteOrder; 33 import jdk.incubator.foreign.*; 34 import static jdk.incubator.foreign.ValueLayout.*; 35 public class CXToken { 36 37 static final MemoryLayout $struct$LAYOUT = MemoryLayout.structLayout( 38 MemoryLayout.sequenceLayout(4, JAVA_INT).withName("int_data"), 39 ADDRESS.withName("ptr_data") 40 ); 41 public static MemoryLayout $LAYOUT() { 42 return CXToken.$struct$LAYOUT; 43 } 44 public static MemorySegment int_data$slice(MemorySegment seg) { 45 return seg.asSlice(0, 16); 46 } 47 static final VarHandle ptr_data$VH = $struct$LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("ptr_data")); 48 public static VarHandle ptr_data$VH() { 49 return CXToken.ptr_data$VH; 50 } 51 public static MemoryAddress ptr_data$get(MemorySegment seg) { 52 return (jdk.incubator.foreign.MemoryAddress)CXToken.ptr_data$VH.get(seg); 53 } 54 public static void ptr_data$set( MemorySegment seg, MemoryAddress x) { 55 CXToken.ptr_data$VH.set(seg, x); 56 } 57 public static MemoryAddress ptr_data$get(MemorySegment seg, long index) { 58 return (jdk.incubator.foreign.MemoryAddress)CXToken.ptr_data$VH.get(seg.asSlice(index*sizeof())); 59 } 60 public static void ptr_data$set(MemorySegment seg, long index, MemoryAddress x) { 61 CXToken.ptr_data$VH.set(seg.asSlice(index*sizeof()), x); 62 } 63 public static long sizeof() { return $LAYOUT().byteSize(); } 64 public static MemorySegment allocate(SegmentAllocator allocator) { return allocator.allocate($LAYOUT()); } 65 public static MemorySegment allocateArray(int len, SegmentAllocator allocator) { 66 return allocator.allocate(MemoryLayout.sequenceLayout(len, $LAYOUT())); 67 } 68 public static MemorySegment allocate(ResourceScope scope) { return allocate(SegmentAllocator.nativeAllocator(scope)); } 69 public static MemorySegment allocateArray(int len, ResourceScope scope) { 70 return allocateArray(len, SegmentAllocator.nativeAllocator(scope)); 71 } 72 public static MemorySegment ofAddress(MemoryAddress addr, ResourceScope scope) { return RuntimeHelper.asArray(addr, $LAYOUT(), 1, scope); } 73 } 74 75