From d72e5f95e70976f9b8bc29a7ace3c354e815ca49 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Aug 2020 13:54:21 +0200 Subject: Add int64 and int64s variable types --- libbuild2/variable.hxx | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'libbuild2/variable.hxx') 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 + { + 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 { @@ -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 struct value_traits_specialization::value && + std::is_signed::value>::type>: + value_traits {}; + + template + struct value_traits_specialization::value && std::is_unsigned::value>::type>: value_traits {}; @@ -1055,6 +1086,7 @@ namespace build2 extern template struct LIBBUILD2_DECEXPORT value_traits>; extern template struct LIBBUILD2_DECEXPORT value_traits; extern template struct LIBBUILD2_DECEXPORT value_traits; + extern template struct LIBBUILD2_DECEXPORT value_traits; extern template struct LIBBUILD2_DECEXPORT value_traits; extern template struct LIBBUILD2_DECEXPORT -- cgit v1.1