mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 03:31:12 +08:00
refactor: 内置十四文件迁移内核访问器调用至能力方法
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! Temporal.Duration:ISO 字符串与 property bag 解析、构造、getter、total/round、
|
||||
//! 加减比较与格式化。
|
||||
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -265,7 +265,7 @@ pub(crate) fn duration_like_values<H: VmHost>(vm: &mut H, val: JsValue) -> Resul
|
||||
|
||||
/// `Temporal.Duration` 构造器,保存十个整数时长分量。
|
||||
pub fn duration_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().duration_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::DurationProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use chrono::Utc;
|
||||
use num_traits::ToPrimitive;
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -300,7 +300,7 @@ pub fn now_time_zone_id<H: VmHost>(vm: &mut H, _args: &[u8]) -> NativeResult {
|
||||
|
||||
/// `Temporal.Instant` 构造器:把参数按 ToBigInt 转换为纪元纳秒。
|
||||
pub fn instant_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().instant_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::InstantProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Temporal.PlainDate:ISO 日期解析与校验、构造、getter、日历属性与加减/差值。
|
||||
|
||||
use chrono::{Datelike, Days, NaiveDate};
|
||||
use oxide_runtime_api::{to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -138,7 +138,7 @@ pub(crate) fn parse_iso_date(s: &str) -> Result<(i32, u32, u32), String> {
|
||||
|
||||
/// `Temporal.PlainDate` 构造器:`new PlainDate(year, month, day)`。
|
||||
pub fn plain_date_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().plain_date_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::PlainDateProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Temporal.PlainDateTime:ISO 日期时间解析、构造、getter、日历属性与加减/差值。
|
||||
|
||||
use chrono::{Datelike, NaiveDate};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -20,7 +20,7 @@ use super::{
|
||||
|
||||
/// `Temporal.PlainDateTime` 构造器:保存 ISO 日期与午夜后纳秒。
|
||||
pub fn plain_date_time_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().plain_date_time_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::PlainDateTimeProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Temporal.PlainMonthDay:ISO 月日解析、构造、getter 与 with/toPlainDate。
|
||||
|
||||
use oxide_runtime_api::{to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -60,7 +60,7 @@ pub(crate) fn temporal_constructor_calendar_id<H: VmHost>(vm: &mut H, value: JsV
|
||||
|
||||
/// `Temporal.PlainMonthDay` 构造器:`new PlainMonthDay(month, day[, calendar[, referenceISOYear]])`。
|
||||
pub fn plain_month_day_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().plain_month_day_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::PlainMonthDayProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Temporal.PlainTime:ISO 时间解析、构造、getter、with/until/since 与加减舍入。
|
||||
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -272,7 +272,7 @@ pub(crate) fn valid_plain_time(hour: u32, minute: u32, second: u32, ms: u32, us:
|
||||
|
||||
/// `Temporal.PlainTime` 构造器:`new PlainTime(h, m, s, ms, us, ns)`,缺省为 0。
|
||||
pub fn plain_time_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().plain_time_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::PlainTimeProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Temporal.PlainYearMonth:ISO 年月解析、构造、getter、日历属性与 with/加减差值。
|
||||
|
||||
use oxide_runtime_api::{to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -26,7 +26,7 @@ fn plain_year_month_ymd<H: VmHost>(vm: &mut H, args: &[u8]) -> Result<(f64, f64,
|
||||
|
||||
/// `Temporal.PlainYearMonth` 构造器:`new PlainYearMonth(year, month[, calendar[, referenceISODay]])`。
|
||||
pub fn plain_year_month_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().plain_year_month_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::PlainYearMonthProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! with/until/since、舍入、加减与格式化。
|
||||
|
||||
use chrono::{Datelike, NaiveDate};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, VmHost};
|
||||
use oxide_runtime_api::{to_number, to_string, NativeResult, ProtoKind, VmHost};
|
||||
use oxide_types::object::JsObject;
|
||||
use oxide_types::value::JsValue;
|
||||
|
||||
@@ -34,7 +34,7 @@ use super::{
|
||||
|
||||
/// `Temporal.ZonedDateTime` 构造器:保存纪元纳秒、固定偏移或 UTC 时区以及 ISO 日历。
|
||||
pub fn zoned_date_time_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
|
||||
let ctor_proto = vm.session().builtin_world().zoned_date_time_proto.as_ptr();
|
||||
let ctor_proto = vm.builtin_proto(ProtoKind::ZonedDateTimeProto);
|
||||
if !is_ctor_call(vm, args, ctor_proto) {
|
||||
return NativeResult::Err(crate::error::create_type_error(
|
||||
vm,
|
||||
|
||||
Reference in New Issue
Block a user