mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 19:51:11 +08:00
fix: symbol 作属性键独立编码,不再塌缩为空串
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use crate::bindings::{apply_binding_table, bind_well_known_method, configure_native_constructor};
|
||||
use oxide_kernel::kernel::{KernelCore, KernelSession};
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -23,21 +23,56 @@ pub fn bind_regexp(core: &Arc<KernelCore>, session: &KernelSession, global: &mut
|
||||
("exec", oxide_builtins::regexp::regexp_exec::<crate::vm::Vm> as *const (), 1),
|
||||
("test", oxide_builtins::regexp::regexp_test::<crate::vm::Vm> as *const (), 1),
|
||||
("toString", oxide_builtins::regexp::regexp_to_string::<crate::vm::Vm> as *const (), 0),
|
||||
("@@match", oxide_builtins::regexp::regexp_symbol_match::<crate::vm::Vm> as *const (), 1),
|
||||
(
|
||||
"@@replace",
|
||||
oxide_builtins::regexp::regexp_symbol_replace::<crate::vm::Vm> as *const (),
|
||||
2,
|
||||
),
|
||||
("@@search", oxide_builtins::regexp::regexp_symbol_search::<crate::vm::Vm> as *const (), 1),
|
||||
("@@split", oxide_builtins::regexp::regexp_symbol_split::<crate::vm::Vm> as *const (), 2),
|
||||
(
|
||||
"@@matchAll",
|
||||
oxide_builtins::regexp::regexp_symbol_match_all::<crate::vm::Vm> as *const (),
|
||||
1,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// Symbol.match 等 well-known symbol 方法按 Symbol 键安装,供 `re[Symbol.match]` 等读取。
|
||||
let world = session.builtin_world();
|
||||
bind_well_known_method(
|
||||
world,
|
||||
core,
|
||||
proto,
|
||||
1,
|
||||
"@@match",
|
||||
oxide_builtins::regexp::regexp_symbol_match::<crate::vm::Vm> as *const (),
|
||||
1,
|
||||
);
|
||||
bind_well_known_method(
|
||||
world,
|
||||
core,
|
||||
proto,
|
||||
2,
|
||||
"@@replace",
|
||||
oxide_builtins::regexp::regexp_symbol_replace::<crate::vm::Vm> as *const (),
|
||||
2,
|
||||
);
|
||||
bind_well_known_method(
|
||||
world,
|
||||
core,
|
||||
proto,
|
||||
3,
|
||||
"@@search",
|
||||
oxide_builtins::regexp::regexp_symbol_search::<crate::vm::Vm> as *const (),
|
||||
1,
|
||||
);
|
||||
bind_well_known_method(
|
||||
world,
|
||||
core,
|
||||
proto,
|
||||
4,
|
||||
"@@split",
|
||||
oxide_builtins::regexp::regexp_symbol_split::<crate::vm::Vm> as *const (),
|
||||
2,
|
||||
);
|
||||
bind_well_known_method(
|
||||
world,
|
||||
core,
|
||||
proto,
|
||||
7,
|
||||
"@@matchAll",
|
||||
oxide_builtins::regexp::regexp_symbol_match_all::<crate::vm::Vm> as *const (),
|
||||
1,
|
||||
);
|
||||
|
||||
bind_constructor!(core, global, "RegExp", ctor_ptr, oxide_builtins::regexp::regexp_constructor::<crate::vm::Vm>, 2, hash: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user