//! 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::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsdrawingactions?language=objc)
#[cfg(all(feature = "UIGraphicsRenderer", feature = "block2"))]
pub type UIGraphicsDrawingActions =
    *mut block2::DynBlock<dyn Fn(NonNull<UIGraphicsRendererContext>)>;

/// UIGraphicsRendererProtected.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsRenderer {
    extern_methods!(
        #[unsafe(method(rendererContextClass))]
        #[unsafe(method_family = none)]
        pub fn rendererContextClass() -> &'static AnyClass;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(contextWithFormat:))]
        // required for soundness, method has `returns_retained` attribute.
        #[unsafe(method_family = copy)]
        pub fn contextWithFormat(format: &UIGraphicsRendererFormat) -> Option<Retained<CGContext>>;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(prepareCGContext:withRendererContext:))]
        #[unsafe(method_family = none)]
        pub fn prepareCGContext_withRendererContext(
            context: &CGContext,
            renderer_context: &UIGraphicsRendererContext,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// - `drawing_actions` must be a valid pointer.
        /// - `completion_actions` must be a valid pointer or null.
        #[unsafe(method(runDrawingActions:completionActions:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn runDrawingActions_completionActions_error(
            &self,
            drawing_actions: UIGraphicsDrawingActions,
            completion_actions: UIGraphicsDrawingActions,
        ) -> Result<(), Retained<NSError>>;
    );
}
