From 7f6c64f2211d37db76a97fbc79a4b5492302ef2f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 27 Oct 2010 17:36:59 +0200 Subject: Implement support for composite value types New test: common/composite. --- odb/validator.cxx | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'odb/validator.cxx') diff --git a/odb/validator.cxx b/odb/validator.cxx index 9f733a1..ee1c4dc 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -6,6 +6,7 @@ #include #include +#include #include using namespace std; @@ -77,8 +78,22 @@ namespace virtual void traverse (type& c) { - if (c.file () != unit_.file () || !c.count ("object")) - return; + if (c.count ("object")) + traverse_object (c); + else if (context::comp_value (c)) + traverse_value (c); + } + + virtual void + traverse_object (type& c) + { + if (c.inherits_begin () != c.inherits_end ()) + { + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: object inheritance is not yet supported" << endl; + + valid_ = false; + } member_.count_ = 0; member_.id_ = 0; @@ -106,6 +121,59 @@ namespace } } + virtual void + traverse_value (type& c) + { + for (type::inherits_iterator i (c.inherits_begin ()); + i != c.inherits_end (); + ++i) + { + type& b (i->base ()); + + if (!context::comp_value (b)) + { + // @@ Should we use hint here? Need template printer. + // + string name (b.fq_anonymous () ? "" : b.fq_name ()); + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: base class '" << name << "' is not a " + << "composite value type" << endl; + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " info: composite value types can only derive from other " + << "composite value types" << endl; + + cerr << b.file () << ":" << b.line () << ":" << b.column () << ":" + << " info: class '" << name << "' is defined here" << endl; + + valid_ = false; + } + } + + member_.count_ = 0; + member_.id_ = 0; + + names (c); + + if (member_.id_ != 0) + { + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: value type data member cannot be designated as " + << "object id" << endl; + + valid_ = false; + } + + if (member_.count_ == 0) + { + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: no persistent data members in the class" << endl; + + valid_ = false; + } + } + bool& valid_; semantics::unit& unit_; -- cgit v1.1