From 9da5febf1d9af9f5cb62d5d35fc87136e6e4cd60 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Apr 2016 09:20:49 +0200 Subject: Add basic support for variable value inheritance Currently, only abs_dir_path inherits from dir_path. --- build2/variable | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'build2/variable') diff --git a/build2/variable b/build2/variable index 14bf7af..ebf0f02 100644 --- a/build2/variable +++ b/build2/variable @@ -28,6 +28,14 @@ namespace build2 const char* name; // Type name for diagnostics. const size_t size; // Type size in value::data_ (only used for PODs). + // Base type, if any. We have very limited support for inheritance: a + // const value (but not non-const) can be cast to the base type. In + // particular, a derived/base value cannot be assigned to base/derived. + // If not NULL, then the cast function below is expected to return the + // base pointer if its second argument points to the base's value_type. + // + const value_type* base; + // Destroy the value. If it is NULL, then the type is assumed to be POD // with a trivial destructor. // @@ -59,7 +67,7 @@ namespace build2 // static_cast to const T*. If it is NULL, then cast data_ directly. Note // that this function is used for both const and non-const values. // - const void* (*const cast) (const value&); + const void* (*const cast) (const value&, const value_type*); // If NULL, then the types are compared as PODs using memcmp(). // -- cgit v1.1