Skip to content

Commit 3ae1c11

Browse files
authored
fix!: Remove objc and Core Foundation types from C bindings public API (#243)
1 parent 31264df commit 3ae1c11

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

bindings/c/cbindgen.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ include_guard = "ACCESSKIT_H"
1010
cpp_compat = true
1111
after_includes = """#ifdef _WIN32
1212
#include <windows.h>
13-
#endif
14-
#ifdef __APPLE__
15-
#include <Foundation/NSObjCRuntime.h>
16-
#include <CoreGraphics/CGGeometry.h>
1713
#endif"""
1814

1915
usize_is_size_t = true
@@ -47,9 +43,6 @@ renaming_overrides_prefixing = true
4743
"LRESULT" = "LRESULT"
4844
"ListStyle" = "accesskit_list_style"
4945
"Live" = "accesskit_live"
50-
"NSArray" = "NSArray"
51-
"NSObject" = "NSObject"
52-
"NSPoint" = "CGPoint"
5346
"NameFrom" = "accesskit_name_from"
5447
"Orientation" = "accesskit_orientation"
5548
"Point" = "accesskit_point"

bindings/c/src/macos.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ use crate::{
1010
use accesskit_macos::{Adapter, NSObject, NSPoint, QueuedEvents, SubclassingAdapter};
1111
use std::{os::raw::c_void, ptr};
1212

13-
#[cfg(not(feature = "cbindgen"))]
14-
pub type NSArray = c_void;
15-
1613
pub struct macos_queued_events {
1714
_private: [u8; 0],
1815
}
@@ -74,29 +71,31 @@ impl macos_adapter {
7471
BoxCastPtr::to_mut_ptr(events)
7572
}
7673

74+
/// Returns a pointer to an `NSArray`. Ownership of the pointer is not transfered.
7775
#[no_mangle]
7876
pub extern "C" fn accesskit_macos_adapter_view_children(
7977
adapter: *const macos_adapter,
80-
) -> *mut NSArray {
78+
) -> *mut c_void {
8179
let adapter = ref_from_ptr(adapter);
8280
adapter.view_children() as *mut _
8381
}
8482

83+
/// Returns a pointer to an `NSObject`. Ownership of the pointer is not transfered.
8584
#[no_mangle]
86-
pub extern "C" fn accesskit_macos_adapter_focus(
87-
adapter: *const macos_adapter,
88-
) -> *mut NSObject {
85+
pub extern "C" fn accesskit_macos_adapter_focus(adapter: *const macos_adapter) -> *mut c_void {
8986
let adapter = ref_from_ptr(adapter);
90-
adapter.focus()
87+
adapter.focus() as *mut _
9188
}
9289

90+
/// Returns a pointer to an `NSObject`. Ownership of the pointer is not transfered.
9391
#[no_mangle]
9492
pub extern "C" fn accesskit_macos_adapter_hit_test(
9593
adapter: *const macos_adapter,
96-
point: NSPoint,
97-
) -> *mut NSObject {
94+
x: f64,
95+
y: f64,
96+
) -> *mut c_void {
9897
let adapter = ref_from_ptr(adapter);
99-
adapter.hit_test(point)
98+
adapter.hit_test(NSPoint::new(x, y)) as *mut _
10099
}
101100
}
102101

0 commit comments

Comments
 (0)