~tim/scheme-vm

ac6b8bca1104b34b18f766537d99fbc1be5c6b6b — Tim Morgan 4 years ago f730d3a
Playing around with ruby-sys
3 files changed, 6 insertions(+), 4 deletions(-)

M Cargo.toml
M src/lib.rs
M test.rb
M Cargo.toml => Cargo.toml +1 -0
@@ 9,6 9,7 @@ crate-type = ["dylib"]

[dependencies]
libc = "0.2.x"
ruby-sys = "0.2.20"

[build-dependencies]
peg = { git = "https://github.com/kevinmehall/rust-peg", branch = "master" }

M src/lib.rs => src/lib.rs +3 -2
@@ 1,4 1,5 @@
extern crate libc;
extern crate ruby_sys;

mod values;
mod tests;


@@ 8,10 9,10 @@ mod lisp {
}

#[no_mangle]
pub extern "C" fn is_ok(program_ptr: *const libc::c_char) -> libc::int8_t {
pub extern "C" fn is_ok(program_ptr: *const libc::c_char) -> i64 {
    let program = string_from_c_ptr(program_ptr);
    if lisp::program(&program).is_ok() {
        1
        0x14
    } else {
        0
    }

M test.rb => test.rb +2 -2
@@ 1,6 1,6 @@
require 'fiddle'

library = Fiddle::dlopen('target/release/libscheme_vm.dylib')
is_ok = Fiddle::Function.new(library['is_ok'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_SHORT)
is_ok = Fiddle::Function.new(library['is_ok'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP)

p is_ok.call(ARGV.first) == 1
p is_ok.call(ARGV.first)