objc2-gameplay-kit 0.3.2

Bindings to the GameplayKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkgridgraph?language=objc)
    #[unsafe(super(GKGraph, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
    pub struct GKGridGraph<NodeType: ?Sized = AnyObject>;
);

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
impl<NodeType: ?Sized + Message + AsRef<GKGridGraphNode>> GKGridGraph<NodeType> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewNodeType: ?Sized + Message + AsRef<GKGridGraphNode>>(
        &self,
    ) -> &GKGridGraph<NewNodeType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
extern_conformance!(
    unsafe impl<NodeType: ?Sized + NSCoding + AsRef<GKGridGraphNode>> NSCoding
        for GKGridGraph<NodeType>
    {
    }
);

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
extern_conformance!(
    unsafe impl<NodeType: ?Sized + AsRef<GKGridGraphNode>> NSCopying for GKGridGraph<NodeType> {}
);

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
unsafe impl<NodeType: ?Sized + Message + AsRef<GKGridGraphNode>> CopyingHelper
    for GKGridGraph<NodeType>
{
    type Result = Self;
}

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
extern_conformance!(
    unsafe impl<NodeType: ?Sized + AsRef<GKGridGraphNode>> NSObjectProtocol for GKGridGraph<NodeType> {}
);

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
extern_conformance!(
    unsafe impl<NodeType: ?Sized + NSSecureCoding + AsRef<GKGridGraphNode>> NSSecureCoding
        for GKGridGraph<NodeType>
    {
    }
);

#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
impl<NodeType: Message + AsRef<GKGridGraphNode>> GKGridGraph<NodeType> {
    extern_methods!(
        #[unsafe(method(gridWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn gridWidth(&self) -> NSUInteger;

        #[unsafe(method(gridHeight))]
        #[unsafe(method_family = none)]
        pub unsafe fn gridHeight(&self) -> NSUInteger;

        #[unsafe(method(diagonalsAllowed))]
        #[unsafe(method_family = none)]
        pub unsafe fn diagonalsAllowed(&self) -> bool;

        /// Connects the given GKGridGraphNode to this graph by connecting it to it's adjacent nodes on the grid
        /// Input node must have coordinates within the rectangle specified by minCoordinates and maxCoordinates
        ///
        /// Parameter `node`: the node to be connected
        #[unsafe(method(connectNodeToAdjacentNodes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectNodeToAdjacentNodes(&self, node: &GKGridGraphNode);

        /// Returns the class of the specified generic index
        #[unsafe(method(classForGenericArgumentAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn classForGenericArgumentAtIndex(&self, index: NSUInteger)
            -> &'static AnyClass;
    );
}

/// Methods declared on superclass `GKGraph`.
#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
impl<NodeType: Message + AsRef<GKGridGraphNode>> GKGridGraph<NodeType> {
    extern_methods!(
        /// Creates a graph with the provided array of nodes.
        ///
        /// Parameter `nodes`: the nodes to create the graph with
        #[unsafe(method(graphWithNodes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn graphWithNodes(nodes: &NSArray<GKGraphNode>) -> Retained<Self>;

        #[unsafe(method(initWithNodes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNodes(
            this: Allocated<Self>,
            nodes: &NSArray<GKGraphNode>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
impl<NodeType: Message + AsRef<GKGridGraphNode>> GKGridGraph<NodeType> {
    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>;
    );
}