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

Generate interface to C++ code #4

Open
nils-ohlmeier opened this issue May 28, 2017 · 4 comments
Open

Generate interface to C++ code #4

nils-ohlmeier opened this issue May 28, 2017 · 4 comments

Comments

@nils-ohlmeier
Copy link
Collaborator

No description provided.

@Paul-E
Copy link
Contributor

Paul-E commented Jun 6, 2017

Looks like there is some documentation for getting rust into FF:

This appears to list of the current (root level) rust components of FF.

For example this is a URL parser written in rust. It looks like they split it up into a pure rust part, and the code you see in dxr is the interface into the rest of FF.

Juicy bits

Looking at the example of the mp4 parser, it looks like they use repr(C) to make rust use the C struct layout. eg rust & C++ version of the mp4parse_track_video_info struct. And then pass it around as a raw pointer. To get a raw pointer it appears you Box::into_raw(Box::new(foo)), example 1 example 2

@Paul-E Paul-E self-assigned this Jun 17, 2017
@jrmuizel
Copy link

It might be worth considering using https://github.com/eqrion/cbindgen/ for this. It's what we use to generate c bindings for webrender.

@nils-ohlmeier
Copy link
Collaborator Author

nils-ohlmeier commented Aug 18, 2017

@jrmuizel thanks for the pointer. We briefly looked at other binding generators, but failed to find a suitable one. cbindgen looks interesting

@na-g
Copy link
Collaborator

na-g commented Jul 11, 2019

We should definitely provide them as a first class part of the library. That is we should be able to annotate the structs and functions in the library without the need of any wrapper library. That way we can have CI coverage of the FFI, the FFI will always be in sync, and it will prevent us from accidentally making commits that cause problems for cbindgen.

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

No branches or pull requests

4 participants