rust-qt / ritual

Use C++ libraries from Rust
Apache License 2.0
1.22k stars 49 forks source link

Attempting to port Clipper using the generator #79

Closed nick-parker closed 4 years ago

nick-parker commented 5 years ago

Hi folks,

I'm hoping to get this working myself and I'll update here if I do. Clipper is a powerful free 2D geometry manipulation library, and as far as I can tell it's a reasonably simple C++ codebase with just one header and one cpp file. A port of this library would be really handy for hacking on all sorts of GIS type problems in Rust.

Let me know if this seems like a reasonable target for this tool or not. In the meantime I'll be stumbling through your codebase.

Riateche commented 5 years ago

Hi. We've been thinking about providing an example of using our project on something other than Qt, and this library looks like a nice option. This is definitely the kind of library we want to support in the future.

However, right now there is one problem with making this work - we don't support the C++ standard library. Since Qt is completely usable without std, this has been a low priority goal. But your library seems to need at least std::vector, so we need some support for that. Once the std support is in place, generating a crate for the library should work.

Adding standard library support should be fairly easy in theory. Ritual would generate a separate crate providing the standard library's API, and all other crates would just use types provided by it, similar to how qt_core crate is now used as a dependency by all other Qt crates. However, I expect a couple of parsing issues because STL is full of tricky templates. There can also be cross-platform compatibility issues because the std headers provided by different compilers are different.

I may look into the std support issue, although I can't give any time estimate. Meanwhile, you can try to look into it yourself. You can also just try to process the library - the std types will be missing, but everything else will hopefully work, so it would be a good starting point.

Make sure to use the develop branch, since master is quite a bit behind (it's the previous alpha release). The docs are also outdated at the moment. Don't hesitate to ask anything - I'm willing to explain things.

Riateche commented 4 years ago

An example of processing a C++ library can now be found here. It uses Clipper as the target library.

nick-parker commented 4 years ago

Wow this is awesome! I've got about a hundred other things to do before revisiting the Rust project I need this port for, but congrats on starting std library support!