Skip to content

Instantly share code, notes, and snippets.

@hean01

hean01/hello.rs Secret

Created June 5, 2017 19:03
Show Gist options
  • Save hean01/65b8c600f8cceec4d651a93ca8656e24 to your computer and use it in GitHub Desktop.
Save hean01/65b8c600f8cceec4d651a93ca8656e24 to your computer and use it in GitHub Desktop.
extern crate mujs;
use std::ffi::{CStr, CString};
pub fn main() {
use mujs;
let mut state = mujs::State::new(mujs::JS_STRICT);
// create a function
state.newfunction( move |x| {
println!("Hello {:?}!", x.tostring(1).unwrap());
}, "myfunc", 0);
state.setglobal("hello");
// call function
state.getglobal("hello");
state.pushundefined();
state.pushstring("world");
state.call(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment