/usr/lib/ruby/1.8/Qt/qtruby4.rb is in ruby-qt4 4:4.8.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 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 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 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 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 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 765 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 818 819 820 821 822 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 1004 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 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 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 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 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 1429 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 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 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 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 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 1851 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 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 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 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 | =begin
/***************************************************************************
qtruby.rb - description
-------------------
begin : Fri Jul 4 2003
copyright : (C) 2003-2008 by Richard Dale
email : richard.j.dale@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
=end
module Qt
module DebugLevel
Off, Minimal, High, Extensive = 0, 1, 2, 3
end
module QtDebugChannel
QTDB_NONE = 0x00
QTDB_AMBIGUOUS = 0x01
QTDB_METHOD_MISSING = 0x02
QTDB_CALLS = 0x04
QTDB_GC = 0x08
QTDB_VIRTUAL = 0x10
QTDB_VERBOSE = 0x20
QTDB_ALL = QTDB_VERBOSE | QTDB_VIRTUAL | QTDB_GC | QTDB_CALLS | QTDB_METHOD_MISSING | QTDB_AMBIGUOUS
end
@@debug_level = DebugLevel::Off
def Qt.debug_level=(level)
@@debug_level = level
Internal::setDebug Qt::QtDebugChannel::QTDB_ALL if level >= DebugLevel::Extensive
end
def Qt.debug_level
@@debug_level
end
module Internal
#
# From the enum MethodFlags in qt-copy/src/tools/moc/generator.cpp
#
AccessPrivate = 0x00
AccessProtected = 0x01
AccessPublic = 0x02
MethodMethod = 0x00
MethodSignal = 0x04
MethodSlot = 0x08
MethodCompatibility = 0x10
MethodCloned = 0x20
MethodScriptable = 0x40
end
class Base
def self.signals(*signal_list)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_signals(signal_list, Internal::MethodSignal | Internal::AccessProtected)
meta.changed = true
end
def self.slots(*slot_list)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_slots(slot_list, Internal::MethodSlot | Internal::AccessPublic)
meta.changed = true
end
def self.private_slots(*slot_list)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_slots(slot_list, Internal::MethodSlot | Internal::AccessPrivate)
meta.changed = true
end
def self.q_signal(signal)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_signals([signal], Internal::MethodSignal | Internal::AccessProtected)
meta.changed = true
end
def self.q_slot(slot)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_slots([slot], Internal::MethodSlot | Internal::AccessPublic)
meta.changed = true
end
def self.q_classinfo(key, value)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
meta.add_classinfo(key, value)
meta.changed = true
end
def **(a)
return Qt::**(self, a)
end
def +(a)
return Qt::+(self, a)
end
def ~(a)
return Qt::~(self, a)
end
def -@()
return Qt::-(self)
end
def -(a)
return Qt::-(self, a)
end
def *(a)
return Qt::*(self, a)
end
def /(a)
return Qt::/(self, a)
end
def %(a)
return Qt::%(self, a)
end
def >>(a)
return Qt::>>(self, a)
end
def <<(a)
return Qt::<<(self, a)
end
def &(a)
return Qt::&(self, a)
end
def ^(a)
return Qt::^(self, a)
end
def |(a)
return Qt::|(self, a)
end
# Module has '<', '<=', '>' and '>=' operator instance methods, so pretend they
# don't exist by calling method_missing() explicitely
def <(a)
begin
Qt::method_missing(:<, self, a)
rescue
super(a)
end
end
def <=(a)
begin
Qt::method_missing(:<=, self, a)
rescue
super(a)
end
end
def >(a)
begin
Qt::method_missing(:>, self, a)
rescue
super(a)
end
end
def >=(a)
begin
Qt::method_missing(:>=, self, a)
rescue
super(a)
end
end
# Object has a '==' operator instance method, so pretend it
# don't exist by calling method_missing() explicitely
def ==(a)
return false if a.nil?
begin
Qt::method_missing(:==, self, a)
rescue
super(a)
end
end
def self.ancestors
klass = self
classid = nil
loop do
classid = Qt::Internal::find_pclassid(klass.name)
break if classid.index
klass = klass.superclass
if klass.nil?
return super
end
end
klasses = super
klasses.delete(Qt::Base)
klasses.delete(self)
ids = []
Qt::Internal::getAllParents(classid, ids)
return [self] + ids.map {|id| Qt::Internal.find_class(Qt::Internal.classid2name(id))} + klasses
end
# Change the behaviors of is_a? and kind_of? (alias of is_a?) to use above self.ancestors method
# Note: this definition also affects Object#===
def is_a?(mod)
super || self.class.ancestors.include?(mod)
end
alias :kind_of? :is_a?
def methods(regular=true)
if !regular
return singleton_methods
end
qt_methods(super, 0x0)
end
def protected_methods(all=true)
# From smoke.h, Smoke::mf_protected 0x80
qt_methods(super, 0x80)
end
def public_methods(all=true)
methods
end
def singleton_methods(all=true)
# From smoke.h, Smoke::mf_static 0x01
qt_methods(super, 0x01)
end
private
def qt_methods(meths, flags)
ids = []
# These methods are all defined in Qt::Base, even if they aren't supported by a particular
# subclass, so remove them to avoid confusion
meths -= ["%", "&", "*", "**", "+", "-", "-@", "/", "<", "<<", "<=", ">", ">=", ">>", "|", "~", "^"]
classid = Qt::Internal::idInstance(self)
Qt::Internal::getAllParents(classid, ids)
ids << classid
ids.each { |c| Qt::Internal::findAllMethodNames(meths, c, flags) }
return meths.uniq
end
end # Qt::Base
# Provides a mutable numeric class for passing to methods with
# C++ 'int*' or 'int&' arg types
class Integer
attr_accessor :value
def initialize(n=0) @value = n end
def +(n)
return Integer.new(@value + n.to_i)
end
def -(n)
return Integer.new(@value - n.to_i)
end
def *(n)
return Integer.new(@value * n.to_i)
end
def /(n)
return Integer.new(@value / n.to_i)
end
def %(n)
return Integer.new(@value % n.to_i)
end
def **(n)
return Integer.new(@value ** n.to_i)
end
def |(n)
return Integer.new(@value | n.to_i)
end
def &(n)
return Integer.new(@value & n.to_i)
end
def ^(n)
return Integer.new(@value ^ n.to_i)
end
def <<(n)
return Integer.new(@value << n.to_i)
end
def >>(n)
return Integer.new(@value >> n.to_i)
end
def >(n)
return @value > n.to_i
end
def >=(n)
return @value >= n.to_i
end
def <(n)
return @value < n.to_i
end
def <=(n)
return @value <= n.to_i
end
def <=>(n)
if @value < n.to_i
return -1
elsif @value > n.to_i
return 1
else
return 0
end
end
def to_f() return @value.to_f end
def to_i() return @value.to_i end
def to_s() return @value.to_s end
def coerce(n)
[n, @value]
end
end
# If a C++ enum was converted to an ordinary ruby Integer, the
# name of the type is lost. The enum type name is needed for overloaded
# method resolution when two methods differ only by an enum type.
class Enum
attr_accessor :type, :value
def initialize(n, enum_type)
@value = n
@type = enum_type
end
def +(n)
return @value + n.to_i
end
def -(n)
return @value - n.to_i
end
def *(n)
return @value * n.to_i
end
def /(n)
return @value / n.to_i
end
def %(n)
return @value % n.to_i
end
def **(n)
return @value ** n.to_i
end
def |(n)
return Enum.new(@value | n.to_i, @type)
end
def &(n)
return Enum.new(@value & n.to_i, @type)
end
def ^(n)
return Enum.new(@value ^ n.to_i, @type)
end
def ~()
return ~ @value
end
def <(n)
return @value < n.to_i
end
def <=(n)
return @value <= n.to_i
end
def >(n)
return @value > n.to_i
end
def >=(n)
return @value >= n.to_i
end
def <<(n)
return Enum.new(@value << n.to_i, @type)
end
def >>(n)
return Enum.new(@value >> n.to_i, @type)
end
def ==(n) return @value == n.to_i end
def to_i() return @value end
def to_f() return @value.to_f end
def to_s() return @value.to_s end
def coerce(n)
[n, @value]
end
def inspect
to_s
end
def pretty_print(pp)
pp.text "#<%s:0x%8.8x @type=%s, @value=%d>" % [self.class.name, object_id, type, value]
end
end
# Provides a mutable boolean class for passing to methods with
# C++ 'bool*' or 'bool&' arg types
class Boolean
attr_accessor :value
def initialize(b=false) @value = b end
def nil?
return !@value
end
end
class AbstractSlider < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class AbstractSocket < Qt::Base
def abort(*args)
method_missing(:abort, *args)
end
end
class AbstractTextDocumentLayout < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class AccessibleEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class ActionEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Action < Qt::Base
def setShortcut(arg)
if arg.kind_of?(String)
return super(Qt::KeySequence.new(arg))
else
return super(arg)
end
end
def shortcut=(arg)
setShortcut(arg)
end
end
class Application < Qt::Base
def initialize(*args)
if args.length == 1 && args[0].kind_of?(Array)
super(args[0].length + 1, [$0] + args[0])
else
super(*args)
end
$qApp = self
end
# Delete the underlying C++ instance after exec returns
# Otherwise, rb_gc_call_finalizer_at_exit() can delete
# stuff that Qt::Application still needs for its cleanup.
def exec
method_missing(:exec)
self.dispose
Qt::Internal.application_terminated = true
end
def type(*args)
method_missing(:type, *args)
end
end
class Buffer < Qt::Base
def open(*args)
method_missing(:open, *args)
end
end
class ButtonGroup < Qt::Base
def id(*args)
method_missing(:id, *args)
end
end
class ByteArray < Qt::Base
def initialize(*args)
if args.size == 1 && args[0].kind_of?(String)
super(args[0], args[0].size)
else
super
end
end
def to_s
return constData()
end
def to_i
return toInt()
end
def to_f
return toDouble()
end
def chop(*args)
method_missing(:chop, *args)
end
def split(*args)
method_missing(:split, *args)
end
end
class CheckBox < Qt::Base
def setShortcut(arg)
if arg.kind_of?(String)
return super(Qt::KeySequence.new(arg))
else
return super(arg)
end
end
def shortcut=(arg)
setShortcut(arg)
end
end
class ChildEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class CloseEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Color < Qt::Base
def inspect
str = super
str.sub(/>$/, " %s>" % name)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " %s>" % name)
end
def name(*args)
method_missing(:name, *args)
end
end
class Connection < Qt::Base
def inspect
str = super
str.sub(/>$/, " memberName=%s, memberType=%s, object=%s>" %
[memberName.inspect, memberType == 1 ? "SLOT" : "SIGNAL", object.inspect] )
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n memberName=%s,\n memberType=%s,\n object=%s>" %
[memberName.inspect, memberType == 1 ? "SLOT" : "SIGNAL", object.inspect] )
end
end
class ContextMenuEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class CoreApplication < Qt::Base
def initialize(*args)
if args.length == 1 && args[0].kind_of?(Array)
super(args.length + 1, [$0] + args[0])
else
super(*args)
end
$qApp = self
end
# Delete the underlying C++ instance after exec returns
# Otherwise, rb_gc_call_finalizer_at_exit() can delete
# stuff that Qt::Application still needs for its cleanup.
def exec
method_missing(:exec)
self.dispose
Qt::Internal.application_terminated = true
end
def type(*args)
method_missing(:type, *args)
end
def exit(*args)
method_missing(:exit, *args)
end
end
class Cursor < Qt::Base
def inspect
str = super
str.sub(/>$/, " shape=%d>" % shape)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " shape=%d>" % shape)
end
end
class CustomEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Date < Qt::Base
def initialize(*args)
if args.size == 1 && args[0].class.name == "Date"
return super(args[0].year, args[0].month, args[0].day)
else
return super(*args)
end
end
def inspect
str = super
str.sub(/>$/, " %s>" % toString)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " %s>" % toString)
end
def to_date
::Date.new! to_julian_day
end
end
class DateTime < Qt::Base
def initialize(*args)
if args.size == 1 && args[0].class.name == "DateTime"
return super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
Qt::Time.new(args[0].hour, args[0].min, args[0].sec) )
elsif args.size == 1 && args[0].class.name == "Time"
result = super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
Qt::Time.new(args[0].hour, args[0].min, args[0].sec, args[0].usec / 1000) )
result.timeSpec = (args[0].utc? ? Qt::UTC : Qt::LocalTime)
return result
else
return super(*args)
end
end
def to_time
if timeSpec == Qt::UTC
return ::Time.utc( date.year, date.month, date.day,
time.hour, time.minute, time.second, time.msec * 1000 )
else
return ::Time.local( date.year, date.month, date.day,
time.hour, time.minute, time.second, time.msec * 1000 )
end
end
def inspect
str = super
str.sub(/>$/, " %s>" % toString)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " %s>" % toString)
end
end
class DBusArgument < Qt::Base
def inspect
str = super
str.sub(/>$/, " currentSignature='%s', atEnd=%s>" % [currentSignature, atEnd])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " currentSignature='%s, atEnd=%s'>" % [currentSignature, atEnd])
end
end
class DBusConnection < Qt::Base
def send(*args)
method_missing(:send, *args)
end
end
class DBusConnectionInterface < Qt::Base
def serviceOwner(name)
return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetNameOwner", [Qt::Variant.new(name)]))
end
def service_owner(name)
return serviceOwner(name)
end
def registeredServiceNames
return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "ListNames"))
end
def registered_service_names
return registeredServiceNames
end
def isServiceRegistered(serviceName)
return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "NameHasOwner", [Qt::Variant.new(serviceName)]))
end
def is_service_registered(serviceName)
return isServiceRegistered(serviceName)
end
def serviceRegistered?(serviceName)
return isServiceRegistered(serviceName)
end
def service_registered?(serviceName)
return isServiceRegistered(serviceName)
end
def servicePid(serviceName)
return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixProcessID", [Qt::Variant.new(serviceName)]))
end
def service_pid(serviceName)
return servicePid(serviceName)
end
def serviceUid(serviceName)
return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixUser", [Qt::Variant.new(serviceName)]))
end
def service_uid(serviceName)
return serviceUid(serviceName)
end
def startService(name)
return call("StartServiceByName", Qt::Variant.new(name), Qt::Variant.new(0)).value
end
def start_service(name)
startService(name)
end
end
class DBusError < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class DBusInterface < Qt::Base
def call(method_name, *args)
if args.length == 0
return super(method_name)
elsif method_name.is_a? Qt::Enum
opt = args.shift
qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
return super(method_name, opt, *qdbusArgs)
else
# If the method is Qt::DBusInterface.call(), create an Array
# 'dbusArgs' of Qt::Variants from '*args'
qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
return super(method_name, *qdbusArgs)
end
end
def method_missing(id, *args)
begin
# First look for a method in the Smoke runtime
# If not found, then throw an exception and try dbus.
super(id, *args)
rescue
if args.length == 0
return call(id.to_s).value
else
return call(id.to_s, *args).value
end
end
end
end
class DBusMessage < Qt::Base
def type(*args)
method_missing(:type, *args)
end
def value
if type() == Qt::DBusMessage::ReplyMessage
reply = arguments()
if reply.length == 0
return nil
elsif reply.length == 1
return reply[0].value
else
return reply.collect {|v| v.value}
end
else
return nil
end
end
def <<(a)
if a.kind_of?(Qt::Variant)
return super(a)
else
return super(qVariantFromValue(a))
end
end
end
class DBusReply
def initialize(reply)
@error = Qt::DBusError.new(reply)
if @error.valid?
@data = Qt::Variant.new
return
end
if reply.arguments.length >= 1
@data = reply.arguments[0]
return
end
# error
@error = Qt::DBusError.new( Qt::DBusError::InvalidSignature,
"Unexpected reply signature" )
@data = Qt::Variant.new # clear it
end
def isValid
return !@error.isValid
end
def valid?
return !@error.isValid
end
def value
return @data.value
end
def error
return @error
end
end
class Dial < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class Dialog < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class Dir < Qt::Base
Time = Qt::Enum.new(1, "QDir::SortFlag")
end
class DomAttr < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class DoubleSpinBox < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class DoubleValidator < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class DomDocumentType < Qt::Base
def name(*args)
method_missing(:name, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class DragEnterEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class DragLeaveEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class DropEvent < Qt::Base
def format(*args)
method_missing(:format, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class Event < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class EventLoop < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
def exit(*args)
method_missing(:exit, *args)
end
end
class File < Qt::Base
def open(*args)
method_missing(:open, *args)
end
end
class FileOpenEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class FileIconProvider < Qt::Base
File = Qt::Enum.new(6, "QFileIconProvider::IconType")
def type(*args)
method_missing(:type, *args)
end
end
class FocusEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Font < Qt::Base
def inspect
str = super
str.sub(/>$/, " family=%s, pointSize=%d, weight=%d, italic=%s, bold=%s, underline=%s, strikeOut=%s>" %
[family.inspect, pointSize, weight, italic, bold, underline, strikeOut])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n family=%s,\n pointSize=%d,\n weight=%d,\n italic=%s,\n bold=%s,\n underline=%s,\n strikeOut=%s>" %
[family.inspect, pointSize, weight, italic, bold, underline, strikeOut])
end
end
class FontDatabase < Qt::Base
Symbol = Qt::Enum.new(30, "QFontDatabase::WritingSystem")
end
class Ftp < Qt::Base
def abort(*args)
method_missing(:abort, *args)
end
end
class GLContext < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class GLPixelBuffer < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class GLWidget < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class GenericArgument < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class Gradient < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsEllipseItem < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsItem < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsItemGroup < Qt::Base
Type = 10
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsLineItem < Qt::Base
Type = 6
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsPathItem < Qt::Base
Type = 2
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsPixmapItem < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsPolygonItem < Qt::Base
Type = 5
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsProxyWidget < Qt::Base
Type = 12
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsRectItem < Qt::Base
Type = 3
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneDragDropEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneMouseEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneContextMenuEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneHoverEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneHelpEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSceneWheelEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSimpleTextItem < Qt::Base
Type = 9
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsSvgItem < Qt::Base
Type = 13
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsTextItem < Qt::Base
Type = 8
def type(*args)
method_missing(:type, *args)
end
end
class GraphicsWidget < Qt::Base
Type = 11
def type(*args)
method_missing(:type, *args)
end
end
class HelpEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class HideEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class HoverEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Http < Qt::Base
def abort(*args)
method_missing(:abort, *args)
end
end
class HttpRequestHeader < Qt::Base
def method(*args)
if args.length == 1
super(*args)
else
method_missing(:method, *args)
end
end
end
class IconDragEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class InputEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class InputMethodEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class IODevice < Qt::Base
def open(*args)
method_missing(:open, *args)
end
end
class Image < Qt::Base
def fromImage(image)
send("operator=".to_sym, image)
end
def format(*args)
method_missing(:format, *args)
end
def load(*args)
method_missing(:load, *args)
end
end
class ImageIOHandler < Qt::Base
def format(*args)
method_missing(:format, *args)
end
def name(*args)
method_missing(:name, *args)
end
end
class ImageReader < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class ImageWriter < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class IntValidator < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class ItemSelection < Qt::Base
include Enumerable
def each
for i in 0...count
yield at(i)
end
return self
end
def select(*args)
method_missing(:select, *args)
end
def split(*args)
method_missing(:split, *args)
end
end
class ItemSelectionModel < Qt::Base
def select(*args)
method_missing(:select, *args)
end
end
class KeyEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class KeySequence < Qt::Base
def initialize(*args)
if args.length == 1 && args[0].kind_of?(Qt::Enum) && args[0].type == "Qt::Key"
return super(args[0].to_i)
end
return super(*args)
end
def inspect
str = super
str.sub(/>$/, " %s>" % toString)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " %s>" % toString)
end
end
class LCDNumber < Qt::Base
def display(item)
method_missing(:display, item)
end
end
class Library < Qt::Base
def load(*args)
method_missing(:load, *args)
end
end
class ListWidgetItem < Qt::Base
def clone(*args)
Qt::ListWidgetItem.new(self)
end
def type(*args)
method_missing(:type, *args)
end
def inspect
str = super
str.sub(/>$/, " text='%s'>" % text)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " text='%s'>" % text)
end
end
class Locale < Qt::Base
def name(*args)
method_missing(:name, *args)
end
def system(*args)
method_missing(:system, *args)
end
end
class Menu < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class MetaClassInfo < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class MetaEnum < Qt::Base
def name(*args)
method_missing(:name, *args)
end
def keyValues()
res = []
for i in 0...keyCount()
if flag?
res.push "%s=0x%x" % [key(i), value(i)]
else
res.push "%s=%d" % [key(i), value(i)]
end
end
return res
end
def inspect
str = super
str.sub(/>$/, " scope=%s, name=%s, keyValues=Array (%d element(s))>" % [scope, name, keyValues.length])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " scope=%s, name=%s, keyValues=Array (%d element(s))>" % [scope, name, keyValues.length])
end
end
class MetaMethod < Qt::Base
# Oops, name clash with the Signal module so hard code
# this value rather than get it from the Smoke runtime
Method = Qt::Enum.new(0, "QMetaMethod::MethodType")
Signal = Qt::Enum.new(1, "QMetaMethod::MethodType")
end
class MetaObject < Qt::Base
def method(*args)
if args.length == 1 && args[0].kind_of?(Symbol)
super(*args)
else
method_missing(:method, *args)
end
end
# Add three methods, 'propertyNames()', 'slotNames()' and 'signalNames()'
# from Qt3, as they are very useful when debugging
def propertyNames(inherits = false)
res = []
if inherits
for p in 0...propertyCount()
res.push property(p).name
end
else
for p in propertyOffset()...propertyCount()
res.push property(p).name
end
end
return res
end
def slotNames(inherits = false)
res = []
if inherits
for m in 0...methodCount()
if method(m).methodType == Qt::MetaMethod::Slot
res.push "%s %s" % [method(m).typeName == "" ? "void" : method(m).typeName,
method(m).signature]
end
end
else
for m in methodOffset()...methodCount()
if method(m).methodType == Qt::MetaMethod::Slot
res.push "%s %s" % [method(m).typeName == "" ? "void" : method(m).typeName,
method(m).signature]
end
end
end
return res
end
def signalNames(inherits = false)
res = []
if inherits
for m in 0...methodCount()
if method(m).methodType == Qt::MetaMethod::Signal
res.push "%s %s" % [method(m).typeName == "" ? "void" : method(m).typeName,
method(m).signature]
end
end
else
for m in methodOffset()...methodCount()
if method(m).methodType == Qt::MetaMethod::Signal
res.push "%s %s" % [method(m).typeName == "" ? "void" : method(m).typeName,
method(m).signature]
end
end
end
return res
end
def enumerators(inherits = false)
res = []
if inherits
for e in 0...enumeratorCount()
res.push enumerator(e)
end
else
for e in enumeratorOffset()...enumeratorCount()
res.push enumerator(e)
end
end
return res
end
def inspect
str = super
str.sub!(/>$/, "")
str << " className=%s," % className
str << " propertyNames=Array (%d element(s))," % propertyNames.length unless propertyNames.length == 0
str << " signalNames=Array (%d element(s))," % signalNames.length unless signalNames.length == 0
str << " slotNames=Array (%d element(s))," % slotNames.length unless slotNames.length == 0
str << " enumerators=Array (%d element(s))," % enumerators.length unless enumerators.length == 0
str << " superClass=%s," % superClass.inspect unless superClass == nil
str.chop!
str << ">"
end
def pretty_print(pp)
str = to_s
str.sub!(/>$/, "")
str << "\n className=%s," % className
str << "\n propertyNames=Array (%d element(s))," % propertyNames.length unless propertyNames.length == 0
str << "\n signalNames=Array (%d element(s))," % signalNames.length unless signalNames.length == 0
str << "\n slotNames=Array (%d element(s))," % slotNames.length unless slotNames.length == 0
str << "\n enumerators=Array (%d element(s))," % enumerators.length unless enumerators.length == 0
str << "\n superClass=%s," % superClass.inspect unless superClass == nil
str << "\n methodCount=%d," % methodCount
str << "\n methodOffset=%d," % methodOffset
str << "\n propertyCount=%d," % propertyCount
str << "\n propertyOffset=%d," % propertyOffset
str << "\n enumeratorCount=%d," % enumeratorCount
str << "\n enumeratorOffset=%d," % enumeratorOffset
str.chop!
str << ">"
pp.text str
end
end
class MetaProperty < Qt::Base
def name(*args)
method_missing(:name, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class MetaType < Qt::Base
Float = Qt::Enum.new(135, "QMetaType::Type")
def load(*args)
method_missing(:load, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class MouseEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class MoveEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Movie < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class NetworkProxy < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Object < Qt::Base
end
class PageSetupDialog < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class PaintEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Picture < Qt::Base
def load(*args)
method_missing(:load, *args)
end
end
class PictureIO < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class Pixmap < Qt::Base
def load(*args)
method_missing(:load, *args)
end
end
class PluginLoader < Qt::Base
def load(*args)
method_missing(:load, *args)
end
end
class Point < Qt::Base
def inspect
str = super
str.sub(/>$/, " x=%d, y=%d>" % [self.x, self.y])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x=%d,\n y=%d>" % [self.x, self.y])
end
end
class PointF < Qt::Base
def inspect
str = super
str.sub(/>$/, " x=%f, y=%f>" % [self.x, self.y])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x=%f,\n y=%f>" % [self.x, self.y])
end
end
class Polygon < Qt::Base
include Enumerable
def each
for i in 0...count
yield point(i)
end
return self
end
end
class PolygonF < Qt::Base
include Enumerable
def each
for i in 0...count
yield point(i)
end
return self
end
end
class PrintDialog < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class Process < Qt::Base
StandardError = Qt::Enum.new(1, "QProcess::ProcessChannel")
end
class ProgressBar < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class ProgressDialog < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class Printer < Qt::Base
def abort(*args)
method_missing(:abort, *args)
end
end
class PushButton < Qt::Base
def setShortcut(arg)
if arg.kind_of?(String)
return super(Qt::KeySequence.new(arg))
else
return super(arg)
end
end
def shortcut=(arg)
setShortcut(arg)
end
end
class Line < Qt::Base
def inspect
str = super
str.sub(/>$/, " x1=%d, y1=%d, x2=%d, y2=%d>" % [x1, y1, x2, y2])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x1=%d,\n y1=%d,\n x2=%d,\n y2=%d>" % [x1, y1, x2, y2])
end
end
class LineF < Qt::Base
def inspect
str = super
str.sub(/>$/, " x1=%f, y1=%f, x2=%f, y2=%f>" % [x1, y1, x2, y2])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x1=%f,\n y1=%f,\n x2=%f,\n y2=%f>" % [x1, y1, x2, y2])
end
end
class MetaType < Qt::Base
def self.type(*args)
method_missing(:type, *args)
end
end
class ModelIndex < Qt::Base
def inspect
str = super
str.sub(/>$/, " valid?=%s, row=%s, column=%s>" % [valid?, row, column])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n valid?=%s,\n row=%s,\n column=%s>" % [valid?, row, column])
end
end
class RadioButton < Qt::Base
def setShortcut(arg)
if arg.kind_of?(String)
return super(Qt::KeySequence.new(arg))
else
return super(arg)
end
end
def shortcut=(arg)
setShortcut(arg)
end
end
class Rect < Qt::Base
def inspect
str = super
str.sub(/>$/, " x=%d, y=%d, width=%d, height=%d>" % [self.x, self.y, width, height])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x=%d,\n y=%d,\n width=%d,\n height=%d>" % [self.x, self.y, width, height])
end
end
class RectF < Qt::Base
def inspect
str = super
str.sub(/>$/, " x=%f, y=%f, width=%f, height=%f>" % [self.x, self.y, width, height])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n x=%f,\n y=%f,\n width=%f,\n height=%f>" % [self.x, self.y, width, height])
end
end
class ResizeEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class ScrollBar < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class Shortcut < Qt::Base
def id(*args)
method_missing(:id, *args)
end
end
class ShortcutEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class ShowEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Size < Qt::Base
def inspect
str = super
str.sub(/>$/, " width=%d, height=%d>" % [width, height])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n width=%d,\n height=%d>" % [width, height])
end
end
class SizeF < Qt::Base
def inspect
str = super
str.sub(/>$/, " width=%f, height=%f>" % [width, height])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n width=%f,\n height=%f>" % [width, height])
end
end
class SizePolicy < Qt::Base
def inspect
str = super
str.sub(/>$/, " horizontalPolicy=%d, verticalPolicy=%d>" % [horizontalPolicy, verticalPolicy])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n horizontalPolicy=%d,\n verticalPolicy=%d>" % [horizontalPolicy, verticalPolicy])
end
end
class Slider < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class SocketNotifier < Qt::Base
Exception = Qt::Enum.new(2, "QSocketNotifier::Type")
def type(*args)
method_missing(:type, *args)
end
end
class SpinBox < Qt::Base
def range=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class SqlDatabase < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
def open(*args)
method_missing(:open, *args)
end
end
class SqlError < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class SqlField < Qt::Base
def name(*args)
method_missing(:name, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class SqlIndex < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class SqlQuery < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class SqlResult < Qt::Base
def exec(*args)
method_missing(:exec, *args)
end
end
class SqlTableModel < Qt::Base
def select(*k)
method_missing(:select, *k)
end
end
class StandardItem < Qt::Base
def inspect
str = super
str.sub(/>$/, " text='%s'>" % [text])
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, "\n text='%s'>" % [text])
end
def type(*args)
method_missing(:type, *args)
end
def clone
Qt::StandardItem.new(self)
end
end
class StandardItemModel < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class StatusTipEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class StyleHintReturn < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class StyleOption < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class SyntaxHighlighter < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class TableWidgetItem < Qt::Base
def clone(*args)
Qt::TableWidgetItem.new(self)
end
def type(*args)
method_missing(:type, *args)
end
def inspect
str = super
str.sub(/>$/, " text='%s'>" % text)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " text='%s'>" % text)
end
end
class TemporaryFile < Qt::Base
def open(*args)
method_missing(:open, *args)
end
end
class TextCursor < Qt::Base
def select(*k)
method_missing(:select, *k)
end
end
class TextDocument < Qt::Base
def clone(*args)
method_missing(:clone, *args)
end
def print(*args)
method_missing(:print, *args)
end
end
class TextFormat < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class TextImageFormat < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class TextInlineObject < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class TextLength < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class TextList < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class TextObject < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class TextTable < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class TextTableCell < Qt::Base
def format(*args)
method_missing(:format, *args)
end
end
class Time < Qt::Base
def initialize(*args)
if args.size == 1 && args[0].class.name == "Time"
return super(args[0].hour, args[0].min, args[0].sec)
else
return super(*args)
end
end
def inspect
str = super
str.sub(/>$/, " %s>" % toString)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " %s>" % toString)
end
end
class TimerEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class TimeLine < Qt::Base
def frameRange=(arg)
if arg.kind_of? Range
return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
else
return super(arg)
end
end
end
class ToolButton < Qt::Base
def setShortcut(arg)
if arg.kind_of?(String)
return super(Qt::KeySequence.new(arg))
else
return super(arg)
end
end
def shortcut=(arg)
setShortcut(arg)
end
end
class Translator < Qt::Base
def load(*args)
method_missing(:load, *args)
end
end
class TreeWidget < Qt::Base
include Enumerable
def each
it = Qt::TreeWidgetItemIterator.new(self)
while it.current
yield it.current
it += 1
end
end
end
class TreeWidgetItem < Qt::Base
include Enumerable
def initialize(*args)
# There is not way to distinguish between the copy constructor
# QTreeWidgetItem (const QTreeWidgetItem & other)
# and
# QTreeWidgetItem (QTreeWidgetItem * parent, const QStringList & strings, int type = Type)
# when the latter has a single argument. So force the second variant to be called
if args.length == 1 && args[0].kind_of?(Qt::TreeWidgetItem)
super(args[0], Qt::TreeWidgetItem::Type)
else
super(*args)
end
end
def inspect
str = super
str.sub!(/>$/, "")
str << " parent=%s," % parent unless parent.nil?
for i in 0..(columnCount - 1)
str << " text%d='%s'," % [i, self.text(i)]
end
str.sub!(/,?$/, ">")
end
def pretty_print(pp)
str = to_s
str.sub!(/>$/, "")
str << " parent=%s," % parent unless parent.nil?
for i in 0..(columnCount - 1)
str << " text%d='%s'," % [i, self.text(i)]
end
str.sub!(/,?$/, ">")
pp.text str
end
def clone(*args)
Qt::TreeWidgetItem.new(self)
end
def type(*args)
method_missing(:type, *args)
end
def each
it = Qt::TreeWidgetItemIterator.new(self)
while it.current
yield it.current
it += 1
end
end
end
class TreeWidgetItemIterator < Qt::Base
def current
return send("operator*".to_sym)
end
end
class Url < Qt::Base
def inspect
str = super
str.sub(/>$/, " url=%s>" % toString)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " url=%s>" % toString)
end
end
class UrlInfo < Qt::Base
def name(*args)
method_missing(:name, *args)
end
end
class Uuid < Qt::Base
Time = Qt::Enum.new(1, "QUuid::Version")
end
class Variant < Qt::Base
String = Qt::Enum.new(10, "QVariant::Type")
Date = Qt::Enum.new(14, "QVariant::Type")
Time = Qt::Enum.new(15, "QVariant::Type")
DateTime = Qt::Enum.new(16, "QVariant::Type")
def initialize(*args)
if args.size == 1 && args[0].nil?
return super()
elsif args.size == 1 && args[0].class.name == "Date"
return super(Qt::Date.new(args[0]))
elsif args.size == 1 && args[0].class.name == "DateTime"
return super(Qt::DateTime.new( Qt::Date.new(args[0].year, args[0].month, args[0].day),
Qt::Time.new(args[0].hour, args[0].min, args[0].sec) ) )
elsif args.size == 1 && args[0].class.name == "Time"
return super(Qt::Time.new(args[0]))
elsif args.size == 1 && args[0].class.name == "BigDecimal"
return super(args[0].to_f) # we have to make do with a float
else
return super(*args)
end
end
def to_a
return toStringList()
end
def to_f
return toDouble()
end
def to_i
return toInt()
end
def to_int
return toInt()
end
def value
case type()
when Qt::Variant::Invalid
return nil
when Qt::Variant::Bitmap
when Qt::Variant::Bool
return toBool
when Qt::Variant::Brush
return qVariantValue(Qt::Brush, self)
when Qt::Variant::ByteArray
return toByteArray
when Qt::Variant::Char
return qVariantValue(Qt::Char, self)
when Qt::Variant::Color
return qVariantValue(Qt::Color, self)
when Qt::Variant::Cursor
return qVariantValue(Qt::Cursor, self)
when Qt::Variant::Date
return toDate
when Qt::Variant::DateTime
return toDateTime
when Qt::Variant::Double
return toDouble
when Qt::Variant::Font
return qVariantValue(Qt::Font, self)
when Qt::Variant::Icon
return qVariantValue(Qt::Icon, self)
when Qt::Variant::Image
return qVariantValue(Qt::Image, self)
when Qt::Variant::Int
return toInt
when Qt::Variant::KeySequence
return qVariantValue(Qt::KeySequence, self)
when Qt::Variant::Line
return toLine
when Qt::Variant::LineF
return toLineF
when Qt::Variant::List
return toList
when Qt::Variant::Locale
return qVariantValue(Qt::Locale, self)
when Qt::Variant::LongLong
return toLongLong
when Qt::Variant::Map
return toMap
when Qt::Variant::Palette
return qVariantValue(Qt::Palette, self)
when Qt::Variant::Pen
return qVariantValue(Qt::Pen, self)
when Qt::Variant::Pixmap
return qVariantValue(Qt::Pixmap, self)
when Qt::Variant::Point
return toPoint
when Qt::Variant::PointF
return toPointF
when Qt::Variant::Polygon
return qVariantValue(Qt::Polygon, self)
when Qt::Variant::Rect
return toRect
when Qt::Variant::RectF
return toRectF
when Qt::Variant::RegExp
return toRegExp
when Qt::Variant::Region
return qVariantValue(Qt::Region, self)
when Qt::Variant::Size
return toSize
when Qt::Variant::SizeF
return toSizeF
when Qt::Variant::SizePolicy
return toSizePolicy
when Qt::Variant::String
return toString
when Qt::Variant::StringList
return toStringList
when Qt::Variant::TextFormat
return qVariantValue(Qt::TextFormat, self)
when Qt::Variant::TextLength
return qVariantValue(Qt::TextLength, self)
when Qt::Variant::Time
return toTime
when Qt::Variant::UInt
return toUInt
when Qt::Variant::ULongLong
return toULongLong
when Qt::Variant::Url
return toUrl
end
return qVariantValue(nil, self)
end
def inspect
str = super
str.sub(/>$/, " typeName=%s>" % typeName)
end
def pretty_print(pp)
str = to_s
pp.text str.sub(/>$/, " typeName=%s>" % typeName)
end
def load(*args)
method_missing(:load, *args)
end
def type(*args)
method_missing(:type, *args)
end
end
class DBusVariant < Variant
def initialize(value)
if value.kind_of? Qt::Variant
super(value)
else
super(Qt::Variant.new(value))
end
end
def setVariant(variant)
end
def variant=(variant)
setVariant(variant)
end
def variant()
return self
end
end
class WhatsThisClickedEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class Widget < Qt::Base
def raise(*args)
method_missing(:raise, *args)
end
end
class WindowStateChangeEvent < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class XmlAttributes < Qt::Base
def type(*args)
method_missing(:type, *args)
end
end
class SignalBlockInvocation < Qt::Object
def initialize(parent, block, signature)
super(parent)
if metaObject.indexOfSlot(signature) == -1
self.class.slots signature
end
@block = block
end
def invoke(*args)
@block.call(*args)
end
end
class BlockInvocation < Qt::Object
def initialize(target, block, signature)
super(target)
if metaObject.indexOfSlot(signature) == -1
self.class.slots signature
end
@block = block
end
def invoke(*args)
@block.call(*args)
end
end
class MethodInvocation < Qt::Object
def initialize(target, method, signature)
super(target)
if metaObject.indexOfSlot(signature) == -1
self.class.slots signature
end
@target = target
method = method.intern unless method.is_a?Symbol
@method = method
end
def invoke(*args)
@target.send @method, *args
end
end
module Internal
@@classes = {}
@@cpp_names = {}
@@idclass = []
@@normalize_procs = []
class ModuleIndex
attr_accessor :index
def smoke
if ! @smoke
return 0
end
return @smoke
end
def initialize(smoke, index)
@smoke = smoke
@index = index
end
end
def self.classes
return @@classes
end
def self.cpp_names
return @@cpp_names
end
def self.idclass
return @@idclass
end
def self.add_normalize_proc(func)
@@normalize_procs << func
end
def Internal.normalize_classname(classname)
@@normalize_procs.each do |func|
ret = func.call(classname)
if !ret.nil?
return ret
end
end
if classname =~ /^Q3/
ruby_classname = classname.sub(/^Q3(?=[A-Z])/,'Qt3::')
elsif classname =~ /^Q/
ruby_classname = classname.sub(/^Q(?=[A-Z])/,'Qt::')
else
ruby_classname = classname
end
ruby_classname
end
def Internal.init_class(c)
if c == "WebCore" || c == "std" || c == "QGlobalSpace"
return
end
classname = Qt::Internal::normalize_classname(c)
classId = Qt::Internal.findClass(c)
insert_pclassid(classname, classId)
@@idclass[classId.index] = classname
@@cpp_names[classname] = c
klass = isQObject(c) ? create_qobject_class(classname, Qt) \
: create_qt_class(classname, Qt)
@@classes[classname] = klass unless klass.nil?
end
def Internal.debug_level
Qt.debug_level
end
def Internal.checkarg(argtype, typename)
puts " #{typename} (#{argtype})" if debug_level >= DebugLevel::High
const_point = typename =~ /^const\s+/ ? -1 : 0
if argtype == 'i'
if typename =~ /^int&?$|^signed int&?$|^signed$|^qint32&?$/
return 6 + const_point
elsif typename =~ /^quint32&?$/
return 4 + const_point
elsif typename =~ /^(?:short|ushort|unsigned short int|unsigned short|uchar||unsigned char|uint|long|ulong|unsigned long int|unsigned|float|double|WId|Q_PID|^quint16&?$|^qint16&?$)$/
return 4 + const_point
elsif typename =~ /^(quint|qint|qulong|qlong|qreal)/
return 4 + const_point
elsif typename =~ /^(long long)$/
return 2 + const_point
else
t = typename.sub(/^const\s+/, '')
t.sub!(/[&*]$/, '')
if isEnum(t)
return 2
end
end
elsif argtype == 'n'
if typename =~ /^double$|^qreal$/
return 6 + const_point
elsif typename =~ /^float$/
return 4 + const_point
elsif typename =~ /^int&?$/
return 2 + const_point
elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|float|double)$/
return 2 + const_point
else
t = typename.sub(/^const\s+/, '')
t.sub!(/[&*]$/, '')
if isEnum(t)
return 2 + const_point
end
end
elsif argtype == 'B'
if typename =~ /^(?:bool)[*&]?$/
return 2 + const_point
end
elsif argtype == 's'
if typename =~ /^(const )?((QChar)[*&]?)$/
return 6 + const_point
elsif typename =~ /^(?:(u(nsigned )?)?char\*)$/
return 4 + const_point
elsif typename =~ /^(?:const (u(nsigned )?)?char\*)$/
return 2 + const_point
elsif typename =~ /^(?:(?:const )?(QString)[*&]?)$/
return 8 + const_point
end
elsif argtype == 'a'
# FIXME: shouldn't be hardcoded. Installed handlers should tell what ruby type they expect.
if typename =~ /^(?:
const\ QCOORD\*|
(?:const\ )?
(?:
QStringList[\*&]?|
QValueList<int>[\*&]?|
QRgb\*|
char\*\*
)
)$/x
return 2 + const_point
end
elsif argtype == 'u'
# Give nil matched against string types a higher score than anything else
if typename =~ /^(?:u?char\*|const u?char\*|(?:const )?((Q(C?)String))[*&]?)$/
return 4 + const_point
# Numerics will give a runtime conversion error, so they fail the match
elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|int)$/
return -99
else
return 2 + const_point
end
elsif argtype == 'U'
if typename =~ /QStringList/
return 4 + const_point
else
return 2 + const_point
end
else
t = typename.sub(/^const\s+/, '')
t.sub!(/(::)?Ptr$/, '')
t.sub!(/[&*]$/, '')
if argtype == t
return 4 + const_point
elsif classIsa(argtype, t)
return 2 + const_point
elsif isEnum(argtype) and
(t =~ /int|qint32|uint|quint32|long|ulong/ or isEnum(t))
return 2 + const_point
end
end
return -99
end
def Internal.find_class(classname)
@@classes[classname]
end
# Runs the initializer as far as allocating the Qt C++ instance.
# Then use a throw to jump back to here with the C++ instance
# wrapped in a new ruby variable of type T_DATA
def Internal.try_initialize(instance, *args)
initializer = instance.method(:initialize)
catch :newqt do
initializer.call(*args)
end
end
# If a block was passed to the constructor, then
# run that now. Either run the context of the new instance
# if no args were passed to the block. Or otherwise,
# run the block in the context of the arg.
def Internal.run_initializer_block(instance, block)
if block.arity == -1 || block.arity == 0
instance.instance_eval(&block)
elsif block.arity == 1
block.call(instance)
else
raise ArgumentError, "Wrong number of arguments to block(#{block.arity} for 1)"
end
end
def Internal.do_method_missing(package, method, klass, this, *args)
if klass.class == Module
classname = klass.name
else
classname = @@cpp_names[klass.name]
if classname.nil?
if klass != Object and klass != Qt
return do_method_missing(package, method, klass.superclass, this, *args)
else
return nil
end
end
end
if method == "new"
method = classname.dup
method.gsub!(/^.*::/,"")
end
method = "operator" + method.sub("@","") if method !~ /[a-zA-Z]+/
# Change foobar= to setFoobar()
method = 'set' + method[0,1].upcase + method[1,method.length].sub("=", "") if method =~ /.*[^-+%\/|=]=$/ && method != 'operator='
methods = []
methods << method.dup
args.each do |arg|
if arg.nil?
# For each nil arg encountered, triple the number of munged method
# templates, in order to cover all possible types that can match nil
temp = []
methods.collect! do |meth|
temp << meth + '?'
temp << meth + '#'
meth << '$'
end
methods.concat(temp)
elsif isObject(arg)
methods.collect! { |meth| meth << '#' }
elsif arg.kind_of? Array or arg.kind_of? Hash
methods.collect! { |meth| meth << '?' }
else
methods.collect! { |meth| meth << '$' }
end
end
methodIds = []
methods.collect { |meth| methodIds.concat( findMethod(classname, meth) ) }
if method =~ /._./ && methodIds.length == 0
# If the method name contains underscores, convert to camel case
# form and try again
method.gsub!(/(.)_(.)/) {$1 + $2.upcase}
return do_method_missing(package, method, klass, this, *args)
end
if debug_level >= DebugLevel::High
puts "classname == #{classname}"
puts ":: method == #{method}"
puts "-> methodIds == #{methodIds.inspect}"
puts "candidate list:"
prototypes = dumpCandidates(methodIds).split("\n")
line_len = (prototypes.collect { |p| p.length }).max
prototypes.zip(methodIds) {
|prototype,id| puts "#{prototype.ljust line_len} (smoke: #{id.smoke} index: #{id.index})"
}
end
chosen = nil
if methodIds.length > 0
best_match = -1
methodIds.each do
|id|
puts "matching => smoke: #{id.smoke} index: #{id.index}" if debug_level >= DebugLevel::High
current_match = (isConstMethod(id) ? 1 : 0)
(0...args.length).each do
|i|
current_match += checkarg(get_value_type(args[i]), get_arg_type_name(id, i))
end
# Note that if current_match > best_match, then chosen must be nil
if current_match > best_match
best_match = current_match
chosen = id
# Multiple matches are an error; the equality test below _cannot_ be commented out.
# If ambiguous matches occur the problem must be fixed be adjusting the relative
# ranking of the arg types involved in checkarg().
elsif current_match == best_match
puts "multiple methods matching, this is an error" if debug_level >= DebugLevel::Minimal
chosen = nil
end
puts "match => #{id.index} score: #{current_match}" if debug_level >= DebugLevel::High
end
puts "Resolved to id: #{chosen.index}" if !chosen.nil? && debug_level >= DebugLevel::High
end
if debug_level >= DebugLevel::Minimal && chosen.nil? && method !~ /^operator/
id = find_pclassid(normalize_classname(klass.name))
hash = findAllMethods(id)
constructor_names = nil
if method == classname
puts "No matching constructor found, possibles:\n"
constructor_names = hash.keys.grep(/^#{classname}/)
else
puts "Possible prototypes:"
constructor_names = hash.keys
end
method_ids = hash.values_at(*constructor_names).flatten
puts dumpCandidates(method_ids)
else
puts "setCurrentMethod(smokeList index: #{chosen.smoke}, meth index: #{chosen.index})" if debug_level >= DebugLevel::High
end
setCurrentMethod(chosen) if chosen
return nil
end
def Internal.init_all_classes()
Qt::Internal::getClassList().each do |c|
if c == "Qt"
# Don't change Qt to Qt::t, just leave as is
@@cpp_names["Qt"] = c
elsif c != "QInternal" && !c.empty?
Qt::Internal::init_class(c)
end
end
@@classes['Qt::Integer'] = Qt::Integer
@@classes['Qt::Boolean'] = Qt::Boolean
@@classes['Qt::Enum'] = Qt::Enum
end
def Internal.get_qinteger(num)
return num.value
end
def Internal.set_qinteger(num, val)
return num.value = val
end
def Internal.create_qenum(num, enum_type)
return Qt::Enum.new(num, enum_type)
end
def Internal.get_qenum_type(e)
return e.type
end
def Internal.get_qboolean(b)
return b.value
end
def Internal.set_qboolean(b, val)
return b.value = val
end
def Internal.getAllParents(class_id, res)
getIsa(class_id).each do |s|
c = findClass(s)
res << c
getAllParents(c, res)
end
end
# Keeps a hash of strings against their corresponding offsets
# within the qt_meta_stringdata sequence of null terminated
# strings. Returns a proc to get an offset given a string.
# That proc also adds new strings to the 'data' array, and updates
# the corresponding 'pack_str' Array#pack template.
def Internal.string_table_handler(data, pack_str)
hsh = {}
offset = 0
return lambda do |str|
if !hsh.has_key? str
hsh[str] = offset
data << str
pack_str << "a*x"
offset += str.length + 1
end
return hsh[str]
end
end
def Internal.makeMetaData(classname, classinfos, dbus, signals, slots)
# Each entry in 'stringdata' corresponds to a string in the
# qt_meta_stringdata_<classname> structure.
# 'pack_string' is used to convert 'stringdata' into the
# binary sequence of null terminated strings for the metaObject
stringdata = []
pack_string = ""
string_table = string_table_handler(stringdata, pack_string)
# This is used to create the array of uints that make up the
# qt_meta_data_<classname> structure in the metaObject
data = [1, # revision
string_table.call(classname), # classname
classinfos.length, classinfos.length > 0 ? 10 : 0, # classinfo
signals.length + slots.length,
10 + (2*classinfos.length), # methods
0, 0, # properties
0, 0] # enums/sets
classinfos.each do |entry|
data.push string_table.call(entry[0]) # key
data.push string_table.call(entry[1]) # value
end
signals.each do |entry|
data.push string_table.call(entry.full_name) # signature
data.push string_table.call(entry.full_name.delete("^,")) # parameters
data.push string_table.call(entry.reply_type) # type, "" means void
data.push string_table.call("") # tag
if dbus
data.push MethodScriptable | MethodSignal | AccessPublic
else
data.push entry.access # flags, always protected for now
end
end
slots.each do |entry|
data.push string_table.call(entry.full_name) # signature
data.push string_table.call(entry.full_name.delete("^,")) # parameters
data.push string_table.call(entry.reply_type) # type, "" means void
data.push string_table.call("") # tag
if dbus
data.push MethodScriptable | MethodSlot | AccessPublic # flags, always public for now
else
data.push entry.access # flags, always public for now
end
end
data.push 0 # eod
return [stringdata.pack(pack_string), data]
end
def Internal.getMetaObject(klass, qobject)
if klass.nil?
klass = qobject.class
end
parentMeta = nil
if @@cpp_names[klass.superclass.name].nil?
parentMeta = getMetaObject(klass.superclass, qobject)
end
meta = Meta[klass.name]
if meta.nil?
meta = Qt::MetaInfo.new(klass)
end
if meta.metaobject.nil? or meta.changed
stringdata, data = makeMetaData( qobject.class.name,
meta.classinfos,
meta.dbus,
meta.signals,
meta.slots )
meta.metaobject = make_metaObject(qobject, parentMeta, stringdata, data)
meta.changed = false
end
meta.metaobject
end
# Handles calls of the form:
# connect(myobj, SIGNAL('mysig(int)'), mytarget) {|arg(s)| ...}
# connect(myobj, SIGNAL('mysig(int)')) {|arg(s)| ...}
# connect(myobj, SIGNAL(:mysig), mytarget) { ...}
# connect(myobj, SIGNAL(:mysig)) { ...}
def Internal.connect(src, signal, target, block)
args = (signal =~ /\((.*)\)/) ? $1 : ""
signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
return Qt::Object.connect( src,
signal,
Qt::BlockInvocation.new(target, block.to_proc, signature),
SLOT(signature) )
end
# Handles calls of the form:
# connect(SIGNAL(:mysig)) { ...}
# connect(SIGNAL('mysig(int)')) {|arg(s)| ...}
def Internal.signal_connect(src, signal, block)
args = (signal =~ /\((.*)\)/) ? $1 : ""
signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
return Qt::Object.connect( src,
signal,
Qt::SignalBlockInvocation.new(src, block.to_proc, signature),
SLOT(signature) )
end
# Handles calls of the form:
# connect(:mysig, mytarget, :mymethod))
# connect(SIGNAL('mysignal(int)'), mytarget, :mymethod))
def Internal.method_connect(src, signal, target, method)
signal = SIGNAL(signal) if signal.is_a?Symbol
args = (signal =~ /\((.*)\)/) ? $1 : ""
signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
return Qt::Object.connect( src,
signal,
Qt::MethodInvocation.new(target, method, signature),
SLOT(signature) )
end
# Handles calls of the form:
# Qt::Timer.singleShot(500, myobj) { ...}
def Internal.single_shot_timer_connect(interval, target, block)
return Qt::Timer.singleShot( interval,
Qt::BlockInvocation.new(target, block, "invoke()"),
SLOT("invoke()") )
end
end # Qt::Internal
Meta = {}
# An entry for each signal or slot
# Example
# int foobar(QString,bool)
# :name is 'foobar'
# :full_name is 'foobar(QString,bool)'
# :arg_types is 'QString,bool'
# :reply_type is 'int'
QObjectMember = Struct.new :name, :full_name, :arg_types, :reply_type, :access
class MetaInfo
attr_accessor :classinfos, :dbus, :signals, :slots, :metaobject, :mocargs, :changed
def initialize(klass)
Meta[klass.name] = self
@klass = klass
@metaobject = nil
@signals = []
@slots = []
@classinfos = []
@dbus = false
@changed = false
Internal.addMetaObjectMethods(klass)
end
def add_signals(signal_list, access)
signal_names = []
signal_list.each do |signal|
if signal.kind_of? Symbol
signal = signal.to_s + "()"
end
signal = Qt::MetaObject.normalizedSignature(signal).to_s
if signal =~ /^(([\w,<>:]*)\s+)?([^\s]*)\((.*)\)/
@signals.push QObjectMember.new( $3,
$3 + "(" + $4 + ")",
$4,
($2 == 'void' || $2.nil?) ? "" : $2,
access )
signal_names << $3
else
qWarning( "#{@klass.name}: Invalid signal format: '#{signal}'" )
end
end
Internal.addSignalMethods(@klass, signal_names)
end
# Return a list of signals, including inherited ones
def get_signals
all_signals = []
current = @klass
while current != Qt::Base
meta = Meta[current.name]
if !meta.nil?
all_signals.concat meta.signals
end
current = current.superclass
end
return all_signals
end
def add_slots(slot_list, access)
slot_list.each do |slot|
if slot.kind_of? Symbol
slot = slot.to_s + "()"
end
slot = Qt::MetaObject.normalizedSignature(slot).to_s
if slot =~ /^(([\w,<>:]*)\s+)?([^\s]*)\((.*)\)/
@slots.push QObjectMember.new( $3,
$3 + "(" + $4 + ")",
$4,
($2 == 'void' || $2.nil?) ? "" : $2,
access )
else
qWarning( "#{@klass.name}: Invalid slot format: '#{slot}'" )
end
end
end
def add_classinfo(key, value)
@classinfos.push [key, value]
if key == 'D-Bus Interface'
@dbus = true
end
end
end # Qt::MetaInfo
# These values are from the enum WindowType in qnamespace.h.
# Some of the names such as 'Qt::Dialog', clash with QtRuby
# class names. So add some constants here to use instead,
# renamed with an ending of 'Type'.
WidgetType = 0x00000000
WindowType = 0x00000001
DialogType = 0x00000002 | WindowType
SheetType = 0x00000004 | WindowType
DrawerType = 0x00000006 | WindowType
PopupType = 0x00000008 | WindowType
ToolType = 0x0000000a | WindowType
ToolTipType = 0x0000000c | WindowType
SplashScreenType = 0x0000000e | WindowType
DesktopType = 0x00000010 | WindowType
SubWindowType = 0x00000012
end # Qt
class Object
def SIGNAL(signal)
if signal.kind_of? Symbol
return "2" + signal.to_s + "()"
else
return "2" + signal
end
end
def SLOT(slot)
if slot.kind_of? Symbol
return "1" + slot.to_s + "()"
else
return "1" + slot
end
end
def emit(signal)
return signal
end
def QT_TR_NOOP(x) x end
def QT_TRANSLATE_NOOP(scope, x) x end
# See the discussion here: http://eigenclass.org/hiki.rb?instance_exec
# about implementations of the ruby 1.9 method instance_exec(). This
# version is the one from Rails. It isn't thread safe, but that doesn't
# matter for the intended use in invoking blocks as Qt slots.
def instance_exec(*arguments, &block)
block.bind(self)[*arguments]
end unless defined? instance_exec
end
class Proc
# Part of the Rails Object#instance_exec implementation
def bind(object)
block, time = self, Time.now
(class << object; self end).class_eval do
method_name = "__bind_#{time.to_i}_#{time.usec}"
define_method(method_name, &block)
method = instance_method(method_name)
remove_method(method_name)
method
end.bind(object)
end
end
class Module
alias_method :_constants, :constants
alias_method :_instance_methods, :instance_methods
alias_method :_protected_instance_methods, :protected_instance_methods
alias_method :_public_instance_methods, :public_instance_methods
private :_constants, :_instance_methods
private :_protected_instance_methods, :_public_instance_methods
def constants
qt_methods(_constants, 0x10, true)
end
def instance_methods(inc_super=true)
qt_methods(_instance_methods(inc_super), 0x0, inc_super)
end
def protected_instance_methods(inc_super=true)
qt_methods(_protected_instance_methods(inc_super), 0x80, inc_super)
end
def public_instance_methods(inc_super=true)
qt_methods(_public_instance_methods(inc_super), 0x0, inc_super)
end
private
def qt_methods(meths, flags, inc_super=true)
if !self.kind_of? Class
return meths
end
klass = self
classid = Qt::Internal::ModuleIndex.new(0, 0)
loop do
classid = Qt::Internal::find_pclassid(klass.name)
break if classid.index
klass = klass.superclass
if klass.nil?
return meths
end
end
# These methods are all defined in Qt::Base, even if they aren't supported by a particular
# subclass, so remove them to avoid confusion
meths -= ["%", "&", "*", "**", "+", "-", "-@", "/", "<", "<<", "<=", ">", ">=", ">>", "|", "~", "^"]
ids = []
if inc_super
Qt::Internal::getAllParents(classid, ids)
end
ids << classid
ids.each { |c| Qt::Internal::findAllMethodNames(meths, c, flags) }
return meths.uniq
end
end
# kate: space-indent false;
|