feat: expose native visual protocols and explicit invalidation
Verify Tessera GUI / verify (push) Failing after 7m23s

This commit is contained in:
2026-10-21 02:42:16 +08:00
parent d2f167e71f
commit dc61f5e33c
13 changed files with 691 additions and 140 deletions
+1 -57
View File
@@ -411,60 +411,4 @@ impl MountTable {
}
}
#[derive(Debug)]
struct MountSet(Vec<ObjectRef>);
impl ObjectPayload for MountSet {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn kind_name(&self) -> &'static str {
"tessera-mount-set"
}
fn allows_attributes(&self) -> bool {
true
}
fn trace(&self, visit: &mut dyn FnMut(ObjectRef)) {
for mount in &self.0 {
visit(*mount);
}
}
}
#[derive(Debug)]
struct At(ObjectRef);
impl NativeCallable for At {
fn invoke(&self, cx: &mut NativeContext<'_>, args: &[Value]) -> Result<NativeResult, VmError> {
let [Value::Number(index)] = args else {
return Err(VmError::InvalidArgument("mount set at expects an index"));
};
let index = index
.as_i64()
.and_then(|v| usize::try_from(v).ok())
.ok_or(VmError::InvalidArgument("invalid mount index"))?;
let mount = *cx
.store()
.payload::<MountSet>(self.0, "Mount set")?
.0
.get(index)
.ok_or(VmError::InvalidArgument("mount index out of range"))?;
Ok(NativeResult::Return(Value::Object(mount)))
}
}
pub fn collection(
cx: &mut NativeContext<'_>,
mounts: Vec<ObjectRef>,
) -> Result<ObjectRef, VmError> {
let first = mounts
.first()
.copied()
.map(Value::Object)
.unwrap_or(Value::Nil);
let count = mounts.len();
let set = cx.allocate(MountSet(mounts))?;
cx.set_attr(set, "first", first)?;
cx.set_attr(set, "count", Value::Number((count as i64).into()))?;
let at = cx.allocate(ContextNativeFunction::new("at", At(set), vec![set]))?;
cx.set_attr(set, "at", Value::Object(at))?;
Ok(set)
}
pub use crate::object_list::collection;