objc2_foundation/generated/
NSExpression.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsexpressiontype?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSExpressionType(pub NSUInteger);
14impl NSExpressionType {
15    #[doc(alias = "NSConstantValueExpressionType")]
16    pub const ConstantValueExpressionType: Self = Self(0);
17    #[doc(alias = "NSEvaluatedObjectExpressionType")]
18    pub const EvaluatedObjectExpressionType: Self = Self(1);
19    #[doc(alias = "NSVariableExpressionType")]
20    pub const VariableExpressionType: Self = Self(2);
21    #[doc(alias = "NSKeyPathExpressionType")]
22    pub const KeyPathExpressionType: Self = Self(3);
23    #[doc(alias = "NSFunctionExpressionType")]
24    pub const FunctionExpressionType: Self = Self(4);
25    #[doc(alias = "NSUnionSetExpressionType")]
26    pub const UnionSetExpressionType: Self = Self(5);
27    #[doc(alias = "NSIntersectSetExpressionType")]
28    pub const IntersectSetExpressionType: Self = Self(6);
29    #[doc(alias = "NSMinusSetExpressionType")]
30    pub const MinusSetExpressionType: Self = Self(7);
31    #[doc(alias = "NSSubqueryExpressionType")]
32    pub const SubqueryExpressionType: Self = Self(13);
33    #[doc(alias = "NSAggregateExpressionType")]
34    pub const AggregateExpressionType: Self = Self(14);
35    #[doc(alias = "NSAnyKeyExpressionType")]
36    pub const AnyKeyExpressionType: Self = Self(15);
37    #[doc(alias = "NSBlockExpressionType")]
38    pub const BlockExpressionType: Self = Self(19);
39    #[doc(alias = "NSConditionalExpressionType")]
40    pub const ConditionalExpressionType: Self = Self(20);
41}
42
43unsafe impl Encode for NSExpressionType {
44    const ENCODING: Encoding = NSUInteger::ENCODING;
45}
46
47unsafe impl RefEncode for NSExpressionType {
48    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
49}
50
51extern_class!(
52    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsexpression?language=objc)
53    #[unsafe(super(NSObject))]
54    #[derive(Debug, PartialEq, Eq, Hash)]
55    pub struct NSExpression;
56);
57
58#[cfg(feature = "NSObject")]
59extern_conformance!(
60    unsafe impl NSCoding for NSExpression {}
61);
62
63#[cfg(feature = "NSObject")]
64extern_conformance!(
65    unsafe impl NSCopying for NSExpression {}
66);
67
68#[cfg(feature = "NSObject")]
69unsafe impl CopyingHelper for NSExpression {
70    type Result = Self;
71}
72
73extern_conformance!(
74    unsafe impl NSObjectProtocol for NSExpression {}
75);
76
77#[cfg(feature = "NSObject")]
78extern_conformance!(
79    unsafe impl NSSecureCoding for NSExpression {}
80);
81
82impl NSExpression {
83    extern_methods!(
84        #[cfg(all(feature = "NSArray", feature = "NSString"))]
85        /// # Safety
86        ///
87        /// `arguments` generic should be of the correct type.
88        #[unsafe(method(expressionWithFormat:argumentArray:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn expressionWithFormat_argumentArray(
91            expression_format: &NSString,
92            arguments: &NSArray,
93        ) -> Retained<NSExpression>;
94
95        /// # Safety
96        ///
97        /// `obj` should be of the correct type.
98        #[unsafe(method(expressionForConstantValue:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn expressionForConstantValue(obj: Option<&AnyObject>)
101            -> Retained<NSExpression>;
102
103        #[unsafe(method(expressionForEvaluatedObject))]
104        #[unsafe(method_family = none)]
105        pub fn expressionForEvaluatedObject() -> Retained<NSExpression>;
106
107        #[cfg(feature = "NSString")]
108        #[unsafe(method(expressionForVariable:))]
109        #[unsafe(method_family = none)]
110        pub fn expressionForVariable(string: &NSString) -> Retained<NSExpression>;
111
112        #[cfg(feature = "NSString")]
113        #[unsafe(method(expressionForKeyPath:))]
114        #[unsafe(method_family = none)]
115        pub fn expressionForKeyPath(key_path: &NSString) -> Retained<NSExpression>;
116
117        #[cfg(all(feature = "NSArray", feature = "NSString"))]
118        /// # Safety
119        ///
120        /// `parameters` generic should be of the correct type.
121        #[unsafe(method(expressionForFunction:arguments:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn expressionForFunction_arguments(
124            name: &NSString,
125            parameters: &NSArray,
126        ) -> Retained<NSExpression>;
127
128        #[cfg(feature = "NSArray")]
129        #[unsafe(method(expressionForAggregate:))]
130        #[unsafe(method_family = none)]
131        pub fn expressionForAggregate(
132            subexpressions: &NSArray<NSExpression>,
133        ) -> Retained<NSExpression>;
134
135        #[unsafe(method(expressionForUnionSet:with:))]
136        #[unsafe(method_family = none)]
137        pub fn expressionForUnionSet_with(
138            left: &NSExpression,
139            right: &NSExpression,
140        ) -> Retained<NSExpression>;
141
142        #[unsafe(method(expressionForIntersectSet:with:))]
143        #[unsafe(method_family = none)]
144        pub fn expressionForIntersectSet_with(
145            left: &NSExpression,
146            right: &NSExpression,
147        ) -> Retained<NSExpression>;
148
149        #[unsafe(method(expressionForMinusSet:with:))]
150        #[unsafe(method_family = none)]
151        pub fn expressionForMinusSet_with(
152            left: &NSExpression,
153            right: &NSExpression,
154        ) -> Retained<NSExpression>;
155
156        #[cfg(all(feature = "NSPredicate", feature = "NSString"))]
157        #[unsafe(method(expressionForSubquery:usingIteratorVariable:predicate:))]
158        #[unsafe(method_family = none)]
159        pub fn expressionForSubquery_usingIteratorVariable_predicate(
160            expression: &NSExpression,
161            variable: &NSString,
162            predicate: &NSPredicate,
163        ) -> Retained<NSExpression>;
164
165        #[cfg(all(feature = "NSArray", feature = "NSString"))]
166        /// # Safety
167        ///
168        /// `parameters` generic should be of the correct type.
169        #[unsafe(method(expressionForFunction:selectorName:arguments:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn expressionForFunction_selectorName_arguments(
172            target: &NSExpression,
173            name: &NSString,
174            parameters: Option<&NSArray>,
175        ) -> Retained<NSExpression>;
176
177        #[unsafe(method(expressionForAnyKey))]
178        #[unsafe(method_family = none)]
179        pub fn expressionForAnyKey() -> Retained<NSExpression>;
180
181        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "block2"))]
182        /// # Safety
183        ///
184        /// - `block` block's return must be a valid pointer.
185        /// - `block` block's argument 3 generic should be of the correct type.
186        #[unsafe(method(expressionForBlock:arguments:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn expressionForBlock_arguments(
189            block: &block2::DynBlock<
190                dyn Fn(
191                    *mut AnyObject,
192                    NonNull<NSArray<NSExpression>>,
193                    *mut NSMutableDictionary,
194                ) -> NonNull<AnyObject>,
195            >,
196            arguments: Option<&NSArray<NSExpression>>,
197        ) -> Retained<NSExpression>;
198
199        #[cfg(feature = "NSPredicate")]
200        #[unsafe(method(expressionForConditional:trueExpression:falseExpression:))]
201        #[unsafe(method_family = none)]
202        pub fn expressionForConditional_trueExpression_falseExpression(
203            predicate: &NSPredicate,
204            true_expression: &NSExpression,
205            false_expression: &NSExpression,
206        ) -> Retained<NSExpression>;
207
208        #[unsafe(method(initWithExpressionType:))]
209        #[unsafe(method_family = init)]
210        pub fn initWithExpressionType(
211            this: Allocated<Self>,
212            r#type: NSExpressionType,
213        ) -> Retained<Self>;
214
215        #[cfg(feature = "NSCoder")]
216        /// # Safety
217        ///
218        /// `coder` possibly has further requirements.
219        #[unsafe(method(initWithCoder:))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn initWithCoder(
222            this: Allocated<Self>,
223            coder: &NSCoder,
224        ) -> Option<Retained<Self>>;
225
226        #[unsafe(method(expressionType))]
227        #[unsafe(method_family = none)]
228        pub fn expressionType(&self) -> NSExpressionType;
229
230        #[unsafe(method(constantValue))]
231        #[unsafe(method_family = none)]
232        pub fn constantValue(&self) -> Option<Retained<AnyObject>>;
233
234        #[cfg(feature = "NSString")]
235        #[unsafe(method(keyPath))]
236        #[unsafe(method_family = none)]
237        pub fn keyPath(&self) -> Retained<NSString>;
238
239        #[cfg(feature = "NSString")]
240        #[unsafe(method(function))]
241        #[unsafe(method_family = none)]
242        pub fn function(&self) -> Retained<NSString>;
243
244        #[cfg(feature = "NSString")]
245        #[unsafe(method(variable))]
246        #[unsafe(method_family = none)]
247        pub fn variable(&self) -> Retained<NSString>;
248
249        #[unsafe(method(operand))]
250        #[unsafe(method_family = none)]
251        pub fn operand(&self) -> Retained<NSExpression>;
252
253        #[cfg(feature = "NSArray")]
254        #[unsafe(method(arguments))]
255        #[unsafe(method_family = none)]
256        pub fn arguments(&self) -> Option<Retained<NSArray<NSExpression>>>;
257
258        #[unsafe(method(collection))]
259        #[unsafe(method_family = none)]
260        pub fn collection(&self) -> Retained<AnyObject>;
261
262        #[cfg(feature = "NSPredicate")]
263        #[unsafe(method(predicate))]
264        #[unsafe(method_family = none)]
265        pub fn predicate(&self) -> Retained<NSPredicate>;
266
267        #[unsafe(method(leftExpression))]
268        #[unsafe(method_family = none)]
269        pub fn leftExpression(&self) -> Retained<NSExpression>;
270
271        #[unsafe(method(rightExpression))]
272        #[unsafe(method_family = none)]
273        pub fn rightExpression(&self) -> Retained<NSExpression>;
274
275        #[unsafe(method(trueExpression))]
276        #[unsafe(method_family = none)]
277        pub fn trueExpression(&self) -> Retained<NSExpression>;
278
279        #[unsafe(method(falseExpression))]
280        #[unsafe(method_family = none)]
281        pub fn falseExpression(&self) -> Retained<NSExpression>;
282
283        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "block2"))]
284        /// # Safety
285        ///
286        /// - The returned block's argument 1 must be a valid pointer or null.
287        /// - The returned block's argument 2 must be a valid pointer.
288        /// - The returned block's argument 3 must be a valid pointer or null.
289        #[unsafe(method(expressionBlock))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn expressionBlock(
292            &self,
293        ) -> NonNull<
294            block2::DynBlock<
295                dyn Fn(
296                    *mut AnyObject,
297                    NonNull<NSArray<NSExpression>>,
298                    *mut NSMutableDictionary,
299                ) -> NonNull<AnyObject>,
300            >,
301        >;
302
303        #[cfg(feature = "NSDictionary")]
304        /// # Safety
305        ///
306        /// - `object` should be of the correct type.
307        /// - `context` generic should be of the correct type.
308        #[unsafe(method(expressionValueWithObject:context:))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn expressionValueWithObject_context(
311            &self,
312            object: Option<&AnyObject>,
313            context: Option<&NSMutableDictionary>,
314        ) -> Option<Retained<AnyObject>>;
315
316        #[unsafe(method(allowEvaluation))]
317        #[unsafe(method_family = none)]
318        pub fn allowEvaluation(&self);
319    );
320}
321
322/// Methods declared on superclass `NSObject`.
323impl NSExpression {
324    extern_methods!(
325        #[unsafe(method(init))]
326        #[unsafe(method_family = init)]
327        pub fn init(this: Allocated<Self>) -> Retained<Self>;
328
329        #[unsafe(method(new))]
330        #[unsafe(method_family = new)]
331        pub fn new() -> Retained<Self>;
332    );
333}
334
335impl DefaultRetained for NSExpression {
336    #[inline]
337    fn default_retained() -> Retained<Self> {
338        Self::new()
339    }
340}