Changeset 595 for CMT/HEAD/source/cmt_generator.cxx
- Timestamp:
- Dec 9, 2011, 1:45:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/source/cmt_generator.cxx
r591 r595 763 763 } 764 764 765 static InGenerator InGen (usecmt); 765 int retval (0); 766 static InGenerator InGen (usecmt, false); 766 767 767 768 bool gen (true); … … 772 773 if (s) // file already exists 773 774 { 774 InGen.build (constituent, os);775 retval = InGen.build (constituent, os); 775 776 ostringstream osn; 776 777 osn << s.rdbuf (); … … 784 785 s.close (); 785 786 s.clear (); 787 if (0 != retval) return retval; 786 788 if (gen) 787 789 { … … 802 804 else 803 805 { 804 InGen.build (constituent, s);806 retval = InGen.build (constituent, s); 805 807 } 806 808 s.close (); // ios_base::failbit … … 817 819 // s.close (); // ios_base::failbit 818 820 819 return 0;821 return retval; 820 822 } 821 823 … … 1530 1532 int InGenerator::Buffer::print (ostream& s) 1531 1533 { 1532 initialize (); 1534 int retval (0); 1535 retval = initialize (); 1536 if (0 > retval) return retval; 1533 1537 s << m_buffer.str (); 1534 1538 return 0; … … 1539 1543 { 1540 1544 m_usecmt = usecmt; 1545 } 1546 1547 //------------------------------------------------------------------------ 1548 void InGenerator::Buffer::set_pedantic (bool pedantic) 1549 { 1550 m_pedantic = pedantic; 1541 1551 } 1542 1552 … … 1551 1561 const cmt_string& name = m_names[i]; 1552 1562 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 } 1554 1569 p.show (Requirements, m_buffer); 1555 1570 /* … … 1571 1586 { 1572 1587 const cmt_string& name = m_names[i]; 1588 if (Cmt::get_debug ()) 1589 { 1590 cout << "InGenerator::Fragments::initialize> " << name << endl; 1591 } 1573 1592 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 } 1575 1608 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 } 1577 1624 } 1578 1625 // cerr << "initialize: " << m_buffer.str (); … … 1581 1628 1582 1629 //------------------------------------------------------------------------ 1583 InGenerator::InGenerator (bool usecmt) 1584 : m_usecmt (usecmt) 1585 { 1630 InGenerator::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 1586 1643 CmtSystem::cmt_string_vector common; 1587 1644 common.push_back ("make_header"); … … 1627 1684 //language.setup_fragments (); 1628 1685 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 (); 1630 1688 if (m_usecmt || !language.m_use->get_package ()->is_cmt ()) 1631 1689 // if (!language.m_use->get_package ()->is_cmt ()) … … 1656 1714 int InGenerator::build (const Constituent& constituent, ostream& s) 1657 1715 { 1716 int retval (0); 1717 1658 1718 constituent.show (s); 1659 m_common.print (s);1719 retval += m_common.print (s); 1660 1720 1661 1721 switch (constituent.type) 1662 1722 { 1663 1723 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); 1667 1727 break; 1668 1728 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); 1672 1732 break; 1673 1733 case Document: 1674 1734 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 } 1676 1746 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 } 1680 1760 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 } 1682 1767 // if (header->use != fragment->use && 1683 1768 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 } 1688 1783 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 } 1690 1790 // if (trailer->use != fragment->use && 1691 1791 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); 1695 1800 break; 1696 1801 } 1697 1802 1698 return 0; 1803 if (m_pedantic) 1804 return retval; 1805 else 1806 return 0; 1699 1807 } 1700 1808 //------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.