Declare visual capabilities and dispatch explicit Presentable views
Verify Tessera GUI / verify (push) Failing after 7m41s
Verify Tessera GUI / verify (push) Failing after 7m41s
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
//! Host capability definitions over Aster's explicit managed trait relations.
|
||||
use endor_core::{MethodRequirement, ObjectRef, Value, Vm, VmError};
|
||||
|
||||
pub fn install(
|
||||
vm: &mut Vm,
|
||||
roots: &mut Vec<ObjectRef>,
|
||||
desktop: ObjectRef,
|
||||
ui: ObjectRef,
|
||||
) -> Result<(), VmError> {
|
||||
let Value::Object(trait_type) = vm.get_attr(ui, "Trait")? else {
|
||||
return Err(VmError::InvalidArgument("missing Trait type"));
|
||||
};
|
||||
let Value::Object(types) = vm.get_attr(desktop, "types")? else {
|
||||
return Err(VmError::InvalidArgument("missing type registry"));
|
||||
};
|
||||
for (name, methods, owner) in [
|
||||
(
|
||||
"Visual",
|
||||
vec![("measure", 2), ("arrange", 2), ("paint", 2), ("hitTest", 2)],
|
||||
Some("Block"),
|
||||
),
|
||||
(
|
||||
"EventTarget",
|
||||
vec![("on", 3), ("dispatch", 2), ("onEvent", 1)],
|
||||
Some("Block"),
|
||||
),
|
||||
(
|
||||
"Children",
|
||||
vec![
|
||||
("append", 1),
|
||||
("remove", 1),
|
||||
("replace", 2),
|
||||
("move", 2),
|
||||
("children", 0),
|
||||
],
|
||||
Some("ContainerBlock"),
|
||||
),
|
||||
("Presentable", vec![("present", 1)], None),
|
||||
] {
|
||||
let requirements = methods
|
||||
.into_iter()
|
||||
.map(|(name, parameters)| MethodRequirement {
|
||||
name: name.into(),
|
||||
parameters,
|
||||
})
|
||||
.collect();
|
||||
let capability = vm.new_trait(name, requirements)?;
|
||||
roots.push(capability);
|
||||
vm.attach_type(capability, trait_type)?;
|
||||
vm.set_attr(ui, name, Value::Object(capability))?;
|
||||
vm.dict_set(types, Value::Text(name.into()), Value::Object(capability))?;
|
||||
if let Some(owner) = owner {
|
||||
let Value::Object(owner) = vm.get_attr(ui, owner)? else {
|
||||
return Err(VmError::InvalidArgument("missing protocol owner"));
|
||||
};
|
||||
vm.implement_trait(owner, capability)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user