@@ -1297,7 +1297,6 @@ namespace Cpp {
1297
1297
// encompassed in an anonymous namespace as follows.
1298
1298
namespace {
1299
1299
static unsigned long long gWrapperSerial = 0LL ;
1300
- static const std::string kIndentString (" " );
1301
1300
1302
1301
enum EReferenceType { kNotReference , kLValueReference , kRValueReference };
1303
1302
@@ -1308,6 +1307,7 @@ namespace Cpp {
1308
1307
// FIXME: Use that routine throughout CallFunc's port in places such as
1309
1308
// make_narg_call.
1310
1309
static inline void indent (ostringstream &buf, int indent_level) {
1310
+ static const std::string kIndentString (" " );
1311
1311
for (int i = 0 ; i < indent_level; ++i)
1312
1312
buf << kIndentString ;
1313
1313
}
@@ -1355,9 +1355,9 @@ namespace Cpp {
1355
1355
QT.print (OS, Policy, type_name);
1356
1356
OS.flush ();
1357
1357
}
1358
- for ( int i = 0 ; i < indent_level; ++i) {
1359
- typedefbuf << kIndentString ;
1360
- }
1358
+
1359
+ indent ( typedefbuf, indent_level) ;
1360
+
1361
1361
typedefbuf << " typedef " << fp_typedef_name << " ;\n " ;
1362
1362
return ;
1363
1363
} else if (QT->isMemberPointerType ()) {
@@ -1370,9 +1370,9 @@ namespace Cpp {
1370
1370
QT.print (OS, Policy, type_name);
1371
1371
OS.flush ();
1372
1372
}
1373
- for ( int i = 0 ; i < indent_level; ++i) {
1374
- typedefbuf << kIndentString ;
1375
- }
1373
+
1374
+ indent ( typedefbuf, indent_level) ;
1375
+
1376
1376
typedefbuf << " typedef " << mp_typedef_name << " ;\n " ;
1377
1377
return ;
1378
1378
} else if (QT->isPointerType ()) {
@@ -1397,9 +1397,7 @@ namespace Cpp {
1397
1397
QT.print (OS, Policy, type_name);
1398
1398
OS.flush ();
1399
1399
}
1400
- for (int i = 0 ; i < indent_level; ++i) {
1401
- typedefbuf << kIndentString ;
1402
- }
1400
+ indent (typedefbuf, indent_level);
1403
1401
typedefbuf << " typedef " << ar_typedef_name << " ;\n " ;
1404
1402
return ;
1405
1403
}
@@ -1431,9 +1429,7 @@ namespace Cpp {
1431
1429
callbuf << ' ' ;
1432
1430
} else {
1433
1431
callbuf << " \n " ;
1434
- for (int j = 0 ; j <= indent_level; ++j) {
1435
- callbuf << kIndentString ;
1436
- }
1432
+ indent (callbuf, indent_level);
1437
1433
}
1438
1434
}
1439
1435
if (refType != kNotReference ) {
@@ -1493,9 +1489,7 @@ namespace Cpp {
1493
1489
callbuf << ' ' ;
1494
1490
} else {
1495
1491
callbuf << " \n " ;
1496
- for (int j = 0 ; j <= indent_level; ++j) {
1497
- callbuf << kIndentString ;
1498
- }
1492
+ indent (callbuf, indent_level);
1499
1493
}
1500
1494
}
1501
1495
const ParmVarDecl* PVD = FD->getParamDecl (i);
@@ -1557,9 +1551,7 @@ namespace Cpp {
1557
1551
callbuf << ' ' ;
1558
1552
} else {
1559
1553
callbuf << " \n " ;
1560
- for (int j = 0 ; j <= indent_level; ++j) {
1561
- callbuf << kIndentString ;
1562
- }
1554
+ indent (callbuf, indent_level);
1563
1555
}
1564
1556
}
1565
1557
@@ -1590,9 +1582,7 @@ namespace Cpp {
1590
1582
// new ClassName(args...);
1591
1583
// }
1592
1584
//
1593
- for (int i = 0 ; i < indent_level; ++i) {
1594
- buf << kIndentString ;
1595
- }
1585
+ indent (buf, indent_level);
1596
1586
buf << " if (ret) {\n " ;
1597
1587
++indent_level;
1598
1588
{
@@ -1601,9 +1591,7 @@ namespace Cpp {
1601
1591
//
1602
1592
// Write the return value assignment part.
1603
1593
//
1604
- for (int i = 0 ; i < indent_level; ++i) {
1605
- callbuf << kIndentString ;
1606
- }
1594
+ indent (callbuf, indent_level);
1607
1595
callbuf << " (*(" << class_name << " **)ret) = " ;
1608
1596
//
1609
1597
// Write the actual new expression.
@@ -1613,43 +1601,31 @@ namespace Cpp {
1613
1601
// End the new expression statement.
1614
1602
//
1615
1603
callbuf << " ;\n " ;
1616
- for (int i = 0 ; i < indent_level; ++i) {
1617
- callbuf << kIndentString ;
1618
- }
1604
+ indent (callbuf, indent_level);
1619
1605
callbuf << " return;\n " ;
1620
1606
//
1621
1607
// Output the whole new expression and return statement.
1622
1608
//
1623
1609
buf << typedefbuf.str () << callbuf.str ();
1624
1610
}
1625
1611
--indent_level;
1626
- for (int i = 0 ; i < indent_level; ++i) {
1627
- buf << kIndentString ;
1628
- }
1612
+ indent (buf, indent_level);
1629
1613
buf << " }\n " ;
1630
- for (int i = 0 ; i < indent_level; ++i) {
1631
- buf << kIndentString ;
1632
- }
1614
+ indent (buf, indent_level);
1633
1615
buf << " else {\n " ;
1634
1616
++indent_level;
1635
1617
{
1636
1618
std::ostringstream typedefbuf;
1637
1619
std::ostringstream callbuf;
1638
- for (int i = 0 ; i < indent_level; ++i) {
1639
- callbuf << kIndentString ;
1640
- }
1620
+ indent (callbuf, indent_level);
1641
1621
make_narg_ctor (FD, N, typedefbuf, callbuf, class_name, indent_level);
1642
1622
callbuf << " ;\n " ;
1643
- for (int i = 0 ; i < indent_level; ++i) {
1644
- callbuf << kIndentString ;
1645
- }
1623
+ indent (callbuf, indent_level);
1646
1624
callbuf << " return;\n " ;
1647
1625
buf << typedefbuf.str () << callbuf.str ();
1648
1626
}
1649
1627
--indent_level;
1650
- for (int i = 0 ; i < indent_level; ++i) {
1651
- buf << kIndentString ;
1652
- }
1628
+ indent (buf, indent_level);
1653
1629
buf << " }\n " ;
1654
1630
}
1655
1631
@@ -1686,21 +1662,15 @@ namespace Cpp {
1686
1662
if (QT->isVoidType ()) {
1687
1663
std::ostringstream typedefbuf;
1688
1664
std::ostringstream callbuf;
1689
- for (int i = 0 ; i < indent_level; ++i) {
1690
- callbuf << kIndentString ;
1691
- }
1665
+ indent (callbuf, indent_level);
1692
1666
make_narg_call (FD, " void" , N, typedefbuf, callbuf, class_name,
1693
1667
indent_level);
1694
1668
callbuf << " ;\n " ;
1695
- for (int i = 0 ; i < indent_level; ++i) {
1696
- callbuf << kIndentString ;
1697
- }
1669
+ indent (callbuf, indent_level);
1698
1670
callbuf << " return;\n " ;
1699
1671
buf << typedefbuf.str () << callbuf.str ();
1700
1672
} else {
1701
- for (int i = 0 ; i < indent_level; ++i) {
1702
- buf << kIndentString ;
1703
- }
1673
+ indent (buf, indent_level);
1704
1674
1705
1675
std::string type_name;
1706
1676
EReferenceType refType = kNotReference ;
@@ -1714,9 +1684,7 @@ namespace Cpp {
1714
1684
//
1715
1685
// Write the placement part of the placement new.
1716
1686
//
1717
- for (int i = 0 ; i < indent_level; ++i) {
1718
- callbuf << kIndentString ;
1719
- }
1687
+ indent (callbuf, indent_level);
1720
1688
callbuf << " new (ret) " ;
1721
1689
collect_type_info (FD, QT, typedefbuf, callbuf, type_name, refType,
1722
1690
isPointer, indent_level, false );
@@ -1742,45 +1710,33 @@ namespace Cpp {
1742
1710
// End the placement new.
1743
1711
//
1744
1712
callbuf << " );\n " ;
1745
- for (int i = 0 ; i < indent_level; ++i) {
1746
- callbuf << kIndentString ;
1747
- }
1713
+ indent (callbuf, indent_level);
1748
1714
callbuf << " return;\n " ;
1749
1715
//
1750
1716
// Output the whole placement new expression and return statement.
1751
1717
//
1752
1718
buf << typedefbuf.str () << callbuf.str ();
1753
1719
}
1754
1720
--indent_level;
1755
- for (int i = 0 ; i < indent_level; ++i) {
1756
- buf << kIndentString ;
1757
- }
1721
+ indent (buf, indent_level);
1758
1722
buf << " }\n " ;
1759
- for (int i = 0 ; i < indent_level; ++i) {
1760
- buf << kIndentString ;
1761
- }
1723
+ indent (buf, indent_level);
1762
1724
buf << " else {\n " ;
1763
1725
++indent_level;
1764
1726
{
1765
1727
std::ostringstream typedefbuf;
1766
1728
std::ostringstream callbuf;
1767
- for (int i = 0 ; i < indent_level; ++i) {
1768
- callbuf << kIndentString ;
1769
- }
1729
+ indent (callbuf, indent_level);
1770
1730
callbuf << " (void)(" ;
1771
1731
make_narg_call (FD, type_name, N, typedefbuf, callbuf, class_name,
1772
1732
indent_level);
1773
1733
callbuf << " );\n " ;
1774
- for (int i = 0 ; i < indent_level; ++i) {
1775
- callbuf << kIndentString ;
1776
- }
1734
+ indent (callbuf, indent_level);
1777
1735
callbuf << " return;\n " ;
1778
1736
buf << typedefbuf.str () << callbuf.str ();
1779
1737
}
1780
1738
--indent_level;
1781
- for (int i = 0 ; i < indent_level; ++i) {
1782
- buf << kIndentString ;
1783
- }
1739
+ indent (buf, indent_level);
1784
1740
buf << " }\n " ;
1785
1741
}
1786
1742
}
@@ -2199,16 +2155,12 @@ namespace Cpp {
2199
2155
// We need one function call clause compiled for every
2200
2156
// possible number of arguments per call.
2201
2157
for (unsigned N = min_args; N <= num_params; ++N) {
2202
- for (int i = 0 ; i < indent_level; ++i) {
2203
- buf << kIndentString ;
2204
- }
2158
+ indent (buf, indent_level);
2205
2159
buf << " if (nargs == " << N << " ) {\n " ;
2206
2160
++indent_level;
2207
2161
make_narg_call_with_return (I, FD, N, class_name, buf, indent_level);
2208
2162
--indent_level;
2209
- for (int i = 0 ; i < indent_level; ++i) {
2210
- buf << kIndentString ;
2211
- }
2163
+ indent (buf, indent_level);
2212
2164
buf << " }\n " ;
2213
2165
}
2214
2166
}
0 commit comments