From fee38529793e23f7f8ed33212a31d0d327ff4d55 Mon Sep 17 00:00:00 2001 From: jonathandturner Date: Thu, 3 Mar 2016 10:55:28 -0500 Subject: [PATCH] Move to lib style, move scripts into their own directory, start source examples --- src/main.rs => examples/rhai_runner.rs | 21 +++------------------ {examples => scripts}/assignment.rhai | 0 {examples => scripts}/function_decl1.rhai | 0 {examples => scripts}/function_decl2.rhai | 0 {examples => scripts}/function_decl3.rhai | 0 {examples => scripts}/if1.rhai | 0 {examples => scripts}/op1.rhai | 0 {examples => scripts}/op2.rhai | 0 {examples => scripts}/op3.rhai | 0 {examples => scripts}/speed_test.rhai | 0 {examples => scripts}/string.rhai | 0 {examples => scripts}/while.rhai | 0 src/lib.rs | 19 +++++++++++++++++++ 13 files changed, 22 insertions(+), 18 deletions(-) rename src/main.rs => examples/rhai_runner.rs (78%) rename {examples => scripts}/assignment.rhai (100%) rename {examples => scripts}/function_decl1.rhai (100%) rename {examples => scripts}/function_decl2.rhai (100%) rename {examples => scripts}/function_decl3.rhai (100%) rename {examples => scripts}/if1.rhai (100%) rename {examples => scripts}/op1.rhai (100%) rename {examples => scripts}/op2.rhai (100%) rename {examples => scripts}/op3.rhai (100%) rename {examples => scripts}/speed_test.rhai (100%) rename {examples => scripts}/string.rhai (100%) rename {examples => scripts}/while.rhai (100%) create mode 100644 src/lib.rs diff --git a/src/main.rs b/examples/rhai_runner.rs similarity index 78% rename from src/main.rs rename to examples/rhai_runner.rs index 31ded9a5..1b6730a2 100644 --- a/src/main.rs +++ b/examples/rhai_runner.rs @@ -3,24 +3,8 @@ use std::fs::File; use std::io::prelude::*; use std::fmt::Display; -mod engine; -use engine::Engine; - -mod fn_register; -use fn_register::FnRegister; - -mod parser; - -// Todo (in no particular order): -// * Doc some examples -// * Maintaining state -// * Overloading -// * How it works -// * Vectors -// * Return -// * Tighten parser? -// * Errors with positions? -// * Remove empty box values? +extern crate rhai; +use rhai::{Engine, FnRegister}; fn showit(x: &mut T) -> () { println!("{}", x) @@ -51,3 +35,4 @@ fn main() { } } } + diff --git a/examples/assignment.rhai b/scripts/assignment.rhai similarity index 100% rename from examples/assignment.rhai rename to scripts/assignment.rhai diff --git a/examples/function_decl1.rhai b/scripts/function_decl1.rhai similarity index 100% rename from examples/function_decl1.rhai rename to scripts/function_decl1.rhai diff --git a/examples/function_decl2.rhai b/scripts/function_decl2.rhai similarity index 100% rename from examples/function_decl2.rhai rename to scripts/function_decl2.rhai diff --git a/examples/function_decl3.rhai b/scripts/function_decl3.rhai similarity index 100% rename from examples/function_decl3.rhai rename to scripts/function_decl3.rhai diff --git a/examples/if1.rhai b/scripts/if1.rhai similarity index 100% rename from examples/if1.rhai rename to scripts/if1.rhai diff --git a/examples/op1.rhai b/scripts/op1.rhai similarity index 100% rename from examples/op1.rhai rename to scripts/op1.rhai diff --git a/examples/op2.rhai b/scripts/op2.rhai similarity index 100% rename from examples/op2.rhai rename to scripts/op2.rhai diff --git a/examples/op3.rhai b/scripts/op3.rhai similarity index 100% rename from examples/op3.rhai rename to scripts/op3.rhai diff --git a/examples/speed_test.rhai b/scripts/speed_test.rhai similarity index 100% rename from examples/speed_test.rhai rename to scripts/speed_test.rhai diff --git a/examples/string.rhai b/scripts/string.rhai similarity index 100% rename from examples/string.rhai rename to scripts/string.rhai diff --git a/examples/while.rhai b/scripts/while.rhai similarity index 100% rename from examples/while.rhai rename to scripts/while.rhai diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..7386c075 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,19 @@ +//! Rhai - embedded scripting for Rust + + +// Todo (in no particular order): +// * Doc some examples +// * Maintaining state +// * Overloading +// * How it works +// * Vectors +// * Tighten parser? +// * Errors with positions? + +mod engine; + +mod fn_register; +mod parser; + +pub use engine::Engine; +pub use fn_register::FnRegister;