From a5aa1faa4597264feea2faf4611d251713960af7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 Jan 2014 11:19:57 +0200 Subject: Only generate inner export macro if we are explicitly instantiating --- odb/common-query.cxx | 38 +++++++++++++++++++++++--------------- odb/common-query.hxx | 6 +++--- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/odb/common-query.cxx b/odb/common-query.cxx index 2d8ad98..14d438c 100644 --- a/odb/common-query.cxx +++ b/odb/common-query.cxx @@ -460,14 +460,10 @@ generate_inst (semantics::data_member& m, semantics::class_& c) // query_columns:: -query_columns (bool ptr) - : ptr_ (ptr), decl_ (true), in_ptr_ (false) -{ -} - -query_columns:: -query_columns (bool ptr, semantics::class_& c) //@@ context::{cur,top}_object - : ptr_ (ptr), decl_ (false), in_ptr_ (false), fq_name_ (class_fq_name (c)) +query_columns (bool decl, bool ptr, semantics::class_& c) + : decl_ (decl), ptr_ (ptr), in_ptr_ (false), + fq_name_ (class_fq_name (c)), + resue_abstract_ (abstract (c) && !polymorphic (c)) { } @@ -495,13 +491,21 @@ traverse_composite (semantics::data_member* m, semantics::class_& c) if (decl_) { + os << "// " << name << endl + << "//" << endl + << "struct "; + // For some bizarre reason VC++ needs the export directive for // a type nested in an (exported) template. This appears not // to cause any problems for GCC. // - os << "// " << name << endl - << "//" << endl - << "struct " << exp << name << suffix; + // We only generate the export directive if we are also + // explicitly instantiating the query_columns templates. + // + if (multi_dynamic && !resue_abstract_) + os << exp; + + os << name << suffix; // Derive from the base in query_columns_base. It contains columns // data for the pointer members. @@ -887,7 +891,8 @@ traverse (type& c) } { - instance t (ptr_); + bool true_ (true); + instance t (true_, ptr_, c); //@@ forwarding t->traverse (c); } @@ -949,7 +954,7 @@ traverse (type& c) } { - instance t (ptr_); + instance t (decl_, ptr_, c); t->traverse (c); } @@ -1041,8 +1046,11 @@ generate_impl (type& c) << endl; } - instance t (ptr_, c); - t->traverse (c); + { + bool false_ (false); + instance t (false_, ptr_, c); + t->traverse (c); + } if (!guard.empty ()) os << "#endif // " << guard << endl diff --git a/odb/common-query.hxx b/odb/common-query.hxx index 5b0f71b..066e88d 100644 --- a/odb/common-query.hxx +++ b/odb/common-query.hxx @@ -120,8 +120,7 @@ struct query_columns: object_columns_base, virtual context { typedef query_columns base; - query_columns (bool ptr); - query_columns (bool ptr, semantics::class_&); + query_columns (bool decl, bool ptr, semantics::class_&); virtual void column_ctor (string const& type, string const& name, string const& base); @@ -145,11 +144,12 @@ struct query_columns: object_columns_base, virtual context traverse_pointer (semantics::data_member&, semantics::class_&); protected: - bool ptr_; bool decl_; + bool ptr_; string const_; // Const prefix or empty. bool in_ptr_; // True while we are "inside" an object pointer. string fq_name_; + bool resue_abstract_; // Object is reuse-abstract. string scope_; }; -- cgit v1.1