aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.h
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2016-08-28 08:09:29 +0300
committerZyX <kp-pav@yandex.ru>2017-03-29 10:08:05 +0300
commit7ee5cc7429017a4a08a8b62b628bea156fea0008 (patch)
tree4f5e046b3265fb4eda2ca3c51b8a53517f86255c /src/nvim/eval/typval.h
parent949f09bdbba592a12629c71e20ff7bb49a21db6c (diff)
downloadrneovim-7ee5cc7429017a4a08a8b62b628bea156fea0008.tar.gz
rneovim-7ee5cc7429017a4a08a8b62b628bea156fea0008.tar.bz2
rneovim-7ee5cc7429017a4a08a8b62b628bea156fea0008.zip
eval: Move get_tv_lnum and get_tv_float to eval/typval.h
Additionally - Rename former tv_get_float to tv_get_float_chk due to name conflict (former get_tv_float is better suited for being tv_get_float). - Add E907 error to get_tv_float() and test that it is being raised when appropriate.
Diffstat (limited to 'src/nvim/eval/typval.h')
-rw-r--r--src/nvim/eval/typval.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 5645772124..3c294b45b8 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -14,6 +14,7 @@
#include "nvim/profile.h" // for proftime_T
#include "nvim/pos.h" // for linenr_T
#include "nvim/gettext.h"
+#include "nvim/message.h"
/// Type used for VimL VAR_NUMBER values
typedef int varnumber_T;
@@ -373,7 +374,8 @@ extern bool tv_in_free_unref_items;
} \
})
-static inline bool tv_get_float(const typval_T *const tv, float_T *const ret_f)
+static inline bool tv_get_float_chk(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.
@@ -381,11 +383,14 @@ bool emsgf(const char *const fmt, ...);
/// Get the float value
///
+/// Raises an error if object is not number or floating-point.
+///
/// @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)
+static inline bool tv_get_float_chk(const typval_T *const tv,
+ float_T *const ret_f)
{
if (tv->v_type == VAR_FLOAT) {
*ret_f = tv->vval.v_float;