Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Jan 12, 2025
1 parent 1ba7ba9 commit 3e5a768
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 45 deletions.
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

[![Latest Version]][crates.io]
[![docs]][docs.rs]
![MIT]
[![Rust](https://img.shields.io/badge/rust-1.53%2B-blue.svg?maxAge=3600)](https://github.com/ralfbiedert/interoptopus)
[![Rust](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml)
[![crates.io-badge]][crates.io-url]
[![docs.rs-badge]][docs.rs-url]
![license-badge]
[![rust-version-badge]][rust-version-url]
[![rust-build-badge]][rust-build-url]

![sample_image](https://media.githubusercontent.com/media/ralfbiedert/interoptopus/master/gfx/mascot_stable_diffusion.jpg)

Expand Down Expand Up @@ -154,15 +154,19 @@ PRs are welcome.

- Submit small bug fixes directly. Major changes should be issues first.
- Anything that makes previously working bindings change behavior or stop compiling
is a major change;
is a major change;
- This doesn't mean we're opposed to breaking stuff just that
we'd like to talk about it before it happens.
we'd like to talk about it before it happens.
- New features or patterns must be materialized in the reference project and accompanied by
an interop test (i.e., a backend test running C# / Python against a DLL invoking that code)
in at least one included backend.

[Latest Version]: https://img.shields.io/crates/v/interoptopus.svg
[crates.io]: https://crates.io/crates/interoptopus
[MIT]: https://img.shields.io/badge/license-MIT-blue.svg
[docs]: https://docs.rs/interoptopus/badge.svg
[docs.rs]: https://docs.rs/interoptopus/
an interop test (i.e., a backend test running C# / Python against a DLL invoking that code)
in at least one included backend.

[crates.io-badge]: https://img.shields.io/crates/v/interoptopus.svg
[crates.io-url]: https://crates.io/crates/interoptopus
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[docs.rs-badge]: https://docs.rs/interoptopus/badge.svg
[docs.rs-url]: https://docs.rs/interoptopus/
[rust-version-badge]: https://img.shields.io/badge/rust-1.83%2B-blue.svg?maxAge=3600
[rust-version-url]: https://github.com/ralfbiedert/interoptopus
[rust-build-badge]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg
[rust-build-url]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml
22 changes: 20 additions & 2 deletions UPGRADE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Tips for solving non-trivial breaking changes when upgrading from previous versi

### 0.14 → 0.15

#### Core Library

- Exported functions (`#[ffi_function]`) don't need to specify `#[no_mangle]` or `extern "C"` anymore as these will be
added automatically.
- Exported types (`#[ffi_type]`) must not specify `#[repr(...)]` anymore as we will handle that. If you need custom
Expand All @@ -13,8 +15,7 @@ Tips for solving non-trivial breaking changes when upgrading from previous versi
they will silently return. If this is not acceptable you must return `Result` or specify a different panic behavior
via that attribute.
- `#[ffi_type(patterns(ffi_error))]` is now `#[ffi_type(error)]`.
- If you used the C# `DotNet` or `Unity` overload writer, these helpers now take their own configuration
where appropriate. If you previously only did `DotNet::new()` this became `DotNet::new_built()`.
- The concept of overload writers has been removed entirely.
- `AsciiPointer` is now called `CStrPointer`, since it can contain non-ASCII data (e.g., when called from C#).
- We fixed capitalization in some backends, e.g., a `Sliceu8` is now `SliceU8`.
- When using `InventoryBuilder` you should call `.validate().inventory()` now.
Expand All @@ -29,6 +30,23 @@ Tips for solving non-trivial breaking changes when upgrading from previous versi
- Backend-related testing functions were moved into an internal `tests` project, as the code was mostly specific to our
project needs anyway.

#### C# Backend

- Unity support was dropped due to a lack of bandwidth on my side and compat issues,
compare [this issue](https://github.com/ralfbiedert/interoptopus/issues/133). If you need
Unity support you should stick with 0.14, wait for Unity to support .NET 8.0, or fork the C# backend. For the latter
option I happily help you get started, please post a comment in the linked issue.
- ~~If you used the C# `DotNet` or `Unity` overload writer, these helpers now take their own configuration
where appropriate. If you previously only did `DotNet::new()` this became `DotNet::new_built()`.~~
- The concept of overload writers was removed entirely.
- The minimum supported C# version was bumped to 8.0
- We're using `LibraryImport` instead of `DLLImport` now, which should be significantly faster
- The concept of `Safe` vs `Unsafe` bindings was removed. Everything is `unsafe` now. This means in your
`.csproj`
you should set `<AllowUnsafeBlocks>true</AllowUnsafeBlocks>`. This greatly simplified some code, and if you haven't
used unsafe before you'll get a massive speed boost. If you shipped safe bindings to customers without a `.csproj`
file so far, you should now ship them with a `.csproj` file that enables that flag instead.

### 0.13 → 0.14

- Removed `inventory!` macro
Expand Down
4 changes: 1 addition & 3 deletions crates/backend_csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ use interoptopus::{Error, Interop};
#[test]
fn bindings_csharp() -> Result<(), Error> {
use interoptopus_backend_csharp::{Config, Generator};
use interoptopus_backend_csharp::overloads::{DotNet, Unity};

let config = Config {
dll_name: "example_library".to_string(),
Expand All @@ -66,7 +65,6 @@ fn bindings_csharp() -> Result<(), Error> {
};

Generator::new(config, example_library_ffi::my_inventory())
.add_overload_writer(DotNet::new())
//.add_overload_writer(Unity::new())
.write_file("bindings/csharp/Interop.cs")?;

Expand Down Expand Up @@ -98,7 +96,7 @@ namespace My.Company
public const string NativeLib = "example_library";

/// Function using the type.
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "my_function")]
[LibraryImport(NativeLib, EntryPoint = "my_function")]
public static extern Vec2 my_function(Vec2 input);
}

Expand Down
34 changes: 19 additions & 15 deletions crates/core/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

[![Latest Version]][crates.io]
[![docs]][docs.rs]
![MIT]
[![Rust](https://img.shields.io/badge/rust-1.53%2B-blue.svg?maxAge=3600)](https://github.com/ralfbiedert/interoptopus)
[![Rust](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml)
[![crates.io-badge]][crates.io-url]
[![docs.rs-badge]][docs.rs-url]
![license-badge]
[![rust-version-badge]][rust-version-url]
[![rust-build-badge]][rust-build-url]

![sample_image](https://media.githubusercontent.com/media/ralfbiedert/interoptopus/master/gfx/mascot_stable_diffusion.jpg)

Expand Down Expand Up @@ -154,15 +154,19 @@ PRs are welcome.

- Submit small bug fixes directly. Major changes should be issues first.
- Anything that makes previously working bindings change behavior or stop compiling
is a major change;
is a major change;
- This doesn't mean we're opposed to breaking stuff just that
we'd like to talk about it before it happens.
we'd like to talk about it before it happens.
- New features or patterns must be materialized in the reference project and accompanied by
an interop test (i.e., a backend test running C# / Python against a DLL invoking that code)
in at least one included backend.

[Latest Version]: https://img.shields.io/crates/v/interoptopus.svg
[crates.io]: https://crates.io/crates/interoptopus
[MIT]: https://img.shields.io/badge/license-MIT-blue.svg
[docs]: https://docs.rs/interoptopus/badge.svg
[docs.rs]: https://docs.rs/interoptopus/
an interop test (i.e., a backend test running C# / Python against a DLL invoking that code)
in at least one included backend.

[crates.io-badge]: https://img.shields.io/crates/v/interoptopus.svg
[crates.io-url]: https://crates.io/crates/interoptopus
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[docs.rs-badge]: https://docs.rs/interoptopus/badge.svg
[docs.rs-url]: https://docs.rs/interoptopus/
[rust-version-badge]: https://img.shields.io/badge/rust-1.83%2B-blue.svg?maxAge=3600
[rust-version-url]: https://github.com/ralfbiedert/interoptopus
[rust-build-badge]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg
[rust-build-url]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml
24 changes: 14 additions & 10 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![cfg_attr(docsrs, feature(doc_cfg))] // does this work?
//!
//! [![Latest Version]][crates.io]
//! [![docs]][docs.rs]
//! ![MIT]
//! [![Rust](https://img.shields.io/badge/rust-1.53%2B-blue.svg?maxAge=3600)](https://github.com/ralfbiedert/interoptopus)
//! [![Rust](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml)
//! [![crates.io-badge]][crates.io-url]
//! [![docs.rs-badge]][docs.rs-url]
//! ![license-badge]
//! [![rust-version-badge]][rust-version-url]
//! [![rust-build-badge]][rust-build-url]
//!
//! ![sample_image](https://media.githubusercontent.com/media/ralfbiedert/interoptopus/master/gfx/mascot_stable_diffusion.jpg)
//!
Expand Down Expand Up @@ -162,11 +162,15 @@
//! an interop test (i.e., a backend test running C# / Python against a DLL invoking that code)
//! in at least one included backend.
//!
//! [Latest Version]: https://img.shields.io/crates/v/interoptopus.svg
//! [crates.io]: https://crates.io/crates/interoptopus
//! [MIT]: https://img.shields.io/badge/license-MIT-blue.svg
//! [docs]: https://docs.rs/interoptopus/badge.svg
//! [docs.rs]: https://docs.rs/interoptopus/
//! [crates.io-badge]: https://img.shields.io/crates/v/interoptopus.svg
//! [crates.io-url]: https://crates.io/crates/interoptopus
//! [license-badge]: https://img.shields.io/badge/license-MIT-blue.svg
//! [docs.rs-badge]: https://docs.rs/interoptopus/badge.svg
//! [docs.rs-url]: https://docs.rs/interoptopus/
//! [rust-version-badge]: https://img.shields.io/badge/rust-1.83%2B-blue.svg?maxAge=3600
//! [rust-version-url]: https://github.com/ralfbiedert/interoptopus
//! [rust-build-badge]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml/badge.svg
//! [rust-build-url]: https://github.com/ralfbiedert/interoptopus/actions/workflows/rust.yml
pub use crate::core::{merge_inventories, non_service_functions, Inventory, InventoryBuilder, InventoryItem, Symbol};
pub use error::Error;
Expand Down

0 comments on commit 3e5a768

Please sign in to comment.