style: 全 workspace 格式订正,消除 fmt 漂移

This commit is contained in:
2026-10-09 23:58:34 +00:00
parent dbdc5556c6
commit c7f7588b81
23 changed files with 172 additions and 218 deletions
+15 -15
View File
@@ -1,8 +1,8 @@
use std::sync::Arc;
use crate::bindings::{
apply_binding_table, bind_accessor_getter, bind_accessor_getset, bind_accessor_getter_key,
bind_well_known_method, configure_native_constructor,
apply_binding_table, bind_accessor_getset, bind_accessor_getter, bind_accessor_getter_key, bind_well_known_method,
configure_native_constructor,
};
use oxide_kernel::kernel::{KernelCore, KernelSession};
use oxide_types::object::JsObject;
@@ -50,16 +50,7 @@ pub fn bind_regexp(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
let sf = core.perm_interner().as_ref();
let mut bind_getset = |name: &str, getter: *const (), setter: *const ()| {
let key = sf.intern(name).0;
bind_accessor_getset(
core,
session,
ctor,
key,
&format!("get {name}"),
&format!("set {name}"),
getter,
setter,
);
bind_accessor_getset(core, session, ctor, key, &format!("get {name}"), &format!("set {name}"), getter, setter);
};
// input/$_:get+set 对(唯一带 setter 的遗留访问器)。
bind_getset(
@@ -74,9 +65,15 @@ pub fn bind_regexp(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
);
// 其余 18 个 getter(set 恒 undefined)。
for (name, getter) in [
("lastMatch", oxide_builtins::regexp::regexp_legacy_get_last_match::<crate::vm::Vm> as *const ()),
(
"lastMatch",
oxide_builtins::regexp::regexp_legacy_get_last_match::<crate::vm::Vm> as *const (),
),
("$&", oxide_builtins::regexp::regexp_legacy_get_last_match::<crate::vm::Vm> as *const ()),
("lastParen", oxide_builtins::regexp::regexp_legacy_get_last_paren::<crate::vm::Vm> as *const ()),
(
"lastParen",
oxide_builtins::regexp::regexp_legacy_get_last_paren::<crate::vm::Vm> as *const (),
),
("$+", oxide_builtins::regexp::regexp_legacy_get_last_paren::<crate::vm::Vm> as *const ()),
(
"leftContext",
@@ -87,7 +84,10 @@ pub fn bind_regexp(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
"rightContext",
oxide_builtins::regexp::regexp_legacy_get_right_context::<crate::vm::Vm> as *const (),
),
("$'", oxide_builtins::regexp::regexp_legacy_get_right_context::<crate::vm::Vm> as *const ()),
(
"$'",
oxide_builtins::regexp::regexp_legacy_get_right_context::<crate::vm::Vm> as *const (),
),
("index", oxide_builtins::regexp::regexp_legacy_get_index::<crate::vm::Vm> as *const ()),
("$1", oxide_builtins::regexp::regexp_legacy_get_dollar_1::<crate::vm::Vm> as *const ()),
("$2", oxide_builtins::regexp::regexp_legacy_get_dollar_2::<crate::vm::Vm> as *const ()),
+5 -16
View File
@@ -45,11 +45,7 @@ pub fn bind_worker(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
let function_proto = world.function_proto.as_ptr() as *mut JsObject;
let mut ctor = JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(function_proto));
ctor.set_function(true);
configure_native_constructor(
&mut ctor,
crate::worker::bindings::worker_constructor as *const (),
1,
);
configure_native_constructor(&mut ctor, crate::worker::bindings::worker_constructor as *const (), 1);
let ptr = Box::into_raw(Box::new(ctor));
world.track_leaked_object(ptr);
ptr
@@ -63,7 +59,8 @@ pub fn bind_worker(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
if sh.lookup_position(ctor.shape_id(), si_name).is_none() {
let shape = sh.make_shape(ctor.shape_id(), si_name);
ctor.set_shape_id(shape);
ctor.ensure_hash_props().push(JsValue::perm_string(sf.string_ptr(sf.intern("Worker").0)));
ctor.ensure_hash_props()
.push(JsValue::perm_string(sf.string_ptr(sf.intern("Worker").0)));
let pos = ctor.hash_props_vec().map_or(0, |v| v.len() as u32).saturating_sub(1);
ctor.set_data_meta(pos, PropAttributes::new(false, false, true));
ctor.bump_generation();
@@ -116,11 +113,7 @@ pub fn bind_worker(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
proto,
core,
&[
(
"postMessage",
crate::worker::bindings::worker_post_message as *const (),
1,
),
("postMessage", crate::worker::bindings::worker_post_message as *const (), 1),
("terminate", crate::worker::bindings::worker_terminate as *const (), 0),
],
);
@@ -147,11 +140,7 @@ pub fn bind_worker(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
global,
core,
&[
(
"postMessage",
crate::worker::bindings::self_post_message as *const (),
1,
),
("postMessage", crate::worker::bindings::self_post_message as *const (), 1),
("close", crate::worker::bindings::self_close as *const (), 0),
],
);
+2 -2
View File
@@ -56,8 +56,6 @@ pub mod bind_shared_array_buffer;
pub mod bind_string;
/// 未实现内置(Proxy/BigInt/WeakMap 等)的 stub 构造器绑定。
pub mod bind_stubs;
/// Worker 构造器绑定(Box 分配,不占 BuiltinWorld P 字段)。
pub mod bind_worker;
/// Symbol 构造器与原型的 native 方法绑定。
pub mod bind_symbol;
/// Temporal 命名空间对象(Now/Instant/PlainDate/PlainTime)绑定。
@@ -66,6 +64,8 @@ pub mod bind_temporal;
pub mod bind_typed_array;
/// WeakMap 构造器与原型四方法的 native 绑定(弱族不占 BuiltinWorld 槽)。
pub mod bind_weak;
/// Worker 构造器绑定(Box 分配,不占 BuiltinWorld P 字段)。
pub mod bind_worker;
use std::sync::Arc;