-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(cua-driver)(macos): guard SkyLight auth-message selector for macOS 14 Sonoma (#1503) #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Apple Objective-C runtime headers: what is the declared return type ofclass_respondsToSelector, and is Objective-CBOOLABI-compatible with Rustboolinextern "C"FFI?💡 Result:
In the Apple Objective-C runtime headers, the function
class_respondsToSelectoris declared to return the Objective-CBOOLtype [1][2]. Whether Objective-CBOOLis ABI-compatible with Rust'sbooldepends on the platform and architecture, asBOOLis not a fixed type but a typedef [3][4]. In the Objective-C runtime headers,BOOLis defined as eitherbool(a C99_Bool) orsigned char, depending on the target [3][4]. 1. Compatibility: Rust'sboolis typically represented as a single byte [5]. WhenBOOLis defined asbool(common on modern 64-bit platforms like Apple Silicon), it is generally ABI-compatible with Rust'sbool[6][3][4]. However, whenBOOLis defined assigned char(common on older architectures or legacy macOS targets), it is not strictly ABI-compatible with Rust'sboolbecause the underlying representations and type-encoding expectations differ [3][4][7]. 2. Risk: BecauseBOOL's definition is platform-dependent, assuming ABI compatibility with Rust'sboolacross all targets is unsafe [6][8]. For robust FFI, it is recommended to use an abstraction (such as those found in crates likeobjc2orabibool) that accounts for the specific target'sBOOLdefinition, or to explicitly handle the conversion based on the target architecture [6][8][9].Citations:
🏁 Script executed:
Repository: trycua/cua
Length of output: 6803
🏁 Script executed:
Repository: trycua/cua
Length of output: 6803
🌐 Web query:
Rust ABI extern "C" return type bool mapping to C _Bool/_Bool ABI rules (bool validity 0/1)💡 Result:
In Rust, the
booltype is guaranteed to have the same representation as the C99_Booltype, and it is safe to use inextern "C"FFI declarations [1][2][3]. Key technical details regarding this mapping include: Representation and Validity: - Rust definesboolto have a size of 1 byte, withfalserepresented by the bit pattern0x00andtrueby0x01[4][5]. - It is considered undefined behavior (UB) for a Rustboolto possess any bit pattern other than0x00or0x01[4]. - When interfacing with C, Rust'sboolaligns with the C99_Booltype, which is also implementation-defined but behaves identically on all platforms currently supported by Rust (where_Boolis typically 1 byte, with0for false and1for true) [2][5]. FFI Considerations: - Whileboolis FFI-safe, it is crucial that the C side also adheres to the expectation that only0and1are used [5]. If a C function returns a value other than0or1into a Rustbool, it will trigger undefined behavior in Rust [4]. - Because_Boolsize and alignment can be implementation-defined in the C standard, reliance onboolfor FFI assumes that the C compiler’s_Boolmatches the platform’s ABI used by the Rust compiler [2][5]. In practice, this is universally true for Rust's supported targets [5]. - If you are dealing with C types that are not_Bool(such as WindowsBOOL, which is typically a 4-byteint), you should not use Rust'sbooldirectly, as the size mismatch will cause errors [6][7]. In such cases, use an explicit integer type (e.g.,i32) on the Rust side and convert manually to preserve safety [6]. Summary: For standard C99_Boolinteroperability, usingboolinextern "C"functions is stable, supported, and the recommended practice [8][1][2]. Ensure the C code treats its_Boolvalues as strictly0or1[5].Citations:
🏁 Script executed:
Repository: trycua/cua
Length of output: 4891
🌐 Web query:
Apple headers typedef for BOOL (MacTypes.h / objc/objc.h) and signature/return type of class_respondsToSelector💡 Result:
The BOOL type in Apple's Objective-C runtime (defined in <objc/objc.h>) is platform-dependent [1][2]. On 64-bit iOS and all watchOS platforms, it is a typedef for the C99 bool type [1][2]. On other platforms (including macOS), it is a typedef for signed char [1][2]. The definition is explicitly signed to ensure that the Objective-C type encoding for BOOL is always 'c' (rather than 'C'), regardless of whether -funsigned-char is used [1][3]. In contrast, the Boolean type found in <MacTypes.h> is a legacy type defined as an unsigned char (typedef unsigned char Boolean) [4]. The function class_respondsToSelector is a runtime function with the following signature [5][6]: BOOL class_respondsToSelector(Class cls, SEL sel); It accepts a class (cls) and a selector (sel) as arguments and returns a BOOL value: YES if instances of the class respond to the specified selector, and NO otherwise [5]. Apple documentation generally recommends using NSObject's instance method responds(to:) or the class method instancesRespond(to:) instead of this low-level runtime function [5][7].
Citations:
Fix FFI return type for
class_respondsToSelectorto matchBOOLIn
libs/cua-driver/rust/crates/platform-macos/src/input/skylight.rs(lines 221-226),RespondsToFnreturns Rustbool, but Apple’sclass_respondsToSelectorreturns Objective‑CBOOL, which issigned charon macOS. Usec_schar/i8(or aBOOLwrapper) as theextern "C"return type and convert with!= 0.🤖 Prompt for AI Agents