objc2-core-graphics 0.3.2

Bindings to the CoreGraphics framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfdictionary?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct CGPDFDictionary {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGPDFDictionary {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("CGPDFDictionary", &[]));
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfdictionaryref?language=objc)
pub type CGPDFDictionaryRef = *mut CGPDFDictionary;

impl CGPDFDictionary {
    /// # Safety
    ///
    /// `dict` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetCount")]
    #[inline]
    pub unsafe fn count(dict: CGPDFDictionaryRef) -> usize {
        extern "C-unwind" {
            fn CGPDFDictionaryGetCount(dict: CGPDFDictionaryRef) -> usize;
        }
        unsafe { CGPDFDictionaryGetCount(dict) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetObject")]
    #[cfg(feature = "CGPDFObject")]
    #[inline]
    pub unsafe fn object(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFObjectRef,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetObject(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFObjectRef,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetObject(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetBoolean")]
    #[cfg(feature = "CGPDFObject")]
    #[inline]
    pub unsafe fn boolean(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFBoolean,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetBoolean(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFBoolean,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetBoolean(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetInteger")]
    #[cfg(feature = "CGPDFObject")]
    #[inline]
    pub unsafe fn integer(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFInteger,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetInteger(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFInteger,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetInteger(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetNumber")]
    #[cfg(feature = "CGPDFObject")]
    #[inline]
    pub unsafe fn number(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFReal,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetNumber(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFReal,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetNumber(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetName")]
    #[inline]
    pub unsafe fn name(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut *const c_char,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetName(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut *const c_char,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetName(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetString")]
    #[cfg(feature = "CGPDFString")]
    #[inline]
    pub unsafe fn string(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFStringRef,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetString(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFStringRef,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetString(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetArray")]
    #[cfg(feature = "CGPDFArray")]
    #[inline]
    pub unsafe fn array(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFArrayRef,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetArray(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFArrayRef,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetArray(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetDictionary")]
    #[inline]
    pub unsafe fn dictionary(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFDictionaryRef,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetDictionary(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFDictionaryRef,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetDictionary(dict, key, value) }
    }

    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `key` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryGetStream")]
    #[cfg(feature = "CGPDFStream")]
    #[inline]
    pub unsafe fn stream(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFStreamRef,
    ) -> bool {
        extern "C-unwind" {
            fn CGPDFDictionaryGetStream(
                dict: CGPDFDictionaryRef,
                key: NonNull<c_char>,
                value: *mut CGPDFStreamRef,
            ) -> bool;
        }
        unsafe { CGPDFDictionaryGetStream(dict, key, value) }
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfdictionaryapplierfunction?language=objc)
#[cfg(feature = "CGPDFObject")]
pub type CGPDFDictionaryApplierFunction =
    Option<unsafe extern "C-unwind" fn(NonNull<c_char>, CGPDFObjectRef, *mut c_void)>;

impl CGPDFDictionary {
    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `function` must be implemented correctly.
    /// - `info` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryApplyFunction")]
    #[cfg(feature = "CGPDFObject")]
    #[inline]
    pub unsafe fn apply_function(
        dict: CGPDFDictionaryRef,
        function: CGPDFDictionaryApplierFunction,
        info: *mut c_void,
    ) {
        extern "C-unwind" {
            fn CGPDFDictionaryApplyFunction(
                dict: CGPDFDictionaryRef,
                function: CGPDFDictionaryApplierFunction,
                info: *mut c_void,
            );
        }
        unsafe { CGPDFDictionaryApplyFunction(dict, function, info) }
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfdictionaryapplierblock?language=objc)
#[cfg(all(feature = "CGPDFObject", feature = "block2"))]
pub type CGPDFDictionaryApplierBlock =
    *mut block2::DynBlock<dyn Fn(NonNull<c_char>, CGPDFObjectRef, *mut c_void) -> bool>;

impl CGPDFDictionary {
    /// # Safety
    ///
    /// - `dict` must be a valid pointer or null.
    /// - `block` must be a valid pointer or null.
    /// - `info` must be a valid pointer or null.
    #[doc(alias = "CGPDFDictionaryApplyBlock")]
    #[cfg(all(feature = "CGPDFObject", feature = "block2"))]
    #[inline]
    pub unsafe fn apply_block(
        dict: CGPDFDictionaryRef,
        block: CGPDFDictionaryApplierBlock,
        info: *mut c_void,
    ) {
        extern "C-unwind" {
            fn CGPDFDictionaryApplyBlock(
                dict: CGPDFDictionaryRef,
                block: CGPDFDictionaryApplierBlock,
                info: *mut c_void,
            );
        }
        unsafe { CGPDFDictionaryApplyBlock(dict, block, info) }
    }
}

extern "C-unwind" {
    #[deprecated = "renamed to `CGPDFDictionary::count`"]
    pub fn CGPDFDictionaryGetCount(dict: CGPDFDictionaryRef) -> usize;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFObject")]
    #[deprecated = "renamed to `CGPDFDictionary::object`"]
    pub fn CGPDFDictionaryGetObject(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFObjectRef,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFObject")]
    #[deprecated = "renamed to `CGPDFDictionary::boolean`"]
    pub fn CGPDFDictionaryGetBoolean(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFBoolean,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFObject")]
    #[deprecated = "renamed to `CGPDFDictionary::integer`"]
    pub fn CGPDFDictionaryGetInteger(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFInteger,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFObject")]
    #[deprecated = "renamed to `CGPDFDictionary::number`"]
    pub fn CGPDFDictionaryGetNumber(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFReal,
    ) -> bool;
}

extern "C-unwind" {
    #[deprecated = "renamed to `CGPDFDictionary::name`"]
    pub fn CGPDFDictionaryGetName(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut *const c_char,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFString")]
    #[deprecated = "renamed to `CGPDFDictionary::string`"]
    pub fn CGPDFDictionaryGetString(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFStringRef,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFArray")]
    #[deprecated = "renamed to `CGPDFDictionary::array`"]
    pub fn CGPDFDictionaryGetArray(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFArrayRef,
    ) -> bool;
}

extern "C-unwind" {
    #[deprecated = "renamed to `CGPDFDictionary::dictionary`"]
    pub fn CGPDFDictionaryGetDictionary(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFDictionaryRef,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFStream")]
    #[deprecated = "renamed to `CGPDFDictionary::stream`"]
    pub fn CGPDFDictionaryGetStream(
        dict: CGPDFDictionaryRef,
        key: NonNull<c_char>,
        value: *mut CGPDFStreamRef,
    ) -> bool;
}

extern "C-unwind" {
    #[cfg(feature = "CGPDFObject")]
    #[deprecated = "renamed to `CGPDFDictionary::apply_function`"]
    pub fn CGPDFDictionaryApplyFunction(
        dict: CGPDFDictionaryRef,
        function: CGPDFDictionaryApplierFunction,
        info: *mut c_void,
    );
}

extern "C-unwind" {
    #[cfg(all(feature = "CGPDFObject", feature = "block2"))]
    #[deprecated = "renamed to `CGPDFDictionary::apply_block`"]
    pub fn CGPDFDictionaryApplyBlock(
        dict: CGPDFDictionaryRef,
        block: CGPDFDictionaryApplierBlock,
        info: *mut c_void,
    );
}