< prev index next >
src/jdk.incubator.jextract/share/classes/jdk/internal/clang/TranslationUnit.java
Print this page
*** 85,98 ****
try (AllocationScope scope = new AllocationScope()) {
MemorySegment files = inMemoryFiles.length == 0 ?
null :
scope.track(MemorySegment.allocateNative(MemoryLayout.ofSequence(inMemoryFiles.length, Index_h.CXUnsavedFile$LAYOUT)));
for (int i = 0; i < inMemoryFiles.length; i++) {
! MemoryAddress start = files.baseAddress().offset(i * Index_h.CXUnsavedFile$LAYOUT.byteSize());
! Utils.setPointer(start.offset(FILENAME_OFFSET), scope.track(Utils.toNativeString(inMemoryFiles[i].file)).baseAddress());
! Utils.setPointer(start.offset(CONTENTS_OFFSET), scope.track(Utils.toNativeString(inMemoryFiles[i].contents)).baseAddress());
! Utils.setLong(start.offset(LENGTH_OFFSET), inMemoryFiles[i].contents.length());
}
return Index_h.clang_reparseTranslationUnit(tu, inMemoryFiles.length,
files == null ? MemoryAddress.NULL : files.baseAddress(),
Index_h.clang_defaultReparseOptions(tu));
}
--- 85,98 ----
try (AllocationScope scope = new AllocationScope()) {
MemorySegment files = inMemoryFiles.length == 0 ?
null :
scope.track(MemorySegment.allocateNative(MemoryLayout.ofSequence(inMemoryFiles.length, Index_h.CXUnsavedFile$LAYOUT)));
for (int i = 0; i < inMemoryFiles.length; i++) {
! MemoryAddress start = files.baseAddress().add(i * Index_h.CXUnsavedFile$LAYOUT.byteSize());
! Utils.setPointer(start.add(FILENAME_OFFSET), scope.track(Utils.toNativeString(inMemoryFiles[i].file)).baseAddress());
! Utils.setPointer(start.add(CONTENTS_OFFSET), scope.track(Utils.toNativeString(inMemoryFiles[i].contents)).baseAddress());
! Utils.setLong(start.add(LENGTH_OFFSET), inMemoryFiles[i].contents.length());
}
return Index_h.clang_reparseTranslationUnit(tu, inMemoryFiles.length,
files == null ? MemoryAddress.NULL : files.baseAddress(),
Index_h.clang_defaultReparseOptions(tu));
}
*** 148,158 ****
public int size() {
return size;
}
public MemorySegment getTokenSegment(int idx) {
! MemoryAddress p = ar.offset(idx * Index_h.CXToken$LAYOUT.byteSize());
return ForeignUnsafe.ofNativeUnchecked(p, Index_h.CXToken$LAYOUT.byteSize());
}
public Token getToken(int index) {
return new Token(getTokenSegment(index));
--- 148,158 ----
public int size() {
return size;
}
public MemorySegment getTokenSegment(int idx) {
! MemoryAddress p = ar.add(idx * Index_h.CXToken$LAYOUT.byteSize());
return ForeignUnsafe.ofNativeUnchecked(p, Index_h.CXToken$LAYOUT.byteSize());
}
public Token getToken(int index) {
return new Token(getTokenSegment(index));
< prev index next >