Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate headers for third party crate? #1038

Open
videni opened this issue Jan 11, 2025 · 1 comment
Open

How to generate headers for third party crate? #1038

videni opened this issue Jan 11, 2025 · 1 comment

Comments

@videni
Copy link

videni commented Jan 11, 2025

Here is a rust example to illustrate the problem

my current crate

use crate::canvas::Canvas;
// app_surface is third party crate
pub use app_surface::{AppSurface, IOSViewObj};

#[no_mangle]
pub extern "C" fn create_canvas(ios_obj: IOSViewObj) -> *mut libc::c_void {
    println!(
        "create_canvas, maximum frames: {}",
        ios_obj.maximum_frames
    );
    
    let obj = Canvas::new(AppSurface::new(ios_obj), 0_i32);
    
    let box_obj = Box::new(obj);
    // 将 box_obj 对象的内存管理权转交给调用方
    Box::into_raw(box_obj) as *mut libc::c_void
}

third party crate


#[repr(C)]
pub struct IOSViewObj {
    pub view: *mut Object,
    pub metal_layer: *mut c_void,
    pub maximum_frames: i32,
    pub callback_to_swift: extern "C" fn(arg: i32),
}

No header found for IOSViewObj, got warning:

WARN: Can't find IOSViewObj. This usually means that this type was incompatible or not found.

@crazyboycjr
Copy link

Maybe you need to take a look at [parse] and potentially [parse.expand].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants