Skip to main content

value_auto_call_function

Function value_auto_call_function 

Source
pub unsafe extern "C" fn value_auto_call_function(
    context: *mut c_context,
    state: *mut EvalState,
    auto_args: *mut value,
    fn_val: *mut value,
    result: *mut value,
) -> err
Expand description

@brief Call a function, drawing its arguments from an attribute set.

Forces @p fn_val and writes the application result into @p result. The result is not forced; call nix_value_force() to evaluate it before inspecting the final value.

  • If @p fn_val is a function that takes a set of named arguments (e.g. { a, b ? 1 }: ...), it is called with an attribute set assembled from @p auto_args: each named argument is taken from @p auto_args when present; an argument absent from @p auto_args falls back to its default; an argument that is both absent and has no default is an error.
  • Otherwise @p fn_val is copied into @p result unchanged. This includes any non-function value as well as a function that takes a single unnamed argument (e.g. x: ...), since there are no named arguments to supply.

@param[out] context Optional, stores error information @param[in] state The evaluation state. @param[in] auto_args Attribute set value supplying the named arguments, or NULL to supply none. @param[in] fn_val The value to call. @param[out] result Pre-allocated nix_value that receives the result. @return NIX_OK if the call was successful, an error code otherwise.