// Generated by jextract package demo.sqlite; import java.lang.invoke.*; import java.lang.foreign.*; import java.nio.ByteOrder; import java.util.*; import java.util.function.*; import java.util.stream.*; import static java.lang.foreign.ValueLayout.*; import static java.lang.foreign.MemoryLayout.PathElement.*; /** * {@snippet lang=c : * int (*callback)(void *, int, char **, char **) * } */ public final class sqlite3_exec$callback { private sqlite3_exec$callback() { // Should not be called directly } /** * The function pointer signature, expressed as a functional interface */ public interface Function { int apply(MemorySegment _x0, int _x1, MemorySegment _x2, MemorySegment _x3); } private static final FunctionDescriptor $DESC = FunctionDescriptor.of( sqlite3_h.C_INT, sqlite3_h.C_POINTER, sqlite3_h.C_INT, sqlite3_h.C_POINTER, sqlite3_h.C_POINTER ); /** * The descriptor of this function pointer */ public static FunctionDescriptor descriptor() { return $DESC; } private static final MethodHandle UP$MH = sqlite3_h.upcallHandle(sqlite3_exec$callback.Function.class, "apply", $DESC); /** * Allocates a new upcall stub, whose implementation is defined by {@code fi}. * The lifetime of the returned segment is managed by {@code arena} */ public static MemorySegment allocate(sqlite3_exec$callback.Function fi, Arena arena) { return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena); } private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); /** * Invoke the upcall stub {@code funcPtr}, with given parameters */ public static int invoke(MemorySegment funcPtr, MemorySegment _x0, int _x1, MemorySegment _x2, MemorySegment _x3) { try { return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3); } catch (Error | RuntimeException ex) { throw ex; } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } } }