From 5789a4f7c5cee94df29e37fd1c2f7c1d9e883002 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Dec 2010 11:03:33 +0200 Subject: Allow inheritance from transient bases for object and composite value types --- odb/common.cxx | 10 ++++++++++ odb/mysql/context.cxx | 5 +++++ odb/mysql/header.cxx | 5 +++++ odb/mysql/source.cxx | 20 ++++++++++++++++++++ odb/validator.cxx | 43 ++++++++++++++++++++++++++++++++++--------- 5 files changed, 74 insertions(+), 9 deletions(-) diff --git a/odb/common.cxx b/odb/common.cxx index 1c1b067..6dccbc1 100644 --- a/odb/common.cxx +++ b/odb/common.cxx @@ -37,6 +37,11 @@ traverse_composite (semantics::data_member& m, semantics::class_& c) void object_members_base:: traverse (semantics::class_& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || context::comp_value (c))) + return; + if (build_table_prefix_ && c.count ("object")) { table_prefix_.prefix = ctx_->table_name (c); @@ -166,6 +171,11 @@ traverse_composite (semantics::data_member& m, void object_columns_base:: traverse (semantics::class_& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || context::comp_value (c))) + return; + inherits (c); names (c); } diff --git a/odb/mysql/context.cxx b/odb/mysql/context.cxx index d1ec0ff..c8bcd83 100644 --- a/odb/mysql/context.cxx +++ b/odb/mysql/context.cxx @@ -90,6 +90,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || context::comp_value (c))) + return; + if (c.count ("mysql::grow")) r_ = c.get ("mysql::grow"); else diff --git a/odb/mysql/header.cxx b/odb/mysql/header.cxx index 3add95e..567fc46 100644 --- a/odb/mysql/header.cxx +++ b/odb/mysql/header.cxx @@ -169,6 +169,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || comp_value (c))) + return; + if (first_) { os << ": "; diff --git a/odb/mysql/source.cxx b/odb/mysql/source.cxx index 6f159c2..e09cbc3 100644 --- a/odb/mysql/source.cxx +++ b/odb/mysql/source.cxx @@ -512,6 +512,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || comp_value (c))) + return; + os << "// " << c.name () << " base" << endl << "//" << endl << "composite_value_traits< " << c.fq_name () << @@ -680,6 +685,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || comp_value (c))) + return; + os << "// " << c.name () << " base" << endl << "//" << endl << "if (composite_value_traits< " << c.fq_name () << @@ -956,6 +966,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || comp_value (c))) + return; + os << "// " << c.name () << " base" << endl << "//" << endl << "if (composite_value_traits< " << c.fq_name () << @@ -1207,6 +1222,11 @@ namespace mysql virtual void traverse (type& c) { + // Ignore transient bases. + // + if (!(c.count ("object") || comp_value (c))) + return; + os << "// " << c.name () << " base" << endl << "//" << endl << "composite_value_traits< " << c.fq_name () << diff --git a/odb/validator.cxx b/odb/validator.cxx index 73c8f90..87edb21 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -84,12 +84,37 @@ namespace virtual void traverse_object (type& c) { - if (c.inherits_begin () != c.inherits_end ()) + for (type::inherits_iterator i (c.inherits_begin ()); + i != c.inherits_end (); + ++i) { - cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: object inheritance is not yet supported" << endl; + type& b (i->base ()); - valid_ = false; + if (b.count ("object")) + { + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: object inheritance is not yet supported" << endl; + + valid_ = false; + } + else if (context::comp_value (b)) + { + // @@ Should we use hint here? + // + string name (b.fq_name ()); + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: base class '" << name << "' is a value type" + << endl; + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " info: object types cannot derive from value types" << endl; + + cerr << b.file () << ":" << b.line () << ":" << b.column () << ":" + << " info: class '" << name << "' is defined here" << endl; + + valid_ = false; + } } member_.count_ = 0; @@ -127,19 +152,19 @@ namespace { type& b (i->base ()); - if (!context::comp_value (b)) + if (b.count ("object")) { // @@ Should we use hint here? // string name (b.fq_name ()); cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: base class '" << name << "' is not a " - << "composite value type" << endl; + << " error: base class '" << name << "' is an object type" + << endl; cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " info: composite value types can only derive from other " - << "composite value types" << endl; + << " info: composite value types cannot derive from object " + << "types" << endl; cerr << b.file () << ":" << b.line () << ":" << b.column () << ":" << " info: class '" << name << "' is defined here" << endl; -- cgit v1.1