diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-12 13:54:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-12 13:54:21 +0200 |
commit | d72e5f95e70976f9b8bc29a7ace3c354e815ca49 (patch) | |
tree | 4ac1f39941be5c6cd57287e15a049ec4d62eb126 /libbuild2/variable.hxx | |
parent | 446c6548a1b61a18a27e24320a53a66a3ef7008a (diff) |
Add int64 and int64s variable types
Diffstat (limited to 'libbuild2/variable.hxx')
-rw-r--r-- | libbuild2/variable.hxx | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index 99eb3aa..6c78c95 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -710,6 +710,30 @@ namespace build2 static const build2::value_type value_type; }; + // int64_t + // + template <> + struct LIBBUILD2_SYMEXPORT value_traits<int64_t> + { + static_assert (sizeof (int64_t) <= value::size_, "insufficient space"); + + // Note: in some places we rely on the convert() function not changing + // the passed names thus we make them const. + // + static int64_t convert (const name&, const name*); + static void assign (value&, int64_t); + static void append (value&, int64_t); // ADD. + static name reverse (int64_t x) {return name (to_string (x));} + static int compare (int64_t, int64_t); + static bool empty (bool) {return false;} + + static const bool empty_value = false; + static const char* const type_name; + static const build2::value_type value_type; + }; + + // uint64_t + // template <> struct LIBBUILD2_SYMEXPORT value_traits<uint64_t> { @@ -730,13 +754,20 @@ namespace build2 static const build2::value_type value_type; }; - // Treat unsigned integral types as uint64. Note that bool is handled - // differently at an earlier stage. + // Treat signed/unsigned integral types as int64/uint64. Note that bool is + // handled differently at an earlier stage. // template <typename T> struct value_traits_specialization<T, typename std::enable_if< std::is_integral<T>::value && + std::is_signed<T>::value>::type>: + value_traits<int64_t> {}; + + template <typename T> + struct value_traits_specialization<T, + typename std::enable_if< + std::is_integral<T>::value && std::is_unsigned<T>::value>::type>: value_traits<uint64_t> {}; @@ -1055,6 +1086,7 @@ namespace build2 extern template struct LIBBUILD2_DECEXPORT value_traits<vector<name>>; extern template struct LIBBUILD2_DECEXPORT value_traits<paths>; extern template struct LIBBUILD2_DECEXPORT value_traits<dir_paths>; + extern template struct LIBBUILD2_DECEXPORT value_traits<int64s>; extern template struct LIBBUILD2_DECEXPORT value_traits<uint64s>; extern template struct LIBBUILD2_DECEXPORT |