Lines Matching +full:cxxbridge +full:- +full:cmd
4 [<img alt="github" src="https://img.shields.io/badge/github-dtolnay/cxx-8da0cb?style=for-the-badge&…
5 [<img alt="crates.io" src="https://img.shields.io/crates/v/cxx.svg?style=for-the-badge&color=fc8d62…
6 [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-cxx-66c2a5?style=for-the-badge&labelC…
7 …/github/actions/workflow/status/dtolnay/cxx/ci.yml?branch=master&style=for-the-badge" height="20">…
11 using bindgen or cbindgen to generate unsafe C-style bindings.
23 [build-dependencies]
24 cxx-build = "1.0"
62 CXX guarantees an ABI-compatible signature that both sides understand, based on
74 of an existing C++ client for a large-file blobstore service. The blobstore
97 fn next_chunk(buf: &mut MultiBuf) -> &[u8];
111 fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
112 fn put(&self, parts: &mut MultiBuf) -> u64;
114 fn metadata(&self, blobid: u64) -> BlobMetadata;
125 - [demo/src/main.rs](demo/src/main.rs)
126 - [demo/build.rs](demo/build.rs)
127 - [demo/include/blobstore.h](demo/include/blobstore.h)
128 - [demo/src/blobstore.cc](demo/src/blobstore.cc)
135 # (requires https://github.com/dtolnay/cargo-expand)
136 $ cargo expand --manifest-path demo/Cargo.toml
139 $ cargo run --manifest-path gen/cmd/Cargo.toml -- demo/src/main.rs
149 - **Shared structs** — their fields are made visible to both languages.
152 - **Opaque types** — their fields are secret from the other language.
155 for an arbitrarily complicated generic language-specific type depending on
158 - **Functions** — implemented in either language, callable from the other
165 `use super::next_chunk` except re-exported to C++. The parent module will either
171 it's possible that this section could be generated bindgen-style from the
185 again inside the cxx::bridge module, though compile-time assertions guarantee
190 [bindgen]: https://github.com/rust-lang/rust-bindgen
197 bindgen-like tool on top of CXX which consumes a C++ header and/or Rust module
204 with an idiomatic C++ API we would end up manually wrapping that API in C-style
210 than `extern "C"` C-style signatures as the shared understanding, common FFI use
222 ## Cargo-based setup
237 [build-dependencies]
238 cxx-build = "1.0"
247 .flag_if_supported("-std=c++11")
248 .compile("cxxbridge-demo");
250 println!("cargo:rerun-if-changed=src/main.rs");
251 println!("cargo:rerun-if-changed=src/demo.cc");
252 println!("cargo:rerun-if-changed=include/demo.h");
258 ## Non-Cargo setup
260 For use in non-Cargo builds like Bazel or Buck, CXX provides an alternate way of
262 packaged as the `cxxbridge-cmd` crate on crates.io or can be built from the
263 *gen/cmd* directory of this repo.
266 $ cargo install cxxbridge-cmd
268 $ cxxbridge src/main.rs --header > path/to/mybridge.h
269 $ cxxbridge src/main.rs > path/to/mybridge.cc
286 - By design, our paired code generators work together to control both sides of
293 - Our static analysis detects and prevents passing types by value that shouldn't
297 - To many people's surprise, it is possible to have a struct in Rust and a
300 bindgen bug that leads to segfaults in absolutely correct-looking code
301 ([rust-lang/rust-bindgen#778]). CXX knows about this and can insert the
302 necessary zero-cost workaround transparently where needed, so go ahead and
306 - Template instantiations: for example in order to expose a UniquePtr\<T\> type
311 [rust-lang/rust-bindgen#778]: https://github.com/rust-lang/rust-bindgen/issues/778
335 <tr><td>fn(T, U) -> V</td><td>rust::Fn<V(T, U)></td><td><sup><i>only passing from Rust to …
345 matter of designing a nice API for each in its non-native language.
378 Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
379 2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
386 for inclusion in this project by you, as defined in the Apache-2.0 license,