}
public int[] getSelection() {
+ return UiList.getSelection(valuePtr);
+ }
+
+ protected static int[] getSelection(MemorySegment uiListPtr) {
ListFuncs ui = ListFuncs.getInstance();
try {
- MemorySegment sel = (MemorySegment)ui.list_get_selection_allocated.invoke(valuePtr);
+ MemorySegment sel = (MemorySegment)ui.list_get_selection_allocated.invoke(uiListPtr);
int count = (int)ui.list_selection_get_count.invoke(sel);
int[] selection = new int[count];
MemorySegment rows = (MemorySegment)ui.list_selection_get_rows.invoke(sel);
}
}
- // TODO: the selection code is almost identical to the UiList selection code -> refactor
public int[] getSelection() {
- ListFuncs ui = ListFuncs.getInstance();
- try {
- MemorySegment sel = (MemorySegment)ui.list_get_selection_allocated.invoke(valuePtr);
- int count = (int)ui.list_selection_get_count.invoke(sel);
- int[] selection = new int[count];
- MemorySegment rows = (MemorySegment)ui.list_selection_get_rows.invoke(sel);
- rows = rows.reinterpret(count * ValueLayout.JAVA_INT.byteSize());
- for(int i=0; i<count; i++) {
- selection[i] = (int)rows.getAtIndex(ValueLayout.JAVA_INT, i);
- }
- ui.list_selection_free.invoke(sel);
- return selection;
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
+ return UiList.getSelection(valuePtr);
}
public int getSelectedIndex() {