From a7e3df85fd7180aa0daf0947e50b08d51b7e2380 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 3 Jul 2015 20:08:05 +0200 Subject: Add support for defining views as class template instantiations --- NEWS | 5 +++++ odb/common.cxx | 4 ++-- odb/common.hxx | 2 +- odb/pragma.cxx | 13 ++++++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 548774e..030073f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +Version 2.5.0 + + * Support for defining views as instantiations of C++ class templates, + similar to objects and composite value types. + Version 2.4.0 * Support for object loading views. Object loading views allow loading of diff --git a/odb/common.cxx b/odb/common.cxx index 6d341b8..21475d3 100644 --- a/odb/common.cxx +++ b/odb/common.cxx @@ -551,9 +551,9 @@ check (semantics::typedefs& t) if (ci == 0) return false; - // It must be an object or composite value. + // It must be an object, view, or composite value. // - if (!object (*ci) && !composite (*ci)) + if (class_kind (*ci) == class_other) return false; // This typedef name should be the one that was used in the pragma. diff --git a/odb/common.hxx b/odb/common.hxx index ef85a4b..170b33c 100644 --- a/odb/common.hxx +++ b/odb/common.hxx @@ -440,7 +440,7 @@ private: columns columns_; }; -// Traverse objects and composite values that are class template +// Traverse objects, views, and composite values that are class template // instantiations. // struct typedefs: traversal::typedefs, context diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 046140e..11e1d4e 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -4335,8 +4335,8 @@ register_odb_pragmas (void*, void*) void post_process_pragmas () { - // Make sure object and composite class template instantiations are fully - // instantiated. + // Make sure object, view, and composite class template instantiations + // are fully instantiated. // for (decl_pragmas::iterator i (decl_pragmas_.begin ()), e (decl_pragmas_.end ()); i != e; ++i) @@ -4349,7 +4349,7 @@ post_process_pragmas () if (!(CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INSTANTIATION (type))) continue; - // Check whether this is an object or composite value type. + // Check whether this is an object, view, or composite value type. // pragma const* p (0); string diag_name; @@ -4365,10 +4365,17 @@ post_process_pragmas () diag_name = "persistent object"; break; } + else if (name == "view") + { + p = &*j; + diag_name = "view"; + break; + } else if (name == "value") { p = &*j; diag_name = "composite value"; + break; } // We don't want to instantiate simple values since they may be // incomplete. -- cgit v1.1