codegen: add rhai_mod and submodule support
This commit is contained in:
29
codegen/ui_tests/rhai_mod_bad_attr.rs
Normal file
29
codegen/ui_tests/rhai_mod_bad_attr.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod(unknown = "thing")]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_bad_attr.stderr
Normal file
11
codegen/ui_tests/rhai_mod_bad_attr.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: unknown attribute 'unknown'
|
||||
--> $DIR/rhai_mod_bad_attr.rs:11:12
|
||||
|
|
||||
11 | #[rhai_mod(unknown = "thing")]
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_bad_attr.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
29
codegen/ui_tests/rhai_mod_bad_value.rs
Normal file
29
codegen/ui_tests/rhai_mod_bad_value.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod(name = true)]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_bad_value.stderr
Normal file
11
codegen/ui_tests/rhai_mod_bad_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting string literal
|
||||
--> $DIR/rhai_mod_bad_value.rs:11:19
|
||||
|
|
||||
11 | #[rhai_mod(name = true)]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_bad_value.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
29
codegen/ui_tests/rhai_mod_junk_arg.rs
Normal file
29
codegen/ui_tests/rhai_mod_junk_arg.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod("wheeeee")]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_junk_arg.stderr
Normal file
11
codegen/ui_tests/rhai_mod_junk_arg.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting identifier
|
||||
--> $DIR/rhai_mod_junk_arg.rs:11:12
|
||||
|
|
||||
11 | #[rhai_mod("wheeeee")]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_junk_arg.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
29
codegen/ui_tests/rhai_mod_missing_value.rs
Normal file
29
codegen/ui_tests/rhai_mod_missing_value.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod(name)]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_missing_value.stderr
Normal file
11
codegen/ui_tests/rhai_mod_missing_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: requires value
|
||||
--> $DIR/rhai_mod_missing_value.rs:11:12
|
||||
|
|
||||
11 | #[rhai_mod(name)]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_missing_value.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
29
codegen/ui_tests/rhai_mod_path_attr.rs
Normal file
29
codegen/ui_tests/rhai_mod_path_attr.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod(rhai::name = "thing")]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_path_attr.stderr
Normal file
11
codegen/ui_tests/rhai_mod_path_attr.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting attribute name
|
||||
--> $DIR/rhai_mod_path_attr.rs:11:12
|
||||
|
|
||||
11 | #[rhai_mod(rhai::name = "thing")]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_path_attr.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
29
codegen/ui_tests/rhai_mod_return_raw.rs
Normal file
29
codegen/ui_tests/rhai_mod_return_raw.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_mod(return_raw = "yes")]
|
||||
pub mod test_mod {
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_mod_return_raw.stderr
Normal file
11
codegen/ui_tests/rhai_mod_return_raw.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: unknown attribute 'return_raw'
|
||||
--> $DIR/rhai_mod_return_raw.rs:11:12
|
||||
|
|
||||
11 | #[rhai_mod(return_raw = "yes")]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_mod_return_raw.rs:24:8
|
||||
|
|
||||
24 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
Reference in New Issue
Block a user