aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-12-03 11:54:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-12-03 11:54:30 +0200
commit52a7a6bcdc93d9776a4f56ac79185b9bc284db88 (patch)
tree81ecb3a60484725064d410eaf952f3a47b86056d
parent77d6727eddc64a95ccbdf87984e22270fce61b35 (diff)
Make --export-symbol and --extern-symbole values database-prefixable
-rw-r--r--odb/common-query.cxx14
-rw-r--r--odb/context.cxx12
-rw-r--r--odb/context.hxx4
-rw-r--r--odb/generator.cxx2
-rw-r--r--odb/option-functions.cxx8
-rw-r--r--odb/options.cli4
6 files changed, 28 insertions, 16 deletions
diff --git a/odb/common-query.cxx b/odb/common-query.cxx
index bbe5fe7..67a2674 100644
--- a/odb/common-query.cxx
+++ b/odb/common-query.cxx
@@ -835,9 +835,9 @@ traverse (type& c)
{
// If we have the extern symbol, generate extern template declarations.
//
- if (!options.extern_symbol ().empty ())
+ if (!ext.empty ())
{
- os << "#ifdef " << options.extern_symbol () << endl
+ os << "#ifdef " << ext << endl
<< endl;
if (has_a (c, test_pointer | exclude_base))
@@ -851,7 +851,7 @@ traverse (type& c)
generate_inst (c);
- os << "#endif // " << options.extern_symbol () << endl
+ os << "#endif // " << ext << endl
<< endl;
}
}
@@ -897,7 +897,7 @@ generate_impl (type& c)
// instantiations in multiple places and we will avoid the VC++
// warning C4661 (no definition provided).
//
- if (multi_dynamic && options.extern_symbol ().empty ())
+ if (multi_dynamic && ext.empty ())
{
guard = make_guard ("ODB_" + db.string () + "_QUERY_COLUMNS_DEF");
@@ -1006,14 +1006,14 @@ generate_decl (type& c)
// Do it before query_columns since the inheritance will trigger
// instantiation and we won't be able to change visibility (GCC).
//
- if (obj_count != 0 && multi_dynamic && !options.extern_symbol ().empty ())
+ if (obj_count != 0 && multi_dynamic && !ext.empty ())
{
- os << "#ifdef " << options.extern_symbol () << endl
+ os << "#ifdef " << ext << endl
<< endl;
generate_inst (c);
- os << "#endif // " << options.extern_symbol () << endl
+ os << "#endif // " << ext << endl
<< endl;
}
diff --git a/odb/context.cxx b/odb/context.cxx
index 6ee8ad1..f5ff975 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -443,6 +443,7 @@ context (ostream& os_,
features (f),
db (options.database ()[0]),
exp (data_->exp_),
+ ext (data_->ext_),
keyword_set (data_->keyword_set_),
include_regex (data_->include_regex_),
accessor_regex (data_->accessor_regex_),
@@ -463,8 +464,10 @@ context (ostream& os_,
// Export control.
//
- if (!ops.export_symbol ().empty ())
- exp = ops.export_symbol () + " ";
+ if (!ops.export_symbol ()[db].empty ())
+ exp = ops.export_symbol ()[db] + " ";
+
+ ext = ops.extern_symbol ()[db];
for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i)
data_->keyword_set_.insert (keywords[i]);
@@ -504,6 +507,7 @@ context ()
features (current ().features),
db (current ().db),
exp (current ().exp),
+ ext (current ().ext),
keyword_set (current ().keyword_set),
include_regex (current ().include_regex),
accessor_regex (current ().accessor_regex),
@@ -1882,8 +1886,6 @@ strlit (string const& str)
void context::
inst_header (bool decl)
{
- string const& ext (options.extern_symbol ());
-
if (decl && !ext.empty ())
os << ext << " ";
@@ -1900,7 +1902,7 @@ inst_header (bool decl)
if (!decl && !ext.empty ())
os << endl
<< "#ifndef " << ext << endl
- << options.export_symbol () << endl
+ << options.export_symbol ()[db] << endl
<< "#endif" << endl;
else
os << " " << exp;
diff --git a/odb/context.hxx b/odb/context.hxx
index 7c7ca71..22750de 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -972,6 +972,7 @@ protected:
semantics::class_* cur_object_;
string exp_;
+ string ext_;
keyword_set_type keyword_set_;
type_map_type type_map_;
@@ -993,7 +994,8 @@ public:
features_type& features;
database const db;
- string& exp;
+ string& exp; // Export symbol (with trailing space if specified).
+ string& ext; // Extern symbol.
keyword_set_type const& keyword_set;
diff --git a/odb/generator.cxx b/odb/generator.cxx
index e95ba25..ab6878b 100644
--- a/odb/generator.cxx
+++ b/odb/generator.cxx
@@ -516,7 +516,7 @@ generate (options const& ops,
// Include query columns implementations for explicit instantiations.
//
string impl_guard;
- if (md == multi_database::dynamic && ops.extern_symbol ().empty ())
+ if (md == multi_database::dynamic && ctx->ext.empty ())
{
impl_guard = ctx->make_guard (
"ODB_" + db.string () + "_QUERY_COLUMNS_DEF");
diff --git a/odb/option-functions.cxx b/odb/option-functions.cxx
index 075e8ab..179967e 100644
--- a/odb/option-functions.cxx
+++ b/odb/option-functions.cxx
@@ -53,6 +53,14 @@ process_options (options& o)
if (o.schema_name ().count (db) == 0)
o.schema_name ()[db] = "";
+ // Set default --{export,extern}-symbol values.
+ //
+ if (o.export_symbol ().count (db) == 0)
+ o.export_symbol ()[db] = "";
+
+ if (o.extern_symbol ().count (db) == 0)
+ o.extern_symbol ()[db] = "";
+
// Set default --*--file-suffix values.
//
{
diff --git a/odb/options.cli b/odb/options.cli
index 42acad7..6da45e8 100644
--- a/odb/options.cli
+++ b/odb/options.cli
@@ -232,7 +232,7 @@ class options
// Export control.
//
- std::string --export-symbol
+ database_map<std::string> --export-symbol
{
"<symbol>",
"Insert <symbol> in places where DLL export/import control statements
@@ -240,7 +240,7 @@ class options
\cb{--extern-symbol} option below."
};
- std::string --extern-symbol
+ database_map<std::string> --extern-symbol
{
"<symbol>",
"If <symbol> is defined, insert it in places where a template