-
Notifications
You must be signed in to change notification settings - Fork 3
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
C-Bindings #10
Comments
Actually, I do have some C bindings in another repo (I use this project from an android), but the code there is not so polished, and I'm very short of time. I'm happy to provide you with the code, and would be nice if you can do a pull request with it! (I don't think it requires much rust knowledge) |
Sounds good. I can not promise to find the time but will give it a try. |
Here you go: download link Unfortunately I don't have time to touch the code at all, so I didn't even try to hide random comments or useless logs. The code is not super nice, but you should be able to easily change it and use it from c. What you can do is the following. You can find functions like: #[no_mangle]
pub unsafe extern "C" fn Java_DataManagment_NavigatorBridge_00024Companion_getWalkTimeSeconds(
_: JNIEnv,
_: JClass,
meters: jint,
) -> jint {
RaptorNavigator::seconds_by_walk(meters as usize)
.try_into()
.unwrap()
} the weird name is due to the need of android JNI. In your case, you can make the previous like: #[no_mangle]
pub unsafe extern "C" fn getWalkTimeSeconds(
meters: i32,
) -> i32 {
RaptorNavigator::seconds_by_walk(meters as usize)
.try_into()
.unwrap()
} and compile it. The build output should be a library easily usable from c. Note that the crate in the zip depends on
P.S. I'm sure that there are better ways to create c bindings for rust code nowadays, automatically. (see https://github.com/rust-lang/rust-bindgen for example) PR are welcomed :) |
Hi,
I am not familiar with Rust but I have experience compiling rust to be used for Apple platform development (iOS, macOS etc).
To do this I would like to see some C-Bindings for this awesome project.
The text was updated successfully, but these errors were encountered: