refactor: 绑定层函数签名收敛为 BindEnv 单参

This commit is contained in:
2026-10-12 17:25:40 +00:00
parent 3c89324736
commit a651cbff54
37 changed files with 770 additions and 1059 deletions
+6 -10
View File
@@ -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),
);
}