refactor: 收敛 builtin 绑定表驱动并补完数组宏化收尾
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -10,29 +10,29 @@ pub fn bind_boolean(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().boolean_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
ctor.set_native_fn(Some(
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::boolean::boolean_constructor as *const (),
|
||||
));
|
||||
ctor.set_native_arg_count(1);
|
||||
1,
|
||||
);
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
(
|
||||
"valueOf",
|
||||
crate::builtins::boolean::boolean_prototype_value_of,
|
||||
0
|
||||
),
|
||||
(
|
||||
"toString",
|
||||
crate::builtins::boolean::boolean_prototype_to_string,
|
||||
0
|
||||
),
|
||||
kernel,
|
||||
&[
|
||||
(
|
||||
"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!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, bind_global_value, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -10,102 +10,196 @@ pub fn bind_date(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().date_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
ctor.set_native_fn(Some(crate::builtins::date::date_constructor as *const ()));
|
||||
ctor.set_native_arg_count(7);
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::date::date_constructor as *const (),
|
||||
7,
|
||||
);
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
ctor,
|
||||
sf,
|
||||
sh,
|
||||
("now", crate::builtins::date::date_now, 0),
|
||||
("parse", crate::builtins::date::date_parse, 1),
|
||||
("UTC", crate::builtins::date::date_utc, 7),
|
||||
kernel,
|
||||
&[
|
||||
("now", crate::builtins::date::date_now as *const (), 0),
|
||||
("parse", crate::builtins::date::date_parse as *const (), 1),
|
||||
("UTC", crate::builtins::date::date_utc as *const (), 7),
|
||||
],
|
||||
);
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
("getTime", crate::builtins::date::date_get_time, 0),
|
||||
("getFullYear", crate::builtins::date::date_get_full_year, 0),
|
||||
("getMonth", crate::builtins::date::date_get_month, 0),
|
||||
("getDate", crate::builtins::date::date_get_date, 0),
|
||||
("getDay", crate::builtins::date::date_get_day, 0),
|
||||
("getHours", crate::builtins::date::date_get_hours, 0),
|
||||
("getMinutes", crate::builtins::date::date_get_minutes, 0),
|
||||
("getSeconds", crate::builtins::date::date_get_seconds, 0),
|
||||
(
|
||||
"getMilliseconds",
|
||||
crate::builtins::date::date_get_milliseconds,
|
||||
0
|
||||
),
|
||||
(
|
||||
"getUTCFullYear",
|
||||
crate::builtins::date::date_get_utc_full_year,
|
||||
0
|
||||
),
|
||||
("getUTCMonth", crate::builtins::date::date_get_utc_month, 0),
|
||||
("getUTCDate", crate::builtins::date::date_get_utc_date, 0),
|
||||
("getUTCDay", crate::builtins::date::date_get_utc_day, 0),
|
||||
("getUTCHours", crate::builtins::date::date_get_utc_hours, 0),
|
||||
(
|
||||
"getUTCMinutes",
|
||||
crate::builtins::date::date_get_utc_minutes,
|
||||
0
|
||||
),
|
||||
(
|
||||
"getUTCSeconds",
|
||||
crate::builtins::date::date_get_utc_seconds,
|
||||
0
|
||||
),
|
||||
(
|
||||
"getUTCMilliseconds",
|
||||
crate::builtins::date::date_get_utc_milliseconds,
|
||||
0
|
||||
),
|
||||
(
|
||||
"getTimezoneOffset",
|
||||
crate::builtins::date::date_get_timezone_offset,
|
||||
0
|
||||
),
|
||||
("setTime", crate::builtins::date::date_set_time, 1),
|
||||
("setFullYear", crate::builtins::date::date_set_full_year, 3),
|
||||
("setMonth", crate::builtins::date::date_set_month, 2),
|
||||
("setDate", crate::builtins::date::date_set_date, 1),
|
||||
("setHours", crate::builtins::date::date_set_hours, 4),
|
||||
("setMinutes", crate::builtins::date::date_set_minutes, 3),
|
||||
("setSeconds", crate::builtins::date::date_set_seconds, 2),
|
||||
(
|
||||
"setMilliseconds",
|
||||
crate::builtins::date::date_set_milliseconds,
|
||||
1
|
||||
),
|
||||
("toISOString", crate::builtins::date::date_to_iso_string, 0),
|
||||
("toJSON", crate::builtins::date::date_to_json, 1),
|
||||
("toString", crate::builtins::date::date_to_string, 0),
|
||||
(
|
||||
"toDateString",
|
||||
crate::builtins::date::date_to_date_string,
|
||||
0
|
||||
),
|
||||
(
|
||||
"toTimeString",
|
||||
crate::builtins::date::date_to_time_string,
|
||||
0
|
||||
),
|
||||
("toUTCString", crate::builtins::date::date_to_utc_string, 0),
|
||||
("valueOf", crate::builtins::date::date_value_of, 0),
|
||||
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,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
let si_d = kernel.string_forge().intern("Date").0;
|
||||
let d_shape = kernel.shape_forge().make_shape(global.shape_id(), si_d);
|
||||
let d_val = JsValue::from_js_object(ctor_ptr);
|
||||
global.set_shape_id(d_shape);
|
||||
global.ensure_hash_props().push(Box::new(d_val));
|
||||
global.bump_generation();
|
||||
bind_global_value(kernel, global, "Date", JsValue::from_js_object(ctor_ptr));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, bind_global_value};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -9,20 +9,24 @@ pub fn bind_json(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let json_ptr = kernel.builtin_world().json_object.as_ptr() as *mut JsObject;
|
||||
let json = unsafe { &mut *json_ptr };
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
json,
|
||||
kernel.string_forge().as_ref(),
|
||||
kernel.shape_forge().as_ref(),
|
||||
("parse", crate::builtins::json::json_parse, 1),
|
||||
("stringify", crate::builtins::json::json_stringify, 1),
|
||||
kernel,
|
||||
&[
|
||||
("parse", crate::builtins::json::json_parse as *const (), 1),
|
||||
(
|
||||
"stringify",
|
||||
crate::builtins::json::json_stringify as *const (),
|
||||
1,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
let si_j = kernel.string_forge().intern("JSON").0;
|
||||
let j_shape = kernel.shape_forge().make_shape(global.shape_id(), si_j);
|
||||
let j_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().json_object.as_ptr() as *mut JsObject);
|
||||
global.set_shape_id(j_shape);
|
||||
global.ensure_hash_props().push(Box::new(j_val));
|
||||
global.bump_generation();
|
||||
bind_global_value(
|
||||
kernel,
|
||||
global,
|
||||
"JSON",
|
||||
JsValue::from_js_object(kernel.builtin_world().json_object.as_ptr() as *mut JsObject),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -10,23 +10,21 @@ pub fn bind_map(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().map_proto.as_ptr() as *mut JsObject;
|
||||
|
||||
ctor.set_native_fn(Some(crate::builtins::map::map_constructor as *const ()));
|
||||
ctor.set_native_arg_count(1);
|
||||
configure_native_constructor(ctor, crate::builtins::map::map_constructor as *const (), 1);
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
("set", crate::builtins::map::map_set, 2),
|
||||
("get", crate::builtins::map::map_get, 1),
|
||||
("has", crate::builtins::map::map_has, 1),
|
||||
("delete", crate::builtins::map::map_delete, 1),
|
||||
("clear", crate::builtins::map::map_clear, 0),
|
||||
("size", crate::builtins::map::map_size, 0),
|
||||
kernel,
|
||||
&[
|
||||
("set", crate::builtins::map::map_set as *const (), 2),
|
||||
("get", crate::builtins::map::map_get as *const (), 1),
|
||||
("has", crate::builtins::map::map_has as *const (), 1),
|
||||
("delete", crate::builtins::map::map_delete as *const (), 1),
|
||||
("clear", crate::builtins::map::map_clear as *const (), 0),
|
||||
("size", crate::builtins::map::map_size as *const (), 0),
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -11,22 +11,26 @@ pub fn bind_regexp(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().regexp_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
ctor.set_native_fn(Some(
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::regexp::regexp_constructor as *const (),
|
||||
));
|
||||
ctor.set_native_arg_count(2);
|
||||
2,
|
||||
);
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
("exec", crate::builtins::regexp::regexp_exec, 1),
|
||||
("test", crate::builtins::regexp::regexp_test, 1),
|
||||
("toString", crate::builtins::regexp::regexp_to_string, 0),
|
||||
kernel,
|
||||
&[
|
||||
("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,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -10,22 +10,20 @@ pub fn bind_set(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().set_proto.as_ptr() as *mut JsObject;
|
||||
|
||||
ctor.set_native_fn(Some(crate::builtins::set::set_constructor as *const ()));
|
||||
ctor.set_native_arg_count(1);
|
||||
configure_native_constructor(ctor, crate::builtins::set::set_constructor as *const (), 1);
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_methods!(
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
("add", crate::builtins::set::set_add, 1),
|
||||
("has", crate::builtins::set::set_has, 1),
|
||||
("delete", crate::builtins::set::set_delete, 1),
|
||||
("clear", crate::builtins::set::set_clear, 0),
|
||||
("size", crate::builtins::set::set_size, 0),
|
||||
kernel,
|
||||
&[
|
||||
("add", crate::builtins::set::set_add as *const (), 1),
|
||||
("has", crate::builtins::set::set_has as *const (), 1),
|
||||
("delete", crate::builtins::set::set_delete as *const (), 1),
|
||||
("clear", crate::builtins::set::set_clear as *const (), 0),
|
||||
("size", crate::builtins::set::set_size as *const (), 0),
|
||||
],
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use crate::bindings::{apply_binding_table, configure_native_constructor};
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -12,15 +12,22 @@ pub fn bind_symbol(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let ctor = unsafe { &mut *ctor_ptr };
|
||||
let proto_ptr = kernel.builtin_world().symbol_proto.as_ptr() as *mut JsObject;
|
||||
let proto = unsafe { &mut *proto_ptr };
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_methods!(
|
||||
configure_native_constructor(
|
||||
ctor,
|
||||
crate::builtins::symbol::symbol_constructor as *const (),
|
||||
1,
|
||||
);
|
||||
|
||||
apply_binding_table(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
("toString", crate::builtins::symbol::symbol_to_string, 0),
|
||||
kernel,
|
||||
&[(
|
||||
"toString",
|
||||
crate::builtins::symbol::symbol_to_string as *const (),
|
||||
0,
|
||||
)],
|
||||
);
|
||||
|
||||
for (name, val) in [
|
||||
@@ -68,4 +75,5 @@ fn bind_well_known_symbol(
|
||||
let shape_id = kernel.shape_forge().make_shape(ctor.shape_id(), si);
|
||||
ctor.set_shape_id(shape_id);
|
||||
ctor.ensure_hash_props().push(Box::new(val));
|
||||
ctor.bump_generation();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ pub mod bind_symbol;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::builtin::BuiltinWorld;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! bind_constructor {
|
||||
@@ -46,6 +49,41 @@ macro_rules! bind_constructor_hash {
|
||||
}};
|
||||
}
|
||||
|
||||
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)],
|
||||
) {
|
||||
let shape_forge = kernel.shape_forge().as_ref();
|
||||
let string_forge = kernel.string_forge().as_ref();
|
||||
for (name, func, nargs) in bindings {
|
||||
let _ = world.bind_method(target, shape_forge, string_forge, name, *func, *nargs);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
global.ensure_hash_props().push(Box::new(value));
|
||||
global.bump_generation();
|
||||
}
|
||||
|
||||
pub fn init_kernel_builtins(kernel: &Arc<OxideKernel>) {
|
||||
let global_ptr = kernel.global_object().as_ptr() as *mut oxide_types::object::JsObject;
|
||||
let global = unsafe { &mut *global_ptr };
|
||||
|
||||
Reference in New Issue
Block a user