Sean1708 / rusty-cheddar

A Rust crate for automatically generating C header files from Rust source file.
http://sean1708.github.io/rusty-cheddar/
191 stars 25 forks source link

Create interfaces to popular languages (python, ruby, etc.) #24

Open Sean1708 opened 8 years ago

Sean1708 commented 8 years ago

Probably require moving to a ParseSess based error handling.

Store the languages requested as a vector of trait-objects.

Hopefully be able to stop special casing C (so generating a header file would just be a case of requesting the C interface).

Sean1708 commented 8 years ago

It would be great to have the entire compiling logic as a trait, then people could implement their own languages.

Sean1708 commented 8 years ago

Maybe something along the lines of

struct Options {
    module: syntax::ast::Path,
    compiler: Vec<Box<Compiler>>,
}

struct Cheddar {
    input: Source,
    // So that all interfaces are put in the same place.
    output_dir: PathBuf
    options: Options,
    custom: String,
    session: syntax::parse::ParseSess,
}

trait Compiler {
    fn compile_type(new: Ident, old: Ty);
    fn compile_fn(name: Ident, params: ..., return: ...);
    ...
}