Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Add quasi_codegen::expand and remove the public dependency on syntex
Browse files Browse the repository at this point in the history
This helps to avoid the issue of incompatible syntex types being
passed between crates.
  • Loading branch information
erickt committed Jun 11, 2016
1 parent 7cb8b75 commit 29aaaba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.12.0

BACKWARDS INCOMPATIBILITIES / NOTES:

* Replaced `quasi_codegen::register`'s public dependency on `syntex` with
`quasi_codegen::expand`.
* Update to rustc 1.11.0-nightly (7d2f75a95 2016-06-09).

## 0.11.0

BACKWARDS INCOMPATIBILITIES / NOTES:
Expand Down
18 changes: 17 additions & 1 deletion quasi_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ extern crate syntax;
#[cfg(not(feature = "with-syntex"))]
extern crate rustc_plugin;

#[cfg(feature = "with-syntex")]
use std::io;

#[cfg(feature = "with-syntex")]
use std::path::Path;

use syntax::ast;
use syntax::codemap::{Span, respan};
use syntax::ext::base::ExtCtxt;
Expand Down Expand Up @@ -806,7 +812,17 @@ fn expand_parse_call(cx: &ExtCtxt,
}

#[cfg(feature = "with-syntex")]
pub fn register(reg: &mut syntex::Registry) {
pub fn expand<S, D>(src: S, dst: D) -> io::Result<()>
where S: AsRef<Path>,
D: AsRef<Path>,
{
let mut registry = syntex::Registry::new();
register(&mut registry);
registry.expand("", src.as_ref(), dst.as_ref())
}

#[cfg(feature = "with-syntex")]
fn register(reg: &mut syntex::Registry) {
reg.add_macro("quote_tokens", expand_quote_tokens);
reg.add_macro("quote_ty", expand_quote_ty);
reg.add_macro("quote_expr", expand_quote_expr);
Expand Down
5 changes: 1 addition & 4 deletions quasi_tests/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
extern crate syntex;
extern crate quasi_codegen;

use std::env;
use std::path::Path;

pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let mut registry = syntex::Registry::new();
quasi_codegen::register(&mut registry);

let src = Path::new("tests/test.rs.in");
let dst = Path::new(&out_dir).join("test.rs");

registry.expand("", &src, &dst).unwrap();
quasi_codegen::expand(&src, &dst).unwrap();
}

0 comments on commit 29aaaba

Please sign in to comment.