mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
refactor: 绑定层函数签名收敛为 BindEnv 单参
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bindings::{apply_binding_table, bind_global_value};
|
||||
use oxide_kernel::kernel::{KernelCore, KernelSession};
|
||||
use crate::bindings::{apply_binding_table, bind_global_value, BindEnv};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
/// 把 JSON 单例对象及其方法(parse/stringify 等)绑定到 global。
|
||||
pub fn bind_json(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
|
||||
let json_ptr = session.builtin_world().json_object.as_ptr() as *mut JsObject;
|
||||
pub fn bind_json(env: BindEnv<'_>, global: &mut JsObject) {
|
||||
let json_ptr = env.world().json_object.as_ptr() as *mut JsObject;
|
||||
let json = unsafe { &mut *json_ptr };
|
||||
|
||||
apply_binding_table(
|
||||
session.builtin_world(),
|
||||
env,
|
||||
json,
|
||||
core,
|
||||
&[
|
||||
("parse", oxide_builtins::json::json_parse::<crate::vm::Vm> as *const (), 2),
|
||||
("stringify", oxide_builtins::json::json_stringify::<crate::vm::Vm> as *const (), 3),
|
||||
@@ -23,9 +19,9 @@ pub fn bind_json(core: &Arc<KernelCore>, session: &KernelSession, global: &mut J
|
||||
);
|
||||
|
||||
bind_global_value(
|
||||
core,
|
||||
env.core,
|
||||
global,
|
||||
"JSON",
|
||||
JsValue::from_js_object(session.builtin_world().json_object.as_ptr() as *mut JsObject),
|
||||
JsValue::from_js_object(env.world().json_object.as_ptr() as *mut JsObject),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user