refactor: 清理未使用符号,合并bind_constructor宏,统一init/rebind绑定列表,bind_number改为表驱动

This commit is contained in:
爱特每羊队
2026-06-24 12:12:44 +08:00
parent f602ae5f00
commit 6bf5daa1af
27 changed files with 140 additions and 297 deletions
-44
View File
@@ -144,20 +144,6 @@ pub struct RegExpMethods {
pub to_string: *const (),
}
pub struct NumberMethods {
pub is_nan: *const (),
pub is_finite: *const (),
pub parse_int: *const (),
pub parse_float: *const (),
pub to_string: *const (),
pub to_fixed: *const (),
pub is_integer: *const (),
pub is_safe_integer: *const (),
pub to_exponential: *const (),
pub to_precision: *const (),
pub value_of: *const (),
}
pub struct FunctionMethods {
pub call: *const (),
pub apply: *const (),
@@ -979,36 +965,6 @@ impl BuiltinWorld {
);
}
pub fn bind_number_methods(&self, methods: &NumberMethods, string_forge: &StringForge, shape_forge: &ShapeForge) {
let ctor_ptr = P::as_ptr(&self.number_constructor) as *mut JsObject;
let ctor = unsafe { &mut *ctor_ptr };
let proto_ptr = P::as_ptr(&self.number_proto) as *mut JsObject;
let proto = unsafe { &mut *proto_ptr };
bind_methods!(
self,
ctor,
string_forge,
shape_forge,
("isNaN", methods.is_nan, 1),
("isFinite", methods.is_finite, 1),
("parseInt", methods.parse_int, 1),
("parseFloat", methods.parse_float, 1),
("isInteger", methods.is_integer, 1),
("isSafeInteger", methods.is_safe_integer, 1),
);
bind_methods!(
self,
proto,
string_forge,
shape_forge,
("toString", methods.to_string, 0),
("toFixed", methods.to_fixed, 0),
("toExponential", methods.to_exponential, 0),
("toPrecision", methods.to_precision, 0),
("valueOf", methods.value_of, 0),
);
}
pub fn bind_function_methods(
&self, methods: &FunctionMethods, string_forge: &StringForge, shape_forge: &ShapeForge,
) {
-5
View File
@@ -80,11 +80,6 @@ impl KernelConfig {
pub fn set_session_gc_threshold(&mut self, bytes: usize) {
self.session_gc_threshold = bytes;
}
pub fn with_session_gc_threshold(mut self, bytes: usize) -> Self {
self.session_gc_threshold = bytes;
self
}
}
impl Default for KernelConfig {
+2 -2
View File
@@ -14,8 +14,8 @@ pub fn hash16(s: &str) -> u16 {
}
pub struct StringEntry {
pub data: String,
pub ref_count: AtomicU32,
pub(crate) data: String,
pub(crate) ref_count: AtomicU32,
pub hash: u16,
}