Ignore:
Timestamp:
Dec 9, 2011, 1:45:45 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 472

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_generator.cxx

    r591 r595  
    763763    }
    764764
    765   static InGenerator InGen (usecmt);
     765  int retval (0);
     766  static InGenerator InGen (usecmt, false);
    766767
    767768  bool gen (true);
     
    772773  if (s) // file already exists
    773774    {
    774       InGen.build (constituent, os);
     775      retval = InGen.build (constituent, os);
    775776      ostringstream osn;
    776777      osn << s.rdbuf ();
     
    784785  s.close ();
    785786  s.clear ();
     787  if (0 != retval) return retval;
    786788  if (gen)
    787789    {
     
    802804          else
    803805            {
    804               InGen.build (constituent, s);
     806              retval = InGen.build (constituent, s);
    805807            }
    806808          s.close (); // ios_base::failbit
     
    817819  //  s.close (); // ios_base::failbit
    818820
    819   return 0;
     821  return retval;
    820822}
    821823
     
    15301532int InGenerator::Buffer::print (ostream& s)
    15311533{
    1532   initialize ();
     1534  int retval (0);
     1535  retval = initialize ();
     1536  if (0 > retval) return retval;
    15331537  s << m_buffer.str ();
    15341538  return 0;
     
    15391543{
    15401544  m_usecmt = usecmt;
     1545}
     1546
     1547//------------------------------------------------------------------------
     1548void InGenerator::Buffer::set_pedantic (bool pedantic)
     1549{
     1550  m_pedantic = pedantic;
    15411551}
    15421552
     
    15511561      const cmt_string& name = m_names[i];
    15521562      Language& p (Language::find (name));
    1553       if (Language::null () == p) { errors += 1; continue; }
     1563      if (Language::null () == p)
     1564        {
     1565          CmtError::set (CmtError::language_not_found, name);
     1566          errors += 1;
     1567          continue;
     1568        }
    15541569      p.show (Requirements, m_buffer);
    15551570      /*
     
    15711586    {
    15721587      const cmt_string& name = m_names[i];
     1588      if (Cmt::get_debug ())
     1589        {
     1590          cout << "InGenerator::Fragments::initialize> " << name << endl;
     1591        }
    15731592      Fragment* fragment (Fragment::find (name));
    1574       if (0 == fragment) { errors += 1; continue; }
     1593      if (0 == fragment)
     1594        {
     1595          if (m_pedantic)
     1596            {
     1597              CmtError::set (CmtError::fragment_not_found, name + " (standard)");
     1598              errors += 1;
     1599            }
     1600          else
     1601            {
     1602              CmtMessage::warning
     1603                (CmtError::get_error_name (CmtError::fragment_not_found)
     1604                 + ": " + name + " (standard)");
     1605            }
     1606          continue;
     1607        }
    15751608      if (m_usecmt || !fragment->use->get_package ()->is_cmt ())
    1576         fragment->print (Requirements, m_buffer);
     1609        if (1 != fragment->print (Requirements, m_buffer))
     1610          {
     1611            if (m_pedantic)
     1612              {
     1613                CmtError::set (CmtError::fragment_not_found, name + " (standard)");
     1614                errors += 1;
     1615              }
     1616            else
     1617              {
     1618                CmtMessage::warning
     1619                  (CmtError::get_error_name (CmtError::fragment_not_found)
     1620                   + ": " + name + " (standard)");
     1621              }
     1622            continue;
     1623          }
    15771624    }
    15781625  //  cerr << "initialize: " << m_buffer.str ();
     
    15811628
    15821629//------------------------------------------------------------------------
    1583 InGenerator::InGenerator (bool usecmt)
    1584   : m_usecmt (usecmt)
    1585 {
     1630InGenerator::InGenerator (bool usecmt, bool pedantic)
     1631  : m_usecmt (usecmt), m_pedantic (pedantic)
     1632{
     1633  m_pedantic = (0 != CmtSystem::getenv ("CMTPEDANTIC").size () ||
     1634                0 != CmtSystem::getenv ("PEDANTIC").size ());
     1635
     1636  m_common.set_pedantic (m_pedantic);
     1637  m_application.set_pedantic (m_pedantic);
     1638  m_application_library.set_pedantic (m_pedantic);
     1639  m_library.set_pedantic (m_pedantic);
     1640  m_document.set_pedantic (m_pedantic);
     1641  m_languages.set_pedantic (m_pedantic);
     1642
    15861643  CmtSystem::cmt_string_vector common;
    15871644  common.push_back ("make_header");
     
    16271684      //language.setup_fragments ();
    16281685      application.push_back (language.fragment_name); //application.name ();
    1629       library.push_back (language.fragment_name + "_library"); //library.name ();
     1686      if (!(language == "java"))
     1687        library.push_back (language.fragment_name + "_library"); //library.name ();
    16301688      if (m_usecmt || !language.m_use->get_package ()->is_cmt ())
    16311689//       if (!language.m_use->get_package ()->is_cmt ())
     
    16561714int InGenerator::build (const Constituent& constituent, ostream& s)
    16571715{
     1716  int retval (0);
     1717
    16581718  constituent.show (s);
    1659   m_common.print (s);
     1719  retval += m_common.print (s);
    16601720
    16611721  switch (constituent.type)
    16621722    {
    16631723    case Application:
    1664       m_application.print (s);
    1665       m_application_library.print (s);
    1666       m_languages.print (s);
     1724      retval += m_application.print (s);
     1725      retval += m_application_library.print (s);
     1726      retval += m_languages.print (s);
    16671727      break;
    16681728    case Library:
    1669       m_application_library.print (s);
    1670       m_library.print (s);
    1671       m_languages.print (s);
     1729      retval += m_application_library.print (s);
     1730      retval += m_library.print (s);
     1731      retval += m_languages.print (s);
    16721732      break;
    16731733    case Document:
    16741734      Fragment* fragment (Fragment::find (constituent.generator));
    1675       if (0 == fragment) return -1;
     1735      if (Cmt::get_debug ())
     1736        {
     1737          cout << "InGenerator::build> " << constituent.generator
     1738               << " |name> " << constituent.name << endl;
     1739        }
     1740      if (0 == fragment)
     1741        {
     1742          CmtError::set (CmtError::fragment_not_found, constituent.generator
     1743                         + " (document " + constituent.name + ")");
     1744          return retval -= 1;
     1745        }
    16761746      if (m_usecmt || !fragment->use->get_package ()->is_cmt ())
    1677         fragment->print (Requirements, s);
    1678       if ("" != fragment->header)
    1679         {
     1747        if (1 != fragment->print (Requirements, s))
     1748          {
     1749            CmtError::set (CmtError::fragment_not_found, constituent.generator
     1750                           + " (document " + constituent.name + ")");
     1751            return retval -= 1;
     1752          }
     1753      if (0 != fragment->header.size ())
     1754        {
     1755          if (Cmt::get_debug ())
     1756            {
     1757              cout << "InGenerator::build> " << fragment->header
     1758                   << " |name> " << constituent.name << endl;
     1759            }
    16801760          Fragment* header (Fragment::find (fragment->header));
    1681           if (0 == header) return -1;
     1761          if (0 == header)
     1762            {
     1763              CmtError::set (CmtError::fragment_not_found, fragment->header
     1764                             + " (document " + constituent.name + ")");
     1765              return retval -= 1;
     1766            }
    16821767          //      if (header->use != fragment->use &&
    16831768          if (m_usecmt || !header->use->get_package ()->is_cmt ())
    1684             header->print (Requirements, s);
    1685         }
    1686       if ("" != fragment->trailer)
    1687         {
     1769            if (1 != header->print (Requirements, s))
     1770              {
     1771                CmtError::set (CmtError::fragment_not_found, fragment->header
     1772                               + " (document " + constituent.name + ")");
     1773                return retval -= 1;
     1774              }
     1775        }
     1776      if (0 != fragment->trailer.size ())
     1777        {
     1778          if (Cmt::get_debug ())
     1779            {
     1780              cout << "InGenerator::build> " << fragment->trailer
     1781                   << " |name> " << constituent.name << endl;
     1782            }
    16881783          Fragment* trailer (Fragment::find (fragment->trailer));
    1689           if (0 == trailer) return -1;
     1784          if (0 == trailer)
     1785            {
     1786              CmtError::set (CmtError::fragment_not_found, fragment->trailer
     1787                             + " (document " + constituent.name + ")");
     1788              return retval -= 1;
     1789            }
    16901790          //      if (trailer->use != fragment->use &&
    16911791          if (m_usecmt || !trailer->use->get_package ()->is_cmt ())
    1692             trailer->print (Requirements, s);
    1693         }
    1694       m_document.print (s);
     1792            if (1 != trailer->print (Requirements, s))
     1793              {
     1794                CmtError::set (CmtError::fragment_not_found, fragment->trailer
     1795                               + " (document " + constituent.name + ")");
     1796                return retval -= 1;
     1797              }
     1798        }
     1799      retval += m_document.print (s);
    16951800      break;
    16961801    }
    16971802
    1698   return 0;
     1803  if (m_pedantic)
     1804    return retval;
     1805  else
     1806    return 0;
    16991807}
    17001808//------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.