refactor: 内置十四文件迁移内核访问器调用至能力方法

This commit is contained in:
2026-10-08 07:59:40 +00:00
parent 5970f804d7
commit 47912535d5
16 changed files with 47 additions and 48 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
use oxide_runtime_api::{NativeResult, VmHost};
use oxide_runtime_api::{NativeResult, ProtoKind, VmHost};
use oxide_types::object::JsObject;
use oxide_types::value::JsValue;
@@ -114,7 +114,7 @@ pub fn string_value_of<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
/// JS `String()` 构造逻辑:把参数转成字符串(单元保真);new 语义返回
/// `[[StringData]]` 包装对象。
pub fn string_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let string_proto = vm.session().builtin_world().string_proto.as_ptr() as *mut JsObject;
let string_proto = vm.builtin_proto(ProtoKind::StringProto);
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
let is_ctor = if this_val.is_object() {
let ptr = this_val.as_js_object_ptr();
+2 -2
View File
@@ -4,7 +4,7 @@ use oxide_kernel::shape_forge::EMPTY_SHAPE_ID;
use oxide_types::object::JsObject;
use oxide_types::value::JsValue;
use oxide_runtime_api::VmHost;
use oxide_runtime_api::{ProtoKind, VmHost};
macro_rules! try_string {
($e:expr) => {
@@ -398,7 +398,7 @@ pub(crate) fn split_limit_to_uint32<H: VmHost>(vm: &mut H, limit_val: JsValue) -
/// 以已构造的字符串值构建字符串数组(元素零拷贝落地),供逐单元产出路径
/// (空分隔 split)复用,跳过 `Vec<String>` 中间层。
pub(crate) fn make_string_array_values<H: VmHost>(vm: &mut H, parts: Vec<JsValue>) -> JsValue {
let proto = vm.session().builtin_world().array_proto.as_ptr() as *mut JsObject;
let proto = vm.builtin_proto(ProtoKind::ArrayProto);
let n = parts.len();
let arr = vm.alloc_object(JsObject::new_array(EMPTY_SHAPE_ID, JsValue::from_js_object(proto), n));
unsafe {