Refine package API.

This commit is contained in:
Stephen Chung
2020-04-22 14:55:40 +08:00
parent c40c0a0bc3
commit 9a1c715aad
13 changed files with 147 additions and 36 deletions

View File

@@ -597,18 +597,16 @@ impl Engine {
let result = func(args, pos)?;
// See if the function match print/debug (which requires special processing)
return match fn_name {
return Ok(match fn_name {
KEYWORD_PRINT if self.on_print.is_some() => {
self.on_print.as_ref().unwrap()(cast_to_string(&result, pos)?);
Ok(().into())
self.on_print.as_ref().unwrap()(cast_to_string(&result, pos)?).into()
}
KEYWORD_DEBUG if self.on_debug.is_some() => {
self.on_debug.as_ref().unwrap()(cast_to_string(&result, pos)?);
Ok(().into())
self.on_debug.as_ref().unwrap()(cast_to_string(&result, pos)?).into()
}
KEYWORD_PRINT | KEYWORD_DEBUG => Ok(().into()),
_ => Ok(result),
};
KEYWORD_PRINT | KEYWORD_DEBUG => ().into(),
_ => result,
});
}
if let Some(prop) = extract_prop_from_getter(fn_name) {