summaryrefslogtreecommitdiff
path: root/odb/validator.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
commit7f6c64f2211d37db76a97fbc79a4b5492302ef2f (patch)
treef2e386644fcaab5c51e3f5ad0ac737ea5b4d5bd2 /odb/validator.cxx
parent5259b98c75f3754a0f713bcee4bddd0ed7ce35ef (diff)
Implement support for composite value types
New test: common/composite.
Diffstat (limited to 'odb/validator.cxx')
-rw-r--r--odb/validator.cxx72
1 files changed, 70 insertions, 2 deletions
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 <iostream>
#include <odb/traversal.hxx>
+#include <odb/context.hxx>
#include <odb/validator.hxx>
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 () ? "<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_;