Skip to content

Releases: dtolnay/cxx

0.5.4

05 Nov 00:50
0.5.4
ce5b068
Compare
Choose a tag to compare
  • Fix no template named 'impl' error in modules containing a reference to &[u8] but no reference to Result

0.5.3

04 Nov 19:09
0.5.3
b3060c6
Compare
Choose a tag to compare
  • Add an item-level #[namespace = "..."] attribute to specify the C++ namespace path of an individual type or function (#370, #380, thanks @adetaylor)

    #[cxx::bridge]
    mod ffi {
        #[namespace = "the::path::of"]
        struct Thing {...}
    
        extern "C++" {
            #[namespace = "some::where::else"]
            fn function() -> Thing;
        }
    }
  • Emit diagnostic on include! paths relative to . or .., as the positioning of generated code inside of Cargo's OUT_DIR is not specified (#368, #375)

  • Treat C++ constructors rust::String(nullptr, 0) and rust::Str(nullptr, 0) as creating empty strings; previously UB (#383)

  • Enable rust::Str and rust::Slice<T> to be passed in registers by C++ (#387)

  • Eliminate warning from rustc 1.46+ when using function pointers in the signature of an extern C++ function (#396)

  • Support single Rust source file containing multiple #[cxx::bridge] modules (#397)

  • Expose a way to bypass is_trivially_destructible/_move_constructible check on extern types passed by value (#406)

    // IsRelocatable<T> is used in assertions that a C++ type passed by value
    // between Rust and C++ is soundly relocatable by Rust.
    //
    // There may be legitimate reasons to opt out of the check for support of types
    // that the programmer knows are soundly Rust-movable despite not being
    // recognized as such by the C++ type system due to a move constructor or
    // destructor. To opt out of the relocatability check, do either of the
    // following things in any header used by `include!` in the bridge.
    //
    //      --- if you define the type:
    //      struct MyType {
    //        ...
    //    +   using IsRelocatable = std::true_type;
    //      };
    //
    //      --- otherwise:
    //    + template <>
    //    + struct rust::IsRelocatable<MyType> : std::true_type {};
    template <typename T>
    struct IsRelocatable;
  • Fix error on pass-by-reference of a shared struct containing a Rust String to a C++ function (#408)

  • Make shared structs order-independent such that a struct is able to contain a field whose type is another shared struct defined later in the same FFI module (#411)

0.5.2

16 Oct 20:35
0.5.2
e37ce2f
Compare
Choose a tag to compare
  • Allow creation of UniquePtrs to extern type aliases of trivial extern types (#361, thanks @adetaylor)
  • Make contents of "rust/cxx.h" header available to high level code generators (#364, thanks @adetaylor)

0.5.1

10 Oct 05:32
0.5.1
52830f5
Compare
Choose a tag to compare
  • Enable functions to have a different name between Rust and C++ (#349)
    • Within cxx::bridge, write #[rust_name = "..."] or #[cxx_name = "..."] to make a change to either name of a function
    • In general many functions can have the same C++ name (due to overloading); every function must continue to have a unique Rust name
#[cxx::bridge]
mod ffi {
    extern "C++" {
        include!("path/to/header.h");

        #[cxx_name = "take"]
        fn take_int(i: i32);

        #[cxx_name = "take"] // different overload of the same name in C++
        fn take_str(s: &str);
    }
}

0.5.0

09 Oct 02:52
0.5.0
c499950
Compare
Choose a tag to compare

0.4.7

24 Sep 20:23
0.4.7
b312bb1
Compare
Choose a tag to compare
  • Add CxxVector::as_slice to get a &[T] from a C++ vector (#322)
  • Make --header command line flag optional when outputting to a file ending with .h extension (#318)
  • Support one cxxbridge command line invocation outputting both the generated header and generated source file (#319)

0.4.6

24 Sep 20:20
0.4.6
71912c3
Compare
Choose a tag to compare
  • Fix noncompilable generated code when returning Result<Box<T>> from Rust to C++ (#309, #311)

0.4.5

16 Sep 16:17
0.4.5
7ff80c4
Compare
Choose a tag to compare
  • Add -o/--output flag for cxxbridge CLI to control output location (#299)
  • Fix missing type in generated code in some cases involving Result (#301, thanks @Nehliin)
  • Support cross compilation to Windows (#302)

0.4.4

08 Sep 23:21
0.4.4
c4ff07b
Compare
Choose a tag to compare
  • Make rust::Error inherit publicly from std::exception so that it can be caught by catch (const std::exception &e) {

0.4.3

07 Sep 07:06
0.4.3
430b5de
Compare
Choose a tag to compare
  • Support working with a C++ namespace that contains Rust reserved words in the namespace path (#286)