-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macOS: handle all messages on disconnect
- Loading branch information
Showing
6 changed files
with
490 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ain/java/net/codecrete/usb/macos/gen/corefoundation/CFMessagePortCreateLocal$callout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Generated by jextract | ||
|
||
package net.codecrete.usb.macos.gen.corefoundation; | ||
|
||
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 : | ||
* CFMessagePortCallBack callout | ||
* } | ||
*/ | ||
public class CFMessagePortCreateLocal$callout { | ||
|
||
CFMessagePortCreateLocal$callout() { | ||
// Should not be called directly | ||
} | ||
|
||
/** | ||
* The function pointer signature, expressed as a functional interface | ||
*/ | ||
public interface Function { | ||
MemorySegment apply(MemorySegment _x0, int _x1, MemorySegment _x2, MemorySegment _x3); | ||
} | ||
|
||
private static final FunctionDescriptor $DESC = FunctionDescriptor.of( | ||
CoreFoundation.C_POINTER, | ||
CoreFoundation.C_POINTER, | ||
CoreFoundation.C_INT, | ||
CoreFoundation.C_POINTER, | ||
CoreFoundation.C_POINTER | ||
); | ||
|
||
/** | ||
* The descriptor of this function pointer | ||
*/ | ||
public static FunctionDescriptor descriptor() { | ||
return $DESC; | ||
} | ||
|
||
private static final MethodHandle UP$MH = CoreFoundation.upcallHandle(CFMessagePortCreateLocal$callout.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(CFMessagePortCreateLocal$callout.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 MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0, int _x1, MemorySegment _x2, MemorySegment _x3) { | ||
try { | ||
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3); | ||
} catch (Throwable ex$) { | ||
throw new AssertionError("should not reach here", ex$); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.