aboutsummaryrefslogtreecommitdiff
path: root/odb/context.cxx
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/context.cxx
parent9ad0acf37561de9bf359a561faed53de17c2ca3b (diff)
Add support for DLL exporting of generated code
New options: --export-symbol, --extern-symbol.
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index 066287b..6ee8ad1 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -442,6 +442,7 @@ context (ostream& os_,
options (ops),
features (f),
db (options.database ()[0]),
+ exp (data_->exp_),
keyword_set (data_->keyword_set_),
include_regex (data_->include_regex_),
accessor_regex (data_->accessor_regex_),
@@ -460,6 +461,11 @@ context (ostream& os_,
assert (current_ == 0);
current_ = this;
+ // Export control.
+ //
+ if (!ops.export_symbol ().empty ())
+ exp = ops.export_symbol () + " ";
+
for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i)
data_->keyword_set_.insert (keywords[i]);
@@ -497,6 +503,7 @@ context ()
options (current ().options),
features (current ().features),
db (current ().db),
+ exp (current ().exp),
keyword_set (current ().keyword_set),
include_regex (current ().include_regex),
accessor_regex (current ().accessor_regex),
@@ -1872,6 +1879,36 @@ strlit (string const& str)
return strlit_ascii (str);
}
+void context::
+inst_header (bool decl)
+{
+ string const& ext (options.extern_symbol ());
+
+ if (decl && !ext.empty ())
+ os << ext << " ";
+
+ os << "template struct";
+
+ if (!exp.empty ())
+ {
+ // If we are generating an explicit instantiation directive rather
+ // than the extern template declaration, then omit the export symbol
+ // if we already have it in the header (i.e., extern symbol specified
+ // and defined). If we don't do that, then we get GCC warnings saying
+ // that the second set of visibility attributes is ignored.
+ //
+ if (!decl && !ext.empty ())
+ os << endl
+ << "#ifndef " << ext << endl
+ << options.export_symbol () << endl
+ << "#endif" << endl;
+ else
+ os << " " << exp;
+ }
+ else
+ os << " ";
+}
+
namespace
{
struct column_count_impl: object_members_base