From af83df9be50a9383d0c54fb24b8e486a658a2a02 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Dec 2009 17:32:14 +0200 Subject: New default/fixed value initialization code Now the default/fixed values are parsed by the compiler at compile time instead of the standard parsing code at runtime. --- xsd/cxx/tree/tree-header.cxx | 50 +++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'xsd/cxx/tree/tree-header.cxx') diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx index 9b39739..c5e3395 100644 --- a/xsd/cxx/tree/tree-header.cxx +++ b/xsd/cxx/tree/tree-header.cxx @@ -3,12 +3,13 @@ // copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include -#include - #include #include +#include +#include +#include + namespace CXX { namespace Tree @@ -1358,20 +1359,35 @@ namespace CXX if (simple) { + Boolean lit (false); + { + IsLiteralValue test (lit); + test.dispatch (m.type ()); + } + if (doxygen) { os << "/**" << endl << " * @brief Return the default value for the " << kind << "." << endl - << " *" << endl - << " * @return A read-only (constant) reference to the " - << kind << "'s" << endl - << " * default value." << endl - << " */" << endl; + << " *" << endl; + + if (lit) + os << " * @return The " << kind << "'s default value." << endl; + else + os << " * @return A read-only (constant) reference to the " + << kind << "'s" << endl + << " * default value." << endl; + + os << " */" << endl; } - os << "static const " << etype (m) << "&" << endl - << edefault_value (m) << " ();" + if (lit) + os << "static " << etype (m) << endl; + else + os << "static const " << etype (m) << "&" << endl; + + os << edefault_value (m) << " ();" << endl; } } @@ -2157,8 +2173,17 @@ namespace CXX if (simple) { - os << "static const " << etype (m) << " " << - edefault_value_member (m) << ";"; + Boolean lit (false); + { + IsLiteralValue test (lit); + test.dispatch (m.type ()); + } + + if (!lit) + { + os << "static const " << etype (m) << " " << + edefault_value_member (m) << ";"; + } } } } @@ -3675,6 +3700,7 @@ namespace CXX Boolean inline_ (ctx.options.value ()); ctx.os << "#include // std::auto_ptr" << endl + << "#include // std::numeric_limits" << endl << "#include // std::binary_search" << endl << endl; -- cgit v1.1