From 36ba4a4f1af667682416f48c1698b1167e66e2b1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Oct 2010 16:13:36 +0200 Subject: Omit _present(bool) for variable-length members --- xsde/cxx/hybrid/extraction-source.cxx | 80 ++++++++++--- xsde/cxx/hybrid/tree-header.cxx | 55 +++++---- xsde/cxx/hybrid/tree-inline.cxx | 220 ++++++++-------------------------- 3 files changed, 140 insertions(+), 215 deletions(-) (limited to 'xsde/cxx') diff --git a/xsde/cxx/hybrid/extraction-source.cxx b/xsde/cxx/hybrid/extraction-source.cxx index 1e2a602..0bcc166 100644 --- a/xsde/cxx/hybrid/extraction-source.cxx +++ b/xsde/cxx/hybrid/extraction-source.cxx @@ -277,14 +277,23 @@ namespace CXX if (!a.default_p ()) { os << "}" - << "else" << endl - << "x." << epresent (a) << " (false);"; + << "else" << endl; + + if (fl) + os << "x." << epresent (a) << " (false);"; + else + os << "x." << name << " (0);"; + } else { os << "}" - << "else" << endl - << "x." << edefault (a) << " (true);"; + << "else" << endl; + + if (fl) + os << "x." << edefault (a) << " (true);"; + else + os << "x." << name << " (0);"; } } @@ -403,9 +412,15 @@ namespace CXX } if (e.min () == 0) + { os << "}" - << "else" << endl - << "x." << epresent (e) << " (false);"; + << "else" << endl; + + if (fl) + os << "x." << epresent (e) << " (false);"; + else + os << "x." << name << " (0);"; + } os << "}"; } @@ -486,9 +501,14 @@ namespace CXX << "return false;"; os << "}" - << "else" << endl - << "x." << present << " (false);" - << "}"; + << "else" << endl; + + if (fl) + os << "x." << present << " (false);"; + else + os << "x." << name << " (0);"; + + os << "}"; } else All::contains (a); @@ -608,9 +628,15 @@ namespace CXX } if (e.min () == 0) + { os << "}" - << "else" << endl - << "x." << epresent (e) << " (false);"; + << "else" << endl; + + if (fl) + os << "x." << epresent (e) << " (false);"; + else + os << "x." << name << " (0);"; + } } os << "break;" @@ -697,9 +723,15 @@ namespace CXX << "return false;"; if (c.min () == 0) + { os << "}" - << "else" << endl - << "x." << epresent (c) << " (false);"; + << "else" << endl; + + if (fl) + os << "x." << epresent (c) << " (false);"; + else + os << "x." << name << " (0);"; + } } os << "break;" @@ -789,9 +821,14 @@ namespace CXX << "return false;"; os << "}" - << "else" << endl - << "x." << present << " (false);" - << "}"; + << "else" << endl; + + if (fl) + os << "x." << present << " (false);"; + else + os << "x." << name << " (0);"; + + os << "}"; } else { @@ -907,9 +944,14 @@ namespace CXX << "return false;"; os << "}" - << "else" << endl - << "x." << present << " (false);" - << "}"; + << "else" << endl; + + if (fl) + os << "x." << present << " (false);"; + else + os << "x." << name << " (0);"; + + os << "}"; } else Sequence::contains (s); diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx index 90bdd24..20f0328 100644 --- a/xsde/cxx/hybrid/tree-header.cxx +++ b/xsde/cxx/hybrid/tree-header.cxx @@ -1358,6 +1358,7 @@ namespace CXX String const& name (ename (a)); SemanticGraph::Type& t (a.type ()); + Boolean fl (fixed_length (t)); if (a.optional_p () && !fix) @@ -1368,9 +1369,10 @@ namespace CXX << name << " () const;" << endl; - os << "void" << endl - << name << " (bool);" - << endl; + if (fl) + os << "void" << endl + << name << " (bool);" + << endl; } // const type& @@ -1406,7 +1408,7 @@ namespace CXX // type* // detach () // - if (detach && !fixed_length (t)) + if (detach && !fl) { arg_.dispatch (t); os << endl @@ -1453,6 +1455,7 @@ namespace CXX String const& name (ename (e)); SemanticGraph::Type& t (e.type ()); + Boolean fl (fixed_length (t)); if (e.max () != 1) { @@ -1496,9 +1499,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; } // const type& @@ -1530,7 +1534,7 @@ namespace CXX // type* // detach () // - if (detach && !fixed_length (t)) + if (detach && !fl) { arg_.dispatch (t); os << endl @@ -1667,9 +1671,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; // const type& // name () const @@ -1967,9 +1972,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; // const type& // name () const @@ -2203,9 +2209,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; } // const type& @@ -2410,9 +2417,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; // const type& // name () const @@ -2610,9 +2618,10 @@ namespace CXX << present << " () const;" << endl; - os << "void" << endl - << present << " (bool);" - << endl; + if (fl) + os << "void" << endl + << present << " (bool);" + << endl; } // const type& diff --git a/xsde/cxx/hybrid/tree-inline.cxx b/xsde/cxx/hybrid/tree-inline.cxx index fa55403..b28397c 100644 --- a/xsde/cxx/hybrid/tree-inline.cxx +++ b/xsde/cxx/hybrid/tree-inline.cxx @@ -414,44 +414,25 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << name << " (bool x)" - << "{"; - - if (def) + if (fl) { - os << "if (x)"; + os << inl + << "void " << scope << "::" << endl + << name << " (bool x)" + << "{"; - if (fl) + if (def) { - os << endl - << "this->" << member << " = " << edefault_value (a) << - " ();"; + os << "if (x)" << endl + << "this->" << member << " = " << edefault_value (a) << " ();"; } else { - os << "{"; - delete_.dispatch (t, L"this->" + member); - os << "this->" << member << " = 0;" - << "}"; - } - } - else - { - if (fl) os << "this->" << epresent_member (a) << " = x;"; - else - { - os << "if (!x)" - << "{"; - delete_.dispatch (t, L"this->" + member); - os << "this->" << member << " = 0;" - << "}"; } - } - os << "}"; + os << "}"; + } } // const type& @@ -644,23 +625,13 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{"; - if (fl) - os << "this->" << epresent_member (e) << " = x;"; - else - { - os << "if (!x)" - << "{"; - delete_.dispatch (t, L"this->" + member); - os << "this->" << member << " = 0;" + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "this->" << epresent_member (e) << " = x;" << "}"; - } - - os << "}"; } // const type& @@ -828,31 +799,20 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{" - << "if (this->" << arm_member << " != " << tag << ")" << endl - << "this->" << arm << " (" << tag << ");"; - if (fl) { - os << endl - << "this->" << umember << "." << member << - ".data_[sizeof ("; + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "if (this->" << arm_member << " != " << tag << ")" << endl + << "this->" << arm << " (" << tag << ");" + << endl + << "this->" << umember << "." << member << ".data_[sizeof ("; var_.dispatch (t); - os << ")] = x;"; - } - else - { - os << "else if (!x)" - << "{"; - delete_.dispatch (t, L"this->" + umember + L"." + member); - os << "this->" << umember << "." << member << " = 0;" + os << ")] = x;" << "}"; } - - os << "}"; } // const type& @@ -1012,34 +972,13 @@ namespace CXX // void // present (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{"; - if (fl) - os << "this->" << epresent_member (a) << " = x;"; - else - { - String p (L"this->" + member); - - os << "if (!x)" - << "{"; - - if (!custom_alloc) - os << "delete " << p << ";"; - else - os << "if (" << p << ")" - << "{" - << p << "->~" << type << " ();" - << "::xsde::cxx::free (" << p << ");" - << "}"; - - os << p << " = 0;" + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "this->" << epresent_member (a) << " = x;" << "}"; - } - - os << "}"; // const type& @@ -1216,34 +1155,13 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{"; - if (fl) - os << "this->" << epresent_member (c) << " = x;"; - else - { - String p (L"this->" + member); - - os << "if (!x)" - << "{"; - - if (!custom_alloc) - os << "delete " << p << ";"; - else - os << "if (" << p << ")" - << "{" - << p << "->~" << type << " ();" - << "::xsde::cxx::free (" << p << ");" - << "}"; - - os << p << " = 0;" + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "this->" << epresent_member (c) << " = x;" << "}"; - } - - os << "}"; // const type& @@ -1406,34 +1324,13 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{"; - if (fl) - os << "this->" << epresent_member (s) << " = x;"; - else - { - String p (L"this->" + member); - - os << "if (!x)" - << "{"; - - if (!custom_alloc) - os << "delete " << p << ";"; - else - os << "if (" << p << ")" - << "{" - << p << "->~" << type << " ();" - << "::xsde::cxx::free (" << p << ");" - << "}"; - - os << p << " = 0;" + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "this->" << epresent_member (s) << " = x;" << "}"; - } - - os << "}"; // const type& @@ -1610,40 +1507,17 @@ namespace CXX // void // preset (bool); // - os << inl - << "void " << scope << "::" << endl - << present << " (bool x)" - << "{" - << "if (this->" << arm_member << " != " << tag << ")" << endl - << "this->" << arm << " (" << tag << ");"; - if (fl) - { - os << endl + os << inl + << "void " << scope << "::" << endl + << present << " (bool x)" + << "{" + << "if (this->" << arm_member << " != " << tag << ")" << endl + << "this->" << arm << " (" << tag << ");" + << endl << "this->" << umember << "." << member << - ".data_[sizeof (" << type << ")] = x;"; - } - else - { - String p (L"this->" + umember + L"." + member); - - os << "else if (!x)" - << "{"; - - if (!custom_alloc) - os << "delete " << p << ";"; - else - os << "if (" << p << ")" - << "{" - << p << "->~" << type << " ();" - << "::xsde::cxx::free (" << p << ");" - << "}"; - - os << p << " = 0;" + ".data_[sizeof (" << type << ")] = x;" << "}"; - } - - os << "}"; } // const type& -- cgit v1.1