aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-14 14:06:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-14 14:06:48 +0200
commit644c7b372ab61ad600817a4945a96f2bfb0f76e2 (patch)
tree3affbadec3a484884b403e1ef506ce48f5f3605b /xsde/cxx
parent783b167522ccf3aee85969dfb932274914449808 (diff)
Error out if generating parser/serializer for customized type
Diffstat (limited to 'xsde/cxx')
-rw-r--r--xsde/cxx/hybrid/generator.cxx14
-rw-r--r--xsde/cxx/hybrid/generator.hxx4
-rw-r--r--xsde/cxx/hybrid/parser-name-processor.cxx33
-rw-r--r--xsde/cxx/hybrid/parser-name-processor.hxx2
-rw-r--r--xsde/cxx/hybrid/serializer-name-processor.cxx33
-rw-r--r--xsde/cxx/hybrid/serializer-name-processor.hxx2
6 files changed, 76 insertions, 12 deletions
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index 8e3d8d1..e47a3c9 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -1125,7 +1125,8 @@ namespace CXX
XSDFrontend::SemanticGraph::Path const& file)
{
ParserNameProcessor proc;
- proc.process (ops, schema, file, false);
+ if (!proc.process (ops, schema, file, false))
+ throw Failed ();
}
Void Hybrid::Generator::
@@ -1134,7 +1135,8 @@ namespace CXX
XSDFrontend::SemanticGraph::Path const& file)
{
SerializerNameProcessor proc;
- proc.process (ops, schema, file, false);
+ if (!proc.process (ops, schema, file, false))
+ throw Failed ();
}
namespace
@@ -2104,7 +2106,9 @@ namespace CXX
//
{
ParserNameProcessor proc;
- proc.process (ops, schema, file_path, true);
+
+ if (!proc.process (ops, schema, file_path, true))
+ throw Failed ();
}
NarrowString name (file_path.leaf ());
@@ -2524,7 +2528,9 @@ namespace CXX
//
{
SerializerNameProcessor proc;
- proc.process (ops, schema, file_path, true);
+
+ if (!proc.process (ops, schema, file_path, true))
+ throw Failed ();
}
NarrowString name (file_path.leaf ());
diff --git a/xsde/cxx/hybrid/generator.hxx b/xsde/cxx/hybrid/generator.hxx
index 805e282..a910a0c 100644
--- a/xsde/cxx/hybrid/generator.hxx
+++ b/xsde/cxx/hybrid/generator.hxx
@@ -32,6 +32,8 @@ namespace CXX
class Generator
{
public:
+ struct Failed {};
+
static Void
usage ();
@@ -79,8 +81,6 @@ namespace CXX
// Generate code.
//
- struct Failed {};
-
static UnsignedLong
generate_tree (
CLI::Options const&,
diff --git a/xsde/cxx/hybrid/parser-name-processor.cxx b/xsde/cxx/hybrid/parser-name-processor.cxx
index b55e9b8..1582004 100644
--- a/xsde/cxx/hybrid/parser-name-processor.cxx
+++ b/xsde/cxx/hybrid/parser-name-processor.cxx
@@ -26,6 +26,8 @@ namespace CXX
//
typedef Cult::Containers::Set<String> NameSet;
+ struct Failed {};
+
class Context: public CXX::Context
{
public:
@@ -495,6 +497,7 @@ namespace CXX
// See if this parser is being customized.
//
+ Boolean custom (false);
CustomParserMap::ConstIterator i (custom_parser_map.find (name));
if (i != custom_parser_map.end ())
@@ -503,10 +506,28 @@ namespace CXX
? find_name (i->second.base, set_)
: i->second.base);
+ custom = i->second.base.empty ();
+
if (i->second.include)
tc.set ("p:impl-include", i->second.include);
}
+ // If this type is completely customized then we cannot generate
+ // a parser implementation for it.
+ //
+ if (!custom && tc.count ("name-base") && !tc.get<String> ("name-base"))
+ {
+ os << t.file () << ":" << t.line () << ":" << t.column ()
+ << ": error: unable to generate parser implementation for "
+ << "customized object model type '" << t.name () << "'" << endl;
+
+ os << t.file () << ":" << t.line () << ":" << t.column ()
+ << ": info: provide custom parser implementation for this "
+ << "type with the --custom-parser option" << endl;
+
+ throw Failed ();
+ }
+
if (aggregate)
{
typedef Cult::Containers::Vector<NarrowString> Names;
@@ -772,13 +793,21 @@ namespace CXX
}
}
- Void ParserNameProcessor::
+ Boolean ParserNameProcessor::
process (CLI::Options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
Boolean deep)
{
- process_impl (ops, tu, file, deep);
+ try
+ {
+ process_impl (ops, tu, file, deep);
+ return true;
+ }
+ catch (Failed const&)
+ {
+ return false;
+ }
}
}
}
diff --git a/xsde/cxx/hybrid/parser-name-processor.hxx b/xsde/cxx/hybrid/parser-name-processor.hxx
index 3ea6d08..ccd369d 100644
--- a/xsde/cxx/hybrid/parser-name-processor.hxx
+++ b/xsde/cxx/hybrid/parser-name-processor.hxx
@@ -21,7 +21,7 @@ namespace CXX
class ParserNameProcessor
{
public:
- Void
+ Boolean
process (CLI::Options const& options,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
diff --git a/xsde/cxx/hybrid/serializer-name-processor.cxx b/xsde/cxx/hybrid/serializer-name-processor.cxx
index 784a2af..63d64b6 100644
--- a/xsde/cxx/hybrid/serializer-name-processor.cxx
+++ b/xsde/cxx/hybrid/serializer-name-processor.cxx
@@ -25,6 +25,8 @@ namespace CXX
//
typedef Cult::Containers::Set<String> NameSet;
+ struct Failed {};
+
class Context: public CXX::Context
{
public:
@@ -502,6 +504,7 @@ namespace CXX
// See if this serializer is being customized.
//
+ Boolean custom (false);
CustomSerializerMap::ConstIterator i (
custom_serializer_map.find (name));
@@ -511,10 +514,28 @@ namespace CXX
? find_name (i->second.base, set_)
: i->second.base);
+ custom = i->second.base.empty ();
+
if (i->second.include)
tc.set ("s:impl-include", i->second.include);
}
+ // If this type is completely customized then we cannot generate
+ // a serializer implementation for it.
+ //
+ if (!custom && tc.count ("name-base") && !tc.get<String> ("name-base"))
+ {
+ os << t.file () << ":" << t.line () << ":" << t.column ()
+ << ": error: unable to generate serializer implementation for "
+ << "customized object model type '" << t.name () << "'" << endl;
+
+ os << t.file () << ":" << t.line () << ":" << t.column ()
+ << ": info: provide custom serializer implementation for this "
+ << "type with the --custom-serializer option" << endl;
+
+ throw Failed ();
+ }
+
if (aggregate)
{
typedef Cult::Containers::Vector<NarrowString> Names;
@@ -780,13 +801,21 @@ namespace CXX
}
}
- Void SerializerNameProcessor::
+ Boolean SerializerNameProcessor::
process (CLI::Options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
Boolean deep)
{
- process_impl (ops, tu, file, deep);
+ try
+ {
+ process_impl (ops, tu, file, deep);
+ return true;
+ }
+ catch (Failed const&)
+ {
+ return false;
+ }
}
}
}
diff --git a/xsde/cxx/hybrid/serializer-name-processor.hxx b/xsde/cxx/hybrid/serializer-name-processor.hxx
index 7a0b50b..fe9eb21 100644
--- a/xsde/cxx/hybrid/serializer-name-processor.hxx
+++ b/xsde/cxx/hybrid/serializer-name-processor.hxx
@@ -21,7 +21,7 @@ namespace CXX
class SerializerNameProcessor
{
public:
- Void
+ Boolean
process (CLI::Options const& options,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,