From 1061c7c0ac3e6e9f6de93a9d8c68ce5d7a40c7ed Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 May 2012 10:25:43 +0200 Subject: Use indenters from libcutl instead of libbackend-elements --- xsde/cxx/parser/generator.cxx | 130 ++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 68 deletions(-) (limited to 'xsde/cxx/parser/generator.cxx') diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx index 8f91f6b..22e1669 100644 --- a/xsde/cxx/parser/generator.cxx +++ b/xsde/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 @@ -27,20 +43,6 @@ #include #include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include - #include #include "../../../libxsde/xsde/cxx/version.hxx" @@ -1180,12 +1182,18 @@ namespace CXX open (epilogue, name); } - // 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; // // @@ -1199,14 +1207,13 @@ namespace CXX if (guard_prefix) guard_prefix += '_'; - // HXX // { Context ctx ( hxx, schema, file_path, ops, &hxx_expr, &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. @@ -1431,23 +1438,21 @@ 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 - << endl; } + if (inline_) + hxx << "#include " << ctx.process_include_path (ixx_name) << endl + << endl; + // Copy epilogue. // hxx << "// Begin epilogue." << endl @@ -1467,12 +1472,11 @@ 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 (); } - // IXX // if (inline_) @@ -1480,8 +1484,7 @@ namespace CXX Context ctx ( ixx, schema, file_path, ops, &hxx_expr, &ixx_expr, &hxx_impl_expr); - Indentation::Clip ixx_sloc (ixx); - + sloc_filter sloc (ixx); // Copy prologue. // @@ -1496,14 +1499,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); } @@ -1521,9 +1520,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 (); } @@ -1534,7 +1533,7 @@ namespace CXX Context ctx ( cxx, schema, file_path, ops, &hxx_expr, &ixx_expr, &hxx_impl_expr); - Indentation::Clip cxx_sloc (cxx); + sloc_filter sloc (cxx); // Copy prologue. // @@ -1549,14 +1548,14 @@ namespace CXX << "// End prologue." << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip cxx_clip (cxx); - - cxx << "#include " << ctx.process_include_path (hxx_name) << 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); @@ -1584,9 +1583,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 @@ -1604,14 +1603,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); } @@ -1625,14 +1621,13 @@ namespace CXX Context ctx (cxx_impl, schema, file_path, ops, &hxx_expr, &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 @@ -1642,17 +1637,16 @@ namespace CXX Context ctx (cxx_driver, schema, file_path, ops, &hxx_expr, &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