Publish native arity and validate callback contracts before registration
Verify Tessera GUI / verify (push) Failing after 7m44s

This commit is contained in:
2026-10-22 12:03:24 +08:00
parent 50422f801a
commit 25275b515c
17 changed files with 297 additions and 35 deletions
+12
View File
@@ -9,6 +9,10 @@ use endor_core::{
#[derive(Debug)]
struct Boolean;
impl NativeCallable for Boolean {
fn arity(&self) -> Option<endor_core::CallArity> {
Some(endor_core::CallArity::exact(1))
}
fn invoke(&self, _: &mut NativeContext<'_>, args: &[Value]) -> Result<NativeResult, VmError> {
let [Value::Bool(value)] = args else {
return Err(VmError::InvalidArgument("hitTest must return Bool"));
@@ -19,6 +23,10 @@ impl NativeCallable for Boolean {
#[derive(Debug)]
struct SameTarget;
impl NativeCallable for SameTarget {
fn arity(&self) -> Option<endor_core::CallArity> {
Some(endor_core::CallArity::exact(2))
}
fn invoke(&self, _: &mut NativeContext<'_>, args: &[Value]) -> Result<NativeResult, VmError> {
let value = match args {
[Value::Object(first), Value::Object(second)] if first == second => {
@@ -132,6 +140,10 @@ struct Prepare {
desktop: ObjectRef,
}
impl NativeCallable for Prepare {
fn arity(&self) -> Option<endor_core::CallArity> {
Some(endor_core::CallArity::exact(0))
}
fn invoke(&self, cx: &mut NativeContext<'_>, _: &[Value]) -> Result<NativeResult, VmError> {
let down = selector(cx, &self.candidates, self.press, self.desktop)?;
let up = selector(cx, &self.candidates, self.release, self.desktop)?;