diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-24 20:20:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-24 20:20:50 +0200 |
commit | 425fb7fdbe9cdb48ad84dda45c53d92dc23c3ad4 (patch) | |
tree | b1cf711fea2d891efdfe2b29f9bf908d9f629572 /odb/inline.cxx | |
parent | dfc260adf46e79b039685d554797b403d76c6bfd (diff) |
Cleanup of member access
Diffstat (limited to 'odb/inline.cxx')
-rw-r--r-- | odb/inline.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
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<type*> (&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<member_access> ("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) |