Context::script_singleton constructor for running a single script from cli
This commit is contained in:
parent
72874d450f
commit
4a939e74d1
@ -19,6 +19,14 @@ impl Context{
|
|||||||
pub const fn new(dom:WeakDom)->Context{
|
pub const fn new(dom:WeakDom)->Context{
|
||||||
Context{dom}
|
Context{dom}
|
||||||
}
|
}
|
||||||
|
pub fn script_singleton(source:String)->(Context,crate::runner::instance::Script){
|
||||||
|
let dom=WeakDom::new(
|
||||||
|
rbx_dom_weak::InstanceBuilder::new("Script")
|
||||||
|
.with_property("Source",rbx_types::Variant::String(source))
|
||||||
|
);
|
||||||
|
let script=crate::runner::instance::Script::new(dom.root_ref());
|
||||||
|
(Context{dom},script)
|
||||||
|
}
|
||||||
pub fn from_mut(dom:&mut WeakDom)->&mut Context{
|
pub fn from_mut(dom:&mut WeakDom)->&mut Context{
|
||||||
unsafe{&mut *(dom as *mut WeakDom as *mut Context)}
|
unsafe{&mut *(dom as *mut WeakDom as *mut Context)}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user