diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
commit | 4fd6bca4e75870958ea61b94e0a1e60e78cd91bc (patch) | |
tree | 2119cae72f45e1ceff1982d8364b4b678ac4ee69 /odb/relational | |
parent | 7cd11b5f604c7d786261568aa31cd2ae3638f61e (diff) |
Add support for defining composite value type as class template instantiations
Diffstat (limited to 'odb/relational')
-rw-r--r-- | odb/relational/common.cxx | 8 | ||||
-rw-r--r-- | odb/relational/header.cxx | 8 | ||||
-rw-r--r-- | odb/relational/header.hxx | 62 | ||||
-rw-r--r-- | odb/relational/inline.cxx | 4 | ||||
-rw-r--r-- | odb/relational/inline.hxx | 37 | ||||
-rw-r--r-- | odb/relational/model.cxx | 4 | ||||
-rw-r--r-- | odb/relational/model.hxx | 14 | ||||
-rw-r--r-- | odb/relational/mysql/source.cxx | 4 | ||||
-rw-r--r-- | odb/relational/oracle/source.cxx | 4 | ||||
-rw-r--r-- | odb/relational/pgsql/source.cxx | 10 | ||||
-rw-r--r-- | odb/relational/processor.cxx | 39 | ||||
-rw-r--r-- | odb/relational/source.cxx | 6 | ||||
-rw-r--r-- | odb/relational/source.hxx | 44 | ||||
-rw-r--r-- | odb/relational/sqlite/source.cxx | 4 |
14 files changed, 146 insertions, 102 deletions
diff --git a/odb/relational/common.cxx b/odb/relational/common.cxx index b7255a2..92e2c8f 100644 --- a/odb/relational/common.cxx +++ b/odb/relational/common.cxx @@ -28,7 +28,7 @@ namespace relational query_columns_base (semantics::class_& c) //@@ context::{cur,top}_object : decl_ (false) { - scope_ = "query_columns_base< " + c.fq_name () + " >"; + scope_ = "query_columns_base< " + class_fq_name (c) + " >"; } void query_columns_base:: @@ -102,7 +102,7 @@ namespace relational os << "typedef" << endl << "odb::query_pointer<" << endl << " odb::pointer_query_columns<" << endl - << " " << ptr->fq_name () << "," << endl + << " " << class_fq_name (*ptr) << "," << endl << " " << name << "_alias_ > >" << endl << name << "_type_ ;" << endl @@ -142,7 +142,7 @@ namespace relational : ptr_ (ptr), decl_ (false) { scope_ = ptr ? "pointer_query_columns" : "query_columns"; - scope_ += "< " + c.fq_name () + ", table >"; + scope_ += "< " + class_fq_name (c) + ", table >"; } void query_columns:: @@ -263,7 +263,7 @@ namespace relational << "typedef" << endl << "odb::query_pointer<" << endl << " odb::pointer_query_columns<" << endl - << " " << ptr->fq_name () << "," << endl + << " " << class_fq_name (*ptr) << "," << endl << " " << name << "_alias_ > >" << endl << name << "_pointer_type_;" << endl; diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx index 11d3cf6..0df7607 100644 --- a/odb/relational/header.cxx +++ b/odb/relational/header.cxx @@ -27,16 +27,20 @@ namespace relational { traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (false); traversal::namespace_ ns; instance<class1> c; unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (false); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; unit.dispatch (ctx.unit); } @@ -44,16 +48,20 @@ namespace relational { traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (false); traversal::namespace_ ns; instance<class2> c; unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (false); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; unit.dispatch (ctx.unit); } diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx index 39f2bbf..ee6cecf 100644 --- a/odb/relational/header.hxx +++ b/odb/relational/header.hxx @@ -62,10 +62,12 @@ namespace relational << " "; } + string const& type (class_fq_name (c)); + if (obj) - os << "object_traits< " << c.fq_name () << " >::image_type"; + os << "object_traits< " << type << " >::image_type"; else - os << "composite_value_traits< " << c.fq_name () << " >::image_type"; + os << "composite_value_traits< " << type << " >::image_type"; } private: @@ -155,7 +157,7 @@ namespace relational } os << (ptr_ ? "pointer_query_columns" : "query_columns") << - "< " << c.fq_name () << ", table >"; + "< " << class_fq_name (c) << ", table >"; } private: @@ -180,11 +182,13 @@ namespace relational if (!object (c)) return; - os << "// " << c.name () << endl + string const& name (class_name (c)); + + os << "// " << name << endl << "//" << endl << "typedef " << (ptr_ ? "pointer_query_columns" : "query_columns") << - "< " << c.fq_name () << ", table > " << c.name () << ";" + "< " << class_fq_name (c) << ", table > " << name << ";" << endl; } @@ -205,7 +209,7 @@ namespace relational virtual void traverse (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); if (ptr_) { @@ -483,13 +487,13 @@ namespace relational if (base) { semantics::class_& b (dynamic_cast<semantics::class_&> (m.scope ())); + string const& type (class_fq_name (b)); if (object (b)) - os << ": access::object_traits< " << b.fq_name () << " >::" << - name; + os << ": access::object_traits< " << type << " >::" << name; else - os << ": access::composite_value_traits< " << b.fq_name () << - " >::" << public_name (m) << "_traits"; // No prefix_. + os << ": access::composite_value_traits< " << type << " >::" << + public_name (m) << "_traits"; // No prefix_. } os << "{"; @@ -911,7 +915,7 @@ namespace relational virtual void traverse (type& c) { - if (c.file () != unit.file ()) + if (class_file (c) != unit.file ()) return; if (object (c)) @@ -936,7 +940,7 @@ namespace relational traverse_object (type& c) { bool abstract (context::abstract (c)); - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); semantics::data_member* id (id_member (c)); bool auto_id (id ? id->count ("auto") : false); @@ -946,7 +950,7 @@ namespace relational column_count_type const& cc (column_count (c)); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl; // class_traits @@ -994,19 +998,21 @@ namespace relational { if (base_id) { - string const& base (id->scope ().fq_name ()); + semantics::class_& b ( + dynamic_cast<semantics::class_&> (id->scope ())); + string const& type (class_fq_name (b)); - os << "typedef object_traits< " << base << " >::id_type id_type;"; + os << "typedef object_traits< " << type << " >::id_type id_type;"; if (optimistic != 0) - os << "typedef object_traits< " << base << " >::version_type " << + os << "typedef object_traits< " << type << " >::version_type " << "version_type;"; os << endl - << "static const bool auto_id = object_traits< " << base << + << "static const bool auto_id = object_traits< " << type << " >::auto_id;" << endl - << "typedef object_traits< " << base << " >::id_image_type " << + << "typedef object_traits< " << type << " >::id_image_type " << "id_image_type;" << endl; } @@ -1335,9 +1341,9 @@ namespace relational virtual void traverse_view (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl; os << "template <>" << endl @@ -1394,8 +1400,8 @@ namespace relational bool alias (!i->alias.empty ()); semantics::class_& o (*i->obj); - string const& name (alias ? i->alias : o.name ()); - string const& type (o.fq_name ()); + string const& name (alias ? i->alias : class_name (o)); + string const& type (class_fq_name (o)); os << "// " << name << endl << "//" << endl; @@ -1438,7 +1444,7 @@ namespace relational bool alias (!vo->alias.empty ()); semantics::class_& o (*vo->obj); - string const& type (o.fq_name ()); + string const& type (class_fq_name (o)); if (alias && vo->alias != table_name (o)) os << "static const char query_alias[];" @@ -1535,9 +1541,9 @@ namespace relational virtual void traverse_composite (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl; os << "template <>" << endl @@ -1626,7 +1632,7 @@ namespace relational virtual void traverse (type& c) { - if (c.file () != unit.file ()) + if (class_file (c) != unit.file ()) return; if (object (c)) @@ -1641,14 +1647,14 @@ namespace relational traverse_object (type& c) { bool abst (abstract (c)); - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); if (options.generate_query ()) { bool has_ptr (has_a (c, test_pointer)); if (has_ptr || !abst) - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl; // query_columns diff --git a/odb/relational/inline.cxx b/odb/relational/inline.cxx index e5371ab..5184a9a 100644 --- a/odb/relational/inline.cxx +++ b/odb/relational/inline.cxx @@ -20,16 +20,20 @@ namespace relational traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (false); traversal::namespace_ ns; class_ c; unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (false); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; os << "namespace odb" << "{"; diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx index 78078eb..629d1aa 100644 --- a/odb/relational/inline.hxx +++ b/odb/relational/inline.hxx @@ -55,15 +55,16 @@ namespace relational // In case of the const instance, we only generate the call if // there is a const callback. // + string const& type (class_fq_name (c)); + if (const_) { if (c.count ("callback-const")) - os << "static_cast< const " << c.fq_name () << "& > (x)." << + os << "static_cast< const " << type << "& > (x)." << name << " (e, db);"; } else - os << "static_cast< " << c.fq_name () << "& > (x)." << - name << " (e, db);"; + os << "static_cast< " << type << "& > (x)." << name << " (e, db);"; } else if (obj) inherits (c); @@ -83,7 +84,7 @@ namespace relational virtual void traverse (type& c) { - if (c.file () != unit.file ()) + if (class_file (c) != unit.file ()) return; if (object (c)) @@ -103,7 +104,7 @@ namespace relational traverse_object (type& c) { bool abstract (context::abstract (c)); - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::object_traits< " + type + " >"); semantics::data_member* id (id_member (c)); @@ -111,7 +112,15 @@ namespace relational semantics::data_member* optimistic (context::optimistic (c)); - os << "// " << c.name () << endl + // Base class the contains the object id and version for optimistic + // concurrency. + // + semantics::class_* base ( + id != 0 && base_id + ? dynamic_cast<semantics::class_*> (&id->scope ()) + : 0); + + os << "// " << class_name (c) << endl << "//" << endl << endl; @@ -130,7 +139,7 @@ namespace relational if (id != 0) { if (base_id) - os << "return object_traits< " << id->scope ().fq_name () << + os << "return object_traits< " << class_fq_name (*base) << " >::id (obj);"; else os << "return obj." << id->name () << ";"; @@ -150,7 +159,7 @@ namespace relational << traits << "::" << endl << "id (const image_type& i)" << "{" - << "return object_traits< " << id->scope ().fq_name () << + << "return object_traits< " << class_fq_name (*base) << " >::id (i);" << "}"; } @@ -164,8 +173,8 @@ namespace relational << traits << "::" << endl << "version (const image_type& i)" << "{" - << "return object_traits< " << - optimistic->scope ().fq_name () << " >::version (i);" + << "return object_traits< " << class_fq_name (*base) << + " >::version (i);" << "}"; } @@ -177,7 +186,7 @@ namespace relational << "void " << traits << "::" << endl << "bind (" << bind_vector << " b, id_image_type& i)" << "{" - << "object_traits< " << id->scope ().fq_name () << + << "object_traits< " << class_fq_name (*base) << " >::bind (b, i);" << "}"; } @@ -189,7 +198,7 @@ namespace relational << "init (id_image_type& i, const id_type& id" << (optimistic != 0 ? ", const version_type* v" : "") << ")" << "{" - << "object_traits< " << id->scope ().fq_name () << + << "object_traits< " << class_fq_name (*base) << " >::init (i, id" << (optimistic != 0 ? ", v" : "") << ");" << "}"; } @@ -298,10 +307,10 @@ namespace relational virtual void traverse_view (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::view_traits< " + type + " >"); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl << endl; diff --git a/odb/relational/model.cxx b/odb/relational/model.cxx index e44ffec..9bb6070 100644 --- a/odb/relational/model.cxx +++ b/odb/relational/model.cxx @@ -123,16 +123,20 @@ namespace relational traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (false); traversal::namespace_ ns; instance<class_> c (*m); unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (false); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; try { diff --git a/odb/relational/model.hxx b/odb/relational/model.hxx index 3d8cc4b..6fe5b0d 100644 --- a/odb/relational/model.hxx +++ b/odb/relational/model.hxx @@ -46,7 +46,7 @@ namespace relational // (unqualified) name. // string t (id_prefix_); - id_prefix_ = c.name () + "::"; + id_prefix_ = class_name (c) + "::"; object_columns_base::traverse_object (c); id_prefix_ = t; } @@ -69,7 +69,7 @@ namespace relational else // Composite base. Add its unqualified name to id_prefix. // - id_prefix_ += c.name () + "::"; + id_prefix_ += class_name (c) + "::"; object_columns_base::traverse_composite (m, c); @@ -273,7 +273,7 @@ namespace relational // (unqualified) name. // string t (id_prefix_); - id_prefix_ = c.name () + "::"; + id_prefix_ = class_name (c) + "::"; object_members_base::traverse_object (c); id_prefix_ = t; } @@ -281,7 +281,7 @@ namespace relational { // Top-level object. Set its id as a prefix. // - id_prefix_ = string (c.fq_name (), 2) + "::"; + id_prefix_ = string (class_fq_name (c), 2) + "::"; object_members_base::traverse_object (c); } } @@ -298,7 +298,7 @@ namespace relational else // Composite base. Add its unqualified name to id_prefix. // - id_prefix_ += c.name () + "::"; + id_prefix_ += class_name (c) + "::"; object_members_base::traverse_composite (m, c); @@ -469,7 +469,7 @@ namespace relational virtual void traverse (type& c) { - if (c.file () != unit.file ()) + if (class_file (c) != unit.file ()) return; if (!object (c) || abstract (c)) @@ -487,7 +487,7 @@ namespace relational return; } - string id (c.fq_name (), 2); // Remove leading '::'. + string id (class_fq_name (c), 2); // Remove leading '::'. sema_rel::object_table& t( model_.new_node<sema_rel::object_table> (id)); diff --git a/odb/relational/mysql/source.cxx b/odb/relational/mysql/source.cxx index 576f80c..06d40b7 100644 --- a/odb/relational/mysql/source.cxx +++ b/odb/relational/mysql/source.cxx @@ -645,7 +645,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;"; if (weak_pointer (mt)) @@ -919,7 +919,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;" << "typedef pointer_traits< " << mi.fq_type () << " > ptr_traits;" diff --git a/odb/relational/oracle/source.cxx b/odb/relational/oracle/source.cxx index 066947e..b4131e1 100644 --- a/odb/relational/oracle/source.cxx +++ b/odb/relational/oracle/source.cxx @@ -400,7 +400,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;"; if (weak_pointer (mt)) @@ -667,7 +667,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;" << "typedef pointer_traits< " << mi.fq_type () << " > ptr_traits;" diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx index 7200405..00ee777 100644 --- a/odb/relational/pgsql/source.cxx +++ b/odb/relational/pgsql/source.cxx @@ -555,7 +555,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;"; if (weak_pointer (mt)) @@ -803,7 +803,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;" << "typedef pointer_traits< " << mi.fq_type () << " > ptr_traits;" @@ -1014,7 +1014,7 @@ namespace relational semantics::data_member* optimistic (context::optimistic (c)); column_count_type const& cc (column_count (c)); - string const& n (c.fq_name ()); + string const& n (class_fq_name (c)); string traits ("access::object_traits< " + n + " >::"); string const& fn (flat_name (n)); string name_decl ("const char " + traits); @@ -1158,7 +1158,7 @@ namespace relational virtual void view_extra (type& c) { - string const& n (c.fq_name ()); + string const& n (class_fq_name (c)); string traits ("access::view_traits< " + n + " >::"); string const& fn (flat_name (n)); string name_decl ("const char " + traits); @@ -1231,7 +1231,7 @@ namespace relational // Prefix top-object name to avoid conflicts with inherited // member statement names. // - string stmt_prefix (top_object->fq_name () + m.fq_name ()); + string stmt_prefix (class_fq_name (*top_object) + m.fq_name ()); os << stmt_decl << endl << "select_all_name[] = " << diff --git a/odb/relational/processor.cxx b/odb/relational/processor.cxx index 41093de..8d80df0 100644 --- a/odb/relational/processor.cxx +++ b/odb/relational/processor.cxx @@ -825,11 +825,12 @@ namespace relational if (!c->complete ()) { os << m.file () << ":" << m.line () << ":" << m.column () << ": " - << "error: pointed-to class '" << c->fq_name () << "' " + << "error: pointed-to class '" << class_fq_name (*c) << "' " << "is incomplete" << endl; os << c->file () << ":" << c->line () << ":" << c->column () << ": " - << "info: class '" << c->name () << "' is declared here" << endl; + << "info: class '" << class_name (*c) << "' is declared here" + << endl; os << c->file () << ":" << c->line () << ":" << c->column () << ": " << "info: consider including its definition with the " @@ -843,11 +844,12 @@ namespace relational if (context::abstract (*c)) { os << m.file () << ":" << m.line () << ":" << m.column () << ": " - << "error: pointed-to class '" << c->fq_name () << "' " + << "error: pointed-to class '" << class_fq_name (*c) << "' " << "is abstract" << endl; os << c->file () << ":" << c->line () << ":" << c->column () << ": " - << "info: class '" << c->name () << "' is defined here" << endl; + << "info: class '" << class_name (*c) << "' is defined here" + << endl; throw operation_failed (); } @@ -857,11 +859,12 @@ namespace relational if (context::id_member (*c) == 0) { os << m.file () << ":" << m.line () << ":" << m.column () << ": " - << "error: pointed-to class '" << c->fq_name () << "' " + << "error: pointed-to class '" << class_fq_name (*c) << "' " << "has no object id" << endl; os << c->file () << ":" << c->line () << ":" << c->column () << ": " - << "info: class '" << c->name () << "' is defined here" << endl; + << "info: class '" << class_name (*c) << "' is defined here" + << endl; throw operation_failed (); } @@ -881,7 +884,7 @@ namespace relational os << m.file () << ":" << m.line () << ":" << m.column () << ": " << "error: unable to resolve data member '" << name << "' " << "specified with '#pragma db inverse' in class '" - << c->fq_name () << "'" << endl; + << class_fq_name (*c) << "'" << endl; throw operation_failed (); } @@ -891,8 +894,8 @@ namespace relational { os << m.file () << ":" << m.line () << ":" << m.column () << ": " << "ice: unable to find semantic graph node corresponding to " - << "data member '" << name << "' in class '" << c->fq_name () - << "'" << endl; + << "data member '" << name << "' in class '" + << class_fq_name (*c) << "'" << endl; throw operation_failed (); } @@ -1691,7 +1694,7 @@ namespace relational if (vq.kind == view_query::condition && !has_o) { error (c.file (), c.line (), c.column ()) - << "view '" << c.fq_name () << "' has an incomplete query " + << "view '" << class_fq_name (c) << "' has an incomplete query " << "template and no associated objects" << endl; info (c.file (), c.line (), c.column ()) @@ -1886,7 +1889,7 @@ namespace relational relationship const& r (rs.back ()); string name (r.pointer->alias.empty () - ? r.pointer->obj->fq_name () + ? class_fq_name (*r.pointer->obj) : r.pointer->alias); name += "::"; name += r.name; @@ -2004,7 +2007,7 @@ namespace relational try { string ptr; - string const& name (c.fq_name ()); + string const& type (class_fq_name (c)); tree decl (0); // Resolved template node. string decl_name; // User-provided template name. @@ -2016,7 +2019,7 @@ namespace relational string const& p (cp.name); if (p == "*") - ptr = name + "*"; + ptr = type + "*"; else if (p[p.size () - 1] == '*') ptr = p; else if (p.find ('<') != string::npos) @@ -2054,7 +2057,7 @@ namespace relational } else if (tc == TEMPLATE_DECL && DECL_CLASS_TEMPLATE_P (decl)) { - ptr = p + "< " + name + " >"; + ptr = p + "< " + type + " >"; decl_name = p; } else @@ -2079,10 +2082,10 @@ namespace relational string const& p (options.default_pointer ()); if (p == "*") - ptr = name + "*"; + ptr = type + "*"; else { - ptr = p + "< " + name + " >"; + ptr = p + "< " + type + " >"; decl_name = p; } @@ -2315,16 +2318,20 @@ namespace relational traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (true); traversal::namespace_ ns; class_ c; unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (true); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; unit.dispatch (ctx.unit); } diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index 749e0d6..39a2ddc 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -172,7 +172,7 @@ namespace relational if (multi_obj) { r += "::"; - r += vo->obj->name (); + r += context::class_name (*vo->obj); } } @@ -563,16 +563,20 @@ namespace relational traversal::unit unit; traversal::defines unit_defines; + typedefs unit_typedefs (false); traversal::namespace_ ns; instance<class_> c; unit >> unit_defines >> ns; unit_defines >> c; + unit >> unit_typedefs >> c; traversal::defines ns_defines; + typedefs ns_typedefs (false); ns >> ns_defines >> ns; ns_defines >> c; + ns >> ns_typedefs >> c; instance<include> i; i->generate (); diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx index 56a356b..6e92607 100644 --- a/odb/relational/source.hxx +++ b/odb/relational/source.hxx @@ -555,7 +555,7 @@ namespace relational if (!(obj || composite (c))) return; - os << "// " << c.name () << " base" << endl + os << "// " << class_name (c) << " base" << endl << "//" << endl; // If the derived class is readonly, then we will never be @@ -569,7 +569,7 @@ namespace relational << "{"; os << (obj ? "object" : "composite_value") << "_traits< " << - c.fq_name () << " >::bind (b + n, i, sk);"; + class_fq_name (c) << " >::bind (b + n, i, sk);"; column_count_type const& cc (column_count (c)); @@ -653,11 +653,11 @@ namespace relational if (!(obj || composite (c))) return; - os << "// " << c.name () << " base" << endl + os << "// " << class_name (c) << " base" << endl << "//" << endl; os << "if (" << (obj ? "object" : "composite_value") << "_traits< " << - c.fq_name () << " >::grow (i, t + " << index_ << "UL))" << endl + class_fq_name (c) << " >::grow (i, t + " << index_ << "UL))" << endl << "grew = true;" << endl; @@ -711,7 +711,7 @@ namespace relational if (!(obj || composite (c))) return; - os << "// " << c.name () << " base" << endl + os << "// " << class_name (c) << " base" << endl << "//" << endl; // If the derived class is readonly, then we will never be @@ -724,7 +724,7 @@ namespace relational << "{"; os << "if (" << (obj ? "object" : "composite_value") << "_traits< " << - c.fq_name () << " >::init (i, o, sk))" << endl + class_fq_name (c) << " >::init (i, o, sk))" << endl << "grew = true;"; if (check) @@ -776,10 +776,10 @@ namespace relational if (!(obj || composite (c))) return; - os << "// " << c.name () << " base" << endl + os << "// " << class_name (c) << " base" << endl << "//" << endl << (obj ? "object" : "composite_value") << "_traits< " << - c.fq_name () << " >::init (o, i, db);" + class_fq_name (c) << " >::init (o, i, db);" << endl; } }; @@ -793,10 +793,12 @@ namespace relational container_traits (semantics::class_& c) : object_members_base (true, true, false), c_ (c) { + string const& type (class_fq_name (c)); + if (object (c)) - scope_ = "access::object_traits< " + c.fq_name () + " >"; + scope_ = "access::object_traits< " + type + " >"; else - scope_ = "access::composite_value_traits< " + c.fq_name () + " >"; + scope_ = "access::composite_value_traits< " + type + " >"; } // Unless the database system can execute several interleaving @@ -1992,7 +1994,7 @@ namespace relational } else if (call_ == load_call && const_type (m->type ())) { - obj_prefix_ = "const_cast< " + c.fq_name () + "& > (\n" + + obj_prefix_ = "const_cast< " + class_fq_name (c) + "& > (\n" + obj_prefix_ + ")"; } @@ -2226,7 +2228,7 @@ namespace relational virtual void traverse (type& c) { - if (c.file () != unit.file ()) + if (class_file (c) != unit.file ()) return; context::top_object = context::cur_object = &c; @@ -2289,7 +2291,7 @@ namespace relational traverse_object (type& c) { bool abstract (context::abstract (c)); - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::object_traits< " + type + " >"); bool has_ptr (has_a (c, test_pointer)); @@ -2312,7 +2314,7 @@ namespace relational column_count_type const& cc (column_count (c)); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl << endl; @@ -3423,7 +3425,7 @@ namespace relational ++end; // Transform the range from [begin, end] to [begin, end). - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::object_traits< " + type + " >"); // create_schema () @@ -3522,10 +3524,10 @@ namespace relational virtual void traverse_view (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::view_traits< " + type + " >"); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl << endl; @@ -3870,7 +3872,7 @@ namespace relational if (!ambig) { error (i->loc) - << "pointed-to object '" << c->name () << "' is " + << "pointed-to object '" << class_name (*c) << "' is " << "ambiguous" << endl; info (i->loc) @@ -3898,7 +3900,7 @@ namespace relational if (vo == 0) { error (i->loc) - << "pointed-to object '" << c->name () << "' " + << "pointed-to object '" << class_name (*c) << "' " << "specified in the join condition has not been " << "previously associated with this view" << endl; @@ -4257,10 +4259,10 @@ namespace relational virtual void traverse_composite (type& c) { - string const& type (c.fq_name ()); + string const& type (class_fq_name (c)); string traits ("access::composite_value_traits< " + type + " >"); - os << "// " << c.name () << endl + os << "// " << class_name (c) << endl << "//" << endl << endl; diff --git a/odb/relational/sqlite/source.cxx b/odb/relational/sqlite/source.cxx index 32ac13e..5a9f5fb 100644 --- a/odb/relational/sqlite/source.cxx +++ b/odb/relational/sqlite/source.cxx @@ -353,7 +353,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;"; if (weak_pointer (mt)) @@ -545,7 +545,7 @@ namespace relational // Handle NULL pointers and extract the id. // os << "{" - << "typedef object_traits< " << c->fq_name () << + << "typedef object_traits< " << class_fq_name (*c) << " > obj_traits;" << "typedef pointer_traits< " << mi.fq_type () << " > ptr_traits;" |