roblox_emulator: deduplicate static_ustr
This commit is contained in:
parent
3d399635d7
commit
16dfe7524f
lib/roblox_emulator/src
@ -1,10 +1,6 @@
|
||||
use crate::util::static_ustr;
|
||||
use rbx_dom_weak::{types::Ref,InstanceBuilder,WeakDom};
|
||||
|
||||
// disallow non-static lifetimes
|
||||
fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
||||
rbx_dom_weak::ustr(s)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ServicesError{
|
||||
WorkspaceNotFound,
|
||||
|
@ -1,3 +1,4 @@
|
||||
mod util;
|
||||
pub mod runner;
|
||||
pub mod context;
|
||||
#[cfg(feature="run-service")]
|
||||
|
@ -4,14 +4,10 @@ use mlua::{FromLua,FromLuaMulti,IntoLua,IntoLuaMulti};
|
||||
use rbx_types::Ref;
|
||||
use rbx_dom_weak::{Ustr,InstanceBuilder,WeakDom};
|
||||
|
||||
use crate::util::static_ustr;
|
||||
use crate::runner::vector3::Vector3;
|
||||
use crate::runner::number::Number;
|
||||
|
||||
// disallow non-static lifetimes
|
||||
fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
||||
rbx_dom_weak::ustr(s)
|
||||
}
|
||||
|
||||
pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
||||
//class functions store
|
||||
lua.set_app_data(ClassMethodsStore::default());
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::context::Context;
|
||||
use crate::util::static_ustr;
|
||||
#[cfg(feature="run-service")]
|
||||
use crate::scheduler::scheduler_mut;
|
||||
|
||||
@ -125,7 +126,7 @@ impl Runnable<'_>{
|
||||
pub fn run_service_step(&self)->Result<(),mlua::Error>{
|
||||
let render_stepped_signal=super::instance::instance::dom_mut(&self.lua,|dom|{
|
||||
let run_service=super::instance::instance::find_first_child_of_class(dom,dom.root(),"RunService").ok_or_else(||mlua::Error::runtime("RunService missing"))?;
|
||||
Ok(match run_service.userdata.get(&rbx_dom_weak::ustr("RenderStepped")){
|
||||
Ok(match run_service.userdata.get(&static_ustr("RenderStepped")){
|
||||
Some(render_stepped)=>Some(render_stepped.borrow::<super::script_signal::ScriptSignal>()?.clone()),
|
||||
None=>None
|
||||
})
|
||||
|
3
lib/roblox_emulator/src/util.rs
Normal file
3
lib/roblox_emulator/src/util.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
||||
rbx_dom_weak::ustr(s)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user