objc2-game-controller 0.3.2

Bindings to the GameController 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcpoint2?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GCPoint2 {
    pub x: c_float,
    pub y: c_float,
}

unsafe impl Encode for GCPoint2 {
    const ENCODING: Encoding =
        Encoding::Struct("GCPoint2", &[<c_float>::ENCODING, <c_float>::ENCODING]);
}

unsafe impl RefEncode for GCPoint2 {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcpoint2zero?language=objc)
    pub static GCPoint2Zero: GCPoint2;
}

impl GCPoint2 {
    // TODO: pub fn GCPoint2Make(x: c_float,y: c_float,) -> GCPoint2;

    // TODO: pub fn GCPoint2Equal(point1: GCPoint2,point2: GCPoint2,) -> bool;
}

#[inline]
pub unsafe extern "C-unwind" fn NSStringFromGCPoint2(point: GCPoint2) -> Retained<NSString> {
    extern "C-unwind" {
        fn NSStringFromGCPoint2(point: GCPoint2) -> *mut NSString;
    }
    let ret = unsafe { NSStringFromGCPoint2(point) };
    unsafe { Retained::retain_autoreleased(ret) }
        .expect("function was marked as returning non-null, but actually returned NULL")
}

mod private_NSValueGCTypes {
    pub trait Sealed {}
}

/// Category "GCTypes" on [`NSValue`].
#[doc(alias = "GCTypes")]
pub unsafe trait NSValueGCTypes: ClassType + Sized + private_NSValueGCTypes::Sealed {
    extern_methods!(
        #[unsafe(method(valueWithGCPoint2:))]
        #[unsafe(method_family = none)]
        unsafe fn valueWithGCPoint2(point: GCPoint2) -> Retained<Self>;

        #[unsafe(method(GCPoint2Value))]
        #[unsafe(method_family = none)]
        unsafe fn GCPoint2Value(&self) -> GCPoint2;
    );
}

impl private_NSValueGCTypes::Sealed for NSValue {}
unsafe impl NSValueGCTypes for NSValue {}