aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-13 15:38:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-13 15:38:11 +0200
commit6f395f9f769866a04f6949cb7ed14f93d90cf728 (patch)
treed1f8343e7b41fc1895676ad4248a5e4942f9172b /xsde/cxx
parentc1f49aa87678c512ac37575365a6676727e5f20a (diff)
Map anySimpleType to a string
Diffstat (limited to 'xsde/cxx')
-rw-r--r--xsde/cxx/elements.cxx7
-rw-r--r--xsde/cxx/elements.hxx7
-rw-r--r--xsde/cxx/hybrid/default-value.cxx5
-rw-r--r--xsde/cxx/hybrid/default-value.hxx2
-rw-r--r--xsde/cxx/hybrid/elements.hxx19
-rw-r--r--xsde/cxx/hybrid/parser-source.cxx12
-rw-r--r--xsde/cxx/hybrid/serializer-source.cxx7
-rw-r--r--xsde/cxx/hybrid/tree-forward.cxx7
-rw-r--r--xsde/cxx/hybrid/tree-header.cxx2
-rw-r--r--xsde/cxx/hybrid/tree-size-processor.cxx2
-rw-r--r--xsde/cxx/parser/generator.cxx4
-rw-r--r--xsde/cxx/parser/parser-header.cxx2
-rw-r--r--xsde/cxx/parser/print-impl-common.hxx18
-rw-r--r--xsde/cxx/serializer/generator.cxx4
-rw-r--r--xsde/cxx/serializer/serializer-header.cxx2
15 files changed, 74 insertions, 26 deletions
diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx
index 7fe8b3f..2289e32 100644
--- a/xsde/cxx/elements.cxx
+++ b/xsde/cxx/elements.cxx
@@ -1339,6 +1339,13 @@ namespace CXX
return literal_;
}
+ Void LiteralValue::
+ traverse (SemanticGraph::AnySimpleType&)
+ {
+ if (str_)
+ literal_ = strlit (value_);
+ }
+
// Boolean.
//
Void LiteralValue::
diff --git a/xsde/cxx/elements.hxx b/xsde/cxx/elements.hxx
index c9f79f2..5952e68 100644
--- a/xsde/cxx/elements.hxx
+++ b/xsde/cxx/elements.hxx
@@ -617,7 +617,9 @@ namespace CXX
}
};
- struct LiteralValue: Traversal::Fundamental::Byte,
+ struct LiteralValue: Traversal::AnySimpleType,
+
+ Traversal::Fundamental::Byte,
Traversal::Fundamental::UnsignedByte,
Traversal::Fundamental::Short,
Traversal::Fundamental::UnsignedShort,
@@ -657,6 +659,9 @@ namespace CXX
String
dispatch (SemanticGraph::Node& type, String const& value);
+ virtual Void
+ traverse (SemanticGraph::AnySimpleType&);
+
// Boolean.
//
virtual Void
diff --git a/xsde/cxx/hybrid/default-value.cxx b/xsde/cxx/hybrid/default-value.cxx
index d63c636..712f405 100644
--- a/xsde/cxx/hybrid/default-value.cxx
+++ b/xsde/cxx/hybrid/default-value.cxx
@@ -229,8 +229,9 @@ namespace CXX
// anySimpleType.
//
Void InitValue::
- traverse (SemanticGraph::AnySimpleType&)
+ traverse (SemanticGraph::AnySimpleType& t)
{
+ string_type (t);
}
// Strings.
@@ -741,7 +742,7 @@ namespace CXX
}
Void InitValue::
- string_type (SemanticGraph::Fundamental::Type& t)
+ string_type (SemanticGraph::Type& t)
{
// In case STL is disabled, strings are returned as literals
// so we end up here only if the type is derived from a string.
diff --git a/xsde/cxx/hybrid/default-value.hxx b/xsde/cxx/hybrid/default-value.hxx
index aef9049..00bd2e0 100644
--- a/xsde/cxx/hybrid/default-value.hxx
+++ b/xsde/cxx/hybrid/default-value.hxx
@@ -177,7 +177,7 @@ namespace CXX
private:
Void
- string_type (SemanticGraph::Fundamental::Type&);
+ string_type (SemanticGraph::Type&);
Void
string_sequence_type ();
diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx
index 7bd8bd1..50f0931 100644
--- a/xsde/cxx/hybrid/elements.hxx
+++ b/xsde/cxx/hybrid/elements.hxx
@@ -798,7 +798,9 @@ namespace CXX
//
//
- struct StringType: Traversal::Fundamental::String,
+ struct StringType: Traversal::AnySimpleType,
+
+ Traversal::Fundamental::String,
Traversal::Fundamental::NormalizedString,
Traversal::Fundamental::Token,
Traversal::Fundamental::Name,
@@ -816,6 +818,12 @@ namespace CXX
}
virtual Void
+ traverse (SemanticGraph::AnySimpleType&)
+ {
+ r_ = true;
+ }
+
+ virtual Void
traverse (SemanticGraph::Fundamental::String&)
{
r_ = true;
@@ -1098,9 +1106,12 @@ namespace CXX
}
virtual Void
- traverse (SemanticGraph::AnySimpleType& t)
+ traverse (SemanticGraph::AnySimpleType&)
{
- type (t);
+ if (stl || use_ != base)
+ string_type ();
+ else
+ os << xs_ns_ << "::any_simple_type_base";
}
// Boolean.
@@ -1688,7 +1699,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType& t)
{
- type (t);
+ string_type (t);
}
// Boolean.
diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx
index 99a350a..c610101 100644
--- a/xsde/cxx/hybrid/parser-source.cxx
+++ b/xsde/cxx/hybrid/parser-source.cxx
@@ -1836,11 +1836,9 @@ namespace CXX
// The following code is similar to what we have in post().
//
- // Default parser implementations for anyType and
- // anySimpleType return void.
+ // Default parser implementation for anyType returns void.
//
- if (!b.is_a<SemanticGraph::AnyType> () &&
- !b.is_a<SemanticGraph::AnySimpleType> ())
+ if (!b.is_a<SemanticGraph::AnyType> ())
{
// If our base is a fixed-length type then copy the data
// over. Note that it cannot be a C-string.
@@ -1999,11 +1997,9 @@ namespace CXX
{
SemanticGraph::Type& b (c.inherits ().base ());
- // Default parser implementations for anyType and
- // anySimpleType return void.
+ // Default parser implementation for anyType returns void.
//
- if (!b.is_a<SemanticGraph::AnyType> () &&
- !b.is_a<SemanticGraph::AnySimpleType> ())
+ if (!b.is_a<SemanticGraph::AnyType> ())
{
// If we are recursive but our base is not, we only call
// base post() if it is the first post call.
diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx
index 9377c5f..ef9eae9 100644
--- a/xsde/cxx/hybrid/serializer-source.cxx
+++ b/xsde/cxx/hybrid/serializer-source.cxx
@@ -1234,11 +1234,10 @@ namespace CXX
<< endl;
}
- // Call base pre(). Default serializer implementations for
- // anyType and anySimpleType return void.
+ // Call base pre(). Default serializer implementation for
+ // anyType takes void.
//
- if (!b.is_a<SemanticGraph::AnyType> () &&
- !b.is_a<SemanticGraph::AnySimpleType> ())
+ if (!b.is_a<SemanticGraph::AnyType> ())
{
if (tiein)
os << "this->base_impl_.pre (";
diff --git a/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx
index dbfdd7e..c9df43c 100644
--- a/xsde/cxx/hybrid/tree-forward.cxx
+++ b/xsde/cxx/hybrid/tree-forward.cxx
@@ -243,7 +243,12 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType&)
{
- gen_using ("::xsde::cxx::hybrid::any_simple_type");
+ gen_typedef ("any_simple_type", string_type_);
+
+ if (!stl)
+ gen_typedef ("any_simple_type_base",
+ "::xsde::cxx::hybrid::string_base");
+ os << endl;
}
// Boolean.
diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx
index c596ab0..b82cb7b 100644
--- a/xsde/cxx/hybrid/tree-header.cxx
+++ b/xsde/cxx/hybrid/tree-header.cxx
@@ -740,7 +740,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType&)
{
- align_type ("char", 1);
+ align_type ("size_t", 5); // std::string
}
// Boolean.
diff --git a/xsde/cxx/hybrid/tree-size-processor.cxx b/xsde/cxx/hybrid/tree-size-processor.cxx
index bf7b328..e56b828 100644
--- a/xsde/cxx/hybrid/tree-size-processor.cxx
+++ b/xsde/cxx/hybrid/tree-size-processor.cxx
@@ -559,7 +559,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType& t)
{
- set (t, true);
+ set (t, stl);
}
// Boolean.
diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx
index 74ba2ea..b6f91ee 100644
--- a/xsde/cxx/parser/generator.cxx
+++ b/xsde/cxx/parser/generator.cxx
@@ -718,6 +718,8 @@ namespace CXX
String qname (xns + L"::qname*");
String string_seq (xns + L"::string_sequence*");
+ xsd_std.types_push_back ("anySimpleType", "char*", "char*");
+
xsd_std.types_push_back ("string", "char*", "char*");
xsd_std.types_push_back ("normalizedString", "char*", "char*");
xsd_std.types_push_back ("token", "char*", "char*");
@@ -743,6 +745,8 @@ namespace CXX
String qname (xns + L"::qname");
String string_seq (xns + L"::string_sequence*");
+ xsd_std.types_push_back ("anySimpleType", "::std::string");
+
xsd_std.types_push_back ("string", "::std::string");
xsd_std.types_push_back ("normalizedString", "::std::string");
xsd_std.types_push_back ("token", "::std::string");
diff --git a/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx
index 11176f9..fe6d67b 100644
--- a/xsde/cxx/parser/parser-header.cxx
+++ b/xsde/cxx/parser/parser-header.cxx
@@ -1222,7 +1222,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType& t)
{
- gen_typedef (t, "void");
+ gen_typedef (t, string_type_);
}
// Boolean.
diff --git a/xsde/cxx/parser/print-impl-common.hxx b/xsde/cxx/parser/print-impl-common.hxx
index 13325bd..4dba38f 100644
--- a/xsde/cxx/parser/print-impl-common.hxx
+++ b/xsde/cxx/parser/print-impl-common.hxx
@@ -17,6 +17,8 @@ namespace CXX
{
struct PrintCall: Traversal::Type,
+ Traversal::AnySimpleType,
+
Traversal::Fundamental::Boolean,
Traversal::Fundamental::Byte,
@@ -80,6 +82,12 @@ namespace CXX
gen_user_type ();
}
+ virtual Void
+ traverse (SemanticGraph::AnySimpleType& t)
+ {
+ gen_string (t);
+ }
+
// Boolean.
//
virtual Void
@@ -885,7 +893,9 @@ namespace CXX
String arg_;
};
- struct DeleteCall: Traversal::Fundamental::String,
+ struct DeleteCall: Traversal::AnySimpleType,
+
+ Traversal::Fundamental::String,
Traversal::Fundamental::NormalizedString,
Traversal::Fundamental::Token,
Traversal::Fundamental::Name,
@@ -912,6 +922,12 @@ namespace CXX
{
}
+ virtual Void
+ traverse (SemanticGraph::AnySimpleType& t)
+ {
+ gen_string (t);
+ }
+
// Strings.
//
virtual Void
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 5c94c98..36539f4 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -703,6 +703,8 @@ namespace CXX
String qname (L"const " + xns + L"::qname*");
String string_seq (L"const " + xns + L"::string_sequence*");
+ xsd_std.types_push_back ("anySimpleType", "const char*", "const char*");
+
xsd_std.types_push_back ("string", "const char*", "const char*");
xsd_std.types_push_back ("normalizedString", "const char*", "const char*");
xsd_std.types_push_back ("token", "const char*", "const char*");
@@ -728,6 +730,8 @@ namespace CXX
String qname (xns + L"::qname");
String string_seq (L"const " + xns + L"::string_sequence*");
+ xsd_std.types_push_back ("anySimpleType", "::std::string");
+
xsd_std.types_push_back ("string", "::std::string");
xsd_std.types_push_back ("normalizedString", "::std::string");
xsd_std.types_push_back ("token", "::std::string");
diff --git a/xsde/cxx/serializer/serializer-header.cxx b/xsde/cxx/serializer/serializer-header.cxx
index 9f0c1f3..e8fd2f5 100644
--- a/xsde/cxx/serializer/serializer-header.cxx
+++ b/xsde/cxx/serializer/serializer-header.cxx
@@ -1384,7 +1384,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::AnySimpleType& t)
{
- gen_typedef (t, "void");
+ gen_typedef (t, string_type_);
}
// Boolean.