~tim/scheme-vm

ref: 82e799de37eb74f44fef9422a1cc72e4a56ac1fa scheme-vm/src/lib.rs -rw-r--r-- 564 bytes
82e799deTim Morgan Use ruby-sys to integrate better with Ruby 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern crate libc;
extern crate ruby_sys;

mod values;
mod tests;

#[macro_use] mod rb;
use rb::{CallbackPtr, Value, RB_TRUE, RB_FALSE};

mod lisp {
    include!(concat!(env!("OUT_DIR"), "/lisp.rs"));
}

fn is_ok(_rself: Value, program: Value) -> Value {
    let program_str = rbstr2str!(&program);
    if lisp::program(&program_str).is_ok() {
        RB_TRUE
    } else {
        RB_FALSE
    }
}

#[no_mangle]
pub extern fn init_parser() {
  let m_parser = rb::define_module("Parser");
  rb::define_singleton_method(&m_parser, "ok?", is_ok as CallbackPtr, 1);
}