From 3067cb353cca291d25b4b1fcf6acdb110e560536 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 May 2012 10:24:07 +0200 Subject: Use indenters from libcutl instead of libbackend-elements --- xsd/cxx/parser/generator.cxx | 128 +++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 66 deletions(-) (limited to 'xsd/cxx/parser') 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 + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + #include #include #include @@ -28,20 +44,6 @@ #include #include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include - #include #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 ()); + typedef + compiler::ostream_filter + ind_filter; + + typedef + compiler::ostream_filter + 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 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 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 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 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 cxx_sloc (cxx); + sloc_filter sloc (cxx); // Copy prologue. // @@ -1352,13 +1353,13 @@ namespace CXX << "// End prologue." << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip 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 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 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 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) { -- cgit v1.1