fix msvc
This commit is contained in:
15
examples/cfunc.rs
Normal file
15
examples/cfunc.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
extern crate mruby_compiler2_sys;
|
||||
use mruby_compiler2_sys::MRubyCompiler2Context;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
unsafe {
|
||||
let mut cxt = MRubyCompiler2Context::new();
|
||||
cxt.compile_to_c_function(
|
||||
"puts \"Hello, mruby-compiler2!\"",
|
||||
"init_test_func",
|
||||
std::path::Path::new("examples/out.c"),
|
||||
)?;
|
||||
}
|
||||
println!("Created examples/out.c");
|
||||
Ok(())
|
||||
}
|
||||
17
examples/smoke.rs
Normal file
17
examples/smoke.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
extern crate mruby_compiler2_sys;
|
||||
use mruby_compiler2_sys::MRubyCompiler2Context;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
unsafe {
|
||||
let mut cxt = MRubyCompiler2Context::new();
|
||||
cxt.dump_bytecode("puts \"Hello, mruby-compiler2!\"")?;
|
||||
|
||||
let bin = cxt.compile("puts \"Hello, mruby-compiler2!\"")?;
|
||||
|
||||
let out = std::fs::File::create("examples/out.mrb")?;
|
||||
std::io::Write::write_all(&mut &out, &bin)?;
|
||||
|
||||
println!("Compiled bytecode file: examples/out.mrb, size: {}", bin.len());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user