style: 减少自动格式化换行
This commit is contained in:
@@ -44,12 +44,5 @@ pub fn bind_array(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
);
|
||||
|
||||
let ctor_ptr = kernel.builtin_world().array_constructor.as_ptr() as *mut JsObject;
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"Array",
|
||||
ctor_ptr,
|
||||
crate::builtins::array::array_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "Array", ctor_ptr, crate::builtins::array::array_constructor, 1);
|
||||
}
|
||||
|
||||
@@ -11,36 +11,17 @@ pub fn bind_boolean(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let proto_ptr = kernel.builtin_world().boolean_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::boolean::boolean_constructor as *const (),
|
||||
1,
|
||||
);
|
||||
configure_native_constructor(ctor, crate::builtins::boolean::boolean_constructor as *const (), 1);
|
||||
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
kernel,
|
||||
&[
|
||||
(
|
||||
"valueOf",
|
||||
crate::builtins::boolean::boolean_prototype_value_of as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"toString",
|
||||
crate::builtins::boolean::boolean_prototype_to_string as *const (),
|
||||
0,
|
||||
),
|
||||
("valueOf", crate::builtins::boolean::boolean_prototype_value_of as *const (), 0),
|
||||
("toString", crate::builtins::boolean::boolean_prototype_to_string as *const (), 0),
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"Boolean",
|
||||
ctor_ptr,
|
||||
crate::builtins::boolean::boolean_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "Boolean", ctor_ptr, crate::builtins::boolean::boolean_constructor, 1);
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ pub fn bind_date(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let proto_ptr = kernel.builtin_world().date_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::date::date_constructor as *const (),
|
||||
7,
|
||||
);
|
||||
configure_native_constructor(ctor, crate::builtins::date::date_constructor as *const (), 7);
|
||||
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
@@ -33,171 +29,39 @@ pub fn bind_date(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
proto,
|
||||
kernel,
|
||||
&[
|
||||
(
|
||||
"getTime",
|
||||
crate::builtins::date::date_get_time as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getFullYear",
|
||||
crate::builtins::date::date_get_full_year as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getMonth",
|
||||
crate::builtins::date::date_get_month as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getDate",
|
||||
crate::builtins::date::date_get_date as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getDay",
|
||||
crate::builtins::date::date_get_day as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getHours",
|
||||
crate::builtins::date::date_get_hours as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getMinutes",
|
||||
crate::builtins::date::date_get_minutes as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getSeconds",
|
||||
crate::builtins::date::date_get_seconds as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getMilliseconds",
|
||||
crate::builtins::date::date_get_milliseconds as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCFullYear",
|
||||
crate::builtins::date::date_get_utc_full_year as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCMonth",
|
||||
crate::builtins::date::date_get_utc_month as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCDate",
|
||||
crate::builtins::date::date_get_utc_date as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCDay",
|
||||
crate::builtins::date::date_get_utc_day as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCHours",
|
||||
crate::builtins::date::date_get_utc_hours as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCMinutes",
|
||||
crate::builtins::date::date_get_utc_minutes as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCSeconds",
|
||||
crate::builtins::date::date_get_utc_seconds as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getUTCMilliseconds",
|
||||
crate::builtins::date::date_get_utc_milliseconds as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"getTimezoneOffset",
|
||||
crate::builtins::date::date_get_timezone_offset as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"setTime",
|
||||
crate::builtins::date::date_set_time as *const (),
|
||||
1,
|
||||
),
|
||||
(
|
||||
"setFullYear",
|
||||
crate::builtins::date::date_set_full_year as *const (),
|
||||
3,
|
||||
),
|
||||
(
|
||||
"setMonth",
|
||||
crate::builtins::date::date_set_month as *const (),
|
||||
2,
|
||||
),
|
||||
(
|
||||
"setDate",
|
||||
crate::builtins::date::date_set_date as *const (),
|
||||
1,
|
||||
),
|
||||
(
|
||||
"setHours",
|
||||
crate::builtins::date::date_set_hours as *const (),
|
||||
4,
|
||||
),
|
||||
(
|
||||
"setMinutes",
|
||||
crate::builtins::date::date_set_minutes as *const (),
|
||||
3,
|
||||
),
|
||||
(
|
||||
"setSeconds",
|
||||
crate::builtins::date::date_set_seconds as *const (),
|
||||
2,
|
||||
),
|
||||
(
|
||||
"setMilliseconds",
|
||||
crate::builtins::date::date_set_milliseconds as *const (),
|
||||
1,
|
||||
),
|
||||
(
|
||||
"toISOString",
|
||||
crate::builtins::date::date_to_iso_string as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"toJSON",
|
||||
crate::builtins::date::date_to_json as *const (),
|
||||
1,
|
||||
),
|
||||
(
|
||||
"toString",
|
||||
crate::builtins::date::date_to_string as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"toDateString",
|
||||
crate::builtins::date::date_to_date_string as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"toTimeString",
|
||||
crate::builtins::date::date_to_time_string as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"toUTCString",
|
||||
crate::builtins::date::date_to_utc_string as *const (),
|
||||
0,
|
||||
),
|
||||
(
|
||||
"valueOf",
|
||||
crate::builtins::date::date_value_of as *const (),
|
||||
0,
|
||||
),
|
||||
("getTime", crate::builtins::date::date_get_time as *const (), 0),
|
||||
("getFullYear", crate::builtins::date::date_get_full_year as *const (), 0),
|
||||
("getMonth", crate::builtins::date::date_get_month as *const (), 0),
|
||||
("getDate", crate::builtins::date::date_get_date as *const (), 0),
|
||||
("getDay", crate::builtins::date::date_get_day as *const (), 0),
|
||||
("getHours", crate::builtins::date::date_get_hours as *const (), 0),
|
||||
("getMinutes", crate::builtins::date::date_get_minutes as *const (), 0),
|
||||
("getSeconds", crate::builtins::date::date_get_seconds as *const (), 0),
|
||||
("getMilliseconds", crate::builtins::date::date_get_milliseconds as *const (), 0),
|
||||
("getUTCFullYear", crate::builtins::date::date_get_utc_full_year as *const (), 0),
|
||||
("getUTCMonth", crate::builtins::date::date_get_utc_month as *const (), 0),
|
||||
("getUTCDate", crate::builtins::date::date_get_utc_date as *const (), 0),
|
||||
("getUTCDay", crate::builtins::date::date_get_utc_day as *const (), 0),
|
||||
("getUTCHours", crate::builtins::date::date_get_utc_hours as *const (), 0),
|
||||
("getUTCMinutes", crate::builtins::date::date_get_utc_minutes as *const (), 0),
|
||||
("getUTCSeconds", crate::builtins::date::date_get_utc_seconds as *const (), 0),
|
||||
("getUTCMilliseconds", crate::builtins::date::date_get_utc_milliseconds as *const (), 0),
|
||||
("getTimezoneOffset", crate::builtins::date::date_get_timezone_offset as *const (), 0),
|
||||
("setTime", crate::builtins::date::date_set_time as *const (), 1),
|
||||
("setFullYear", crate::builtins::date::date_set_full_year as *const (), 3),
|
||||
("setMonth", crate::builtins::date::date_set_month as *const (), 2),
|
||||
("setDate", crate::builtins::date::date_set_date as *const (), 1),
|
||||
("setHours", crate::builtins::date::date_set_hours as *const (), 4),
|
||||
("setMinutes", crate::builtins::date::date_set_minutes as *const (), 3),
|
||||
("setSeconds", crate::builtins::date::date_set_seconds as *const (), 2),
|
||||
("setMilliseconds", crate::builtins::date::date_set_milliseconds as *const (), 1),
|
||||
("toISOString", crate::builtins::date::date_to_iso_string as *const (), 0),
|
||||
("toJSON", crate::builtins::date::date_to_json as *const (), 1),
|
||||
("toString", crate::builtins::date::date_to_string as *const (), 0),
|
||||
("toDateString", crate::builtins::date::date_to_date_string as *const (), 0),
|
||||
("toTimeString", crate::builtins::date::date_to_time_string as *const (), 0),
|
||||
("toUTCString", crate::builtins::date::date_to_utc_string as *const (), 0),
|
||||
("valueOf", crate::builtins::date::date_value_of as *const (), 0),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -7,20 +7,13 @@ use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
fn bind_error_subtype_constructor(
|
||||
kernel: &Arc<OxideKernel>,
|
||||
global: &mut JsObject,
|
||||
name: &str,
|
||||
proto_ptr: *mut JsObject,
|
||||
ctor_fn: *const (),
|
||||
kernel: &Arc<OxideKernel>, global: &mut JsObject, name: &str, proto_ptr: *mut JsObject, ctor_fn: *const (),
|
||||
) {
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
let function_proto_ptr = kernel.builtin_world().function_proto.as_ptr() as *mut JsObject;
|
||||
|
||||
let mut ctor = Box::new(JsObject::new_empty(
|
||||
EMPTY_SHAPE_ID,
|
||||
JsValue::from_js_object(function_proto_ptr),
|
||||
));
|
||||
let mut ctor = Box::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(function_proto_ptr)));
|
||||
ctor.set_function(true);
|
||||
ctor.set_native_fn(Some(ctor_fn));
|
||||
ctor.set_native_arg_count(1);
|
||||
@@ -32,25 +25,19 @@ fn bind_error_subtype_constructor(
|
||||
let ctor_shape1 = sh.make_shape(EMPTY_SHAPE_ID, si_prototype);
|
||||
let ctor_shape2 = sh.make_shape(ctor_shape1, si_name);
|
||||
ctor.set_shape_id(ctor_shape2);
|
||||
ctor.ensure_hash_props()
|
||||
.push(Box::new(JsValue::from_js_object(proto_ptr)));
|
||||
ctor.ensure_hash_props()
|
||||
.push(Box::new(JsValue::string(name_si, 0)));
|
||||
ctor.ensure_hash_props().push(Box::new(JsValue::from_js_object(proto_ptr)));
|
||||
ctor.ensure_hash_props().push(Box::new(JsValue::string(name_si, 0)));
|
||||
|
||||
let ctor_ptr = Box::into_raw(ctor);
|
||||
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let proto_ctor_shape = sh.make_shape(proto.shape_id(), sf.intern("constructor").0);
|
||||
proto.set_shape_id(proto_ctor_shape);
|
||||
proto
|
||||
.ensure_hash_props()
|
||||
.push(Box::new(JsValue::from_js_object(ctor_ptr)));
|
||||
proto.ensure_hash_props().push(Box::new(JsValue::from_js_object(ctor_ptr)));
|
||||
|
||||
let global_shape = sh.make_shape(global.shape_id(), name_si);
|
||||
global.set_shape_id(global_shape);
|
||||
global
|
||||
.ensure_hash_props()
|
||||
.push(Box::new(JsValue::from_js_object(ctor_ptr)));
|
||||
global.ensure_hash_props().push(Box::new(JsValue::from_js_object(ctor_ptr)));
|
||||
global.bump_generation();
|
||||
}
|
||||
|
||||
@@ -74,8 +61,7 @@ pub fn bind_error(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
|
||||
let si_err = kernel.string_forge().intern("Error").0;
|
||||
let err_shape = kernel.shape_forge().make_shape(global.shape_id(), si_err);
|
||||
let err_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().error_constructor.as_ptr() as *mut JsObject);
|
||||
let err_val = JsValue::from_js_object(kernel.builtin_world().error_constructor.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(err_shape);
|
||||
global.ensure_hash_props().push(Box::new(err_val));
|
||||
global.bump_generation();
|
||||
|
||||
@@ -15,11 +15,7 @@ pub fn bind_json(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
kernel,
|
||||
&[
|
||||
("parse", crate::builtins::json::json_parse as *const (), 1),
|
||||
(
|
||||
"stringify",
|
||||
crate::builtins::json::json_stringify as *const (),
|
||||
1,
|
||||
),
|
||||
("stringify", crate::builtins::json::json_stringify as *const (), 1),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -27,12 +27,5 @@ pub fn bind_map(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"Map",
|
||||
ctor_ptr,
|
||||
crate::builtins::map::map_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "Map", ctor_ptr, crate::builtins::map::map_constructor, 1);
|
||||
}
|
||||
|
||||
@@ -66,18 +66,14 @@ pub fn bind_math(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
("SQRT2", std::f64::consts::SQRT_2),
|
||||
] {
|
||||
let si = kernel.string_forge().as_ref().intern(name).0;
|
||||
let sh_c = kernel
|
||||
.shape_forge()
|
||||
.as_ref()
|
||||
.make_shape(math.shape_id(), si);
|
||||
let sh_c = kernel.shape_forge().as_ref().make_shape(math.shape_id(), si);
|
||||
math.set_shape_id(sh_c);
|
||||
math.ensure_hash_props().push(Box::new(JsValue::float(val)));
|
||||
}
|
||||
|
||||
let si_m = kernel.string_forge().intern("Math").0;
|
||||
let m_shape = kernel.shape_forge().make_shape(global.shape_id(), si_m);
|
||||
let m_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().math_object.as_ptr() as *mut JsObject);
|
||||
let m_val = JsValue::from_js_object(kernel.builtin_world().math_object.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(m_shape);
|
||||
global.ensure_hash_props().push(Box::new(m_val));
|
||||
global.bump_generation();
|
||||
|
||||
@@ -28,9 +28,7 @@ pub fn bind_number(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
|
||||
let si_num = kernel.string_forge().intern("Number").0;
|
||||
let num_shape = kernel.shape_forge().make_shape(global.shape_id(), si_num);
|
||||
let num_val = JsValue::from_js_object(
|
||||
kernel.builtin_world().number_constructor.as_ptr() as *mut JsObject
|
||||
);
|
||||
let num_val = JsValue::from_js_object(kernel.builtin_world().number_constructor.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(num_shape);
|
||||
global.ensure_hash_props().push(Box::new(num_val));
|
||||
global.bump_generation();
|
||||
@@ -38,9 +36,7 @@ pub fn bind_number(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
{
|
||||
let num_ctor_ptr = kernel.builtin_world().number_constructor.as_ptr() as *mut JsObject;
|
||||
let num_ctor = unsafe { &mut *num_ctor_ptr };
|
||||
num_ctor.set_native_fn(Some(
|
||||
crate::builtins::number::number_constructor as *const (),
|
||||
));
|
||||
num_ctor.set_native_fn(Some(crate::builtins::number::number_constructor as *const ()));
|
||||
num_ctor.set_native_arg_count(1);
|
||||
|
||||
for (name, value) in [
|
||||
@@ -55,9 +51,7 @@ pub fn bind_number(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
] {
|
||||
num_ctor.ensure_hash_props().push(Box::new(value));
|
||||
let prop_si = kernel.string_forge().intern(name).0;
|
||||
let next_shape = kernel
|
||||
.shape_forge()
|
||||
.make_shape(num_ctor.shape_id(), prop_si);
|
||||
let next_shape = kernel.shape_forge().make_shape(num_ctor.shape_id(), prop_si);
|
||||
num_ctor.set_shape_id(next_shape);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ pub fn bind_object(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
create: crate::builtins::object::object_create as *const (),
|
||||
assign: crate::builtins::object::object_assign as *const (),
|
||||
define_property: crate::builtins::object::object_define_property as *const (),
|
||||
get_own_property_descriptor: crate::builtins::object::object_get_own_property_descriptor
|
||||
as *const (),
|
||||
get_own_property_descriptor: crate::builtins::object::object_get_own_property_descriptor as *const (),
|
||||
freeze: crate::builtins::object::object_freeze as *const (),
|
||||
seal: crate::builtins::object::object_seal as *const (),
|
||||
prevent_extensions: crate::builtins::object::object_prevent_extensions as *const (),
|
||||
@@ -27,19 +26,10 @@ pub fn bind_object(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
entries: crate::builtins::object::object_entries as *const (),
|
||||
values: crate::builtins::object::object_values as *const (),
|
||||
};
|
||||
kernel.builtin_world().bind_object_methods(
|
||||
&methods,
|
||||
kernel.string_forge().as_ref(),
|
||||
kernel.shape_forge().as_ref(),
|
||||
);
|
||||
kernel
|
||||
.builtin_world()
|
||||
.bind_object_methods(&methods, kernel.string_forge().as_ref(), kernel.shape_forge().as_ref());
|
||||
|
||||
let ctor_ptr = kernel.builtin_world().object_constructor.as_ptr() as *mut JsObject;
|
||||
bind_constructor!(
|
||||
kernel,
|
||||
global,
|
||||
"Object",
|
||||
ctor_ptr,
|
||||
crate::builtins::object::object_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor!(kernel, global, "Object", ctor_ptr, crate::builtins::object::object_constructor, 1);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,7 @@ pub fn bind_regexp(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let proto_ptr = kernel.builtin_world().regexp_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::regexp::regexp_constructor as *const (),
|
||||
2,
|
||||
);
|
||||
configure_native_constructor(ctor, crate::builtins::regexp::regexp_constructor as *const (), 2);
|
||||
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
@@ -25,20 +21,9 @@ pub fn bind_regexp(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
&[
|
||||
("exec", crate::builtins::regexp::regexp_exec as *const (), 1),
|
||||
("test", crate::builtins::regexp::regexp_test as *const (), 1),
|
||||
(
|
||||
"toString",
|
||||
crate::builtins::regexp::regexp_to_string as *const (),
|
||||
0,
|
||||
),
|
||||
("toString", crate::builtins::regexp::regexp_to_string as *const (), 0),
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"RegExp",
|
||||
ctor_ptr,
|
||||
crate::builtins::regexp::regexp_constructor,
|
||||
2
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "RegExp", ctor_ptr, crate::builtins::regexp::regexp_constructor, 2);
|
||||
}
|
||||
|
||||
@@ -26,12 +26,5 @@ pub fn bind_set(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"Set",
|
||||
ctor_ptr,
|
||||
crate::builtins::set::set_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "Set", ctor_ptr, crate::builtins::set::set_constructor, 1);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ pub fn bind_string(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
|
||||
let si_str = kernel.string_forge().intern("String").0;
|
||||
let str_shape = kernel.shape_forge().make_shape(global.shape_id(), si_str);
|
||||
let str_val = JsValue::from_js_object(
|
||||
kernel.builtin_world().string_constructor.as_ptr() as *mut JsObject
|
||||
);
|
||||
let str_val = JsValue::from_js_object(kernel.builtin_world().string_constructor.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(str_shape);
|
||||
global.ensure_hash_props().push(Box::new(str_val));
|
||||
global.bump_generation();
|
||||
|
||||
@@ -13,21 +13,13 @@ pub fn bind_symbol(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let proto_ptr = kernel.builtin_world().symbol_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::symbol::symbol_constructor as *const (),
|
||||
1,
|
||||
);
|
||||
configure_native_constructor(ctor, crate::builtins::symbol::symbol_constructor as *const (), 1);
|
||||
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
kernel,
|
||||
&[(
|
||||
"toString",
|
||||
crate::builtins::symbol::symbol_to_string as *const (),
|
||||
0,
|
||||
)],
|
||||
&[("toString", crate::builtins::symbol::symbol_to_string as *const (), 0)],
|
||||
);
|
||||
|
||||
for (name, val) in [
|
||||
@@ -55,22 +47,10 @@ pub fn bind_symbol(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
bind_well_known_symbol(kernel, ctor, name, val);
|
||||
}
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
global,
|
||||
"Symbol",
|
||||
ctor_ptr,
|
||||
crate::builtins::symbol::symbol_constructor,
|
||||
1
|
||||
);
|
||||
bind_constructor_hash!(kernel, global, "Symbol", ctor_ptr, crate::builtins::symbol::symbol_constructor, 1);
|
||||
}
|
||||
|
||||
fn bind_well_known_symbol(
|
||||
kernel: &Arc<OxideKernel>,
|
||||
ctor: &mut JsObject,
|
||||
name: &str,
|
||||
val: JsValue,
|
||||
) {
|
||||
fn bind_well_known_symbol(kernel: &Arc<OxideKernel>, ctor: &mut JsObject, name: &str, val: JsValue) {
|
||||
let si = kernel.string_forge().intern(name).0;
|
||||
let shape_id = kernel.shape_forge().make_shape(ctor.shape_id(), si);
|
||||
ctor.set_shape_id(shape_id);
|
||||
|
||||
@@ -49,20 +49,13 @@ macro_rules! bind_constructor_hash {
|
||||
}};
|
||||
}
|
||||
|
||||
pub(crate) fn configure_native_constructor(
|
||||
ctor: &mut JsObject,
|
||||
native_fn: *const (),
|
||||
arg_count: u8,
|
||||
) {
|
||||
pub(crate) fn configure_native_constructor(ctor: &mut JsObject, native_fn: *const (), arg_count: u8) {
|
||||
ctor.set_native_fn(Some(native_fn));
|
||||
ctor.set_native_arg_count(arg_count);
|
||||
}
|
||||
|
||||
pub(crate) fn apply_binding_table(
|
||||
world: &BuiltinWorld,
|
||||
target: &mut JsObject,
|
||||
kernel: &Arc<OxideKernel>,
|
||||
bindings: &[(&'static str, *const (), u8)],
|
||||
world: &BuiltinWorld, target: &mut JsObject, kernel: &Arc<OxideKernel>, bindings: &[(&'static str, *const (), u8)],
|
||||
) {
|
||||
let shape_forge = kernel.shape_forge().as_ref();
|
||||
let string_forge = kernel.string_forge().as_ref();
|
||||
@@ -71,12 +64,7 @@ pub(crate) fn apply_binding_table(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn bind_global_value(
|
||||
kernel: &Arc<OxideKernel>,
|
||||
global: &mut JsObject,
|
||||
name: &str,
|
||||
value: JsValue,
|
||||
) {
|
||||
pub(crate) fn bind_global_value(kernel: &Arc<OxideKernel>, global: &mut JsObject, name: &str, value: JsValue) {
|
||||
let si = kernel.string_forge().intern(name).0;
|
||||
let shape = kernel.shape_forge().make_shape(global.shape_id(), si);
|
||||
global.set_shape_id(shape);
|
||||
|
||||
Reference in New Issue
Block a user