mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
eval: Move get_float_arg to typval.h
Assuming `inline` is there for a reason, so it is kept and function was moved to typval.h and not to typval.c which does not have problems with #including message.h.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "nvim/lib/queue.h"
|
||||
#include "nvim/profile.h" // for proftime_T
|
||||
#include "nvim/pos.h" // for linenr_T
|
||||
#include "nvim/gettext.h"
|
||||
|
||||
/// Type used for VimL VAR_NUMBER values
|
||||
typedef int varnumber_T;
|
||||
@@ -370,6 +371,32 @@ extern bool tv_in_free_unref_items;
|
||||
} \
|
||||
})
|
||||
|
||||
static inline bool tv_get_float(const typval_T *const tv, float_T *const ret_f)
|
||||
REAL_FATTR_NONNULL_ALL REAL_FATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
// FIXME circular dependency, cannot import message.h.
|
||||
bool emsgf(const char *const fmt, ...);
|
||||
|
||||
/// Get the float value
|
||||
///
|
||||
/// @param[in] tv VimL object to get value from.
|
||||
/// @param[out] ret_f Location where resulting float is stored.
|
||||
///
|
||||
/// @return true in case of success, false if tv is not a number or float.
|
||||
static inline bool tv_get_float(const typval_T *const tv, float_T *const ret_f)
|
||||
{
|
||||
if (tv->v_type == VAR_FLOAT) {
|
||||
*ret_f = tv->vval.v_float;
|
||||
return true;
|
||||
}
|
||||
if (tv->v_type == VAR_NUMBER) {
|
||||
*ret_f = (float_T)tv->vval.v_number;
|
||||
return true;
|
||||
}
|
||||
emsgf(_("E808: Number or Float required"));
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "eval/typval.h.generated.h"
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user