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

objc2-metal crate lacks makeLibrary(data:) #635

Closed
mxpv opened this issue Jun 28, 2024 · 2 comments
Closed

objc2-metal crate lacks makeLibrary(data:) #635

mxpv opened this issue Jun 28, 2024 · 2 comments
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request

Comments

@mxpv
Copy link

mxpv commented Jun 28, 2024

It looks like makeLibrary(data:) is not generated for objc2-metal crate. It is useful to load Metal's libraries from data in memory. This likely might require some further bindings to Dispatch Data (to create dispatch_data_t).

Here is an example of use case: https://github.com/gfx-rs/metal-rs/blob/2b7240232ca8621f22d2df58718919f67562feca/src/device.rs#L1727

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Jun 28, 2024
@madsmtm
Copy link
Owner

madsmtm commented Jun 28, 2024

Indeed it isn't, since like you said, it requires types from libdispatch, and that isn't yet mapped.

You can work around this by using msg_send_id! with its error conversion support, like the following:

type dispatch_data_t = *mut AnyObject;
// Create the dispatch data manually
let data: dispatch_data_t = dispatch_data_create(...);

let library: Result<Retained<MTLLibrary>, Retained<NSError>> = unsafe {
    msg_send_id![self, newLibraryWithData: data, error: _]
};

Feel free to ask further questions, but otherwise I'm going to close this, since it's already tracked in #77 (and the larger work is tracked in #556).

@madsmtm madsmtm closed this as completed Jun 28, 2024
@mxpv
Copy link
Author

mxpv commented Jun 28, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants