mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 18:51:13 +08:00
refactor: 拆分 Kernel 中可变 Session 与不可变 Core
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_kernel::kernel::{KernelCore, KernelSession};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
pub fn bind_math(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let math_ptr = kernel.builtin_world().math_object.as_ptr() as *mut JsObject;
|
||||
pub fn bind_math(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
|
||||
let math_ptr = session.builtin_world().math_object.as_ptr() as *mut JsObject;
|
||||
let math = unsafe { &mut *math_ptr };
|
||||
|
||||
let bw = kernel.builtin_world();
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
let bw = session.builtin_world();
|
||||
let sf = core.string_forge().as_ref();
|
||||
let sh = core.shape_forge().as_ref();
|
||||
|
||||
bind_methods!(
|
||||
bw,
|
||||
@@ -65,15 +65,15 @@ pub fn bind_math(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
("SQRT1_2", std::f64::consts::FRAC_1_SQRT_2),
|
||||
("SQRT2", std::f64::consts::SQRT_2),
|
||||
] {
|
||||
let si = kernel.string_forge().as_ref().intern(name).0;
|
||||
let sh_c = kernel.shape_forge().as_ref().make_shape(math.shape_id(), si);
|
||||
let si = core.string_forge().as_ref().intern(name).0;
|
||||
let sh_c = core.shape_forge().as_ref().make_shape(math.shape_id(), si);
|
||||
math.set_shape_id(sh_c);
|
||||
math.ensure_hash_props().push(JsValue::float(val));
|
||||
}
|
||||
|
||||
let si_m = kernel.string_forge().intern("Math").0;
|
||||
let m_shape = kernel.shape_forge().make_shape(global.shape_id(), si_m);
|
||||
let m_val = JsValue::from_js_object(kernel.builtin_world().math_object.as_ptr() as *mut JsObject);
|
||||
let si_m = core.string_forge().intern("Math").0;
|
||||
let m_shape = core.shape_forge().make_shape(global.shape_id(), si_m);
|
||||
let m_val = JsValue::from_js_object(session.builtin_world().math_object.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(m_shape);
|
||||
global.ensure_hash_props().push(m_val);
|
||||
global.bump_generation();
|
||||
|
||||
Reference in New Issue
Block a user