check_call_opt_key: [] -> ()
(cherry picked from commit 76966c24dcf6413a4ebdfe0ddba00e3d1d7e5fff)
This commit is contained in:
parent
cc2e640e7f
commit
c235b32868
2 changed files with 4 additions and 4 deletions
|
|
@ -225,12 +225,12 @@ impl EvalState {
|
|||
let attr_name = CString::new(attr_name)
|
||||
.with_context(|| "require_attrs_select_opt: attrName contains null byte")?;
|
||||
let v2 = unsafe {
|
||||
check_call_opt_key!(raw::get_attr_byname[
|
||||
check_call_opt_key!(raw::get_attr_byname(
|
||||
&mut self.context,
|
||||
v.raw_ptr(),
|
||||
self.eval_state.as_ptr(),
|
||||
attr_name.as_ptr()
|
||||
])
|
||||
))
|
||||
}?;
|
||||
Ok(v2.map(Value::new))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ pub use check_call;
|
|||
// TODO: Generalize this macro to work with any error code or any error handling logic
|
||||
#[macro_export]
|
||||
macro_rules! check_call_opt_key {
|
||||
($f:path[$ctx:expr, $($arg:expr),*]) => {
|
||||
($($f:ident)::+($ctx:expr, $($arg:expr),*)) => {
|
||||
{
|
||||
let ctx : &mut $crate::context::Context = $ctx;
|
||||
let ret = $f(ctx.ptr(), $($arg,)*);
|
||||
let ret = $($f)::*(ctx.ptr(), $($arg,)*);
|
||||
if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } {
|
||||
ctx.clear();
|
||||
return Ok(None);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue