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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
extern_class!(
/// The individual node(s) that make up a GKQuadtree.
/// Used as a hint for faster removal via [GKQuadtree removeData:WithNode:]
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkquadtreenode?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKQuadtreeNode;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKQuadtreeNode {}
);
impl GKQuadtreeNode {
extern_methods!();
}
/// Methods declared on superclass `NSObject`.
impl GKQuadtreeNode {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// A tree data structure where each level has 4 children that subdivide a given space into the four quadrants.
/// Stores arbitrary NSObject data via points and quads.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkquadtree?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKQuadtree<ElementType: ?Sized = AnyObject>;
);
impl<ElementType: ?Sized + Message + AsRef<NSObject>> GKQuadtree<ElementType> {
/// Unchecked conversion of the generic parameter.
///
/// # Safety
///
/// The generic must be valid to reinterpret as the given type.
#[inline]
pub unsafe fn cast_unchecked<NewElementType: ?Sized + Message + AsRef<NSObject>>(
&self,
) -> &GKQuadtree<NewElementType> {
unsafe { &*((self as *const Self).cast()) }
}
}
extern_conformance!(
unsafe impl<ElementType: ?Sized + AsRef<NSObject>> NSObjectProtocol for GKQuadtree<ElementType> {}
);
impl<ElementType: Message + AsRef<NSObject>> GKQuadtree<ElementType> {
extern_methods!(
/// Removes the given NSObject from this quad tree.
/// Note that this is an exhaustive search and is slow.
/// Cache the relevant GKQuadTreeNode and use removeElement:WithNode: for better performance.
///
///
/// Parameter `element`: the data to be removed
///
/// Returns: returns YES if the data was removed, NO otherwise
#[unsafe(method(removeElement:))]
#[unsafe(method_family = none)]
pub unsafe fn removeElement(&self, element: &ElementType) -> bool;
/// Removes the given NSObject from the given quadtree node
/// Note that this is not an exhaustive search and is faster than removeData:
///
///
/// Parameter `data`: the data to be removed
///
/// Parameter `node`: the node in which this data resides
///
/// Returns: returns YES if the data was removed, NO otherwise
#[unsafe(method(removeElement:withNode:))]
#[unsafe(method_family = none)]
pub unsafe fn removeElement_withNode(
&self,
data: &ElementType,
node: &GKQuadtreeNode,
) -> bool;
);
}
/// Methods declared on superclass `NSObject`.
impl<ElementType: Message + AsRef<NSObject>> GKQuadtree<ElementType> {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}