* list getvaluefunc wrapper
*/
public static MemorySegment getValue(MemorySegment list, MemorySegment elm, int row, int col, MemorySegment userdata, MemorySegment freeValue) {
+ if(userdata == MemorySegment.NULL) {
+ return MemorySegment.NULL;
+ }
+ userdata = userdata.reinterpret(16); // long[2]
long ctxPtr = userdata.getAtIndex(ValueLayout.JAVA_LONG, 0);
long converterIndex = userdata.getAtIndex(ValueLayout.JAVA_LONG, 1);
- long listCtxPtr = list.getAtIndex(ValueLayout.JAVA_LONG, 0);
- long listIndex = list.getAtIndex(ValueLayout.JAVA_LONG, 1);
+ ListFuncs listfuncs = ListFuncs.getInstance();
+
+ MemorySegment listdata = null; // long[2]
+ try {
+ listdata = ((MemorySegment)listfuncs.list_get_data.invoke(list)).reinterpret(16);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ long listCtxPtr = listdata.getAtIndex(ValueLayout.JAVA_LONG, 0);
+ long listIndex = listdata.getAtIndex(ValueLayout.JAVA_LONG, 1);
Context listCtx = Toolkit.getInstance().getContext(listCtxPtr);
UiList uilist = listCtx.getList((int)listIndex);
+ Object listElm = null;
+ try {
+ listElm = uilist.get((int) row);
+ } catch (Throwable e) {
+ return MemorySegment.NULL;
+ }
+
Context ctx = Toolkit.getInstance().getContext(ctxPtr);
ListValueConverter conv = ctx.getValueConverter((int)converterIndex);
- Object value = conv.getValue(null, col);
+ Object value = conv.getValue(listElm, col);
if(value instanceof String) {
- freeValue.setAtIndex(ValueLayout.JAVA_BOOLEAN, 0, true);
+ freeValue.reinterpret(1).setAtIndex(ValueLayout.JAVA_BOOLEAN, 0, true);
return CUtils.cstring((String)value);
}