objc2-sprite-kit 0.3.2

Bindings to the SpriteKit 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/spritekit/skshader?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SKShader;
);

extern_conformance!(
    unsafe impl NSCoding for SKShader {}
);

extern_conformance!(
    unsafe impl NSCopying for SKShader {}
);

unsafe impl CopyingHelper for SKShader {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SKShader {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SKShader {}
);

impl SKShader {
    extern_methods!(
        /// Create a custom shader with source code.
        ///
        ///
        /// Parameter `source`: the source code for the custom fragment shader.
        #[unsafe(method(initWithSource:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSource(this: Allocated<Self>, source: &NSString) -> Retained<Self>;

        #[cfg(feature = "SKUniform")]
        /// Create a custom shader with source code and uniforms.
        ///
        ///
        /// Parameter `source`: the source code for the custom fragment shader.
        ///
        /// Parameter `uniforms`: the array of uniforms supplied to this shader
        #[unsafe(method(initWithSource:uniforms:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSource_uniforms(
            this: Allocated<Self>,
            source: &NSString,
            uniforms: &NSArray<SKUniform>,
        ) -> Retained<Self>;

        #[unsafe(method(shader))]
        #[unsafe(method_family = none)]
        pub unsafe fn shader() -> Retained<Self>;

        #[unsafe(method(shaderWithSource:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shaderWithSource(source: &NSString) -> Retained<Self>;

        #[cfg(feature = "SKUniform")]
        #[unsafe(method(shaderWithSource:uniforms:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shaderWithSource_uniforms(
            source: &NSString,
            uniforms: &NSArray<SKUniform>,
        ) -> Retained<Self>;

        /// Loads a shader source file named 'name' from the main bundle. This is simpler yet functionally equivalent to the following code
        ///
        /// [SKShader shaderWithSource:[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:
        /// "
        /// fsh"]
        /// encoding:NSUTF8StringEncoding
        /// error:NULL]];
        ///
        /// The encoding is assumed to be NSUTF8StringEncoding.
        #[unsafe(method(shaderWithFileNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shaderWithFileNamed(name: &NSString) -> Retained<Self>;

        /// Shader source must define the 'main' method of the fragment shader
        ///
        /// Your shader must assign a premultipled fragment value to 'gl_FragColor'
        ///
        /// The following implicit uniforms are available:
        ///
        /// 1. sampler2D u_texture  (the primary texuture attached the the sprite)
        ///
        /// The following varyings are available:
        ///
        /// 1. vec2 v_tex_coord  (normalized texture coordiantes for the primary texture)
        /// 2. vec4 v_color_mix  (premultiplied color value based on color
        /// &
        /// alpha)
        ///
        /// The following functions are available:
        ///
        /// 1. vec4 SKDefaultShading()  (returns the fragment value that would have been output if no shader was used)
        ///
        ///
        /// Sample shader source that produces the same result are SpriteKit's normal rendering:
        ///
        /// "void main() { gl_FragColor = SKDefaultShading(); }"
        #[unsafe(method(source))]
        #[unsafe(method_family = none)]
        pub unsafe fn source(&self) -> Option<Retained<NSString>>;

        /// Setter for [`source`][Self::source].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSource:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSource(&self, source: Option<&NSString>);

        #[cfg(feature = "SKUniform")]
        /// You may define additional uniforms to be used in your shader here.
        /// There is no need to declare them in you source, just use them by name.
        ///
        /// All uniforms declared must be used within the source.
        #[unsafe(method(uniforms))]
        #[unsafe(method_family = none)]
        pub unsafe fn uniforms(&self) -> Retained<NSArray<SKUniform>>;

        #[cfg(feature = "SKUniform")]
        /// Setter for [`uniforms`][Self::uniforms].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setUniforms:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUniforms(&self, uniforms: &NSArray<SKUniform>);

        #[cfg(feature = "SKUniform")]
        #[unsafe(method(addUniform:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addUniform(&self, uniform: &SKUniform);

        #[cfg(feature = "SKUniform")]
        #[unsafe(method(uniformNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn uniformNamed(&self, name: &NSString) -> Option<Retained<SKUniform>>;

        #[unsafe(method(removeUniformNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeUniformNamed(&self, name: &NSString);

        #[cfg(feature = "SKAttribute")]
        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributes(&self) -> Retained<NSArray<SKAttribute>>;

        #[cfg(feature = "SKAttribute")]
        /// Setter for [`attributes`][Self::attributes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributes(&self, attributes: &NSArray<SKAttribute>);
    );
}

/// Methods declared on superclass `NSObject`.
impl SKShader {
    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>;
    );
}