Ruby support #1
1 changed files with 6 additions and 18 deletions
|
|
@ -222,17 +222,15 @@ impl TryConvert for BevyVec3 {
|
||||||
|
|
||||||
impl From<magnus::Error> for ScriptingError {
|
impl From<magnus::Error> for ScriptingError {
|
||||||
fn from(value: magnus::Error) -> Self {
|
fn from(value: magnus::Error) -> Self {
|
||||||
// TODO: DRY
|
|
||||||
ScriptingError::RuntimeError(
|
ScriptingError::RuntimeError(
|
||||||
value.inspect(),
|
value.inspect(),
|
||||||
value
|
value
|
||||||
.value()
|
.value()
|
||||||
.unwrap()
|
.expect("No error value")
|
||||||
.funcall::<_, _, magnus::RArray>("backtrace", ()) // TODO: is there an API for this
|
.funcall::<_, _, magnus::RArray>("backtrace", ())
|
||||||
// somehwere
|
.expect("Failed to get backtrace")
|
||||||
.unwrap()
|
|
||||||
.to_vec::<String>()
|
.to_vec::<String>()
|
||||||
.unwrap()
|
.expect("Failed to convert backtrace to vec of strings")
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -385,18 +383,8 @@ impl Runtime for RubyRuntime {
|
||||||
var.ivar_set("_current", BevyEntity(entity))
|
var.ivar_set("_current", BevyEntity(entity))
|
||||||
.expect("Failed to set current entity handle");
|
.expect("Failed to set current entity handle");
|
||||||
|
|
||||||
ruby.eval::<magnus::value::Value>(&script).map_err(|e| {
|
ruby.eval::<magnus::value::Value>(&script)
|
||||||
ScriptingError::RuntimeError(
|
.map_err(|e| <magnus::Error as Into<ScriptingError>>::into(e))?;
|
||||||
e.inspect(),
|
|
||||||
e.value()
|
|
||||||
.unwrap()
|
|
||||||
.funcall::<_, _, magnus::RArray>("backtrace", ())
|
|
||||||
.unwrap()
|
|
||||||
.to_vec::<String>()
|
|
||||||
.unwrap()
|
|
||||||
.join("\n"),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
var.ivar_set("_current", ruby.qnil().as_value())
|
var.ivar_set("_current", ruby.qnil().as_value())
|
||||||
.expect("Failed to unset current entity handle");
|
.expect("Failed to unset current entity handle");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue