pub unsafe fn make_new_handler<T>(
    name: &str,
    func: unsafe extern "C" fn(*mut T, id, id),
    data: *mut T,
) -> id {
    make_class_decl(name);

    let class = Class::get(name).unwrap();
    let instance: id = msg_send![class, alloc];
    let instance: id = msg_send![instance, init];
    log::debug!(
        "make_new_handler - Creating class instance this={:?}",
        instance
    );
    {
        let instance = instance.as_mut().unwrap();
        instance.set_ivar("instance_ptr", func as *mut c_void);
        instance.set_ivar("internal_data", data as *mut c_void);
    }

    log::debug!(
        "make_new_handler - Registering callback this={:?} data={:?} instance={:?}",
        instance,
        data as *mut c_void,
        func as *mut c_void
    );

    instance
}
/// Create a WebKit message handler class around the input function.
///
/// # Safety
/// Will panic if:
/// - The same name is used twice
Create a WebKit message handler class around the input function.
Create a WebKit message handler class around the input function .
pub unsafe fn make_new_handler<T>(
    name: &str,
    func: unsafe extern "C" fn(*mut T, id, id),
    data: *mut T,
) -> id {
    make_class_decl(name);
    let class = Class::get(name).unwrap();
    let instance: id = msg_send![class, alloc];
    let instance: id = msg_send![instance, init];
    log::debug!(
        "make_new_handler - Creating class instance this={:?}",
        instance
    );
    {
        let instance = instance.as_mut().unwrap();
        instance.set_ivar("instance_ptr", func as *mut c_void);
        instance.set_ivar("internal_data", data as *mut c_void);
    }
    log::debug!(
        "make_new_handler - Registering callback this={:?} data={:?} instance={:?}",
        instance,
        data as *mut c_void,
        func as *mut c_void
    );
    instance
}
pub unsafe fn make_new_handler < T > ( name : & str , func : unsafe extern " " fn ( * mut T , id , id ) , data : * mut T , ) -> id { make_class_decl ( name ) ; let class = Class :: get ( name ) . unwrap ( ) ; let instance : id = msg_send ! [ class alloc ] ; let instance : id = msg_send ! [ instance init ] ; log :: debug ! ( " " instance ) ; { let instance = instance . as_mut ( ) . unwrap ( ) ; instance . set_ivar ( " " , func as * mut c_void ) ; instance . set_ivar ( " " , data as * mut c_void ) ; } log :: debug ! ( " " instance data as mut c_void func as mut c_void ) ; instance }
Create a WebKit message handler class around the input function.
Create a WebKit message handler class around the input function .
name
&str
func
unsafe extern "C" fn(*mut T, id, id)
data
*mut T
name
&str
func
unsafe extern "C" fn(*mut T, id, id)
data
*mut T
safety
Will panic if:
The same name is used twice
Will panic if : The same name is used twice