feat: render source paint overrides with read-only object dependencies
Verify Tessera GUI / verify (push) Failing after 7m37s

This commit is contained in:
2026-10-21 14:20:02 +08:00
parent dc61f5e33c
commit 6a88447524
12 changed files with 637 additions and 7 deletions
+69 -1
View File
@@ -48,6 +48,20 @@ pub fn collection(
mounts: Vec<ObjectRef>,
desktop: ObjectRef,
) -> Result<ObjectRef, VmError> {
build(cx, mounts, desktop, None)
}
fn build(
cx: &mut NativeContext<'_>,
mounts: Vec<ObjectRef>,
desktop: ObjectRef,
definition: Option<ObjectRef>,
) -> Result<ObjectRef, VmError> {
if mounts.len() > 10_000 {
return Err(VmError::InvalidArgument(
"object list exceeds 10000 members",
));
}
let first = mounts
.first()
.copied()
@@ -55,7 +69,11 @@ pub fn collection(
.unwrap_or(Value::Nil);
let count = mounts.len();
let set = cx.allocate(ObjectList(mounts))?;
crate::ui_bridge::attach_desktop_type(cx, set, "ObjectList", desktop)?;
if let Some(definition) = definition {
cx.attach_type(set, definition)?;
} else {
crate::ui_bridge::attach_desktop_type(cx, set, "ObjectList", desktop)?;
}
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]))?;
@@ -63,3 +81,53 @@ pub fn collection(
cx.set_attr(set, "at", Value::Object(at))?;
Ok(set)
}
pub fn items(store: &endor_core::ObjectStore, list: ObjectRef) -> Result<&[ObjectRef], VmError> {
Ok(&store.payload::<ObjectList>(list, "ObjectList")?.0)
}
#[derive(Debug)]
pub struct Constructor {
pub desktop: ObjectRef,
}
impl NativeCallable for Constructor {
fn invoke(&self, cx: &mut NativeContext<'_>, args: &[Value]) -> Result<NativeResult, VmError> {
let [Value::Object(definition), values @ ..] = args else {
return Err(VmError::InvalidArgument("ObjectList type argument"));
};
let fields = cx
.store()
.payload::<endor_core::EndorTypeObject>(*definition, "Type")?
.fields()
.to_vec();
if fields
.iter()
.any(|field| matches!(field.name.as_str(), "count" | "first" | "at"))
{
return Err(VmError::InvalidArgument("reserved ObjectList field"));
}
let count = values
.len()
.checked_sub(fields.len())
.ok_or(VmError::InvalidArgument(
"missing ObjectList subclass fields",
))?;
let members = values[..count]
.iter()
.map(|value| {
if let Value::Object(object) = value {
Ok(*object)
} else {
Err(VmError::InvalidArgument(
"ObjectList members must be objects",
))
}
})
.collect::<Result<Vec<_>, _>>()?;
let list = build(cx, members, self.desktop, Some(*definition))?;
for (field, value) in fields.iter().zip(&values[count..]) {
cx.set_attr(list, &field.name, value.clone())?;
}
Ok(NativeResult::Return(Value::Object(list)))
}
}