use syntax::ast;
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ptr::P;
pub trait Language : Sync {
fn name(&self) -> &'static str;
fn plugger_crate_name(&self) -> &'static str;
fn marshall_path(&self, ecx: &mut ExtCtxt) -> ast::Path;
fn marshall_ty(&self, ecx: &mut ExtCtxt) -> P<ast::Ty> {
let path = self.marshall_path(ecx);
ecx.ty_path(path)
}
fn value_path(&self, ecx: &mut ExtCtxt) -> ast::Path;
fn value_ty(&self, ecx: &mut ExtCtxt) -> P<ast::Ty> {
let path = self.value_path(ecx);
ecx.ty_path(path)
}
}
pub static LANGUAGES: &'static [&'static Language] = &[
#[cfg(feature = "ruby")] &ruby::Ruby,
];
#[cfg(feature = "ruby")]
mod ruby {
use super::Language;
use syntax::codemap::DUMMY_SP;
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ast;
pub struct Ruby;
impl Language for Ruby {
fn name(&self) -> &'static str { "ruby" }
fn plugger_crate_name(&self) -> &'static str { "plugger_ruby" }
fn marshall_path(&self, ecx: &mut ExtCtxt) -> ast::Path {
ecx.path_global(DUMMY_SP, vec![
ast::Ident::from_str(self.plugger_crate_name()),
ast::Ident::from_str("Marshall")])
}
fn value_path(&self, ecx: &mut ExtCtxt) -> ast::Path {
ecx.path_global(DUMMY_SP, vec![
ast::Ident::from_str(self.plugger_crate_name()),
ast::Ident::from_str("Value"),
])
}
}
}