aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-22 17:12:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-22 17:12:20 +0200
commit2ca7acef7c858fb7f21b5101dedfc021aea62ff8 (patch)
treeb53a7d56da0a7f04ee46438f5ce6bb12c05b8f3a
parent6e35807bd495c0001cba229fd082e45f0421100e (diff)
Get rid of member_[u]type(), other cleanups
-rw-r--r--odb/context.cxx66
-rw-r--r--odb/context.hxx48
-rw-r--r--odb/processor.cxx4
-rw-r--r--odb/relational/source.hxx4
-rw-r--r--odb/relational/validator.cxx2
5 files changed, 69 insertions, 55 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index dc94abc..737138a 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -946,8 +946,7 @@ null (semantics::data_member& m, string const& kp) const
return null (m);
semantics::type& c (utype (m));
- semantics::type& t (member_utype (m, kp));
- semantics::names* hint (0); // No hint for container elements.
+ semantics::type& t (utype (m, kp));
if (object_pointer (t))
{
@@ -1005,8 +1004,7 @@ null (semantics::data_member& m, string const& kp) const
// Otherwise, check the wrapped type.
//
pt = t.get<semantics::type*> ("wrapper-type");
- hint = t.get<semantics::names*> ("wrapper-hint");
- pt = &utype (*pt, hint);
+ pt = &utype (*pt);
if (pt->count ("null"))
return true;
@@ -1167,20 +1165,40 @@ utype (semantics::type& t, semantics::names*& hint)
}
semantics::type& context::
-utype (semantics::data_member& m, semantics::names*& hint)
+utype (semantics::data_member& m, semantics::names*& hint, string const& kp)
{
- semantics::type& t (m.type ());
+ semantics::type* t (0);
- if (semantics::qualifier* q = dynamic_cast<semantics::qualifier*> (&t))
+ if (kp.empty ())
{
- hint = q->qualifies ().hint ();
- return q->base_type ();
+ t = &m.type ();
+
+ if (semantics::qualifier* q = dynamic_cast<semantics::qualifier*> (t))
+ {
+ hint = q->qualifies ().hint ();
+ t = &q->base_type ();
+ }
+ else
+ hint = m.belongs ().hint ();
}
else
{
- hint = m.belongs ().hint ();
- return t;
+ if (m.count (kp + "-tree-type"))
+ t = indirect_type (m, kp, hint);
+ else
+ {
+ t = &utype (m);
+
+ // "See through" wrappers.
+ //
+ if (semantics::type* wt = wrapper (*t))
+ t = indirect_type (utype (*wt), kp, hint);
+ else
+ t = indirect_type (*t, kp, hint);
+ }
}
+
+ return *t;
}
bool context::
@@ -1192,30 +1210,6 @@ const_type (semantics::type& t)
return false;
}
-semantics::type& context::
-member_type (semantics::data_member& m, string const& key_prefix)
-{
- // This function returns the potentially-qualified type but for
- // intermediate types we use unqualified versions.
- //
- if (key_prefix.empty ())
- return m.type ();
-
- string const key (key_prefix + "-tree-type");
-
- if (m.count (key))
- return *indirect_value<semantics::type*> (m, key);
-
- // "See throught" wrappers.
- //
- semantics::type& t (utype (m));
-
- if (semantics::type* wt = wrapper (t))
- return *indirect_value<semantics::type*> (utype (*wt), key);
- else
- return *indirect_value<semantics::type*> (t, key);
-}
-
string context::
type_ref_type (semantics::type& t,
semantics::names* hint,
@@ -1969,7 +1963,7 @@ column_options (semantics::data_member& m, string const& kp)
// Accumulate options from type, container, and member.
//
semantics::type& c (utype (m));
- semantics::type& t (member_utype (m, kp));
+ semantics::type& t (utype (m, kp));
string r;
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<X> (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<func> (tk) (hint);
+ else
+ {
+ hint = c.get<semantics::names*> (kp + "-tree-hint");
+ return c.get<semantics::type*> (tk);
+ }
+ }
+
public:
typedef std::set<string> keyword_set_type;
diff --git a/odb/processor.cxx b/odb/processor.cxx
index f4cff89..ee143e2 100644
--- a/odb/processor.cxx
+++ b/odb/processor.cxx
@@ -43,11 +43,11 @@ namespace
// Indirect (dynamic) context values.
//
static semantics::type*
- id_tree_type ()
+ id_tree_type (semantics::names*& hint)
{
context& c (context::current ());
semantics::data_member& id (*context::id_member (*c.top_object));
- return &id.type ();
+ return &c.utype (id, hint);
}
struct data_member: traversal::data_member, context
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index 5880a2b..53034ac 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -2193,7 +2193,7 @@ namespace relational
// When handling a pointer, mi.t is the id type of the referenced
// object.
//
- semantics::type& pt (member_utype (mi.m, key_prefix_));
+ semantics::type& pt (utype (mi.m, key_prefix_));
type = "obj_traits::id_type";
@@ -2704,7 +2704,7 @@ namespace relational
// When handling a pointer, mi.t is the id type of the referenced
// object.
//
- semantics::type& pt (member_utype (mi.m, key_prefix_));
+ semantics::type& pt (utype (mi.m, key_prefix_));
if (lazy_pointer (pt))
os << member << " = ptr_traits::pointer_type (" << endl
diff --git a/odb/relational/validator.cxx b/odb/relational/validator.cxx
index 3b867f8..5dea25f 100644
--- a/odb/relational/validator.cxx
+++ b/odb/relational/validator.cxx
@@ -61,7 +61,7 @@ namespace relational
// Make sure it is a pointer or a member with points_to pragma.
//
- if (!object_pointer (member_utype (m, kp)) && !points_to (m))
+ if (!object_pointer (utype (m, kp)) && !points_to (m))
{
error (l) << "on_delete specified for non-object pointer" << endl;
valid_ = false;