aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-25 15:34:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-25 15:34:52 +0200
commit956fab80f55ba64a15e736a8ccdbf89af9f71f2b (patch)
treeeb26cf24b22303d73a7a2ee824e273ced21556d4 /xsde/cxx
parentc5e3c6ee3e291a5dfc6670160677f4962d526dc4 (diff)
Generate "weak" includes in the serializer implementation source file
Diffstat (limited to 'xsde/cxx')
-rw-r--r--xsde/cxx/hybrid/elements.cxx8
-rw-r--r--xsde/cxx/hybrid/elements.hxx8
-rw-r--r--xsde/cxx/hybrid/generator.cxx17
-rw-r--r--xsde/cxx/hybrid/parser-source.cxx8
-rw-r--r--xsde/cxx/hybrid/parser-source.hxx2
-rw-r--r--xsde/cxx/hybrid/serializer-source.cxx28
-rw-r--r--xsde/cxx/hybrid/serializer-source.hxx2
7 files changed, 57 insertions, 16 deletions
diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx
index 4d5a481..4bb230d 100644
--- a/xsde/cxx/hybrid/elements.cxx
+++ b/xsde/cxx/hybrid/elements.cxx
@@ -630,26 +630,26 @@ namespace CXX
{
case forward:
{
- inc_path = ctx_.fwd_expr->merge (path_str);
+ inc_path = (regex_ ? regex_ : ctx_.fwd_expr)->merge (path_str);
break;
}
case header:
case impl_header:
case source:
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->merge (path_str);
break;
}
case inline_:
{
if (weak)
{
- inc_path = ctx_.hxx_expr->merge (path_str);
+ inc_path = (regex_ ? regex_ : ctx_.hxx_expr)->merge (path_str);
ctx_.os << "#include " << ctx_.process_include_path (inc_path)
<< endl;
}
- inc_path = ctx_.ixx_expr->merge (path_str);
+ inc_path = (regex_ ? regex_ : ctx_.ixx_expr)->merge (path_str);
break;
}
}
diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx
index 8539009..352f5a0 100644
--- a/xsde/cxx/hybrid/elements.hxx
+++ b/xsde/cxx/hybrid/elements.hxx
@@ -20,12 +20,14 @@ namespace CXX
{
namespace Hybrid
{
+ typedef BackendElements::Regex::Expression<Char> Regex;
+
//
//
class Context: public CXX::Context
{
public:
- typedef BackendElements::Regex::Expression<Char> Regex;
+ typedef Hybrid::Regex Regex;
public:
Context (std::wostream&,
@@ -2167,10 +2169,11 @@ namespace CXX
source
};
- Includes (Context& c, Type type)
+ Includes (Context& c, Type type, Regex const* r = 0)
: ctx_ (c),
type_ (type),
forward_ (c.options.value<CLI::generate_forward> ()),
+ regex_ (r),
namespace_ (c),
type_forward_ (c)
{
@@ -2197,6 +2200,7 @@ namespace CXX
Context& ctx_;
Type type_;
Boolean forward_;
+ Regex const* regex_;
Traversal::Schema schema_;
Traversal::Names schema_names_;
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index e47a3c9..fa6f358 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -2390,7 +2390,7 @@ namespace CXX
// CXX
//
{
- Context ctx (cxx, schema, file_path, ops, 0, &hxx_obj_expr, 0);
+ Context ctx (cxx, schema, file_path, ops, 0, &hxx_expr, 0);
Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (cxx);
@@ -2419,7 +2419,7 @@ namespace CXX
cxx << "#include " << ctx.process_include_path (hxx_name) << endl
<< endl;
- generate_parser_source (ctx);
+ generate_parser_source (ctx, hxx_obj_expr);
if (aggr)
generate_parser_aggregate_source (ctx);
@@ -2540,6 +2540,9 @@ namespace CXX
NarrowString hxx_suffix (ops.value <CLI::hxx_suffix> ());
NarrowString cxx_suffix (ops.value <CLI::cxx_suffix> ());
+ NarrowString hxx_obj_regex (
+ find_value (ops.value <CLI::hxx_regex> (), ""));
+
NarrowString hxx_skel_regex (
find_value (ops.value <CLI::hxx_regex> (), "sskel"));
NarrowString hxx_regex (
@@ -2547,6 +2550,14 @@ namespace CXX
NarrowString cxx_regex (
find_value (ops.value <CLI::cxx_regex> (), "simpl"));
+ // Here we need to make sure that hxx_obj_expr is the same
+ // as in generate().
+ //
+ Regex hxx_obj_expr (
+ hxx_obj_regex.empty ()
+ ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + hxx_suffix + "#"
+ : hxx_obj_regex);
+
// Here we need to make sure that hxx_skel_expr is the same
// as in the C++/Serializer generator.
//
@@ -2828,7 +2839,7 @@ namespace CXX
cxx << "#include " << ctx.process_include_path (hxx_name) << endl
<< endl;
- generate_serializer_source (ctx);
+ generate_serializer_source (ctx, hxx_obj_expr);
if (aggr)
generate_serializer_aggregate_source (ctx);
diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx
index 3bfac39..6c53f55 100644
--- a/xsde/cxx/hybrid/parser-source.cxx
+++ b/xsde/cxx/hybrid/parser-source.cxx
@@ -2087,7 +2087,7 @@ namespace CXX
}
Void
- generate_parser_source (Context& ctx)
+ generate_parser_source (Context& ctx, Regex const& hxx_obj_expr)
{
if (ctx.enum_)
{
@@ -2104,11 +2104,11 @@ namespace CXX
{
// Emit "weak" header includes for the object model types.
- // Otherwise we cannot delete the objects of forward-declared
- // classes in the parser implementations.
+ // Otherwise they will only be forward-declared and we won't
+ // be able to call delete on them.
//
Traversal::Schema schema;
- Includes includes (ctx, Includes::source);
+ Includes includes (ctx, Includes::source, &hxx_obj_expr);
schema >> includes;
diff --git a/xsde/cxx/hybrid/parser-source.hxx b/xsde/cxx/hybrid/parser-source.hxx
index 0e6ac62..fafd8e3 100644
--- a/xsde/cxx/hybrid/parser-source.hxx
+++ b/xsde/cxx/hybrid/parser-source.hxx
@@ -13,7 +13,7 @@ namespace CXX
namespace Hybrid
{
Void
- generate_parser_source (Context&);
+ generate_parser_source (Context&, Regex const& hxx_obj_expr);
}
}
diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx
index fa613d4..178dc73 100644
--- a/xsde/cxx/hybrid/serializer-source.cxx
+++ b/xsde/cxx/hybrid/serializer-source.cxx
@@ -1383,7 +1383,7 @@ namespace CXX
}
Void
- generate_serializer_source (Context& ctx)
+ generate_serializer_source (Context& ctx, Regex const& hxx_obj_expr)
{
if (ctx.poly_code && !ctx.stl)
ctx.os << "#include <string.h>" << endl
@@ -1399,6 +1399,32 @@ namespace CXX
<< endl;
}
+ {
+ // Emit "weak" header includes for the object model types.
+ // Otherwise they will only be forward-declared.
+ //
+ Traversal::Schema schema;
+ Includes includes (ctx, Includes::source, &hxx_obj_expr);
+
+ schema >> includes;
+
+ schema.dispatch (ctx.schema_root);
+ }
+
+ if (ctx.poly_code)
+ {
+ // Also emit "weak" header includes for the serializer
+ // implementations. These are needed for the _static_type if we are
+ // generating polymorphic code.
+ //
+ Traversal::Schema schema;
+ Includes includes (ctx, Includes::source);
+
+ schema >> includes;
+
+ schema.dispatch (ctx.schema_root);
+ }
+
Traversal::Schema schema;
Traversal::Sources sources;
diff --git a/xsde/cxx/hybrid/serializer-source.hxx b/xsde/cxx/hybrid/serializer-source.hxx
index 91407e4..ae75b15 100644
--- a/xsde/cxx/hybrid/serializer-source.hxx
+++ b/xsde/cxx/hybrid/serializer-source.hxx
@@ -13,7 +13,7 @@ namespace CXX
namespace Hybrid
{
Void
- generate_serializer_source (Context&);
+ generate_serializer_source (Context&, Regex const& hxx_obj_expr);
}
}