aboutsummaryrefslogtreecommitdiff
path: root/odb/relational
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-11-28 13:47:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-11-28 13:47:35 +0200
commit77d6727eddc64a95ccbdf87984e22270fce61b35 (patch)
tree8c119200e3e6c70c9a158a4212b4c93565a0bba9 /odb/relational
parent9ad0acf37561de9bf359a561faed53de17c2ca3b (diff)
Add support for DLL exporting of generated code
New options: --export-symbol, --extern-symbol.
Diffstat (limited to 'odb/relational')
-rw-r--r--odb/relational/header.cxx16
-rw-r--r--odb/relational/header.hxx29
-rw-r--r--odb/relational/source.hxx4
3 files changed, 29 insertions, 20 deletions
diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx
index 543e1ac..ff2679e 100644
--- a/odb/relational/header.cxx
+++ b/odb/relational/header.cxx
@@ -52,8 +52,8 @@ traverse_object (type& c)
// object_traits_impl
//
os << "template <>" << endl
- << "class access::object_traits_impl< " << type << ", id_" << db <<
- " >:" << endl
+ << "class " << exp << "access::object_traits_impl< " << type << ", " <<
+ "id_" << db << " >:" << endl
<< " public access::object_traits< " << type << " >"
<< "{"
<< "public:" << endl;
@@ -680,8 +680,8 @@ traverse_view (type& c)
// view_traits_impl
//
os << "template <>" << endl
- << "class access::view_traits_impl< " << type << ", id_" <<
- db << " >:" << endl
+ << "class " << exp << "access::view_traits_impl< " << type << ", " <<
+ "id_" << db << " >:" << endl
<< " public access::view_traits< " << type << " >"
<< "{"
<< "public:" << endl;
@@ -834,9 +834,13 @@ traverse_composite (type& c)
os << "// " << class_name (c) << endl
<< "//" << endl;
+ // While composite_value_traits is not used directly by user code, we
+ // still need to export it if the generated code for the same database
+ // is split into several DLLs.
+ //
os << "template <>" << endl
- << "class access::composite_value_traits< " << type << ", " <<
- "id_" << db << " >"
+ << "class " << exp << "access::composite_value_traits< " << type <<
+ ", id_" << db << " >"
<< "{"
<< "public:" << endl;
diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx
index 89ef664..3e0480f 100644
--- a/odb/relational/header.hxx
+++ b/odb/relational/header.hxx
@@ -747,8 +747,8 @@ namespace relational
: id_image_member_ ("id_"),
version_image_member_ ("version_"),
discriminator_image_member_ ("discriminator_"),
- query_columns_type_ (false, true),
- pointer_query_columns_type_ (true, true)
+ query_columns_type_ (false, true, false),
+ pointer_query_columns_type_ (true, true, false)
{
}
@@ -758,8 +758,8 @@ namespace relational
id_image_member_ ("id_"),
version_image_member_ ("version_"),
discriminator_image_member_ ("discriminator_"),
- query_columns_type_ (false, true),
- pointer_query_columns_type_ (true, true)
+ query_columns_type_ (false, true, false),
+ pointer_query_columns_type_ (true, true, false)
{
}
@@ -823,7 +823,8 @@ namespace relational
typedef class2 base;
class2 ()
- : query_columns_type_ (false, true),
+ : query_columns_type_ (false, true, false),
+ query_columns_type_inst_ (false, false, true),
view_query_columns_type_ (true)
{
}
@@ -831,7 +832,8 @@ namespace relational
class2 (class_ const&)
: root_context (), //@@ -Wextra
context (),
- query_columns_type_ (false, true),
+ query_columns_type_ (false, true, false),
+ query_columns_type_inst_ (false, false, true),
view_query_columns_type_ (true)
{
}
@@ -855,19 +857,21 @@ namespace relational
{
if (options.generate_query ())
{
- bool has_ptr (has_a (c, test_pointer | include_base));
-
- if (has_ptr)
- os << "// " << class_name (c) << endl
- << "//" << endl;
+ os << "// " << class_name (c) << endl
+ << "//" << endl;
// query_columns
//
// If we don't have any pointers, then query_columns is generated
// in pass 1 (see the comment in class1 for details).
//
- if (has_ptr)
+ if (has_a (c, test_pointer | include_base))
query_columns_type_->traverse (c);
+
+ // Generate extern template declarations.
+ //
+ if (multi_dynamic)
+ query_columns_type_inst_->traverse (c);
}
// Move header comment out of if-block if adding any code here.
@@ -896,6 +900,7 @@ namespace relational
private:
instance<query_columns_type> query_columns_type_;
+ instance<query_columns_type> query_columns_type_inst_;
instance<view_query_columns_type> view_query_columns_type_;
};
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index ed5f0e3..610c545 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -3294,7 +3294,7 @@ namespace relational
typedef class_ base;
class_ ()
- : query_columns_type_ (false, false),
+ : query_columns_type_ (false, false, false),
view_query_columns_type_ (false),
grow_base_ (index_),
grow_member_ (index_),
@@ -3318,7 +3318,7 @@ namespace relational
class_ (class_ const&)
: root_context (), //@@ -Wextra
context (),
- query_columns_type_ (false, false),
+ query_columns_type_ (false, false, false),
view_query_columns_type_ (false),
grow_base_ (index_),
grow_member_ (index_),