From 8d89bf37dd4ef3cb7373e1841ff57a53916fff0d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Mar 2012 08:36:21 +0200 Subject: Polymorphic inheritance support --- odb/common.cxx | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'odb/common.cxx') diff --git a/odb/common.cxx b/odb/common.cxx index 35bfc87..28b80cb 100644 --- a/odb/common.cxx +++ b/odb/common.cxx @@ -85,12 +85,23 @@ traverse (semantics::class_& c) return; } - semantics::class_* prev (context::cur_object); - context::cur_object = &c; + if (top_level_) + top_level_ = false; + else + { + // Unless requested otherwise, don't go into bases if we are a derived + // type in a polymorphic hierarchy. + // + if (!traverse_poly_base_ && polymorphic (c)) + return; + } if (context::top_object == 0) context::top_object = &c; + semantics::class_* prev (context::cur_object); + context::cur_object = &c; + if (member_scope_.empty ()) member_scope_.push_back (class_inheritance_chain ()); @@ -138,10 +149,10 @@ traverse (semantics::class_& c) if (member_scope_.back ().empty ()) member_scope_.pop_back (); + context::cur_object = prev; + if (prev == 0) context::top_object = 0; - - context::cur_object = prev; } void object_members_base:: @@ -363,15 +374,23 @@ traverse (semantics::class_& c) if (top_level_) top_level_ = false; + else + { + // Unless requested otherwise, don't go into bases if we are a derived + // type in a polymorphic hierarchy. + // + if (!traverse_poly_base_ && polymorphic (c)) + return; + } semantics::class_* prev (0); if (k == class_object || k == class_view) { - prev = context::cur_object; - context::cur_object = &c; - if (context::top_object == 0) context::top_object = &c; + + prev = context::cur_object; + context::cur_object = &c; } if (member_scope_.empty ()) @@ -393,10 +412,10 @@ traverse (semantics::class_& c) if (k == class_object || k == class_view) { + context::cur_object = prev; + if (prev == 0) context::top_object = 0; - - context::cur_object = prev; } if (f && !first_) -- cgit v1.1