mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
refactor: 表驱动化直接 builtin 绑定模块
This commit is contained in:
@@ -16,7 +16,7 @@ macro_rules! bind_method {
|
||||
macro_rules! bind_methods {
|
||||
($world:expr, $target:expr, $sf:expr, $sh:expr,
|
||||
$(($name:literal, $func:expr, $nargs:expr)),* $(,)?) => {
|
||||
$( bind_method!($world, $target, $sf, $sh, $name, $func, $nargs); )*
|
||||
$( $crate::bind_method!($world, $target, $sf, $sh, $name, $func, $nargs); )*
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -18,23 +18,21 @@ pub fn bind_boolean(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
));
|
||||
ctor.set_native_arg_count(1);
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"valueOf",
|
||||
crate::builtins::boolean::boolean_prototype_value_of,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toString",
|
||||
crate::builtins::boolean::boolean_prototype_to_string,
|
||||
0
|
||||
(
|
||||
"valueOf",
|
||||
crate::builtins::boolean::boolean_prototype_value_of,
|
||||
0
|
||||
),
|
||||
(
|
||||
"toString",
|
||||
crate::builtins::boolean::boolean_prototype_to_string,
|
||||
0
|
||||
),
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -16,330 +16,90 @@ pub fn bind_date(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
ctor.set_native_fn(Some(crate::builtins::date::date_constructor as *const ()));
|
||||
ctor.set_native_arg_count(7);
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
ctor,
|
||||
sf,
|
||||
sh,
|
||||
"now",
|
||||
crate::builtins::date::date_now,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
ctor,
|
||||
sf,
|
||||
sh,
|
||||
"parse",
|
||||
crate::builtins::date::date_parse,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
ctor,
|
||||
sf,
|
||||
sh,
|
||||
"UTC",
|
||||
crate::builtins::date::date_utc,
|
||||
7
|
||||
("now", crate::builtins::date::date_now, 0),
|
||||
("parse", crate::builtins::date::date_parse, 1),
|
||||
("UTC", crate::builtins::date::date_utc, 7),
|
||||
);
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getTime",
|
||||
crate::builtins::date::date_get_time,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getFullYear",
|
||||
crate::builtins::date::date_get_full_year,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getMonth",
|
||||
crate::builtins::date::date_get_month,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getDate",
|
||||
crate::builtins::date::date_get_date,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getDay",
|
||||
crate::builtins::date::date_get_day,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getHours",
|
||||
crate::builtins::date::date_get_hours,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getMinutes",
|
||||
crate::builtins::date::date_get_minutes,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getSeconds",
|
||||
crate::builtins::date::date_get_seconds,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getMilliseconds",
|
||||
crate::builtins::date::date_get_milliseconds,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCFullYear",
|
||||
crate::builtins::date::date_get_utc_full_year,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCMonth",
|
||||
crate::builtins::date::date_get_utc_month,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCDate",
|
||||
crate::builtins::date::date_get_utc_date,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCDay",
|
||||
crate::builtins::date::date_get_utc_day,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCHours",
|
||||
crate::builtins::date::date_get_utc_hours,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCMinutes",
|
||||
crate::builtins::date::date_get_utc_minutes,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCSeconds",
|
||||
crate::builtins::date::date_get_utc_seconds,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getUTCMilliseconds",
|
||||
crate::builtins::date::date_get_utc_milliseconds,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"getTimezoneOffset",
|
||||
crate::builtins::date::date_get_timezone_offset,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setTime",
|
||||
crate::builtins::date::date_set_time,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setFullYear",
|
||||
crate::builtins::date::date_set_full_year,
|
||||
3
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setMonth",
|
||||
crate::builtins::date::date_set_month,
|
||||
2
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setDate",
|
||||
crate::builtins::date::date_set_date,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setHours",
|
||||
crate::builtins::date::date_set_hours,
|
||||
4
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setMinutes",
|
||||
crate::builtins::date::date_set_minutes,
|
||||
3
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setSeconds",
|
||||
crate::builtins::date::date_set_seconds,
|
||||
2
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"setMilliseconds",
|
||||
crate::builtins::date::date_set_milliseconds,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toISOString",
|
||||
crate::builtins::date::date_to_iso_string,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toJSON",
|
||||
crate::builtins::date::date_to_json,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toString",
|
||||
crate::builtins::date::date_to_string,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toDateString",
|
||||
crate::builtins::date::date_to_date_string,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toTimeString",
|
||||
crate::builtins::date::date_to_time_string,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toUTCString",
|
||||
crate::builtins::date::date_to_utc_string,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"valueOf",
|
||||
crate::builtins::date::date_value_of,
|
||||
0
|
||||
("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),
|
||||
);
|
||||
|
||||
let si_d = kernel.string_forge().intern("Date").0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -9,23 +9,13 @@ 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_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
json,
|
||||
kernel.string_forge().as_ref(),
|
||||
kernel.shape_forge().as_ref(),
|
||||
"parse",
|
||||
crate::builtins::json::json_parse,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
json,
|
||||
kernel.string_forge().as_ref(),
|
||||
kernel.shape_forge().as_ref(),
|
||||
"stringify",
|
||||
crate::builtins::json::json_stringify,
|
||||
1
|
||||
("parse", crate::builtins::json::json_parse, 1),
|
||||
("stringify", crate::builtins::json::json_stringify, 1),
|
||||
);
|
||||
|
||||
let si_j = kernel.string_forge().intern("JSON").0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -16,59 +16,17 @@ pub fn bind_map(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"set",
|
||||
crate::builtins::map::map_set,
|
||||
2
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"get",
|
||||
crate::builtins::map::map_get,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"has",
|
||||
crate::builtins::map::map_has,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"delete",
|
||||
crate::builtins::map::map_delete,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"clear",
|
||||
crate::builtins::map::map_clear,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"size",
|
||||
crate::builtins::map::map_size,
|
||||
0
|
||||
("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),
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_kernel::{bind_method, bind_methods};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::builtin::NumberMethods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_kernel::{bind_method, bind_methods};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -19,32 +19,14 @@ pub fn bind_regexp(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
));
|
||||
ctor.set_native_arg_count(2);
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"exec",
|
||||
crate::builtins::regexp::regexp_exec,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"test",
|
||||
crate::builtins::regexp::regexp_test,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toString",
|
||||
crate::builtins::regexp::regexp_to_string,
|
||||
0
|
||||
("exec", crate::builtins::regexp::regexp_exec, 1),
|
||||
("test", crate::builtins::regexp::regexp_test, 1),
|
||||
("toString", crate::builtins::regexp::regexp_to_string, 0),
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::bind_constructor_hash;
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
|
||||
@@ -16,50 +16,16 @@ pub fn bind_set(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"add",
|
||||
crate::builtins::set::set_add,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"has",
|
||||
crate::builtins::set::set_has,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"delete",
|
||||
crate::builtins::set::set_delete,
|
||||
1
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"clear",
|
||||
crate::builtins::set::set_clear,
|
||||
0
|
||||
);
|
||||
bind_method!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"size",
|
||||
crate::builtins::set::set_size,
|
||||
0
|
||||
("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),
|
||||
);
|
||||
|
||||
bind_constructor_hash!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use oxide_kernel::bind_method;
|
||||
use oxide_kernel::bind_methods;
|
||||
use oxide_kernel::kernel::OxideKernel;
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
@@ -15,35 +15,38 @@ pub fn bind_symbol(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
let sf = kernel.string_forge().as_ref();
|
||||
let sh = kernel.shape_forge().as_ref();
|
||||
|
||||
bind_method!(
|
||||
bind_methods!(
|
||||
kernel.builtin_world(),
|
||||
proto,
|
||||
sf,
|
||||
sh,
|
||||
"toString",
|
||||
crate::builtins::symbol::symbol_to_string,
|
||||
0
|
||||
("toString", crate::builtins::symbol::symbol_to_string, 0),
|
||||
);
|
||||
|
||||
let sym_match_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_match.as_ptr() as *mut JsObject);
|
||||
bind_well_known_symbol(kernel, ctor, sf, sh, "match", sym_match_val);
|
||||
|
||||
let sym_replace_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_replace.as_ptr() as *mut JsObject);
|
||||
bind_well_known_symbol(kernel, ctor, sf, sh, "replace", sym_replace_val);
|
||||
|
||||
let sym_search_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_search.as_ptr() as *mut JsObject);
|
||||
bind_well_known_symbol(kernel, ctor, sf, sh, "search", sym_search_val);
|
||||
|
||||
let sym_split_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_split.as_ptr() as *mut JsObject);
|
||||
bind_well_known_symbol(kernel, ctor, sf, sh, "split", sym_split_val);
|
||||
|
||||
let sym_iterator_val =
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_iterator.as_ptr() as *mut JsObject);
|
||||
bind_well_known_symbol(kernel, ctor, sf, sh, "iterator", sym_iterator_val);
|
||||
for (name, val) in [
|
||||
(
|
||||
"match",
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_match.as_ptr() as *mut JsObject),
|
||||
),
|
||||
(
|
||||
"replace",
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_replace.as_ptr() as *mut JsObject),
|
||||
),
|
||||
(
|
||||
"search",
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_search.as_ptr() as *mut JsObject),
|
||||
),
|
||||
(
|
||||
"split",
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_split.as_ptr() as *mut JsObject),
|
||||
),
|
||||
(
|
||||
"iterator",
|
||||
JsValue::from_js_object(kernel.builtin_world().sym_iterator.as_ptr() as *mut JsObject),
|
||||
),
|
||||
] {
|
||||
bind_well_known_symbol(kernel, ctor, name, val);
|
||||
}
|
||||
|
||||
bind_constructor_hash!(
|
||||
kernel,
|
||||
@@ -58,8 +61,6 @@ pub fn bind_symbol(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
|
||||
fn bind_well_known_symbol(
|
||||
kernel: &Arc<OxideKernel>,
|
||||
ctor: &mut JsObject,
|
||||
_sf: &oxide_kernel::string_forge::StringForge,
|
||||
_sh: &oxide_kernel::shape_forge::ShapeForge,
|
||||
name: &str,
|
||||
val: JsValue,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user