// Generated by jextract package duncan.win.advapi; 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 : * typedef DWORD (*LPHANDLER_FUNCTION_EX)(DWORD, DWORD, LPVOID, LPVOID) __attribute__((stdcall)) * } */ public class LPHANDLER_FUNCTION_EX { /** * The function pointer signature, expressed as a functional interface */ public interface Function { int apply(int dwControl, int dwEventType, MemorySegment lpEventData, MemorySegment lpContext); } private static final FunctionDescriptor $DESC = FunctionDescriptor.of( Advapi32_h.C_LONG, Advapi32_h.C_LONG, Advapi32_h.C_LONG, Advapi32_h.C_POINTER, Advapi32_h.C_POINTER ); /** * The descriptor of this function pointer */ public static FunctionDescriptor descriptor() { return $DESC; } private static final MethodHandle UP$MH = Advapi32_h.upcallHandle(LPHANDLER_FUNCTION_EX.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(LPHANDLER_FUNCTION_EX.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,int dwControl, int dwEventType, MemorySegment lpEventData, MemorySegment lpContext) { try { return (int) DOWN$MH.invokeExact(funcPtr, dwControl, dwEventType, lpEventData, lpContext); } catch (Throwable ex$) { throw new AssertionError("should not reach here", ex$); } } }