diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-08 10:24:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-08 10:24:07 +0200 |
commit | 3067cb353cca291d25b4b1fcf6acdb110e560536 (patch) | |
tree | b9ca3a097f2cd372a49b055a42a179a3f8f4b5d2 /xsd/cxx/parser | |
parent | ab392684ea4502b09b9a20655ed89be1379b9d90 (diff) |
Use indenters from libcutl instead of libbackend-elements
Diffstat (limited to 'xsd/cxx/parser')
-rw-r--r-- | xsd/cxx/parser/generator.cxx | 128 |
1 files changed, 62 insertions, 66 deletions
diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx index 3635730..1a121cd 100644 --- a/xsd/cxx/parser/generator.cxx +++ b/xsd/cxx/parser/generator.cxx @@ -3,6 +3,22 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <iostream> + +#include <boost/filesystem/fstream.hpp> + +#include <cult/containers/set.hxx> +#include <cult/containers/vector.hxx> + +#include <cutl/compiler/code-stream.hxx> +#include <cutl/compiler/cxx-indenter.hxx> +#include <cutl/compiler/sloc-counter.hxx> + +#include <backend-elements/regex.hxx> +#include <backend-elements/indentation/clip.hxx> + +#include <xsd-frontend/semantic-graph.hxx> + #include <type-map/lexer.hxx> #include <type-map/parser.hxx> #include <type-map/type-map.hxx> @@ -28,20 +44,6 @@ #include <cxx/parser/attribute-validation-source.hxx> #include <cxx/parser/characters-validation-source.hxx> -#include <xsd-frontend/semantic-graph.hxx> - -#include <backend-elements/regex.hxx> -#include <backend-elements/indentation/cxx.hxx> -#include <backend-elements/indentation/sloc.hxx> -#include <backend-elements/indentation/clip.hxx> - -#include <cult/containers/set.hxx> -#include <cult/containers/vector.hxx> - -#include <boost/filesystem/fstream.hpp> - -#include <iostream> - #include <usage.hxx> #include "../../../libxsd/xsd/cxx/version.hxx" @@ -1159,9 +1161,17 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc (0); + UnsignedLong sloc_total (0); Boolean show_sloc (ops.value<CLI::show_sloc> ()); + typedef + compiler::ostream_filter<compiler::cxx_indenter, wchar_t> + ind_filter; + + typedef + compiler::ostream_filter<compiler::sloc_counter, wchar_t> + sloc_filter; + // // Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. @@ -1186,7 +1196,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx); + sloc_filter sloc (hxx); String guard (guard_expr.merge (guard_prefix + hxx_name)); guard = ctx.escape (guard); // Make it a C++ id. @@ -1221,24 +1231,20 @@ namespace CXX << "// End prologue." << endl << endl; + // Generate. + // { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx); - + ind_filter ind (hxx); // We don't want to indent prologues/epilogues. - // Generate. - // if (!generate_xml_schema) generate_parser_forward (ctx); generate_parser_header (ctx, generate_xml_schema); - - - if (inline_) - hxx << "#include " << ctx.process_include_path (ixx_name) << endl; } + if (inline_) + hxx << "#include " << ctx.process_include_path (ixx_name) << endl; + // Copy epilogue. // hxx << "// Begin epilogue." << endl @@ -1258,9 +1264,9 @@ namespace CXX hxx << "#endif // " << guard << endl; if (show_sloc) - wcerr << hxx_path << ": " << hxx_sloc.buffer ().count () << endl; + wcerr << hxx_path << ": " << sloc.stream ().count () << endl; - sloc += hxx_sloc.buffer ().count (); + sloc_total += sloc.stream ().count (); } @@ -1277,8 +1283,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> ixx_sloc (ixx); - + sloc_filter sloc (ixx); // Copy prologue. // @@ -1293,14 +1298,10 @@ namespace CXX << "// End prologue." << endl << endl; + // Generate. + // { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> ixx_clip (ixx); - - - // Generate. - // + ind_filter ind (ixx); // We don't want to indent prologues/epilogues. generate_parser_inline (ctx); } @@ -1318,9 +1319,9 @@ namespace CXX << endl; if (show_sloc) - wcerr << ixx_path << ": " << ixx_sloc.buffer ().count () << endl; + wcerr << ixx_path << ": " << sloc.stream ().count () << endl; - sloc += ixx_sloc.buffer ().count (); + sloc_total += sloc.stream ().count (); } @@ -1337,7 +1338,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (cxx); + sloc_filter sloc (cxx); // Copy prologue. // @@ -1352,13 +1353,13 @@ namespace CXX << "// End prologue." << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> cxx_clip (cxx); + cxx << "#include " << ctx.process_include_path (hxx_name) << endl + << endl; - cxx << "#include " << ctx.process_include_path (hxx_name) << endl - << endl; + // Generate. + // + { + ind_filter ind (cxx); // We don't want to indent prologues/epilogues. if (!inline_) generate_parser_inline (ctx); @@ -1387,9 +1388,9 @@ namespace CXX << endl; if (show_sloc) - wcerr << cxx_path << ": " << cxx_sloc.buffer ().count () << endl; + wcerr << cxx_path << ": " << sloc.stream ().count () << endl; - sloc += cxx_sloc.buffer ().count (); + sloc_total += sloc.stream ().count (); } // HXX impl @@ -1413,14 +1414,11 @@ namespace CXX << "#define " << guard << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (hxx_impl); - - hxx_impl << "#include " << ctx.process_include_path (hxx_name) - << endl << endl; + hxx_impl << "#include " << ctx.process_include_path (hxx_name) + << endl << endl; + { + ind_filter ind (hxx_impl); generate_impl_header (ctx); } @@ -1440,14 +1438,13 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_impl); - cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_impl_source (ctx); + { + ind_filter ind (cxx_impl); + generate_impl_source (ctx); + } } // CXX driver @@ -1463,17 +1460,16 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_driver); - cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_driver_source (ctx); + { + ind_filter ind (cxx_driver); + generate_driver_source (ctx); + } } - return sloc; + return sloc_total; } catch (UnrepresentableCharacter const& e) { |