use std::sync::Arc; use crate::bindings::{apply_binding_table, configure_native_constructor}; use oxide_kernel::kernel::{KernelCore, KernelSession}; use oxide_types::object::JsObject; use crate::bind_constructor; /// 把 RegExp 构造器与原型方法绑定到 global。 pub fn bind_regexp(core: &Arc, session: &KernelSession, global: &mut JsObject) { let ctor_ptr = session.builtin_world().regexp_constructor.as_ptr() as *mut JsObject; let ctor = unsafe { &mut *ctor_ptr }; let proto_ptr = session.builtin_world().regexp_proto.as_ptr() as *mut JsObject; let proto = unsafe { &mut *proto_ptr }; configure_native_constructor(ctor, oxide_builtins::regexp::regexp_constructor:: as *const (), 2); apply_binding_table( session.builtin_world(), proto, core, &[ ("exec", oxide_builtins::regexp::regexp_exec:: as *const (), 1), ("test", oxide_builtins::regexp::regexp_test:: as *const (), 1), ("toString", oxide_builtins::regexp::regexp_to_string:: as *const (), 0), ("@@match", oxide_builtins::regexp::regexp_symbol_match:: as *const (), 1), ( "@@replace", oxide_builtins::regexp::regexp_symbol_replace:: as *const (), 2, ), ("@@search", oxide_builtins::regexp::regexp_symbol_search:: as *const (), 1), ("@@split", oxide_builtins::regexp::regexp_symbol_split:: as *const (), 2), ( "@@matchAll", oxide_builtins::regexp::regexp_symbol_match_all:: as *const (), 1, ), ], ); bind_constructor!(core, global, "RegExp", ctor_ptr, oxide_builtins::regexp::regexp_constructor::, 2, hash: true); }