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