objc2_application_services/generated/HIServices/
AXValue.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct AXValueType(pub u32);
21impl AXValueType {
22 #[doc(alias = "kAXValueTypeCGPoint")]
23 pub const CGPoint: Self = Self(1);
24 #[doc(alias = "kAXValueTypeCGSize")]
25 pub const CGSize: Self = Self(2);
26 #[doc(alias = "kAXValueTypeCGRect")]
27 pub const CGRect: Self = Self(3);
28 #[doc(alias = "kAXValueTypeCFRange")]
29 pub const CFRange: Self = Self(4);
30 #[doc(alias = "kAXValueTypeAXError")]
31 pub const AXError: Self = Self(5);
32 #[doc(alias = "kAXValueTypeIllegal")]
33 pub const Illegal: Self = Self(0);
34}
35
36#[cfg(feature = "objc2")]
37unsafe impl Encode for AXValueType {
38 const ENCODING: Encoding = u32::ENCODING;
39}
40
41#[cfg(feature = "objc2")]
42unsafe impl RefEncode for AXValueType {
43 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46pub static kAXValueCGPointType: u32 = AXValueType::CGPoint.0;
48
49pub static kAXValueCGSizeType: u32 = AXValueType::CGSize.0;
51
52pub static kAXValueCGRectType: u32 = AXValueType::CGRect.0;
54
55pub static kAXValueCFRangeType: u32 = AXValueType::CFRange.0;
57
58pub static kAXValueAXErrorType: u32 = AXValueType::AXError.0;
60
61pub static kAXValueIllegalType: u32 = AXValueType::Illegal.0;
63
64#[doc(alias = "AXValueRef")]
66#[repr(C)]
67pub struct AXValue {
68 inner: [u8; 0],
69 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
70}
71
72cf_type!(
73 unsafe impl AXValue {}
74);
75#[cfg(feature = "objc2")]
76cf_objc2_type!(
77 unsafe impl RefEncode<"__AXValue"> for AXValue {}
78);
79
80unsafe impl ConcreteType for AXValue {
81 #[doc(alias = "AXValueGetTypeID")]
84 #[inline]
85 fn type_id() -> CFTypeID {
86 extern "C-unwind" {
87 fn AXValueGetTypeID() -> CFTypeID;
88 }
89 unsafe { AXValueGetTypeID() }
90 }
91}
92
93impl AXValue {
94 #[doc(alias = "AXValueCreate")]
105 #[inline]
106 pub unsafe fn new(
107 the_type: AXValueType,
108 value_ptr: NonNull<c_void>,
109 ) -> Option<CFRetained<AXValue>> {
110 extern "C-unwind" {
111 fn AXValueCreate(
112 the_type: AXValueType,
113 value_ptr: NonNull<c_void>,
114 ) -> Option<NonNull<AXValue>>;
115 }
116 let ret = unsafe { AXValueCreate(the_type, value_ptr) };
117 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
118 }
119
120 #[doc(alias = "AXValueGetType")]
126 #[inline]
127 pub unsafe fn r#type(&self) -> AXValueType {
128 extern "C-unwind" {
129 fn AXValueGetType(value: &AXValue) -> AXValueType;
130 }
131 unsafe { AXValueGetType(self) }
132 }
133
134 #[doc(alias = "AXValueGetValue")]
145 #[inline]
146 pub unsafe fn value(&self, the_type: AXValueType, value_ptr: NonNull<c_void>) -> bool {
147 extern "C-unwind" {
148 fn AXValueGetValue(
149 value: &AXValue,
150 the_type: AXValueType,
151 value_ptr: NonNull<c_void>,
152 ) -> Boolean;
153 }
154 let ret = unsafe { AXValueGetValue(self, the_type, value_ptr) };
155 ret != 0
156 }
157}
158
159#[deprecated = "renamed to `AXValue::new`"]
160#[inline]
161pub unsafe extern "C-unwind" fn AXValueCreate(
162 the_type: AXValueType,
163 value_ptr: NonNull<c_void>,
164) -> Option<CFRetained<AXValue>> {
165 extern "C-unwind" {
166 fn AXValueCreate(
167 the_type: AXValueType,
168 value_ptr: NonNull<c_void>,
169 ) -> Option<NonNull<AXValue>>;
170 }
171 let ret = unsafe { AXValueCreate(the_type, value_ptr) };
172 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
173}
174
175extern "C-unwind" {
176 #[deprecated = "renamed to `AXValue::type`"]
177 pub fn AXValueGetType(value: &AXValue) -> AXValueType;
178}
179
180#[deprecated = "renamed to `AXValue::value`"]
181#[inline]
182pub unsafe extern "C-unwind" fn AXValueGetValue(
183 value: &AXValue,
184 the_type: AXValueType,
185 value_ptr: NonNull<c_void>,
186) -> bool {
187 extern "C-unwind" {
188 fn AXValueGetValue(
189 value: &AXValue,
190 the_type: AXValueType,
191 value_ptr: NonNull<c_void>,
192 ) -> Boolean;
193 }
194 let ret = unsafe { AXValueGetValue(value, the_type, value_ptr) };
195 ret != 0
196}