[pygccxml-commit] SF.net SVN: pygccxml: [221] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-06-17 18:12:06
|
Revision: 221 Author: roman_yakovenko Date: 2006-06-17 11:11:32 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=221&view=rev Log Message: ----------- adding indexing suite - first release Modified Paths: -------------- pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml pyplusplus_dev/pyplusplus/code_creators/__init__.py pyplusplus_dev/pyplusplus/code_creators/class_declaration.py pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py pyplusplus_dev/pyplusplus/module_builder/__init__.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/pyplusplus/module_creator/types_database.py pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp pyplusplus_dev/unittests/indexing_suites_tester.py Modified: pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/examples/pyboost_dev/dev/date_time/generate_code.py 2006-06-17 18:11:32 UTC (rev 221) @@ -138,13 +138,22 @@ for operator in [ '>', '>=', '<=', '<', '-' ]: ptime.add_code( 'def( bp::self %s bp::self )' % operator ) - def beautify_code( self, mb ): + def beautify_code( self, mb ): + + def is_vector_of_strings( decl ): + if not declarations.vector_traits.is_vector( decl ): + return False + return declarations.is_std_string( declarations.vector_traits.value_type(decl) ) + + str_vec = mb.class_( is_vector_of_strings ) + str_vec.alias = "strings" + extmodule = mb.code_creator extmodule.add_namespace_usage( 'boost' ) extmodule.add_namespace_usage( 'boost::date_time' ) for full_ns_name, alias in customization_data.ns_aliases.items(): extmodule.add_namespace_alias( alias, full_ns_name ) - + def customize_extmodule( self, mb ): extmodule = mb.code_creator #beautifying include code generation Modified: pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml =================================================================== --- pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/examples/pyboost_dev/dev/date_time/include/date_time.pypp.xml 2006-06-17 18:11:32 UTC (rev 221) @@ -2,8 +2,8 @@ <GCC_XML cvs_revision="1.112"> <Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 _16 _17 _18 _19 _20 _21 _22 _23 _24 _25 _26 _27 _28 _29 _30 _31 _32 _33 _34 _35 _36 _37 _38 _39 _40 _41 _42 _43 _44 _45 _46 _47 _48 _49 _50 _51 _52 _53 _54 _55 _56 _57 _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 _68 _69 _70 _71 _72 _73 _74 _75 _76 _77 _78 _79 _80 _81 _82 _83 _84 _85 _86 _87 _88 _89 _90 _91 _92 _93 _94 _95 _96 _97 _98 _99 _100 _101 _102 _103 _104 _105 _106 _107 _108 _109 _110 _111 _112 _113 _114 _115 _116 _117 _118 _119 _120 _121 _122 _123 _124 _125 _126 _127 _128 _129 _130 _131 _132 _133 _134 _135 _136 _137 _138 _139 _140 _141 _142 _143 _144 _145 _146 _147 _148 _149 _150 _151 _152 _153 _154 _155 _156 _157 _158 _159 _160 _161 _162 _163 _164 _165 _166 _167 _168 _169 _170 _171 _172 _173 _174 _175 _176 _177 _178 _179 _180 _181 _182 _183 _184 _185 _186 _187 _188 _189 _190 _191 _192 _193 _194 _195 _196 _197 _198 _199 _200 _201 _202 _203 _204 _205 _206 _207 _208 _209 _210 _211 _212 _213 _214 _215 _216 _217 _218 _219 _220 _221 _222 _223 _224 _225 _226 _227 _228 _229 _230 _231 _232 _233 _234 _235 _236 _237 _238 _239 _240 _241 _242 _243 _244 _245 _246 _247 _248 _249 _250 _251 _252 _253 _254 _255 _256 _257 _258 _259 _260 _261 _262 _263 _264 _265 _266 _267 _268 _269 _270 _271 _272 _273 _274 _275 _276 _277 _278 _279 _280 _281 _282 _283 _284 _285 _286 _287 _288 _289 _290 _291 _292 _293 _294 _295 _296 _297 _298 _299 _300 _301 _302 _303 _304 _305 _306 _307 _308 _309 _310 _311 _312 _313 _314 _315 _316 _317 _318 _319 _320 _321 _322 _323 _324 _325 _326 _327 _328 _329 _330 _331 _332 _333 _334 _335 _336 _337 _338 _339 _340 _341 _342 _343 _344 _345 _346 _347 _348 _349 _350 _351 _352 _353 _354 _355 _356 _357 _358 _359 _360 _361 _362 _363 _364 _365 _366 _367 _368 _369 _370 _371 _372 _373 _374 _375 _376 _377 _378 _379 _380 _381 _382 _383 _384 _385 _386 _387 _388 _389 _390 _391 _392 _393 _394 _395 _396 _397 _398 _399 _400 _401 _402 _403 _404 _405 _406 _407 _408 _409 _410 _411 _412 _413 _414 _415 _416 _417 _418 _419 _420 _421 _422 _423 _424 _425 _426 _427 _428 _429 _430 _431 _432 _433 _434 _435 _436 _437 _438 _439 _440 _441 _442 _443 _444 _445 _446 _447 _448 _449 _450 _451 _452 _453 _454 _455 _456 _457 _458 _459 _460 _461 _462 _463 _464 _465 _466 _467 _468 _469 _470 _471 _472 _473 _474 _475 _476 _477 _478 _479 _480 _482 _483 _484 _485 _486 _487 _488 _489 _490 _491 _492 _493 _494 _495 _496 _497 _498 _499 _501 _502 _503 _504 _505 _506 _508 _509 _510 _511 _512 _513 _514 _515 _516 _517 _518 _519 _520 _521 _522 _523 _524 _525 _526 _527 _528 _529 _530 _531 _532 _533 _534 _535 _536 _537 _538 _539 _540 _541 _542 _543 _544 _545 _546 _547 _548 _549 _550 _551 _552 _553 _554 _555 _556 _557 _558 _559 _560 _561 _562 _563 _564 _565 _566 _567 _568 _569 _570 _571 _572 _573 _574 _575 _576 _577 _578 _579 _580 _581 _582 _583 _584 _585 _586 _587 _588 _589 _590 _591 _592 _593 _594 _595 _596 _597 _598 _599 _600 _601 _602 _603 _604 _605 _606 _607 _608 _609 _610 _611 _612 _613 _614 _615 _616 _617 _618 _619 _621 _622 _623 _624 _625 _626 _627 _628 _629 _630 _631 _632 _633 _634 _635 _636 _638 _639 _640 _641 _642 _643 _644 _645 _646 _647 _648 _649 _650 _651 _652 _653 _654 _655 _656 _657 _658 _659 _660 _661 _662 _663 _664 _665 _666 _667 _668 _669 _670 _671 _672 _673 _674 _675 _676 _677 _678 _679 _680 _681 _682 _683 _684 _685 _686 _687 _688 _689 _690 _691 _692 _693 _694 _695 _696 _697 _698 _699 _700 _701 _702 _703 _704 _705 _706 _707 _708 _709 _710 _711 _712 _713 _714 _715 _716 _717 _718 _719 _720 _721 _722 _723 _724 _725 _726 _727 _728 _729 _730 _731 _732 _733 _734 _735 _736 _737 _738 _739 _740 _741 _742 _743 _744 _745 _746 _747 _748 _749 _750 _751 _752 _753 _754 _755 _756 _757 _758 _759 _760 _761 _762 _763 _764 _766 _767 _768 _769 _770 _771 _772 _773 _774 _775 _776 _777 _778 _779 _780 _781 _782 _783 _784 _785 _786 _787 _788 _789 _790 _791 _792 _793 _794 _795 _796 _797 _798 _799 _800 _801 _802 _803 _804 _805 _806 _807 _808 _809 _810 _811 _812 _813 _814 _815 _816 _817 _819 _820 _821 _823 _824 _825 _826 _827 _828 _829 _830 _831 _832 _833 _834 _835 _836 _837 _838 _839 _840 _841 _842 _843 _844 _845 _846 _847 _848 _849 _850 _851 _852 _853 _854 _855 _856 _857 _858 _859 _860 _861 _862 _863 _864 _865 _866 _867 _868 _869 _870 _871 _872 _873 _874 _875 _876 _877 _878 _879 _880 _881 _882 _883 _884 _885 _886 _887 _888 _889 _890 _891 _892 _893 _894 _895 _896 _897 _898 _899 _900 _901 _902 _903 _904 _905 _906 _907 _908 _909 _910 _911 _912 _913 _914 _915 _916 _917 _918 _919 _920 _921 _922 _923 _924 _925 _926 _927 _928 _929 _930 _931 _932 _933 _934 _935 _936 _937 _938 _939 _940 _941 _942 _943 _944 _945 _946 _947 _948 _949 _950 _951 _952 _953 _954 _955 _956 _957 _958 _959 _960 _961 _962 _963 _964 _965 _966 _967 _968 _969 _970 _971 _972 _973 _974 _975 _976 _977 _978 _979 _980 _981 _982 _983 _984 _985 _986 _987 _988 _989 _990 _991 _992 _993 _994 _995 _996 _997 _998 _999 _1000 _1001 _1002 _1003 _1005 _1006 _1007 _1008 _1009 _1010 _1011 _1012 _1013 _1014 _1015 _1016 _1017 _1018 _1019 _1020 _1021 _1022 _1023 _1024 _1025 _1026 _1027 _1028 _1029 _1030 _1031 _1032 _1033 _1034 _1035 _1036 _1037 _1038 _1039 _1040 _1041 _1042 _1043 _1044 _1045 _1046 _1047 _1048 _1049 _1050 _1051 _1052 _1053 _1054 _1055 _1056 _1057 _1058 _1059 _1060 _1061 _1062 _1063 _1064 _1065 _1066 _1067 _1068 _1069 _1070 _1071 _1072 _1073 _1074 _1075 _1076 _1077 _1078 _1079 _1080 _1081 _1082 _1083 _1084 _1085 _1086 _1087 _1088 _1089 _1090 _1091 _1092 _1093 _1094 _1095 _1096 _1097 _1098 _1099 _1100 _1101 _1102 _1103 _1104 _1106 _1108 _1110 _1111 _1112 _1113 _1114 _1115 _1116 _1117 _1118 _1119 _1120 _1121 _1122 _1123 _1124 _1125 _1126 _1127 _1128 _1129 _1130 _1131 _1132 _1133 _1135 _1134 _1137 _1139 _1141 _1143 _1144 _1145 _1146 _1147 _1148 _1149 _1150 _1151 _1152 _1153 _1155 _1156 _1157 _1158 _1160 _1161 _1163 _1164 _1166 _1167 _1169 _1171 _1173 _1175 _1177 _1179 _1181 _1183 _1185 _1186 _1187 _1188 _1189 _1190 _1191 _1105 _1107 _765 _1192 _1194 _1195 _1193 _1196 _1197 _1198 _1199 _1200 _1201 _1202 _1203 _1204 _1205 _1206 _1207 _1208 _1209 _1210 _1211 _1212 _1213 _1214 _1215 _1216 _1217 _1218 _1219 _1220 _1221 _1222 _1223 _1224 _1225 _1226 _1227 _1228 _1229 _1230 _1231 _1232 _1233 _1234 _1235 _1236 _1237 _1238 _1239 _1241 _1242 _1243 _1244 _1245 _1247 _1249 _1250 _1251 _1252 _1253 _1255 _1256 _1257 _1258 _1260 _1261 _1262 _1263 _1264 _1265 _1266 _1267 _1268 _1269 _1270 _1271 _1272 _1273 _1274 _1275 _1276 _1277 _1278 _1279 _1280 _1281 _1282 _1283 _1284 _1285 _1286 _1287 _1288 _1289 _1290 _1291 _1292 _1293 _1294 _1295 _1296 _1297 _1298 _1299 _1300 _1301 _1302 _1303 _1304 _1305 _1306 _1307 _1308 _1309 _1310 _1311 _1312 _1313 _1314 _1315 _1316 _1317 _1318 _1319 _1320 _1321 _1322 _1323 _1324 _1325 _1326 _1327 _1328 _1329 _1330 _1331 _1332 _1333 _1334 _1335 _1336 _1337 _1338 _1339 _1340 _1341 _1342 _1343 _1344 _1345 _1346 _1347 _1348 _1349 _1350 _1351 _1352 _1353 _1354 _1355 _1356 _1357 _1358 _1359 _1360 _1361 _1362 _1363 _1364 _1365 _1366 _1367 _1368 _1369 _1370 _1371 _1372 _1373 _1374 _1375 _1376 _1377 _1378 _1379 _1380 _1381 _1382 _1383 _1384 _1385 _1386 _1387 _1388 _1389 _1390 _1391 _1392 _1393 _1394 _1395 _1396 _1397 _1398 _1399 _1400 _1401 _1402 _1403 _1404 _1405 _1406 _1407 _1408 _1409 _1410 _1411 _1412 _1413 _1414 _1415 _1416 _1417 _1418 _1419 _1420 _1421 _1422 _1423 _1424 _1425 _1426 _1427 _1428 _1430 _1431 _1432 _1433 _1434 _1435 _1436 _1437 _1438 _1439 _1440 _1441 _1442 _1443 _1444 _1445 _1446 _1447 _1448 _1449 _1450 _1451 _1452 _1453 _1454 _1455 _1456 _1457 _1458 _1459 _1460 _1461 _1462 _1463 _1464 _1465 _1466 _1467 _1468 _1469 _1470 _1471 _1472 _1473 _1474 _1475 _1476 _1477 _1478 _1479 _1480 _1481 _1482 _1483 _1484 _1485 _1486 _1487 _1488 _1489 _1491 _1490 _1492 _1493 _818 _1494 _1495 _1496 _1497 _1499 _1498 _1501 _1502 _1503 _1504 _1505 _1506 _1507 _1508 _1509 _1510 _1512 _1513 _1514 _1515 _1516 _1517 _1518 _1519 _1520 _1521 _1522 _1523 _1525 _1524 _1526 _1527 _1528 _1529 _1530 _1531 _1532 _1533 _1534 _1535 _1536 _1537 _1538 _1539 _1540 _1541 _1542 _1543 _1544 _1545 _1546 _1547 _1548 _1549 _1550 _1551 _1552 _1553 _1554 _1555 _1556 _1557 _1558 _1559 _1560 _1562 _1563 _1564 _1565 _1566 _1567 _1568 _1569 _1570 _1571 _1573 _1574 _1575 _1576 _1577 _1578 _1579 _1580 _1581 _1582 _1583 _1584 _1585 _1586 _1587 _1588 _1589 _1590 _1591 _1592 _1593 _1594 _1561 _1595 _1596 _1597 _1598 _1599 _1600 _1601 _1602 _1603 _1604 _1605 _1606 _1607 _1608 _1609 _1610 _1611 _1612 _1613 _1614 _1615 _1616 _1617 _1618 _1619 _1620 _1621 _1622 _1623 _1624 _1625 _1626 _1627 _1628 _1629 _1630 _1631 _1632 _1633 _1634 _1635 _1636 _1637 _1638 _1639 _1640 _1641 _1642 _1643 _1644 _1645 _1646 _1647 _1648 _1649 _1650 _1651 _1652 _1653 _1654 _1655 _1656 _1657 _1658 _1659 _1660 _1661 _1662 _1663 _1664 _1665 _1666 _1667 _1668 _1669 _1670 _1671 _1672 _1673 _1674 _1675 _1676 _1677 _1678 _1679 _1680 _1681 _1682 _1683 _1684 _1685 _1686 _1687 _1688 _1689 _1690 _1691 _1692 _1693 _1694 _1695 _1696 _1697 _1698 _1699 _1700 _1701 _1702 _1703 _1704 _1705 _1706 _1707 _1708 _1709 _1710 _1711 _1712 _1713 _1714 _1715 _1716 _1717 _1718 _1719 _1720 _1721 _1722 _1723 _1724 _1725 _1726 _1727 _1728 _1729 _1730 _1731 _1732 _1733 _1734 _1735 _1736 _1737 _1738 _1739 _1740 _1741 _1742 _1743 _1744 _1745 _1746 _1747 _1748 _1749 _1750 _1751 _1752 _1753 _1754 _1755 _1756 _1757 _1758 _1759 _1760 _1761 _1762 _1763 _1764 _1765 _1766 _1767 _1768 _1769 _1770 _1771 _1772 _1773 _1774 _1775 _1776 _1777 _1778 _1779 _1780 _1781 _1782 _1783 _1784 _1785 _1786 _1787 _1788 _1789 _1790 _1791 _1792 _1793 _1794 _1795 _1796 _1797 _1798 _1799 _1800 _1801 _1802 _1803 _1804 _1805 _1806 _1807 _1808 _1809 _1810 _1811 _1812 _1813 _1814 _1815 _1816 _1817 _1818 _1819 _1820 _1821 _1822 _1823 _1824 _1825 _1826 _1827 _1828 _1829 _1830 _1831 _1832 _1833 _1834 _1835 _1836 _1837 _1838 _1839 _1840 _1841 _1842 _1843 _1844 _1845 _1846 _1847 _1848 _1849 _1850 " mangled="_Z2::" demangled="::"/> <Namespace id="_2" name="std" context="_1" members="_1852 _1853 _1854 _1855 _1856 _1857 _1858 _1859 _1860 _1861 _1862 _1863 _1864 _1865 _1866 _1867 _1868 _1869 _1870 _1871 _1872 _1873 _1874 _1875 _1876 _1877 _1878 _1879 _1880 _1881 _1882 _1883 _1884 _1885 _1886 _1887 _1888 _1889 _1890 _1891 _1892 _1893 _1894 _1895 _1896 _1897 _1898 _1899 _1900 _1901 _1906 _1907 _1912 _1913 _1926 _1927 _1932 _1933 _1938 _1939 _1940 _1941 _1942 _1943 _1944 _1945 _1946 _1947 _1948 _1962 _1963 _1964 _1965 _1966 _1967 _1968 _1969 _1970 _1971 _1974 _1979 _1980 _1981 _1982 _1987 _1988 _1989 _1990 _1993 _1994 _1995 _1996 _1997 _1998 _1999 _2000 _2001 _2002 _2003 _2012 _2013 _2014 _2045 _2054 _2055 _2056 _2057 _2058 _2059 _2060 _2061 _2062 _2063 _2064 _2065 _2066 _2067 _2068 _2069 _2070 _2071 _2072 _2073 _2074 _2075 _2076 _2077 _2078 _2079 _2080 _2081 _2082 _2083 _2084 _2085 _2086 _2087 _2088 _2089 _2090 _2091 _2092 _2093 _2094 _2095 _2096 _2097 _2098 _2099 _2100 _2106 _2107 _2148 _2149 _2150 _2168 _2169 _2209 _2211 _2212 _2213 _2274 _2287 _2296 _2313 _2314 _2319 _2321 _2322 _2323 _2330 _2331 _2332 _2455 _2456 _2457 _2458 _2459 _2460 _2461 _2462 _2463 _2465 _2467 _2469 _2471 _2473 _2475 _2477 _2479 _2481 _2483 _2485 _2487 _2489 _2491 _2493 _2495 _2497 _2499 _2501 _2503 _2505 _2507 _2509 _2511 _2513 _2515 _2516 _2521 _2522 _2523 _2524 _2525 _2526 _2527 _2528 _2529 _2530 _2531 _2532 _2533 _2534 _2536 _2537 _2538 _2539 _2540 _2541 _2542 _2543 _2544 _2546 _2548 _2567 _2568 _2569 _2570 _2571 _2572 _2573 _2574 _2575 _2638 _2639 _2640 _2641 _2642 _2643 _2644 _2653 _2654 _2655 " mangled="_Z3std" demangled="std"/> - <Function id="_3" name="_GLOBAL__D__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppB25SPb" returns="_1154" context="_1" location="f0:131" file="f0" line="131" endline="131"/> - <Function id="_4" name="_GLOBAL__I__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hppB25SPb" returns="_1154" context="_1" location="f0:131" file="f0" line="131" endline="131"/> + <Function id="_3" name="_GLOBAL__D__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hpp5J35cd" returns="_1154" context="_1" location="f0:131" file="f0" line="131" endline="131"/> + <Function id="_4" name="_GLOBAL__I__home_roman_pygccxml_sources_sources_pyplusplus_dev_examples_pyboost_dev_dev_date_time_include_date_time.pypp.hpp5J35cd" returns="_1154" context="_1" location="f0:131" file="f0" line="131" endline="131"/> <Variable id="_5" name="_ZGVN5boost9date_time10date_facetINS_9gregorian4dateEcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE" type="_1248" context="_1" location="f1:372" file="f1" line="372" artificial="1"/> <Function id="_6" name="__static_initialization_and_destruction_0" returns="_1154" context="_1" mangled="_Z41__static_initialization_and_destruction_0ii" demangled="__static_initialization_and_destruction_0(int, int)" location="f0:131" file="f0" line="131" endline="76"> <Argument name="__initialize_p" type="_500" location="f0:131" file="f0" line="131"/> Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-06-17 18:11:32 UTC (rev 221) @@ -88,6 +88,7 @@ from class_declaration import class_t from class_declaration import class_wrapper_t +from class_declaration import class_declaration_t from instruction import instruction_t Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-06-17 18:11:32 UTC (rev 221) @@ -12,10 +12,71 @@ import smart_pointers import declaration_based import array_1_registrator -import indexing_suites import member_variable from pygccxml import declarations +class class_declaration_t( scoped.scoped_t ): + def __init__(self, class_inst, parent=None ): + scoped.scoped_t.__init__( self + , parent=parent + , declaration=class_inst ) + + def _generate_class_definition(self): + class_identifier = algorithm.create_identifier( self, '::boost::python::class_' ) + return declarations.templates.join( class_identifier, [self.decl_identifier] ) + + def _generate_code_no_scope(self): + result = [] + result.append( self._generate_class_definition() ) + for x in self.creators: + code = x.create() + tmpl = '%s.%s' + if self.is_comment( code ): + tmpl = '%s%s' + result.append( self.indent( tmpl % ( os.linesep, code ) ) ) + result.append( ';' ) + return ''.join( result ) + + def _get_class_var_name(self): + return self.alias + '_exposer' + class_var_name = property( _get_class_var_name ) + + def _generate_code_with_scope(self): + result = [] + scope_var_name = self.alias + '_scope' + typedef_name = self.class_var_name + '_t' + result.append( 'typedef ' + self._generate_class_definition() + ' ' + typedef_name + ';') + result.append( typedef_name + ' ' + self.class_var_name ) + result[-1] = result[-1] + ' = '+ typedef_name + '();' + + result.append( algorithm.create_identifier( self, '::boost::python::scope' ) ) + result[-1] = result[-1] + ' ' + scope_var_name + result[-1] = result[-1] + '( %s );' % self.class_var_name + + for x in self.creators: + if not ( x is used_init ): + if self._should_creator_be_exported_under_scope( x ): + result.append( x.create() ) + elif isinstance( x, custom.custom_t ) and x.works_on_instance == False: + result.append( '%s;' % x.create() ) + else: + result.append( '%s.%s;' % ( self.class_var_name, x.create() ) ) + + code = os.linesep.join( result ) + + result = [ 'if( true ){' ] + result.append( self.indent( code ) ) + result.append( '}' ) + + return os.linesep.join( result ) + + def _create_impl(self): + if self.declaration.always_expose_using_scope: + return self._generate_code_with_scope() + else: + return self._generate_code_no_scope() + + class class_t( scoped.scoped_t ): """ Creates boost.python code that needed to export a class @@ -146,6 +207,8 @@ used_init = inits[0] result.append( ", " ) result.append( used_init.create_init_code() ) + elif self.declaration.indexing_suite: + pass #in this case all constructors are exposed by indexing suite else:#it is possible to class to have public accessed constructor #that could not be exported by boost.python library #for example constructor takes as argument pointer to function @@ -187,9 +250,6 @@ if isinstance( inst, array_1_registrator.array_1_registrator_t ): return True - if isinstance( inst, indexing_suites.indexing_suite_t ): - return True - if isinstance( inst, member_variable.mem_var_ref_t ): return True Modified: pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2006-06-17 18:11:32 UTC (rev 221) @@ -5,26 +5,22 @@ import os import types -import scoped -import custom -import calldef import algorithm -import smart_pointers -import declaration_based -import array_1_registrator +import code_creator from pygccxml import declarations -class indexing_suite_t( scoped.scoped_t ): - def __init__(self, class_inst, suite_configuration, parent=None ): - scoped.scoped_t.__init__( self - , parent=parent - , declaration=class_inst ) - self._suite_configuration = suite_configuration +class indexing_suite_t( code_creator.code_creator_t ): + def __init__(self, parent=None ): + code_creator.code_creator_t.__init__( self, parent=parent ) - def _get_suite_configuration( self ): - return self._suite_configuration - suite_configuration = property( _get_suite_configuration ) + def _get_configuration( self ): + return self.parent.declaration.indexing_suite + configuration = property( _get_configuration ) + def _get_container( self ): + return self.parent.declaration + container = property( _get_container ) + class vector_indexing_suite_t( indexing_suite_t ): """ Creates boost.python code that needed to export a vector of some class @@ -33,39 +29,24 @@ # .def(vector_indexing_suite<std::vector<X> >()) #; - def __init__(self, class_inst, suite_configuration, parent=None ): - indexing_suite_t.__init__( self - , class_inst=class_inst - , suite_configuration=suite_configuration - , parent=parent ) + def __init__(self, parent=None ): + indexing_suite_t.__init__( self, parent=parent ) def _create_indexing_suite_declaration( self ): vector_indexing_suite = algorithm.create_identifier( self, 'boost::python::vector_indexing_suite' ) - container_identifier = algorithm.create_identifier( self, self.suite_configuration.container ) - container = declarations.templates.join( container_identifier, [ self.decl_identifier ] ) - args = [container] - if self.suite_configuration.derived_policies: - if self.suite_configuration.no_proxy: + args = [ self.container.decl_string ] + if self.configuration.derived_policies: + if self.configuration.no_proxy: args.append( 'true' ) else: args.append( 'false' ) - args.append( self.suite_configuration.derived_policies ) + args.append( self.configuration.derived_policies ) else: - if self.suite_configuration.no_proxy: + if self.configuration.no_proxy: args.append( 'true' ) return declarations.templates.join( vector_indexing_suite, args ) - def _create_class_declaration( self ): - class_ = algorithm.create_identifier( self, 'boost::python::class_' ) - container_identifier = algorithm.create_identifier( self, self.suite_configuration.container ) - container = declarations.templates.join( container_identifier, [ self.decl_identifier ] ) - return declarations.templates.join( class_, [ container ] ) - def _create_impl(self): - result = [] - result.append( self._create_class_declaration() + '("%s")' % self.suite_configuration.name ) - result.append( self.indent( ".def( %s() )" % self._create_indexing_suite_declaration() ) ) - result.append( ';' ) - return os.linesep.join( result ) - + return "def( %s() )" % self._create_indexing_suite_declaration() + \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-06-17 18:11:32 UTC (rev 221) @@ -44,7 +44,6 @@ from calldef_wrapper import free_function_t from calldef_wrapper import free_operator_t -from class_wrapper import vector_indexing_suite_t from class_wrapper import class_declaration_t from class_wrapper import class_t @@ -58,8 +57,6 @@ from scopedef_wrapper import scopedef_t - - from pygccxml import declarations from call_policies import call_policy_t @@ -89,6 +86,10 @@ from user_text import user_text_t from user_text import class_user_text_t +from indexing_suite import indexing_suite_t +from indexing_suite import vector_suite_t + + class dwfactory_t( declarations.decl_factory_t ): """ declarations factory class Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-06-17 18:11:32 UTC (rev 221) @@ -3,24 +3,37 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +import user_text import decl_wrapper import scopedef_wrapper from pygccxml import declarations -import user_text +import indexing_suite as container_suites + + +def guess_indexing_suite( class_ ): + if declarations.vector_traits.is_vector( class_ ): + return container_suites.vector_suite_t( class_ ) -class vector_indexing_suite_t( object ): - def __init__( self, name, container='std::vector', no_proxy=False, derived_policies='' ): - object.__init__( self ) - self.name = name - self.container = container - self.no_proxy = no_proxy - self.derived_policies = derived_policies - +#this will only be exported if indexing suite is not None and only when needed class class_declaration_t(decl_wrapper.decl_wrapper_t, declarations.class_declaration_t): def __init__(self, *arguments, **keywords): declarations.class_declaration_t.__init__(self, *arguments, **keywords ) decl_wrapper.decl_wrapper_t.__init__( self ) + self._always_expose_using_scope = False + self._indexing_suite = None + def _get_always_expose_using_scope( self ): + return self._always_expose_using_scope + def _set_always_expose_using_scope( self, value ): + self._always_expose_using_scope = value + always_expose_using_scope = property( _get_always_expose_using_scope, _set_always_expose_using_scope ) + + def _get_indexing_suite( self ): + if self._indexing_suite is None: + self._indexing_suite = guess_indexing_suite( self ) + return self._indexing_suite + indexing_suite = property( _get_indexing_suite ) + class class_t(scopedef_wrapper.scopedef_t, declarations.class_t): def __init__(self, *arguments, **keywords): declarations.class_t.__init__(self, *arguments, **keywords ) @@ -33,7 +46,7 @@ self._wrapper_alias = self._generate_valid_name() + "_wrapper" self._user_code = [] self._wrapper_user_code = [] - self._indexing_suites = [] + self._indexing_suite = None def _get_always_expose_using_scope( self ): return self._always_expose_using_scope @@ -89,11 +102,11 @@ self._wrapper_user_code = value wrapper_user_code = property( _get_wrapper_user_code, _set_wrapper_user_code ) - def _get_indexing_suites( self ): - return self._indexing_suites - def _set_indexing_suites( self, value ): - self._indexing_suites = value - indexing_suites = property( _get_indexing_suites, _set_indexing_suites ) + def _get_indexing_suite( self ): + if self._indexing_suite is None: + self._indexing_suite = guess_indexing_suite( self ) + return self._indexing_suite + indexing_suite = property( _get_indexing_suite ) def add_code( self, code, works_on_instance=True ): """works_on_instance: If true, the custom code can be applied directly to obj inst. Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py 2006-06-17 18:11:32 UTC (rev 221) @@ -17,23 +17,47 @@ # 5. shared_ptr class indexing_suite_t( object ): - def __init__( self, no_proxy=None, derived_policies=None ): + def __init__( self, container_class, no_proxy=None, derived_policies=None ): object.__init__( self ) self.__no_proxy = no_proxy self.__derived_policies = None + self.__container_class = container_class + def _get_container_class( self ): + return self.__container_class + container_class = property( _get_container_class ) + def value_type(self): raise NotImplementedError() def _get_no_proxy( self ): if self.__no_proxy is None: value_type = self.value_type() - if declaration.is_fundamental( value_type ): + if declarations.is_fundamental( value_type ) \ + or declarations.is_enum( value_type ) \ + or declarations.is_std_string( value_type ) \ + or declarations.is_std_wstring( value_type ) \ + or declarations.smart_pointer_traits.is_smart_pointer( value_type ): self.__no_proxy = True - elif declarations.is_enum( value_type ): - self.__no_proxy = True + else: + self.__no_proxy = False + return self.__no_proxy + def _set_no_proxy( self, no_proxy ): + self.__no_proxy = no_proxy + + no_proxy = property( _get_no_proxy, _set_no_proxy ) - - - \ No newline at end of file + def _get_derived_policies( self ): + return self.__derived_policies + def _set_derived_policied( self, derived_policies ): + self.__derived_policies = derived_policies + derived_policies = property( _get_derived_policies, _set_derived_policied ) + + +class vector_suite_t( indexing_suite_t ): + def __init__( self, cls ): + indexing_suite_t.__init__( self, cls ) + + def value_type( self ): + return declarations.vector_traits.value_type( self.container_class ) Modified: pyplusplus_dev/pyplusplus/module_builder/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-06-17 18:11:32 UTC (rev 221) @@ -43,8 +43,6 @@ from pyplusplus.decl_wrappers import variable_t from pyplusplus.decl_wrappers import scopedef_t -from pyplusplus.decl_wrappers import vector_indexing_suite_t - from pyplusplus.decl_wrappers import print_declarations import call_policies Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-06-17 18:11:32 UTC (rev 221) @@ -352,6 +352,20 @@ else: pass + def _treat_indexing_suite( self ): + if self.__types_db.used_vectors: + header = "boost/python/suite/indexing/vector_indexing_suite.hpp" + self.__extmodule.add_system_header( header ) + self.__extmodule.add_include( header=header ) + for cls in self.__types_db.used_vectors: + cls_creator = None + if isinstance( cls, declarations.class_t ): + cls_creator = code_creators.class_t( class_inst=cls ) + else: + cls_creator = code_creators.class_declaration_t( class_inst=cls ) + cls_creator.adopt_creator( code_creators.vector_indexing_suite_t() ) + self.__module_body.adopt_creator( cls_creator ) + def create(self, decl_headers=None): """Create and return the module for the extension. @@ -372,6 +386,7 @@ for operator in self.__free_operators: self._adopt_free_operator( operator ) self._treat_smart_pointers() + self._treat_indexing_suite() for creator in code_creators.make_flatten( self.__extmodule ): creator.target_configuration = self.__target_configuration #last action. @@ -382,16 +397,10 @@ for cls in self.__decls: if not isinstance( cls, decl_wrappers.class_t ): continue - if cls.indexing_suites: - self.__extmodule.add_system_header( "boost/python/suite/indexing/vector_indexing_suite.hpp" ) - include = code_creators.include_t( header="boost/python/suite/indexing/vector_indexing_suite.hpp" ) - self.__extmodule.adopt_include(include) - break for fn in declarations.declaration_files( self.__decls ): include = code_creators.include_t( header=fn ) self.__extmodule.adopt_include(include) - def guess_functions_code_creators( self ): maker_cls = None fwrapper_cls = None @@ -544,14 +553,7 @@ def visit_class_declaration(self ): pass - - def register_indexing_suites(self, class_decl, class_code_creator): - for suite in class_decl.indexing_suites: - assert isinstance( suite, decl_wrappers.vector_indexing_suite_t ) - creator = code_creators.vector_indexing_suite_t( class_inst=class_decl - , suite_configuration=suite ) - class_code_creator.adopt_creator( creator ) - + def visit_class(self ): if self.curr_decl.ignore: return @@ -608,8 +610,6 @@ self.curr_decl = temp_curr_decl self.curr_code_creator = temp_curr_parent - self.register_indexing_suites( self.curr_decl, self.curr_code_creator ) - def visit_enumeration(self): if self.curr_decl.ignore: return Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-06-17 18:11:32 UTC (rev 221) @@ -16,7 +16,8 @@ self.__smart_ptrs = [ 'shared_ptr', 'auto_ptr' ] self.__fundamental_strs = declarations.FUNDAMENTAL_TYPES.keys() self.__normalize_data = [ ',', '<', '>', '*', '&', '(', ')', '::' ] - + self.__used_vectors = set() + def update( self, decl ): if isinstance( decl, declarations.calldef_t ): if not isinstance( decl, declarations.constructor_t ): @@ -45,8 +46,21 @@ answer = answer.replace( data + ' ', data ) answer = answer.replace( ' ' + data, data ) return answer.replace( ' ', ' ' ) + + def _update_containers_db( self, type ): + #will return True is type was treated + type = declarations.remove_alias( type ) + type = declarations.remove_pointer( type ) + type = declarations.remove_reference( type ) + may_be_vector = declarations.vector_traits.declaration_or_none( type ) + if not ( None is may_be_vector ): + self.__used_vectors.add( may_be_vector ) + return True + return False def _update_db( self, db, type_ ): + if self._update_containers_db( type_ ): + return decl_string = self._normalize( declarations.base_type( type_ ).decl_string ) if not templates.is_instantiation( decl_string ): return @@ -138,3 +152,7 @@ for db in dbs: self._print_single_db( db ) + def _get_used_vectors( self ): + return self.__used_vectors + used_vectors = property( _get_used_vectors ) + Modified: pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/unittests/data/indexing_suites_to_be_exported.hpp 2006-06-17 18:11:32 UTC (rev 221) @@ -24,6 +24,8 @@ int value; }; + +typedef std::vector<item_t> items_t; inline item_t get_value( const std::vector<item_t>& vec, unsigned int index ){ return vec.at(index); @@ -34,6 +36,9 @@ vec[index] = value; } +typedef std::vector<int> ivector; +ivector empty_ivector(){ return ivector(); } + } #endif//__indexing_suites_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/indexing_suites_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites_tester.py 2006-06-17 18:09:21 UTC (rev 220) +++ pyplusplus_dev/unittests/indexing_suites_tester.py 2006-06-17 18:11:32 UTC (rev 221) @@ -7,6 +7,7 @@ import sys import unittest import fundamental_tester_base +from pygccxml import declarations from pyplusplus import module_builder @@ -18,10 +19,20 @@ self , tester_t.EXTENSION_NAME , *args ) + + @staticmethod + def matcher( item, decl ): + if not declarations.vector_traits.is_vector( decl ): + return False + value_type = declarations.vector_traits.value_type(decl) + if item is value_type: + return True + return False def customize(self, generator): - item_cls = generator.class_( 'item_t' ) - item_cls.indexing_suites.append( module_builder.vector_indexing_suite_t( 'items_t' ) ) + item = generator.class_( 'item_t' ) + items = generator.class_( lambda decl: self.matcher( item, decl ) ) + items.alias = "items_t" def run_tests( self, module): items = module.items_t() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |