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

Make cxx.h available to high level code generators. #364

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ This directory contains CXX's C++ code generator. This code generator has two
public frontends, one a command-line application (binary) in the *cmd* directory
and the other a library intended to be used from a build.rs in the *build*
directory.

There's also a 'lib' frontend which is intended to allow higher level code generators
to embed cxx. This is not yet recommended for general use.
6 changes: 6 additions & 0 deletions gen/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod syntax;
pub use crate::error::Error;
pub use crate::gen::{GeneratedCode, Opt};
use proc_macro2::TokenStream;
use gen::include::HEADER;

/// Generate C++ bindings code from a Rust token stream. This should be a Rust
/// token stream which somewhere contains a `#[cxx::bridge] mod {}`.
Expand All @@ -31,3 +32,8 @@ pub fn generate_header_and_cc(rust_source: TokenStream, opt: &Opt) -> Result<Gen
.map_err(Error::from)?;
gen::generate(syntax, opt).map_err(Error::from)
}

/// Returns the complete contents of the cxx.h header.
pub fn get_cxx_header_contents() -> &'static str {
HEADER
}