From 425fb7fdbe9cdb48ad84dda45c53d92dc23c3ad4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Jun 2015 20:20:50 +0200 Subject: Cleanup of member access --- odb/inline.cxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'odb/inline.cxx') diff --git a/odb/inline.cxx b/odb/inline.cxx index 73b50c1..1af84b6 100644 --- a/odb/inline.cxx +++ b/odb/inline.cxx @@ -116,6 +116,8 @@ traverse_object (type& c) bool auto_id (id && auto_ (*id)); bool base_id (id && &id->scope () != &c); // Comes from base. + data_member* opt (context::optimistic (c)); + // Base class that contains the object id. // type* base (id != 0 && base_id ? dynamic_cast (&id->scope ()) : 0); @@ -166,6 +168,34 @@ traverse_object (type& c) os << "}"; } + if (opt != 0) + { + os << "inline" << endl + << traits << "::version_type" << endl + << traits << "::" << endl + << "version (const object_type& o)" + << "{"; + + if (base_id) + os << "return object_traits< " << class_fq_name (*base) << + " >::version (o);"; + else + { + // Get the id using the accessor expression. If this is not + // a synthesized expression, then output its location for + // easier error tracking. + // + member_access& ma (opt->get ("get")); + + if (!ma.synthesized) + os << "// From " << location_string (ma.loc, true) << endl; + + os << "return " << ma.translate ("o") << ";"; + } + + os << "}"; + } + // The rest does not apply to reuse-abstract objects. // if (reuse_abst) -- cgit v1.1