From 9f5c4c1ae3bff517eefb39130287016514fb31c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 6 Jan 2017 17:28:45 +0200 Subject: Store platform targets as typed target_triplet --- build2/variable.cxx | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index 1741172..48ea8aa 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -858,6 +858,51 @@ namespace build2 &default_empty }; + // target_triplet value + // + target_triplet value_traits:: + convert (name&& n, name* r) + { + if (r == nullptr) + { + if (n.simple ()) + { + try + { + return n.empty () ? target_triplet () : target_triplet (n.value); + } + catch (const invalid_argument& e) + { + throw invalid_argument ( + string ("invalid target_triplet value: ") + e.what ()); + } + } + + // Fall through. + } + + throw_invalid_argument (n, r, "target_triplet"); + } + + const char* const value_traits::type_name = "target_triplet"; + + const value_type value_traits::value_type + { + type_name, + sizeof (target_triplet), + nullptr, // No base. + &default_dtor, + &default_copy_ctor, + &default_copy_assign, + &simple_assign, + nullptr, // Append not supported. + nullptr, // Prepend not supported. + &simple_reverse, + nullptr, // No cast (cast data_ directly). + &simple_compare, + &default_empty + }; + // variable_pool // const variable& variable_pool:: -- cgit v1.1