feat: Event 体系内核接线九 P 字段加 BuiltinId 加脏位加 ProtoKind

This commit is contained in:
2026-10-10 08:02:05 +00:00
parent ab16e9ce79
commit 9ecd573526
11 changed files with 224 additions and 28 deletions
@@ -0,0 +1,28 @@
//! Event 体系绑定:本文件是内核接线占位(零行为变化)。九枚 P 字段
//! (Event / MessageEvent / ErrorEvent / CustomEvent 四枚原型与构造器对加
//! EventTarget 原型)当前是空对象,本函数为它们的绑定入口预留,真实构造器 /
//! 原型方法 / 原型链连线由后续任务就地填充(不新建对象——P 字段本身就是槽位,
//! 快照 / 脏检查 / 收尾枚举已覆盖)。
use std::sync::Arc;
use oxide_kernel::kernel::{KernelCore, KernelSession};
use oxide_types::object::JsObject;
/// Event 体系绑定入口(当前为空占位)。
///
/// # 幂等
/// 本函数从三条路径到达:`init_kernel_builtins`(占位是空对象)、
/// `rebind_dirty_builtins` 的 `event` 分支(占位是重建后的空对象)、
/// global-dirty 路径(占位可能已填满)。本函数当前不写任何槽位,空操作天然
/// 幂等;后续任务就地填充时,各槽写须沿用 `lookup_position` 前置守卫
/// (有槽即跳过),保持与 `bind_broadcast_channel` 同型的幂等契约。
///
/// # 边界
/// 九枚 P 字段是空对象占位,本函数不读不写,行为与未调用一致;
/// EventTarget 原型不占 ProtoKind(builtins 不读它),绑定层后续直接访问
/// `world.event_target_proto` 槽。
///
/// `core` / `session` / `global` / `realm_id` 当前未使用,保留签名与其他
/// 绑定函数一致,供后续任务就地填充时直接取用。
pub fn bind_event(_core: &Arc<KernelCore>, _session: &KernelSession, _global: &mut JsObject, _realm_id: u32) {}
+5
View File
@@ -26,6 +26,8 @@ pub mod bind_date;
pub mod bind_disposable_stack;
/// Error 家族构造器与原型的 native 方法绑定(含各子类型构造器创建)。
pub mod bind_error;
/// Event 体系绑定入口(当前为空占位,九枚 P 字段由后续任务就地填充)。
pub mod bind_event;
/// Function 构造器与原型的 native 方法绑定。
pub mod bind_function;
/// global 对象上的普通全局函数(parseInt、isNaN 等)绑定。
@@ -1343,6 +1345,9 @@ pub fn rebind_dirty_builtins(
if dirty.map_or(true, |d| d.broadcast_channel) {
bind_broadcast_channel::bind_broadcast_channel(core, session, global, realm_id);
}
if dirty.map_or(true, |d| d.event) {
bind_event::bind_event(core, session, global, realm_id);
}
if dirty.map_or(true, |d| d.console) {
bind_console::bind_console(core, session, global);
}
+4
View File
@@ -144,6 +144,10 @@ impl oxide_runtime_api::VmHost for Vm {
ProtoKind::BigUint64ArrayConstructor => &world.biguint64array_constructor,
ProtoKind::MessagePortProto => &world.message_port_proto,
ProtoKind::BroadcastChannelProto => &world.broadcast_channel_proto,
ProtoKind::EventProto => &world.event_proto,
ProtoKind::MessageEventProto => &world.message_event_proto,
ProtoKind::ErrorEventProto => &world.error_event_proto,
ProtoKind::CustomEventProto => &world.custom_event_proto,
};
P::as_ptr(p) as *mut JsObject
}