From 2ca7acef7c858fb7f21b5101dedfc021aea62ff8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Jun 2015 17:12:20 +0200 Subject: Get rid of member_[u]type(), other cleanups --- odb/context.hxx | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'odb/context.hxx') diff --git a/odb/context.hxx b/odb/context.hxx index a98167f..e743a4a 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -614,12 +614,20 @@ public: static semantics::type& utype (semantics::type&, semantics::names*& hint); - // The same for a member's type. + // The same for a member's type but also do custom C++ type translation. // static semantics::type& utype (semantics::data_member& m) { - return utype (m.type ()); + semantics::names* hint (0); + return utype (m, hint); + } + + static semantics::type& + utype (semantics::data_member& m, string const& key_prefix) + { + semantics::names* hint (0); + return utype (m, hint, key_prefix); } // In addition to the unqualified type, this version also returns the @@ -628,7 +636,9 @@ public: // qualifies edge. // static semantics::type& - utype (semantics::data_member&, semantics::names*& hint); + utype (semantics::data_member&, + semantics::names*& hint, + string const& key_prefix = string ()); // For arrays this function returns true if the (innermost) element // type is const. @@ -636,15 +646,6 @@ public: static bool const_type (semantics::type&); - static semantics::type& - member_type (semantics::data_member&, string const& key_prefix); - - static semantics::type& - member_utype (semantics::data_member& m, string const& key_prefix) - { - return utype (member_type (m, key_prefix)); - } - // Form a reference type for a member type. If make_const is true, then // add top-level const qualifier, unless it is already there. If it is // false, then strip it if it is already there. If var is not empty, @@ -1448,7 +1449,7 @@ public: if (key_prefix.empty ()) return inverse (m); - if (!object_pointer (member_utype (m, key_prefix))) + if (!object_pointer (utype (m, key_prefix))) return 0; string k (key_prefix + "-inverse"); @@ -1475,7 +1476,7 @@ public: static semantics::type& container_idt (semantics::data_member& m) { - return member_utype (m, "id"); + return utype (m, "id"); } static semantics::type& @@ -1611,6 +1612,25 @@ private: return c.get (key); } + static semantics::type* + indirect_type (semantics::context const& c, + string const& kp, + semantics::names*& hint) + { + typedef semantics::type* (*func) (semantics::names*&); + + string const tk (kp + "-tree-type"); + std::type_info const& ti (c.type_info (tk)); + + if (ti == typeid (func)) + return c.get (tk) (hint); + else + { + hint = c.get (kp + "-tree-hint"); + return c.get (tk); + } + } + public: typedef std::set keyword_set_type; -- cgit v1.1