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

Commit

Permalink
Don't expose codegen functions
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed May 18, 2015
1 parent 551bc93 commit a08065b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
40 changes: 28 additions & 12 deletions quasi_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![feature(plugin_registrar, unboxed_closures, rustc_private)]

extern crate aster;
extern crate rustc;
extern crate syntax;

use syntax::ast;
Expand All @@ -28,7 +29,7 @@ use syntax::ptr::P;
/// construction of the same token tree, with token::SubstNt interpreted
/// as antiquotes (splices).
pub fn expand_quote_tokens<'cx>(
fn expand_quote_tokens<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree],
Expand All @@ -38,7 +39,7 @@ pub fn expand_quote_tokens<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_ty<'cx>(
fn expand_quote_ty<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -47,7 +48,7 @@ pub fn expand_quote_ty<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_expr<'cx>(
fn expand_quote_expr<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -56,7 +57,7 @@ pub fn expand_quote_expr<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_stmt<'cx>(
fn expand_quote_stmt<'cx>(
cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -65,7 +66,7 @@ pub fn expand_quote_stmt<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_attr<'cx>(
fn expand_quote_attr<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -78,7 +79,7 @@ pub fn expand_quote_attr<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_matcher<'cx>(
fn expand_quote_matcher<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -97,7 +98,7 @@ pub fn expand_quote_matcher<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_pat<'cx>(
fn expand_quote_pat<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -106,7 +107,7 @@ pub fn expand_quote_pat<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_arm<'cx>(
fn expand_quote_arm<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -115,7 +116,7 @@ pub fn expand_quote_arm<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_block<'cx>(
fn expand_quote_block<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -124,7 +125,7 @@ pub fn expand_quote_block<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_item<'cx>(
fn expand_quote_item<'cx>(
cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -134,7 +135,7 @@ pub fn expand_quote_item<'cx>(
base::MacEager::expr(expanded)
}

pub fn expand_quote_impl_item<'cx>(
fn expand_quote_impl_item<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree]
Expand All @@ -145,7 +146,7 @@ pub fn expand_quote_impl_item<'cx>(
}

/*
pub fn expand_quote_where_clause<'cx>(cx: &mut ExtCtxt,
fn expand_quote_where_clause<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[ast::TokenTree])
-> Box<base::MacResult+'cx> {
Expand Down Expand Up @@ -656,3 +657,18 @@ fn expand_parse_call(cx: &ExtCtxt,
expand_wrapper(sp, cx_expr, expr, &[&["quasi"]])
}
}

pub fn register(reg: &mut rustc::plugin::Registry) {
reg.register_macro("quote_tokens", expand_quote_tokens);
reg.register_macro("quote_ty", expand_quote_ty);
reg.register_macro("quote_expr", expand_quote_expr);
reg.register_macro("quote_matcher", expand_quote_matcher);
reg.register_macro("quote_stmt", expand_quote_stmt);
reg.register_macro("quote_attr", expand_quote_attr);
reg.register_macro("quote_pat", expand_quote_pat);
reg.register_macro("quote_arm", expand_quote_arm);
reg.register_macro("quote_block", expand_quote_block);
reg.register_macro("quote_item", expand_quote_item);
reg.register_macro("quote_impl_item", expand_quote_impl_item);
//reg.register_macro("quote_where_clause", expand_quote_where_clause);
}
17 changes: 2 additions & 15 deletions quasi_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@
extern crate quasi_codegen;
extern crate rustc;

use rustc::plugin::Registry;

#[plugin_registrar]
#[doc(hidden)]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("quote_tokens", quasi_codegen::expand_quote_tokens);
reg.register_macro("quote_ty", quasi_codegen::expand_quote_ty);
reg.register_macro("quote_expr", quasi_codegen::expand_quote_expr);
reg.register_macro("quote_matcher", quasi_codegen::expand_quote_matcher);
reg.register_macro("quote_stmt", quasi_codegen::expand_quote_stmt);
reg.register_macro("quote_attr", quasi_codegen::expand_quote_attr);
reg.register_macro("quote_pat", quasi_codegen::expand_quote_pat);
reg.register_macro("quote_arm", quasi_codegen::expand_quote_arm);
reg.register_macro("quote_block", quasi_codegen::expand_quote_block);
reg.register_macro("quote_item", quasi_codegen::expand_quote_item);
reg.register_macro("quote_impl_item", quasi_codegen::expand_quote_impl_item);
//reg.register_macro("quote_where_clause", quasi_codegen::expand_quote_where_clause);
pub fn plugin_registrar(reg: &mut rustc::plugin::Registry) {
quasi_codegen::register(reg);
}

0 comments on commit a08065b

Please sign in to comment.