From 77d6727eddc64a95ccbdf87984e22270fce61b35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 28 Nov 2012 13:47:35 +0200 Subject: Add support for DLL exporting of generated code New options: --export-symbol, --extern-symbol. --- odb/context.cxx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'odb/context.cxx') 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 -- cgit v1.1