summaryrefslogtreecommitdiffstats
path: root/kalyptus/kalyptusCxxToJNI.pm
blob: 7dfae76507a09ec391afc687ad0fd2dd3afe9197 (plain)
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
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
#***************************************************************************
#            kalyptusCxxToJNI.pm -  Generates *.java and *.cpp files for a JNI based
#									version of Qt/KDE java bindings
#                             -------------------
#    begin                : Sun Nov 16 12:00:00 2003
#    copyright            : (C) 2003, Richard Dale. All Rights Reserved.
#    email                : Richard_Dale@tipitina.demon.co.uk
#    author               : Richard Dale, based on the SMOKE generation code
#                            by David Faure.
#***************************************************************************/

#/***************************************************************************
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU General Public License as published by  *
# *   the Free Software Foundation; either version 2 of the License, or     *
# *   (at your option) any later version.                                   *
# *                                                                         *
#***************************************************************************/

package kalyptusCxxToJNI;

use File::Path;
use File::Basename;

use Carp;
use Ast;
use kdocAstUtil;
use kdocUtil;
use Iter;
use kalyptusDataDict;

use strict;
no strict "subs";

use vars qw/
	$libname $rootnode $outputdir $opt $debug
	$qapplicationExtras $qapplicationjniExtras $qbitmapExtras $qbitmapjniExtras
	$qlistviewExtras $qlistviewjniExtras $qlistviewitemExtras $qlistviewitemjniExtras
	$qpopupmenujniExtras $qmenudatajniExtras $qmenubarjniExtras
	$qdragobjectExtras $qdragobjectjniExtras $qdropeventExtras $qdropeventjniExtras $qmimesourceExtras $qmimesourcejniExtras
	$qtExtras $qtjniExtras $qobjectExtras $qobjectjniExtras $qimagejniExtras $qwidgetExtras $qwidgetjniExtras
	$qpixmapExtras $qpixmapjniExtras $qpaintdeviceExtras $qpaintdevicejniExtras
	$qdragobjectExtras $qdragobjectjniExtras $qiodeviceExtras $qpointarrayExtras $qpointarrayjniExtras
	$qtextcodecExtras $qtextcodecjniExtras $quridragExtras $quridragjniExtras
	$kapplicationExtras $kapplicationjniExtras $kmainwindowExtras $kmainwindowjniExtras
	$kcmdlineargsjniExtras $schedulerjniExtras
	$methodNumber
	%builtins %typeunion %allMethods %allTypes %enumValueToType %typedeflist %mungedTypeMap %javaImports
	%skippedClasses %skippedJniMethods %operatorNames /;

BEGIN
{

# Types supported by the StackItem union
# Key: C++ type  Value: Union field of that type
%typeunion = (
    'void*' => 's_voidp',
    'bool' => 's_bool',
    'char' => 's_char',
    'uchar' => 's_uchar',
    'short' => 's_short',
    'ushort' => 's_ushort',
    'int' => 's_int',
    'uint' => 's_uint',
    'long' => 's_long',
    'ulong' => 's_ulong',
    'float' => 's_float',
    'double' => 's_double',
    'enum' => 's_enum',
    'class' => 's_class'
);

# Mapping for iterproto, when making up the munged method names
%mungedTypeMap = (
     'TQString' => '$',
     'TQString*' => '$',
     'TQString&' => '$',
     'TQCString' => '$',
     'TQCString*' => '$',
     'TQCString&' => '$',
     'TQByteArray' => '$',
     'TQByteArray&' => '$',
     'TQByteArray*' => '$',
     'char*' => '$',
     'TQCOORD*' => '?',
     'TQRgb*' => '?',
);

# Yes some of this is in kalyptusDataDict's ctypemap
# but that one would need to be separated (builtins vs normal classes)
%typedeflist =
(
   'signed char' => 'char',
   'unsigned char' => 'uchar',
   'signed short' => 'short',
   'unsigned short' => 'ushort',
   'signed' => 'int',
   'signed int' => 'int',
   'unsigned' => 'uint',
   'unsigned int' => 'uint',
   'KIO::filesize_t' => 'long',
   'signed long' => 'long',
   'unsigned long' => 'ulong',

# Anything that is not known is mapped to void*, so no need for those here anymore
#   'TQWSEvent*'  =>  'void*',
#   'TQDiskFont*'  =>  'void*',
#   'XEvent*'  =>  'void*',
#   'FILE*'  =>  'void*',
#   'TQUnknownInterface*'  =>  'void*',
#   'GDHandle'  =>  'void*',
#   '_NPStream*'  =>  'void*',
#   'TQTextFormat*'  =>  'void*',
#   'TQTextDocument*'  =>  'void*',
#   'TQTextCursor*'  =>  'void*',
#   'TQTextParag**'  =>  'void*',
#   'TQTextParag*'  =>  'void*',
#   'TQRemoteInterface*'  =>  'void*',
#   'TQSqlRecordPrivate*'  =>  'void*',
#   'TQTSMFI'  =>  'void*', # TQTextStream's TQTSManip
#   'const GUID&'  =>  'void*',
#   'TQWidgetMapper*'  =>  'void*',
#   'MSG*'  =>  'void*',
#   'const TQSqlFieldInfoList&'  =>  'void*', # TQSqlRecordInfo - TODO (templates)

   'TQStyleHintReturn*'  =>  'void*',
   'TQPtrCollection::Item'  =>  'void*', # to avoid a warning

   'mode_t'  =>  'long',
   'TQProcess::PID'  =>  'long',
   'size_type'  =>  'int', # TQSqlRecordInfo
   'TQt::ComparisonFlags'  =>  'uint',
   'TQt::ToolBarDock'  =>  'int', # compat thing, Qt shouldn't use it
   'TQIODevice::Offset'  =>  'ulong',
   'WState'  =>  'int',
   'WId'  =>  'ulong',
   'TQRgb'  =>  'uint',
   'ksocklen_t' => 'uint',
   'TQCOORD'  =>  'int',
   'TQTSMFI'  =>  'int',
   'TQt::WState'  =>  'int',
   'TQt::WFlags'  =>  'int',
   'TQt::HANDLE' => 'uint',
   'TQEventLoop::ProcessEventsFlags' => 'uint',
   'TQStyle::SCFlags' => 'int',
   'TQStyle::SFlags' => 'int',
   'Q_INT16' => 'short',
   'Q_INT32' => 'int',
   'Q_INT64' => 'long',
   'Q_INT8' => 'char',
   'Q_LONG' => 'long',
   'Q_LLONG' => 'long',
   'Q_ULLONG' => 'long',
   'Q_UINT16' => 'ushort',
   'Q_UINT32' => 'uint',
   'Q_UINT64' => 'long',
   'Q_UINT8' => 'uchar',
   'Q_ULONG' => 'long',
   'pid_t' => 'int',
   'size_t' => 'int',
   'pid_t' => 'int',
   'time_t' => 'int',
   'short int' => 'short',
   'unsigned long long int' => 'ulong',
   'long long int' => 'long',
   'signed long int' => 'long',
   'unsigned long int' => 'ulong',
   'int long' => 'long',
   'unsigned short int' => 'ushort',
);

%operatorNames =
(
    'operator^' => 'op_xor',
    'operator^=' => 'op_xor_assign',
    'operator<' => 'op_lt',
    'operator<<' => 'op_write',
    'operator<=' => 'op_lte',
#    'operator=' => 'op_assign',
    'operator==' => 'op_equals',
    'operator>' => 'op_gt',
    'operator>=' => 'op_gte',
    'operator>>' => 'op_read',
    'operator|' => 'op_or',
    'operator|=' => 'op_or_assign',
    'operator-' => 'op_minus',
    'operator-=' => 'op_minus_assign',
    'operator--' => 'op_decr',
    'operator!' => 'op_not',
    'operator!=' => 'op_not_equals',
    'operator/' => 'op_div',
    'operator/=' => 'op_div_assign',
    'operator()' => 'op_expr',
    'operator[]' => 'op_at',
    'operator*' => 'op_mult',
    'operator*=' => 'op_mult_assign',
    'operator&' => 'op_and',
    'operator&=' => 'op_and_assign',
    'operator+' => 'op_plus',
    'operator+=' => 'op_plus_assign',
    'operator++' => 'op_incr',
);

%skippedJniMethods =
(
	'Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2Z' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2I' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication___3I_3Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication___3I_3Ljava_lang_String_2Z' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication___3I_3Ljava_lang_String_2I' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication__I_3Ljava_lang_String_2I' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication__I_3Ljava_lang_String_2Z' => 1,
	'Java_org_kde_qt_QApplication_newTQApplication__I_3Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QApplication_args__' => 1,
	'Java_org_kde_qt_QBitmap_newTQBitmap__Lorg_kde_qt_QPixmap_2' => 1,
	'Java_org_kde_qt_QBitmap_newTQBitmap__Lorg_kde_qt_QImage_2' => 1,
	'Java_org_kde_qt_QListView_itemList' => 1,
	'Java_org_kde_qt_QListViewItem_itemList' => 1,
	'Java_org_kde_qt_Qt_color0' => 1,
	'Java_org_kde_qt_Qt_color1' => 1,
	'Java_org_kde_qt_Qt_black' => 1,
	'Java_org_kde_qt_Qt_white' => 1,
	'Java_org_kde_qt_Qt_darkGray' => 1,
	'Java_org_kde_qt_Qt_lightGray' => 1,
	'Java_org_kde_qt_Qt_gray' => 1,
	'Java_org_kde_qt_Qt_red' => 1,
	'Java_org_kde_qt_Qt_green' => 1,
	'Java_org_kde_qt_Qt_blue' => 1,
	'Java_org_kde_qt_Qt_cyan' => 1,
	'Java_org_kde_qt_Qt_magenta' => 1,
	'Java_org_kde_qt_Qt_yellow' => 1,
	'Java_org_kde_qt_Qt_darkRed' => 1,
	'Java_org_kde_qt_Qt_darkGreen' => 1,
	'Java_org_kde_qt_Qt_darkBlue' => 1,
	'Java_org_kde_qt_Qt_darkCyan' => 1,
	'Java_org_kde_qt_Qt_darkMagenta' => 1,
	'Java_org_kde_qt_Qt_darkYellow' => 1,
	'Java_org_kde_qt_Qt_arrowCursor' => 1,
	'Java_org_kde_qt_Qt_upArrowCursor' => 1,
	'Java_org_kde_qt_Qt_crossCursor' => 1,
	'Java_org_kde_qt_Qt_waitCursor' => 1,
	'Java_org_kde_qt_Qt_ibeamCursor' => 1,
	'Java_org_kde_qt_Qt_sizeVerCursor' => 1,
	'Java_org_kde_qt_Qt_sizeHorCursor' => 1,
	'Java_org_kde_qt_Qt_sizeBDiagCursor' => 1,
	'Java_org_kde_qt_Qt_sizeFDiagCursor' => 1,
	'Java_org_kde_qt_Qt_sizeAllCursor' => 1,
	'Java_org_kde_qt_Qt_blankCursor' => 1,
	'Java_org_kde_qt_Qt_splitVCursor' => 1,
	'Java_org_kde_qt_Qt_splitHCursor' => 1,
	'Java_org_kde_qt_Qt_pointingHandCursor' => 1,
	'Java_org_kde_qt_Qt_forbiddenCursor' => 1,
	'Java_org_kde_qt_Qt_qApp' => 1,
	'Java_org_kde_qt_Qt_qDebug' => 1,
	'Java_org_kde_qt_Qt_qWarning' => 1,
	'Java_org_kde_qt_Qt_qFatal' => 1,
	'Java_org_kde_qt_QObject_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QObject_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QObject_disconnect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QObject_disconnect__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QObject_emit' => 1,
	'Java_org_kde_qt_QWidget_paintDevice' => 1,
	'Java_org_kde_qt_QImage_bits__' => 1,
	'Java_org_kde_qt_QImage_colorTable__' => 1,
	'Java_org_kde_qt_QImage_scanLine__I' => 1,
	'Java_org_kde_qt_QPixmap_paintDevice' => 1,
	'Java_org_kde_qt_QPixmap_loadFromData___3C' => 1,
	'Java_org_kde_qt_QPaintDevice_paintDevice' => 1,
	'Java_org_kde_qt_QDragObject_mimeSource' => 1,
	'Java_org_kde_qt_QPointArray_point__I_3I_3I' => 1,
	'Java_org_kde_qt_QPointArray_setPoints__I_3S' => 1,
	'Java_org_kde_qt_QPointArray_putPoints__II_3S' => 1,
	'Java_org_kde_qt_QPointArray_count__' => 1,
	'Java_org_kde_qt_QPointArray_isEmpty__' => 1,
	'Java_org_kde_qt_QPointArray_isNull__' => 1,
	'Java_org_kde_qt_QPointArray_resize__' => 1,
	'Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II' => 1,
	'Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QPopupMenu_connectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QPopupMenu_disconnectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II' => 1,
	'Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_connectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuData_disconnectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II' => 1,
	'Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_connectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QMenuBar_disconnectItem__ILorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QUriDrag_decode__Lorg_kde_qt_QMimeSourceInterface_2_3Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QUriDrag_decodeToUnicodeUris__Lorg_kde_qt_QMimeSourceInterface_2_3Ljava_lang_String_2' => 1,
	'Java_org_kde_qt_QUriDrag_decodeLocalFiles__Lorg_kde_qt_QMimeSourceInterface_2_3Ljava_lang_String_2' => 1,
	'Java_org_kde_koala_KApplication_setJavaSlotFactory' => 1,
	'Java_org_kde_koala_KMainWindow_memberList' => 1,
	'Java_org_kde_koala_KCmdLineArgs_init__I_3Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2' => 1,
	'Java_org_kde_koala_KCmdLineArgs_init__I_3Ljava_lang_String_2Lorg_kde_koala_KAboutData_2' => 1,
	'Java_org_kde_koala_KCmdLineArgs_init__I_3Ljava_lang_String_2Lorg_kde_koala_KAboutData_2Z' => 1,
	'Java_org_kde_koala_KCmdLineArgs_init__I_3Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Z' => 1,
	'Java_org_kde_koala_Scheduler_connect__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_koala_Scheduler_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Ljava_lang_String_2' => 1,
	'Java_org_kde_koala_Scheduler_disconnect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2' => 1,
	'Java_org_kde_koala_Scheduler_disconnect' => 1,
);	
	
	$qapplicationExtras = <<EOF;
	public native String[] args();

EOF
	
	$qapplicationjniExtras = <<EOF;
static jobjectArray _args = 0;

JNIEXPORT void JNICALL
Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2(JNIEnv *env, jobject obj, jobjectArray args)
{
	int argc = (int) env->GetArrayLength(args) + 1;
	_args = (jobjectArray) env->NewGlobalRef(args);
 	if (QtSupport::getQt(env, obj) == 0) {
 		QtSupport::setQt(env, obj, new TQApplicationJBridge(argc, QtSupport::toArgv(env, args)));
 		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
 	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2Z(JNIEnv *env, jobject obj, jobjectArray args, jboolean GUIenabled)
{
	int argc = (int) env->GetArrayLength(args) + 1;
	_args = (jobjectArray) env->NewGlobalRef(args);
 	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new TQApplicationJBridge(argc, QtSupport::toArgv(env, args), (bool) GUIenabled));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
 	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QApplication_newTQApplication___3Ljava_lang_String_2I(JNIEnv *env, jobject obj, jobjectArray args, jint arg1)
{
	int argc = (int) env->GetArrayLength(args) + 1;
	_args = (jobjectArray) env->NewGlobalRef(args);
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new TQApplicationJBridge(argc, QtSupport::toArgv(env, args), (TQApplication::Type) arg1));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
 	}
	return;
}

JNIEXPORT jobjectArray JNICALL
Java_org_kde_qt_QApplication_args(JNIEnv *env, jobject obj)
{
	(void) env;
	(void) obj;
	return _args;
}

EOF
	
	$qbitmapExtras = <<EOF;
	public TQBitmap(TQPixmap arg1) {
		super((Class) null);
		newTQBitmap(arg1);
	}
	private native void newTQBitmap(TQPixmap arg1);
	public TQBitmap(TQImage arg1) {
		super((Class) null);
		newTQBitmap(arg1);
	}
	private native void newTQBitmap(TQImage arg1);
	
EOF
	
	$qbitmapjniExtras = <<EOF;
JNIEXPORT void JNICALL
Java_org_kde_qt_QBitmap_newTQBitmap__Lorg_kde_qt_QPixmap_2(JNIEnv *env, jobject obj, jobject arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		TQBitmap temp;
		temp = (TQPixmap&) *(TQPixmap *) QtSupport::getQt(env, arg1);
		QtSupport::setQt(env, obj, new TQBitmapJBridge(temp));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QBitmap_newTQBitmap__Lorg_kde_qt_QImage_2(JNIEnv *env, jobject obj, jobject arg1)
{
	if (QtSupport::getQt(env, obj) == 0) {
		TQBitmap temp;
		temp = (TQImage&) *(TQImage *) QtSupport::getQt(env, arg1);
		QtSupport::setQt(env, obj, new TQBitmapJBridge(temp));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

EOF

	$qlistviewExtras = <<EOF;
	public native ArrayList itemList();

EOF
	
	$qlistviewjniExtras = <<EOF;
JNIEXPORT jobject JNICALL
Java_org_kde_qt_QListView_itemList(JNIEnv *env, jobject obj)
{
	TQListViewItemIterator iterator((TQListView*) QtSupport::getQt(env, obj));
	return QtSupport::arrayWithTQListViewItemList(env, &iterator);
}

EOF
	$qlistviewitemExtras = <<EOF;
	public native ArrayList itemList();

EOF
	
	$qlistviewitemjniExtras = <<EOF;
JNIEXPORT jobject JNICALL
Java_org_kde_qt_QListViewItem_itemList(JNIEnv *env, jobject obj)
{
	TQListViewItemIterator iterator((TQListViewItem*) QtSupport::getQt(env, obj));
	return QtSupport::arrayWithTQListViewItemList(env, &iterator);
}

EOF

	$qtExtras = <<EOF;
	/** This member allows a typecast of an instance which wraps a Qt instance,
		to a more specialized type. Invokes the private qtjava.dynamicCast()
		via reflection, as that method isn't part of the public Qt api */
	public static QtSupport dynamicCast(String type, QtSupport source) {
		Method		method = null;
		
		try {
			method = qtjava.class.getDeclaredMethod(	"dynamicCast",
														new Class[] { String.class, QtSupport.class } );
		} catch (NoSuchMethodException e1) {
			Qt.qWarning("No such method : qtjava.dynamicCast()");
		}

		try {
			method.setAccessible(true);
			Object result = method.invoke(qtjava.class, new Object[] { type, source } );
			return (QtSupport) result;
		} catch (InvocationTargetException e) {
			Qt.qWarning("Invocation failed : qtjava.dynamicCast()");
			return null;
		} catch (IllegalAccessException e) {
			Qt.qWarning("Invocation failed : qtjava.dynamicCast()");
			return null;
		}
	}
	
	public static native TQColor color0();
	public static native TQColor color1();
	public static native TQColor black();
	public static native TQColor white();
	public static native TQColor darkGray();
	public static native TQColor gray();
	public static native TQColor lightGray();
	public static native TQColor red();
	public static native TQColor green();
	public static native TQColor blue();
	public static native TQColor cyan();
	public static native TQColor magenta();
	public static native TQColor yellow();
	public static native TQColor darkRed();
	public static native TQColor darkGreen();
	public static native TQColor darkBlue();
	public static native TQColor darkCyan();
	public static native TQColor darkMagenta();
	public static native TQColor darkYellow();
	
    // Global cursors

	public static native TQCursor arrowCursor();	// standard arrow cursor
	public static native TQCursor upArrowCursor();	// upwards arrow
	public static native TQCursor crossCursor();	// crosshair
	public static native TQCursor waitCursor();	// hourglass/watch
	public static native TQCursor ibeamCursor();	// ibeam/text entry
	public static native TQCursor sizeVerCursor();	// vertical resize
	public static native TQCursor sizeHorCursor();	// horizontal resize
	public static native TQCursor sizeBDiagCursor();	// diagonal resize (/)
	public static native TQCursor sizeFDiagCursor();	// diagonal resize (\)
	public static native TQCursor sizeAllCursor();	// all directions resize
	public static native TQCursor blankCursor();	// blank/invisible cursor
	public static native TQCursor splitVCursor();	// vertical bar with left-right
						// arrows
	public static native TQCursor splitHCursor();	// horizontal bar with up-down
						// arrows
	public static native TQCursor pointingHandCursor();	// pointing hand
	public static native TQCursor forbiddenCursor();	// forbidden cursor (slashed circle)
	public static native TQCursor whatsThisCursor();	// arrow with a question mark
	
	public static native TQApplication qApp();
	
	public static native void qDebug(String message);
	public static void qDebug(String pattern, Object[] arguments) {
		qDebug(MessageFormat.format(pattern, arguments));
	}
	
	public static native void qWarning(String message);
	public static void qWarning(String pattern, Object[] arguments) {
		qWarning(MessageFormat.format(pattern, arguments));
	}
	
	public static native void qFatal(String message);
	public static void qFatal(String pattern, Object[] arguments) {
		qFatal(MessageFormat.format(pattern, arguments));
	}
	
	private static String sqeezeOut(String from, char toss) {
		char[] chars = from.toCharArray();
		int len = chars.length;
		int put = 0;
		
		for (int i = 0; i < len; i++) {
			if (chars[i] != toss) {
				chars[put++] = chars[i];
			}
		}
		
		return new String(chars, 0, put);
	}
	
	/** Prepend a '2' to a signal string and remove any spaces */
	public static String SIGNAL(String signal) {
		return "2" + sqeezeOut(signal, ' ');
	}
	
	/** Prepend a '1' to a slot string and remove any spaces */
	public static String SLOT(String slot) {
		return "1" + sqeezeOut(slot, ' ');
	}
	
	/** Convert from a UTF-8 string to Unicode - the java equivalent to TQString::fromUtf8() */
	public String fromUtf8(byte[] bytes) {
		String result = null;
		
		try {
			result = new String(bytes, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			qWarning("UTF-8 encoding not supported");
		} finally {
			return result;
		}
	}
	
EOF

	$qtjniExtras = <<EOF;
#include <qapplication.h>
#include <qstring.h>
#include <qcstring.h>

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_color0(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::color0, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_color1(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::color1, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_black(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::black, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_white(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::white, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkGray(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkGray, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_lightGray(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::lightGray, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_gray(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::gray, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_red(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::red, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_green(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::green, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_blue(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::blue, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_cyan(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::cyan, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_magenta(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::magenta, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_yellow(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::yellow, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkRed(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkRed, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkGreen(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkGreen, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkBlue(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkBlue, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkCyan(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkCyan, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkMagenta(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkMagenta, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_darkYellow(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::darkYellow, "org.kde.qt.TQColor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_arrowCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::arrowCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_upArrowCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::upArrowCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_crossCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::crossCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_waitCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::waitCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_ibeamCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::ibeamCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_sizeVerCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::sizeVerCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_sizeHorCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::sizeHorCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_sizeBDiagCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::sizeBDiagCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_sizeFDiagCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::sizeFDiagCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_sizeAllCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::sizeAllCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_blankCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::blankCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_splitVCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::splitVCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_splitHCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::splitHCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_pointingHandCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::pointingHandCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_forbiddenCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::forbiddenCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_whatsThisCursor(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, (void*)&TQt::whatsThisCursor, "org.kde.qt.TQCursor");
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_Qt_qApp(JNIEnv* env, jclass cls)
{
	(void) cls;
	return (jobject) QtSupport::objectForQtKey(env, qApp, "org.kde.qt.TQApplication");
}

JNIEXPORT void JNICALL
Java_org_kde_qt_Qt_qDebug(JNIEnv* env, jclass cls, jstring message)
{
static TQCString * _qstring_message = 0;
	(void) cls;
	qDebug("%s", (const char *) QtSupport::toCharString(env, message, &_qstring_message));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_Qt_qWarning(JNIEnv* env, jclass cls, jstring message)
{
static TQCString * _qstring_message = 0;
	(void) cls;
	qWarning("%s", (const char *) QtSupport::toCharString(env, message, &_qstring_message));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_Qt_qFatal(JNIEnv* env, jclass cls, jstring message)
{
static TQCString * _qstring_message = 0;
	(void) cls;
	qFatal("%s", (const char *) QtSupport::toCharString(env, message, &_qstring_message));
	return;
}

EOF

	$qobjectExtras = <<EOF;
	/** i18n() is just a synonym of tr() for now */
    public static String i18n(String s) {
      return tr(s);
	}
	
	public native void emit(String signal, Object[] args);

	protected void emit(String signal) {
		Object[] args = new Object[0];
		emit("2" + signal.trim() + "()", args);
	}

	protected void emit(String signal, Object value) {
		Object[] args = new Object[1];
		args[0] = value;
		emit("2" + signal.trim() + "(" + value.getClass().getName() + ")", args);
	}

	protected void emit(String signal, Object value1, Object value2) {
		Object[] args = new Object[2];
		args[0] = value1;
		args[1] = value2;
		emit("2" + signal.trim() + "(" 	+ value1.getClass().getName() + ","
										+ value2.getClass().getName()
										+ ")", args);
	}

	protected void emit(String signal, Object value1, Object value2, Object value3) {
		Object[] args = new Object[3];
		args[0] = value1;
		args[1] = value2;
		args[2] = value3;
		emit("2" + signal.trim() + "("	+ value1.getClass().getName() + ","
										+ value2.getClass().getName() + ","
										+ value3.getClass().getName()
										+ ")", args);
	}

	protected void emit(String signal, Object value1, Object value2, Object value3, Object value4) {
		Object[] args = new Object[4];
		args[0] = value1;
		args[1] = value2;
		args[2] = value3;
		args[3] = value4;
		emit("2" + signal.trim() + "("	+ value1.getClass().getName() + ","
										+ value2.getClass().getName() + ","
										+ value3.getClass().getName() + ","
										+ value4.getClass().getName()
										+ ")", args);
	}

	protected void emit(String signal, boolean value) {
		Object[] args = new Object[1];
		args[0] = new Boolean(value);
		emit("2" + signal.trim() + "(boolean)", args);
	}
	
	protected void emit(String signal, char value) {
		Object[] args = new Object[1];
		args[0] = new Character(value);
		emit("2" + signal.trim() + "(char)", args);
	}
	
	protected void emit(String signal, byte value) {
		Object[] args = new Object[1];
		args[0] = new Byte(value);
		emit("2" + signal.trim() + "(byte)", args);
	}

	protected void emit(String signal, short value) {
		Object[] args = new Object[1];
		args[0] = new Short(value);
		emit("2" + signal.trim() + "(short)", args);
	}
	
	protected void emit(String signal, int value) {
		Object[] args = new Object[1];
		args[0] = new Integer(value);
		emit("2" + signal.trim() + "(int)", args);
	}
	
	protected void emit(String signal, int value1, int value2) {
		Object[] args = new Object[2];
		args[0] = new Integer(value1);
		args[1] = new Integer(value2);
		emit("2" + signal.trim() + "(int,int)", args);
	}

	protected void emit(String signal, Object value1, int value2) {
		Object[] args = new Object[2];
		args[0] = value1;
		args[1] = new Integer(value2);
		emit("2" + signal.trim() + "(" 	+ value1.getClass().getName() + ","
										+ "int"
										+ ")", args);
	}

	protected void emit(String signal, int value1, int value2, int value3) {
		Object[] args = new Object[3];
		args[0] = new Integer(value1);
		args[1] = new Integer(value2);
		args[2] = new Integer(value3);
		emit("2" + signal.trim() + "(int,int,int)", args);
	}

	protected void emit(String signal, int value1, int value2, int value3, Object value4) {
		Object[] args = new Object[4];
		args[0] = new Integer(value1);
		args[1] = new Integer(value2);
		args[2] = new Integer(value3);
		args[3] = value4;
		emit("2" + signal.trim() + "(int,int,int," + value4.getClass().getName() + ")", args);
	}

	protected void emit(String signal, int value1, Object value2, Object value3) {
		Object[] args = new Object[3];
		args[0] = new Integer(value1);
		args[1] = value2;
		args[2] = value3;
		emit("2" + signal.trim()	+ "(int,"
									+ value2.getClass().getName() + ","
									+ value3.getClass().getName()
									+ ")", args);
	}

	protected void emit(String signal, int value1, Object value2, Object value3, int value4) {
		Object[] args = new Object[4];
		args[0] = new Integer(value1);
		args[1] = value2;
		args[2] = value3;
		args[3] = new Integer(value4);
		emit("2" + signal.trim()	+ "(int,"
									+ value2.getClass().getName() + ","
									+ value3.getClass().getName()
									+ ",int)", args);
	}
	
	protected void emit(String signal, int value1, boolean value2) {
		Object[] args = new Object[2];
		args[0] = new Integer(value1);
		args[1] = new Boolean(value2);
		emit("2" + signal.trim() + "(int,boolean)", args);
	}

	protected void emit(String signal, long value) {
		Object[] args = new Object[1];
		args[0] = new Long(value);
		emit("2" + signal.trim() + "(long)", args);
	}

	protected void emit(String signal, float value) {
		Object[] args = new Object[1];
		args[0] = new Float(value);
		emit("2" + signal.trim() + "(float)", args);
	}

	protected void emit(String signal, double value) {
		Object[] args = new Object[1];
		args[0] = new Double(value);
		emit("2" + signal.trim() + "(double)", args);
	}

	protected void emit(String signal, Object value1, int value2, int value3) {
		Object[] args = new Object[3];
		args[0] = value1;
		args[1] = new Integer(value2);
		args[2] = new Integer(value3);
		emit("2" + signal.trim() + "(" + value1.getClass().getName() + ",int,int)", args);
	}	

EOF

	$qobjectjniExtras = <<EOF;
JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QObject_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv* env, jclass cls, jobject sender, jstring signal, jobject receiver, jstring member)
{
	(void) cls;
	return (jboolean) QtSupport::connect(env, sender, signal, receiver, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QObject_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv* env, jobject obj, jobject sender, jstring signal, jstring member)
{
	return (jboolean) QtSupport::connect(env, sender, signal, obj, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QObject_disconnect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jclass cls, jobject sender, jstring signal, jobject receiver, jstring member)
{
	(void) cls;
	return (jboolean) QtSupport::disconnect(env, sender, signal, receiver, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QObject_disconnect__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv* env, jobject obj, jstring signal, jobject receiver, jstring member)
{
	return (jboolean) QtSupport::disconnect(env, obj, signal, receiver, member);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QObject_emit(JNIEnv* env, jobject obj, jstring signal, jobjectArray args)
{
	QtSupport::emitJavaSignal(env, obj, signal, args);
	return;
}
	
EOF

	$qwidgetExtras = <<EOF;
	/** Internal method */
	protected native long paintDevice();

EOF

	$qwidgetjniExtras = <<EOF;
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QWidget_paintDevice(JNIEnv* env, jobject obj)
{
	return (jlong) (TQPaintDevice*)(TQWidget*) QtSupport::getQt(env, obj);
}

EOF
	
	$qimagejniExtras = <<EOF;
JNIEXPORT jbyteArray JNICALL
Java_org_kde_qt_QImage_bits(JNIEnv *env, jobject obj)
{
static uchar * ptr = 0;
	ptr = ((TQImageJBridge*) QtSupport::getQt(env, obj))->bits();
	int len = ((TQImageJBridge*) QtSupport::getQt(env, obj))->numBytes();
	jbyteArray result = env->NewByteArray(len);
	env->SetByteArrayRegion(result, 0, len, (jbyte *) ptr);
	return result;
}

JNIEXPORT jbyteArray JNICALL
Java_org_kde_qt_QImage_scanLine(JNIEnv *env, jobject obj, jint arg1)
{
static uchar * ptr = 0;
	ptr = ((TQImageJBridge*) QtSupport::getQt(env, obj))->scanLine(arg1);
	int len = ((TQImageJBridge*) QtSupport::getQt(env, obj))->numBytes() / ((TQImageJBridge*) QtSupport::getQt(env, obj))->height();
	jbyteArray result = env->NewByteArray(len);
	env->SetByteArrayRegion(result, 0, len, (jbyte *) ptr);
	return result;
}

JNIEXPORT jintArray JNICALL
Java_org_kde_qt_QImage_colorTable(JNIEnv *env, jobject obj)
{
static TQRgb * ptr = 0;
	ptr = ((TQImageJBridge*) QtSupport::getQt(env, obj))->colorTable();
	int len = ((TQImageJBridge*) QtSupport::getQt(env, obj))->numColors();
	jintArray result = env->NewIntArray(len);
	env->SetIntArrayRegion(result, 0, len, (jint *) ptr);
	return result;
}

EOF

	$qpixmapExtras = <<EOF;
	public native boolean loadFromData(char[] data);
	
	/** Internal method */
	protected native long paintDevice();

EOF

	$qpixmapjniExtras = <<EOF;
JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPixmap_loadFromData___3C(JNIEnv *env, jobject obj, jcharArray data)
{
static TQByteArray * _qbyteArray_data = 0;
	return (jboolean) ((TQPixmapJBridge*) QtSupport::getQt(env, obj))->loadFromData((uchar *) QtSupport::toUcharArray(env, data, &_qbyteArray_data), env->GetArrayLength(data), 0, 0);
}
	
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QPixmap_paintDevice(JNIEnv* env, jobject obj)
{
	return (jlong) (TQPaintDevice*)(TQPixmap*) QtSupport::getQt(env, obj);
}

EOF

	$qpaintdeviceExtras = <<EOF;
	/** Internal method */
	protected native long paintDevice();

EOF

	$qpaintdevicejniExtras = <<EOF;
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QPaintDevice_paintDevice(JNIEnv* env, jobject obj)
{
	return (jlong) (TQPaintDevice *) QtSupport::getQt(env, obj);
}

EOF

	$qdragobjectExtras = <<EOF;
	/** Internal method */
	protected native long mimeSource();

EOF
	
	$qdragobjectjniExtras = <<EOF;
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QDragObject_mimeSource(JNIEnv* env, jobject obj)
{
	return (jlong) (TQMimeSource*) (TQDragObject*) QtSupport::getQt(env, obj);
}

EOF
		
	$qdropeventExtras = <<EOF;
	/** Internal method */
	protected native long mimeSource();
	
EOF
	
	$qdropeventjniExtras = <<EOF;
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QDropEvent_mimeSource(JNIEnv* env, jobject obj)
{
	return (jlong) (TQMimeSource*) (TQDropEvent*) QtSupport::getQt(env, obj);
}

EOF
	
	$qmimesourceExtras = <<EOF;
	/** Internal method */
	protected native long mimeSource();

EOF
	
	$qmimesourcejniExtras = <<EOF;
JNIEXPORT jlong JNICALL
Java_org_kde_qt_QMimeSource_mimeSource(JNIEnv* env, jobject obj)
{
	return (jlong) (TQMimeSource *) QtSupport::getQt(env, obj);
}

EOF
	
	$qiodeviceExtras = <<EOF;
	public static final int IO_Direct = 0x0100;		// direct access device
	public static final int IO_Sequential		= 0x0200;		// sequential access device
	public static final int IO_Combined		= 0x0300;		// combined direct/sequential
	public static final int IO_TypeMask		= 0x0f00;

// IO handling modes

	public static final int IO_Raw			= 0x0040;		// raw access (not buffered)
	public static final int IO_Async		= 0x0080;		// asynchronous mode

// IO device open modes

	public static final int IO_ReadOnly		= 0x0001;		// readable device
	public static final int IO_WriteOnly		= 0x0002;		// writable device
	public static final int IO_ReadWrite		= 0x0003;		// read+write device
	public static final int IO_Append		= 0x0004;		// append
	public static final int IO_Truncate		= 0x0008;		// truncate device
	public static final int IO_Translate		= 0x0010;		// translate CR+LF
	public static final int IO_ModeMask		= 0x00ff;

// IO device state

	public static final int IO_Open			= 0x1000;		// device is open
	public static final int IO_StateMask		= 0xf000;


// IO device status

	public static final int IO_Ok			= 0;
	public static final int IO_ReadError		= 1;		// read error
	public static final int IO_WriteError		= 2;		// write error
	public static final int IO_FatalError		= 3;		// fatal unrecoverable error
	public static final int IO_ResourceError	= 4;		// resource limitation
	public static final int IO_OpenError		= 5;		// cannot open device
	public static final int IO_ConnectError		= 5;		// cannot connect to device
	public static final int IO_AbortError		= 6;		// abort error
	public static final int IO_TimeOutError		= 7;		// time out
	public static final int IO_UnspecifiedError	= 8;		// unspecified error

EOF
	
	$qpointarrayExtras = <<EOF;
	public native int size();
	public native int count();
	public native boolean isEmpty();
	public native boolean isNull();
	public native boolean resize( int size);
	public native boolean truncate( int pos);
	public native int begin();
	public native int end();
	public native TQPoint at(int index);
	
EOF
		
	$qpointarrayjniExtras = <<EOF;
JNIEXPORT void JNICALL
Java_org_kde_qt_QPointArray_point__I_3I_3I(JNIEnv *env, jobject obj, jint i, jintArray x, jintArray y)
{
	int argx;
	int argy;
	((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->point((uint) i,  &argx,  &argy);
	env->SetIntArrayRegion(x, 0, 1, (jint *) &argx);
	env->SetIntArrayRegion(y, 0, 1, (jint *) &argy);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_setPoints(JNIEnv *env, jobject obj, jint nPoints, jshortArray points)
{
	if (!((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->resize((uint)nPoints)) {
		return JNI_FALSE;
	}

	short *	shortArray = QtSupport::toShortPtr(env, points);
	for (int index = 0; index < nPoints; index++) {
		((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->setPoint(index, shortArray[index * 2], shortArray[(index * 2) + 1]);
	}
	return JNI_TRUE;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_putPoints__II_3S(JNIEnv *env, jobject obj, jint index, jint nPoints, jshortArray points)
{
	if (	((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->size() < (uint) nPoints
			&& !((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->resize((uint) nPoints) )
	{
		return JNI_FALSE;
	}

	short *	shortArray = QtSupport::toShortPtr(env, points);
	for (int i = (int) index; nPoints > 0; i++, nPoints--) {
		((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->setPoint(i, shortArray[i * 2], shortArray[(i * 2) + 1]);
	}
	return JNI_TRUE;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPointArray_size(JNIEnv* env, jobject obj)
{
	return (jint) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->size();
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPointArray_count(JNIEnv* env, jobject obj)
{
	return (jint) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->count();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_isEmpty(JNIEnv* env, jobject obj)
{
	return (jboolean) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->isEmpty();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_isNull(JNIEnv* env, jobject obj)
{
	return (jboolean) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->isNull();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_resize(JNIEnv* env, jobject obj, jint size)
{
	return (jboolean) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->resize((uint) size);
}
JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPointArray_truncate(JNIEnv *env, jobject obj, jint pos)
{
	return (jboolean) ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->truncate((uint) pos);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QPointArray_at(JNIEnv * env, jobject obj, jint index)
{
	TQPoint _p= ((TQPointArrayJBridge*) QtSupport::getQt(env, obj))->at((uint) index);
	return (jobject) QtSupport::objectForQtKey(env, (void *)new TQPoint(_p.x(),_p.y()), "org.kde.qt.TQPoint", TRUE);
}
	
EOF

	$qpopupmenujniExtras = <<EOF;
JNIEXPORT jint JNICALL
Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member, jobject accel, jint identifier, jint index)
{
	identifier = Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2II(env, obj, text, identifier, index);

	if ((bool) Java_org_kde_qt_QPopupMenu_connectItem(env, obj, identifier, receiver, member)) {
		Java_org_kde_qt_QPopupMenu_setAccel(env, obj, accel, identifier);
	}

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QPopupMenu_insertItem__Ljava_lang_String_2II(env, obj, text, -1, -1);
	Java_org_kde_qt_QPopupMenu_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jstring text, jobject receiver, jstring member)
{
static TQString * _qstring_text = 0;
	jint identifier = Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2II(env, obj, icon, text, -1, -1);
	Java_org_kde_qt_QPopupMenu_connectItem(env, obj, identifier, receiver, member);
	
	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QPixmap_2II(env, obj, pixmap, -1, -1);
	Java_org_kde_qt_QPopupMenu_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QPopupMenu_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2II(env, obj, icon, pixmap, -1, -1);
	Java_org_kde_qt_QPopupMenu_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPopupMenu_connectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQPopupMenuJBridge*) QtSupport::getQt(env, obj))->connectItem(	identifier,
																			javaSlot,
																			javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QPopupMenu_disconnectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQPopupMenuJBridge*) QtSupport::getQt(env, obj))->disconnectItem(	identifier,
																				javaSlot,
																				javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}

EOF

	$qmenudatajniExtras = <<EOF;
JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member, jobject accel, jint identifier, jint index)
{
	identifier = Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2II(env, obj, text, identifier, index);

	if ((bool) Java_org_kde_qt_QMenuData_connectItem(env, obj, identifier, receiver, member)) {
		Java_org_kde_qt_QMenuData_setAccel(env, obj, accel, identifier);
	}

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuData_insertItem__Ljava_lang_String_2II(env, obj, text, -1, -1);
	Java_org_kde_qt_QMenuData_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jstring text, jobject receiver, jstring member)
{
static TQString * _qstring_text = 0;
	jint identifier = Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2II(env, obj, icon, text, -1, -1);
	Java_org_kde_qt_QMenuData_connectItem(env, obj, identifier, receiver, member);
	
	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QPixmap_2II(env, obj, pixmap, -1, -1);
	Java_org_kde_qt_QMenuData_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuData_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2II(env, obj, icon, pixmap, -1, -1);
	Java_org_kde_qt_QMenuData_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QMenuData_connectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQMenuDataJBridge*) QtSupport::getQt(env, obj))->connectItem(	identifier,
																			javaSlot,
																			javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QMenuData_disconnectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQMenuDataJBridge*) QtSupport::getQt(env, obj))->disconnectItem(	identifier,
																				javaSlot,
																				javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}

EOF

	$qmenubarjniExtras = <<EOF;
JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2Lorg_kde_qt_QKeySequence_2II(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member, jobject accel, jint identifier, jint index)
{
	identifier = Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2II(env, obj, text, identifier, index);

	if ((bool) Java_org_kde_qt_QMenuBar_connectItem(env, obj, identifier, receiver, member)) {
		Java_org_kde_qt_QMenuBar_setAccel(env, obj, accel, identifier);
	}

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring text, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuBar_insertItem__Ljava_lang_String_2II(env, obj, text, -1, -1);
	Java_org_kde_qt_QMenuBar_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jstring text, jobject receiver, jstring member)
{
static TQString * _qstring_text = 0;
	jint identifier = Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Ljava_lang_String_2II(env, obj, icon, text, -1, -1);
	Java_org_kde_qt_QMenuBar_connectItem(env, obj, identifier, receiver, member);
	
	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QPixmap_2II(env, obj, pixmap, -1, -1);
	Java_org_kde_qt_QMenuBar_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject icon, jobject pixmap, jobject receiver, jstring member)
{
	jint identifier = Java_org_kde_qt_QMenuBar_insertItem__Lorg_kde_qt_QIconSet_2Lorg_kde_qt_QPixmap_2II(env, obj, icon, pixmap, -1, -1);
	Java_org_kde_qt_QMenuBar_connectItem(env, obj, identifier, receiver, member);

	return identifier;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QMenuBar_connectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQMenuBarJBridge*) QtSupport::getQt(env, obj))->connectItem(	identifier,
																			javaSlot,
																			javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QMenuBar_disconnectItem(JNIEnv *env, jobject obj, jint identifier, jobject receiver, jstring member)
{
	JavaSlot * javaSlot = QtSupport::slotForReceiver(env, receiver, member);

	if (	((TQMenuBarJBridge*) QtSupport::getQt(env, obj))->disconnectItem(	identifier,
																				javaSlot,
																				javaSlot->javaToQtSlotName(env, member) ) )
	{
		return(jboolean) JNI_TRUE;
	} else {
		return (jboolean) JNI_FALSE;
	}
}


EOF

	$quridragExtras  = <<EOF;
	public static native boolean decode(TQMimeSourceInterface e, ArrayList i);
	public static native boolean decodeToUnicodeUris(TQMimeSourceInterface e, ArrayList i);
	public static native boolean decodeLocalFiles(TQMimeSourceInterface e, ArrayList i);
	
EOF

	$quridragjniExtras = <<EOF;
JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QUriDrag_decode(JNIEnv *env, jclass cls, jobject e, jobject i)
{
static TQStrList * _qlist_i = 0;
	if (_qlist_i == 0) {
		_qlist_i = new TQStrList();
	}
	(void) cls;
	jboolean result = (jboolean) TQUriDragJBridge::decode(QtSupport::mimeSource(env, e), *_qlist_i);
	QtSupport::arrayWithTQStrList(env, _qlist_i, i);
	return result;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QUriDrag_decodeToUnicodeUris(JNIEnv *env, jclass cls, jobject e, jobject i)
{
static TQStringList * _qlist_i = 0;
	if (_qlist_i == 0) {
		_qlist_i = new TQStringList();
	}
	(void) cls;
	jboolean result = (jboolean) TQUriDragJBridge::decodeToUnicodeUris(QtSupport::mimeSource(env, e), *_qlist_i);
	QtSupport::arrayWithTQStringList(env, _qlist_i, i);
	return result;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QUriDrag_decodeLocalFiles(JNIEnv *env, jclass cls, jobject e, jobject i)
{
static TQStringList * _qlist_i = 0;
	if (_qlist_i == 0) {
		_qlist_i = new TQStringList();
	}
	(void) cls;
	jboolean result = (jboolean) TQUriDragJBridge::decodeLocalFiles(QtSupport::mimeSource(env, e), *_qlist_i);
	QtSupport::arrayWithTQStringList(env, _qlist_i, i);
	return result;
}
	
EOF

	$kapplicationExtras = <<EOF;
	/**
		Used internally by the KDE Koala Java bindings runtime
	*/
	public static native void setJavaSlotFactory();
	
EOF

	$kapplicationjniExtras = <<EOF;
#include <kdejava/KDEJavaSlot.h>

JNIEXPORT void JNICALL
Java_org_kde_koala_KApplication_setJavaSlotFactory(JNIEnv* env, jclass cls)
{
	(void) env;
	(void) cls;
	JavaSlot::setJavaSlotFactory(new KDEJavaSlotFactory());
	return;
}
	
EOF
	
	$kmainwindowExtras = <<EOF;	
	/**
 		List of members of KMainWindow class.
	*/
	public native ArrayList memberList();
	
	public static void RESTORE(String typeName) {
		Class	savedClass;
		
		try {
			savedClass = Class.forName(typeName);
			int n = 1;
			while (KMainWindow.canBeRestored(n)){
				((KMainWindow) savedClass.newInstance()).restore(n);
				n++;
			}
		} catch(Exception e) {
			return;
		}
		
		return;
	}
	
EOF
	
	$kmainwindowjniExtras = <<EOF;
JNIEXPORT jobject JNICALL
Java_org_kde_koala_KMainWindow_memberList(JNIEnv* env, jobject obj)
{
	return (jobject) KDESupport::arrayWithKMainWindowList(env, KMainWindow::memberList);
}

EOF
	
	$kcmdlineargsjniExtras = <<EOF;
JNIEXPORT void JNICALL
Java_org_kde_koala_KCmdLineArgs_init___3Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv* env, jclass cls, jobjectArray args, jstring _appname, jstring programName, jstring _description, jstring _version)
{
	(void) cls;
static TQCString* _qstring__appname = 0;
static TQCString* _qstring_programName = 0;
static TQCString* _qstring__description = 0;
static TQCString* _qstring__version = 0;
	int argc = (int) env->GetArrayLength(args);
	KCmdLineArgsJBridge::init((int) argc+1, (char**) QtSupport::toArgv(env, args), (const char*) QtSupport::toCharString(env, _appname, &_qstring__appname), (const char*) QtSupport::toCharString(env, programName, &_qstring_programName), (const char*) QtSupport::toCharString(env, _description, &_qstring__description), (const char*) QtSupport::toCharString(env, _version, &_qstring__version));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KCmdLineArgs_init___3Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Z(JNIEnv* env, jclass cls, jobjectArray args, jstring _appname, jstring programName, jstring _description, jstring _version, jboolean noKApp)
{
	(void) cls;
static TQCString* _qstring__appname = 0;
static TQCString* _qstring_programName = 0;
static TQCString* _qstring__description = 0;
static TQCString* _qstring__version = 0;
	int argc = (int) env->GetArrayLength(args);
	KCmdLineArgsJBridge::init(argc+1, (char**) QtSupport::toArgv(env, args), (const char*) QtSupport::toCharString(env, _appname, &_qstring__appname), (const char*) QtSupport::toCharString(env, programName, &_qstring_programName), (const char*) QtSupport::toCharString(env, _description, &_qstring__description), (const char*) QtSupport::toCharString(env, _version, &_qstring__version), (bool) noKApp);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KCmdLineArgs_init___3Ljava_lang_String_2Lorg_kde_koala_KAboutData_2(JNIEnv* env, jclass cls, jobjectArray args, jobject about)
{
	(void) cls;
	int argc = (int) env->GetArrayLength(args);
	KCmdLineArgsJBridge::init(argc+1, (char**) QtSupport::toArgv(env, args), (const KAboutData*) QtSupport::getQt(env, about));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KCmdLineArgs_init___3Ljava_lang_String_2Lorg_kde_koala_KAboutData_2Z(JNIEnv* env, jclass cls, jobjectArray args, jobject about, jboolean noKApp)
{
	(void) cls;
	int argc = (int) env->GetArrayLength(args);
	KCmdLineArgsJBridge::init(argc+1, (char**) QtSupport::toArgv(env, args), (const KAboutData*) QtSupport::getQt(env, about), (bool) noKApp);
	return;
}

EOF

	$schedulerjniExtras = <<EOF;
JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_connect__Ljava_lang_String_2Lorg_kde_qt_QObject_2Ljava_lang_String_2(JNIEnv* env, jclass cls, jstring signal, jobject receiver, jstring member)
{
	(void) cls;
	JavaSlot *		javaSlot = QtSupport::slotForReceiver(env, receiver, member);
	TQString			qtSignalName(javaSlot->javaToQtSignalName(env, signal, 0));
	jboolean xret = (jboolean) SchedulerJBridge::connect((const char*) qtSignalName, (const TQObject*) javaSlot, javaSlot->javaToQtSlotName(env, member, qtSignalName));
	return xret;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_connect__Lorg_kde_qt_QObject_2Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject sender, jstring signal, jstring member)
{
	return QtSupport::connect(env, sender, signal, obj, member);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_Scheduler_disconnect(JNIEnv *env, jclass cls, jobject sender, jstring signal, jobject receiver, jstring member)
{
	(void) cls;
	return QtSupport::disconnect(env, sender, signal, receiver, member);
}

EOF

}

sub javaImport($)
{
	my ( $classname ) = @_;
	my $classname_ptr = $classname . "*";
	if ( cplusplusToJava($classname_ptr) eq "" or $classname eq $main::globalSpaceClassName ) {
		return "";
	} elsif ( cplusplusToJava($classname_ptr) eq "ArrayList" ) {
		return "java.util.ArrayList";
	} elsif ( cplusplusToJava($classname_ptr) eq "Calendar" ) {
		return "java.util.Calendar";
	} elsif ( cplusplusToJava($classname_ptr) eq "StringBuffer" ) {
		return "";
	} elsif ( cplusplusToJava($classname_ptr) eq "String" ) {
		return "";
	} elsif ( cplusplusToJava($classname_ptr) eq "String[][]" ) {
		return "";
	} elsif ( cplusplusToJava($classname_ptr) eq "String[]" ) {
		return "";
	} elsif ( cplusplusToJava($classname_ptr) eq "Date" ) {
		return "java.util.Date";
	} elsif ( cplusplusToJava($classname_ptr) =~ /^[a-z]/ ) {
		return "";
	} elsif ( $classname =~ /^Q/ ) {
		return "org.kde.qt." . $classname;
	} else {
		return "org.kde.koala." . $classname;
	}
}
	
sub cplusplusToJava
{
	my ( $cplusplusType )  = @_;
	my $isConst = ($cplusplusType =~ /const / or $cplusplusType !~ /[*&]/ ? 1 : 0);
	$cplusplusType =~ s/const //;
	$cplusplusType =~ s/^signed//;
	my $className = $cplusplusType;
	$className =~ s/[*&]//;
	
	if ( $cplusplusType =~ /void\*|DCOPArg|DCOPRef|^MSG\s*\*|TQGfx|^Display\s*\*|KHTMLPart::PageSecurity|TQFileInfoList|TQValueList<TQIconDragItem>|TQValueList<TQCString>|TQValueList<TQVariant>|TQValueList<TQPixmap>|TQValueListConstIterator<TQString>|TQMap|EditMode|TQPtrList<TQPixmap>|TQPtrList<TQPoint>|TQTextFormat|TQTextCursor|TQTextDocument|TQNetworkProtocolFactoryBase|TQDomNodePrivate|TQSqlDriverCreatorBase|TQSqlFieldInfoList|TQObjectUserData|TQUObject|TQTextParag|TQWidgetMapper|TQMemArray<int>|TQBitArray|TQLayoutIterator|TQAuBucket|TQUnknownInterface|TQConnectionList/ ) {
		return ""; # Unsupported type
	} elsif ( $cplusplusType =~ /TQSignal\s*\*|TQMenuItem|TQWSEvent|TQWSDisplay|TQWSSocket|TQPaintDeviceX11Data|TQWindowsMime|TQDirectPainter|TQMember|TQDiskFont|TQGCache|TQRichText|TQWSDecoration/ && $main::qt_embedded ) {
		return ""; # Unsupported Qt/E type
	} elsif ( $cplusplusType =~ /bool/ && kalyptusDataDict::ctypemap($cplusplusType) eq "int" ) {
		return "boolean";
	} elsif ( $cplusplusType =~ /bool\s*[*&]/ ) {
		return "boolean[]";
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /^void\s*\*/ ) {
		return "int";
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /^\s*(unsigned )?int\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /^qt_QIntValueList\*/
				|| $cplusplusType =~ /^int[*&]$/ )
	{
		return "int[]";
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /^\s*double\s*\*/ ) {
		return "double[]";
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /^\s*(unsigned )?short\s*\*/ ) {
		return "short[]";
	} elsif ( $cplusplusType =~ /KCmdLineOptions/ ) {
		return "String[][]";	
	} elsif ( $cplusplusType =~ /char\s*\*\*/ || $cplusplusType =~ /TQStringList/|| $cplusplusType =~ /TQStrList/) {
		return "String[]";
	} elsif ( 	kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QUrlInfoValueList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QVariantValueList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QIconDragItemValueList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QPixmapValueList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_QCStringList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QObjectList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QDomNodeList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QWidgetList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_KURLList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_KMainWindow\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_KFileItemList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_KFileViewItemList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_DOMNodeList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_StyleSheetList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_MediaList\s*\*/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_OfferList\s*\*/
				|| $cplusplusType =~ /TQMemArray<TQRect>/
				|| $cplusplusType =~ /TQArray<TQRect>/
				|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QCanvasItemList\s*\*/ ) {
		return "ArrayList"
	} elsif ( $cplusplusType =~ /uchar\s*\*/ ) {
		return "char[]";
	} elsif ( $cplusplusType =~ /QC?String/ and !$isConst ) {
		return "StringBuffer"
	} elsif ( $cplusplusType =~ /(DOM::)?DOMString/ || $cplusplusType =~ /TQString/ || $cplusplusType =~ /TQCString/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /^(const )?char\s*\*/ ) {
		return "String"
	} elsif ( $cplusplusType =~ /TQChar\s*[&\*]?/ || $cplusplusType =~ /^char$/ ) {
		return "char"
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QTime\s*\*/ ) {
		return "Date"
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QDateTime\s*\*/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QDate\s*\*/ ) {
		return "Calendar"
	} elsif ( $cplusplusType =~ /TQPaintDevice/ ) {
		return "TQPaintDeviceInterface"
	} elsif ( $cplusplusType =~ /TQByteArray/ ) {
		return "byte[]"
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_([^\*\s]*)(.*)$/ and !$skippedClasses{$className}) {
		if ( kalyptusDataDict::interfacemap($1) ne () ) {
			return $1."Interface";
        } else {
			return $1;
		}
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /kde_([^\*\s]*)(.*)$/ and !$skippedClasses{$className}) {
		if ( kalyptusDataDict::interfacemap($1) ne () ) {
			return $1."Interface";
        } else {
			return $1;
		}
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /unsigned char/ ) {
		return "short";
	} elsif ( $typedeflist{$cplusplusType} =~ /ulong|long/ ) {
		return "long";
	} elsif ( $typedeflist{$cplusplusType} =~ /uint|int/ or $cplusplusType =~ /^int\&$/ ) {
		return "int";
	} elsif ( $typedeflist{$cplusplusType} =~ /ushort|short/ ) {
		return "short";
	} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /(unsigned )(.*)/ ) {
		return $2;
	} else {
		my $node;
		my $item;
		if ($className =~ /^(\w+)::(\w+)$/) {
			$node = kdocAstUtil::findRef( $rootnode, $1 );
			$item = kdocAstUtil::findRef( $node, $2 ) if defined $node;
			if (defined $item && $item->{NodeType} eq 'enum') {
				return "int";
			} elsif (defined $item && ($item->{NodeType} eq 'class' || $item->{NodeType} eq 'struct')) {
				return $skippedClasses{$className} ? "" : $2;
			}
		}

		if ($className =~ /^\w+$/) {
			$item = kdocAstUtil::findRef( $rootnode, $className );
			if (defined $item && ($item->{NodeType} eq 'class' || $item->{NodeType} eq 'struct')) {
				return $skippedClasses{$className} ? "" : $className;
			}
		}
		return kalyptusDataDict::ctypemap($cplusplusType);
	}

}

sub cplusplusToJNI
{
	my ( $cplusplusType )  = @_;
	my $javaType = cplusplusToJava( $cplusplusType );
	
	if ( $cplusplusType =~ /void/ ) {
		return "void"
	} elsif ( $javaType =~ /^Calendar$/ ) {
		return "jobject"
	} elsif ( $javaType =~ /^Date$/ ) {
		return "jobject"
	} elsif ( 	$javaType =~ /ArrayList/ ) {
		return "jobjectArray"
	} elsif ( $javaType =~ /String\[\]\[\]/ ) {
		return "jobjectArray";
	} elsif ( $javaType =~ /String\[\]/ ) {
		return "jobjectArray";
	} elsif ( $javaType =~ /StringBuffer/ ) {
		return "jobject";
	} elsif ( $javaType =~ /^String$/ ) {
		return "jstring";
	} elsif ( $javaType =~ /boolean\[\]/ ) {
		return "jbooleanArray";
	} elsif ( $javaType =~ /char\[\]/ ) {
		return "jcharArray";
	} elsif ( $javaType =~ /byte\[\]/ ) {
		return "jbyteArray";
	} elsif ( $javaType =~ /short\[\]/ ) {
		return "jshortArray";
	} elsif ( $javaType =~ /int\[\]/ ) {
		return "jintArray";
	} elsif ( $javaType =~ /double\[\]/ ) {
		return "jdoubleArray";
	} elsif ( $javaType =~ /^Q/ ) {
		return "jobject";
	} elsif ( $javaType =~ /^[A-Z]/ ) {
		return "jobject";
	} elsif ( $javaType =~ /^boolean\s*/ ) {
		return "jboolean";
	} elsif ( $javaType =~ /^byte\s*/ ) {
		return "jbyte";
	} elsif ( $javaType =~ /^char\s*/ ) {
		return "jchar";
	} elsif ( $javaType =~ /^short\s*/ ) {
		return "jshort";
	} elsif ( $javaType =~ /^int\s*/ ) {
		return "jint";
	} elsif ( $javaType =~ /^long\s*/ ) {
		return "jlong";
	} elsif ( $javaType =~ /^float\s*/ ) {
		return "jfloat";
	} elsif ( $javaType =~ /^double\s*/ ) {
		return "jdouble";
	} else {
		return "";
	}

}

sub cplusplusToJNISignature
{
	my ( $cplusplusType )  = @_;
	my $javaType = cplusplusToJava( $cplusplusType );
	
	if ( $javaType =~ /^Calendar$/ ) {
		return "Ljava_util_Calendar_2"
	} elsif ( $javaType eq 'Date' ) {
		return "Ljava_util_Date_2"
	} elsif ( 	$javaType =~ /ArrayList/ ) {
		return "Ljava_util_ArrayList_2"
	} elsif ( $javaType =~ /String\[\]\[\]/ ) {
		return "_3_3Ljava_lang_String_2";
	} elsif ( $javaType =~ /String\[\]/ ) {
		return "_3Ljava_lang_String_2";
	} elsif ( $javaType =~ /StringBuffer/ ) {
		return "Ljava_lang_StringBuffer_2";
	} elsif ( $javaType eq 'String' ) {
		return "Ljava_lang_String_2";
	} elsif ( $javaType =~ /boolean\[\]/ ) {
		return "_3Z";
	} elsif ( $javaType =~ /char\[\]/ ) {
		return "_3C";
	} elsif ( $javaType =~ /byte\[\]/ ) {
		return "_3B";
	} elsif ( $javaType =~ /short\[\]/ ) {
		return "_3S";
	} elsif ( $javaType =~ /int\[\]/ ) {
		return "_3I";
	} elsif ( $javaType =~ /double\[\]/ ) {
		return "_3D";
	} elsif ( $javaType =~ /^Q/ ) {
		return "Lorg_kde_qt_$javaType"."_2";
	} elsif ( $javaType =~ /^[A-Z]/ ) {
		return "Lorg_kde_koala_$javaType"."_2";
	} elsif ( $javaType =~ /^boolean\s*/ ) {
		return "Z";
	} elsif ( $javaType =~ /^byte\s*/ ) {
		return "B";
	} elsif ( $javaType =~ /^char\s*/ ) {
		return "C";
	} elsif ( $javaType =~ /^short\s*/ ) {
		return "S";
	} elsif ( $javaType =~ /^int\s*/ ) {
		return "I";
	} elsif ( $javaType =~ /^long\s*/ ) {
		return "J";
	} elsif ( $javaType =~ /^float\s*/ ) {
		return "F";
	} elsif ( $javaType =~ /^double\s*/ ) {
		return "D";
	} else {
		return "";
	}

}

sub jniArgTocplusplus
{
	my ( $cplusplusType, $argName )  = @_;
	my $jniLocal = ''; # output
	my $jniArg = ''; # output
	my $jniCleanup = ''; # output
	
	my $javaType = cplusplusToJava( $cplusplusType );
	my $jniType = cplusplusToJNI( $cplusplusType );
 	
	if ( $javaType =~ /^Calendar$/ ) {
		my $dateclass = $cplusplusType =~ /TQDateTime/ ? "TQDateTime" : "TQDate";
		$jniLocal = "static $dateclass* _qdate_$argName = 0;\n";
		if ( $cplusplusType =~ /[\*]/ ) {
			$jniArg = "($cplusplusType) QtSupport::to$dateclass(env, $argName, &_qdate_$argName)";
		} else {
			$jniArg = "($cplusplusType)*($dateclass*) QtSupport::to$dateclass(env, $argName, &_qdate_$argName)";
		}
	} elsif ( $javaType =~ /^Date$/ ) {
		$jniLocal = "static TQTime* _qtime_$argName = 0;\n";
		if ( $cplusplusType =~ /[\*]/ ) {
			$jniArg = "($cplusplusType) QtSupport::toTQTime(env, $argName, &_qtime_$argName)";
		} else {
			$jniArg = "($cplusplusType)*(TQTime*) QtSupport::toTQTime(env, $argName, &_qtime_$argName)";
		}
	} elsif ( 	$javaType =~ /ArrayList/ ) {
		if ( $cplusplusType =~ /KFileItemList/ ) {
			$jniLocal ="static KFileItemList* _qlist_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) KDESupport::toKFileItemList(env, $argName, &_qlist_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQStrList*) KDESupport::toKFileItemList(env, $argName, &_qlist_$argName)";
			}
		} elsif ( $cplusplusType =~ /TQCStringList/ ) {
			$jniLocal ="static TQCStringList* _qlist_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) KDESupport::toTQCStringList(env, $argName, &_qlist_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQCStringList*) KDESupport::toTQCStringList(env, $argName, &_qlist_$argName)";
			}
		} elsif ( $cplusplusType =~ /KURL::List/ ) {
			$jniLocal ="static KURL::List* _qlist_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) KDESupport::toKURLList(env, $argName, &_qlist_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(KURL::List*) KDESupport::toKURLList(env, $argName, &_qlist_$argName)";
			}
		}
	} elsif ( $javaType =~ /String\[\]\[\]/ ) {
		if ( $cplusplusType =~ /KCmdLineOptions/ ) {
			$jniArg = "(KCmdLineOptions*) KDESupport::toKCmdLineOptions(env, $argName)";
		}
	} elsif ( $javaType =~ /String\[\]/ ) {
		if ( $cplusplusType =~ /TQStringList/ ) {
			$jniLocal ="static TQStringList* _qlist_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQStringList(env, $argName, &_qlist_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQStringList*) QtSupport::toTQStringList(env, $argName, &_qlist_$argName)";
			}
		} elsif ( $cplusplusType =~ /TQStrList/ ) {
			$jniLocal ="static TQStrList* _qlist_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQStrList(env, $argName, &_qlist_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQStrList*) QtSupport::toTQStrList(env, $argName, &_qlist_$argName)";
			}
		} elsif ( $cplusplusType =~ /char\s*\*\*/ ) {
			$jniArg = "($cplusplusType) QtSupport::toStringArray(env, $argName)";
		}
	} elsif ( $javaType =~ /StringBuffer/ ) {
		if ( $cplusplusType =~ /TQCString/ ) {
			$jniLocal = "static TQCString* _qcstring_$argName = 0;\n";
			$jniLocal .= "\tif (_qcstring_$argName == 0) {\n";
			$jniLocal .= "\t\t_qcstring_$argName = new TQCString();\n";
			$jniLocal .= "\t}\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) _qcstring_$argName";
			} else {
				$jniArg = "($cplusplusType)*(TQCString*) _qcstring_$argName";
			}
			$jniCleanup = "\tQtSupport::fromTQCStringToStringBuffer(env, _qcstring_$argName, $argName);\n";
		} else {
			$jniLocal ="static TQString* _qstring_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQStringFromStringBuffer(env, $argName, &_qstring_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQString*) QtSupport::toTQStringFromStringBuffer(env, $argName, &_qstring_$argName)";
			}
			$jniCleanup = "\tQtSupport::fromTQStringToStringBuffer(env, _qstring_$argName, $argName);\n";
		}
	} elsif ( $javaType =~ /^String$/ ) {
		if ( $cplusplusType =~ /TQString/ ) {
			$jniLocal ="static TQString* _qstring_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQString(env, $argName, &_qstring_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQString*) QtSupport::toTQString(env, $argName, &_qstring_$argName)";
			}
		} elsif ( $cplusplusType =~ /TQCString/ ) {
			$jniLocal ="static TQCString* _qcstring_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQCString(env, $argName, &_qcstring_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQCString*) QtSupport::toTQCString(env, $argName, &_qcstring_$argName)";
			}
		} elsif ( $cplusplusType =~ /DOMString/ ) {
			$jniLocal ="static DOM::DOMString* _domstring_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "(DOM::DOMString*) KDESupport::toDOMString(env, $argName, &_domstring_$argName)";
			} else {
				$jniArg = "(DOM::DOMString)*(DOM::DOMString*) KDESupport::toDOMString(env, $argName, &_domstring_$argName)";
			}
		} else {
			$jniLocal ="static TQCString* _qstring_$argName = 0;\n";
			$jniArg = "($cplusplusType) ". ($cplusplusType =~ /[\&]/ ? "*(char*)" : "") . "QtSupport::toCharString(env, $argName, &_qstring_$argName)";
		}	
	} elsif ( $javaType =~ /boolean\[\]/ ) {
		$jniLocal ="\tbool* _bool_$argName = QtSupport::toBooleanPtr(env, $argName);\n";
		$jniArg = " ($cplusplusType) " . ($cplusplusType =~ /[\*]/ ? "" : "*") . "_bool_$argName";
		$jniCleanup = "\tenv->SetBooleanArrayRegion($argName, 0, 1, (jboolean*) _bool_$argName);\n";
	} elsif ( $javaType =~ /char\[\]/ ) {
		$jniLocal ="static TQByteArray* _qbytearray_$argName = 0;\n";
		$jniArg = "($cplusplusType) QtSupport::toUcharArray(env, $argName, &_qbytearray_$argName)";
	} elsif ( $javaType =~ /byte\[\]/ ) {
		$jniLocal = "static TQByteArray* _qbyteArray_$argName = 0;\n";
		if ( $cplusplusType =~ /[\*]/ ) {
			$jniArg = "($cplusplusType) QtSupport::toTQByteArray(env, $argName, &_qbyteArray_$argName)";
		} else {
			$jniArg = "($cplusplusType)*(TQByteArray*) QtSupport::toTQByteArray(env, $argName, &_qbyteArray_$argName)";
		}
	} elsif ( $javaType =~ /short\[\]/ ) {
		$jniLocal ="\tshort* _short_$argName = QtSupport::toShortPtr(env, $argName);\n";
		$jniArg = " ($cplusplusType) " . ($cplusplusType =~ /[\*]/ ? "" : "*") . "_short_$argName";
		$jniCleanup = "\tenv->SetShortArrayRegion($argName, 0, 1, (jshort*) _short_$argName);\n";
	} elsif ( $javaType =~ /int\[\]/ ) {
		if ( $cplusplusType =~ /TQValueList/ ) {
			$jniLocal = "static TQValueList<int>* _qlist_$argName = 0;\n";
			$jniArg = "($cplusplusType) QtSupport::toTQIntValueList(env, $argName, &_qlist_$argName)";
		} else {
			$jniLocal ="\tint* _int_$argName = QtSupport::toIntPtr(env, $argName);\n";
			$jniArg = " ($cplusplusType) " . ($cplusplusType =~ /[\*]/ ? "" : "*") . "_int_$argName";
			$jniCleanup = "\tenv->SetIntArrayRegion($argName, 0, 1, (jint *) _int_$argName);\n";
		}
	} elsif ( $javaType =~ /double\[\]/ ) {
		$jniLocal ="\tdouble* _double_$argName = QtSupport::toDoublePtr(env, $argName);\n";
		$jniArg = " ($cplusplusType) " . ($cplusplusType =~ /[\*]/ ? "" : "*") . "_double_$argName";
		$jniCleanup = "\tenv->SetDoubleArrayRegion($argName, 0, 1, (jdouble*) _double_$argName);\n";
	} elsif ( $javaType =~ /^TQPaintDeviceInterface$/ ) {
		$jniArg = "($cplusplusType) QtSupport::paintDevice(env, $argName)";
	} elsif ( $javaType =~ /^TQMimeSourceInterface$/ ) {
		$jniArg = "($cplusplusType) QtSupport::mimeSource(env, $argName)";
	} elsif ( $javaType =~ /^[A-Z]/ ) {
		( my $className = $cplusplusType ) =~ s/[&*]//g;
		$jniArg = (($cplusplusType !~ /[\*]/ or $cplusplusType =~ /\*\&/) ? "($cplusplusType)*" : "") . "($className*) QtSupport::getQt(env, $argName)";
	} elsif ( $javaType =~ /^boolean\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif ( $javaType =~ /^byte\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif	( $javaType =~ /^char\s*/ ) {	
		if ( $cplusplusType =~ /TQChar/ ) {
			$jniLocal = "static TQChar* _qchar_$argName = 0;\n";
			if ( $cplusplusType =~ /[\*]/ ) {
				$jniArg = "($cplusplusType) QtSupport::toTQChar(env, $argName, &_qchar_$argName)";
			} else {
				$jniArg = "($cplusplusType)*(TQChar*) QtSupport::toTQChar(env, $argName, &_qchar_$argName)";
			}
		} else {
			$jniArg = "($cplusplusType) $argName";
		}
	} elsif ( $javaType =~ /^short\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif ( $javaType =~ /^int\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif ( $javaType =~ /^long\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif ( $javaType =~ /^float\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} elsif ( $javaType =~ /^double\s*/ ) {
		$jniArg = "($cplusplusType) $argName";
	} else {
		;
	}
	
	return ($jniLocal, $jniArg, $jniCleanup);
}

sub jniToReturnValue($$$)
{
	my ( $cplusplusType, $functionCall, $jniCleanups )  = @_;
	my $jniLocal = ''; # output
	my $returnCall = ''; # output
	
	my $javaType = cplusplusToJava( $cplusplusType );
	my $const = ($cplusplusType =~ /const / ? "const " : "");
	
	if ( $cplusplusType =~ /void/ ) {
		$returnCall = "\t$functionCall;\n\treturn;\n";
		$returnCall = "\t$functionCall;\n$jniCleanups\treturn;\n";
	} elsif ( $javaType =~ /^Calendar$/ ) {
		$cplusplusType =~ /(TQDateTime|TQDate)\s*(\*)?&?\s*$/;
		$jniLocal = "\t$1 $2 _qdate;\n";
		$returnCall = "\t_qdate = $functionCall;\n$jniCleanups";
		$returnCall .= "\treturn (jobject) QtSupport::from$1(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qdate);\n";
	} elsif ( $javaType =~ /^Date$/ ) {
		$cplusplusType =~ /(TQTime)\s*(\*)?&?\s*$/;
		$jniLocal = "\t$1 $2 _qtime;\n";
		$returnCall = "\t_qtime = $functionCall;\n$jniCleanups";
		$returnCall .= "\treturn (jobject) QtSupport::fromTQTime(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qtime);\n";
	} elsif ( 	$javaType =~ /ArrayList/ || $javaType =~ /String\[\]/ ) {
		if ( $cplusplusType !~ /\*/ ) {
			$const = "";
		}
		$cplusplusType =~ /(const )?([^\&]*)(\*)?&?/;
		$jniLocal = "\t$const$2 $3 _qlist;\n";
		$returnCall = "\t_qlist = $functionCall;\n$jniCleanups";
		if ( $cplusplusType =~ /(TQStrList|TQStringList|TQCanvasItemList|TQWidgetList|TQDomNodeList|TQObjectList)\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) QtSupport::arrayWith$1(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /DOM::(NodeList|StyleSheetList|MediaList)\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) KDESupport::arrayWith$1(env, (DOM::$1 *) " . ($2 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /(TQCStringList|KFileItemList|KFileViewItemList)\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) KDESupport::arrayWith$1(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /(KTrader::OfferList)\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) KDESupport::arrayWithOfferList(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /(KURL::List)\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) KDESupport::arrayWithKURLList(env, ($1*) " . ($2 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /TQValueList<TQIconDragItem>\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) QtSupport::arrayWithTQIconDragItemList(env, (TQValueList<TQIconDragItem>*) " . ($1 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /TQMemArray<TQRect>\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) QtSupport::arrayWithTQRectList(env, (TQMemArray<TQRect>*) " . ($1 eq "\*" ? "" : "&") . "_qlist);\n";
		} elsif ( $cplusplusType =~ /TQArray<TQRect>\s*([\*\&])?\s*$/ ) {
			$returnCall .= "\treturn (jobject) QtSupport::arrayWithTQRectList(env, (TQArray<TQRect>*) " . ($1 eq "\*" ? "" : "&") . "_qlist);\n";
		}	
	} elsif ( $javaType =~ /String\[\]/ ) {
		; # Do nothing, string arrays are ArrayLists as return values
	} elsif ( $javaType =~ /String/ || $javaType =~ /StringBuffer/ ) {
		if ( $cplusplusType =~ /TQString(\s*\*)?/ ) {
			$jniLocal = "\tTQString $1 _qstring;\n";
			$returnCall = "\t_qstring = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn QtSupport::fromTQString(env, " . ($cplusplusType =~ /\*/ ? "" : "&") . "_qstring);\n";
		} elsif ($cplusplusType =~ /TQCString(\s*\*)?/) {
			$jniLocal = "\tTQCString $1 _qstring;\n";
			$returnCall = "\t_qstring = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn QtSupport::fromTQCString(env, " . ($cplusplusType =~ /\*/ ? "" : "&") . "_qstring);\n";
		} elsif ($cplusplusType =~ /DOM::DOMString(\s*\*)?/) {
			$jniLocal = "\tDOM::DOMString $1 _qstring;\n";
			$returnCall = "\t_qstring = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn KDESupport::fromDOMString(env, " . ($cplusplusType =~ /\*/ ? "" : "&") . "_qstring);\n";
		} else {
			$jniLocal = "\t$cplusplusType _qstring;\n";
			$returnCall = "\t_qstring = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn QtSupport::fromCharString(env, (char *) _qstring);\n";
		}
	} elsif ( $javaType =~ /boolean\[\]/ ) {
		;
	} elsif ( $cplusplusType =~ /uchar\s*\*/ ) {
		;
	} elsif ( $javaType =~ /char\[\]/ ) {
		;
	} elsif ( $javaType =~ /byte\[\]/ ) {
		$jniLocal = "\tTQByteArray " . ($cplusplusType =~ /\*/ ? "*" : "") . "_qbyteArray;\n";
		$returnCall = "\t_qbyteArray = $functionCall;\n$jniCleanups";
		$returnCall .= "\treturn QtSupport::fromTQByteArray(env, " . ($cplusplusType =~ /\*/ ? "" : "&") . "_qbyteArray);\n";
	} elsif ( $javaType =~ /short\[\]/ ) {
		;
	} elsif ( $javaType =~ /int\[\]/ && $cplusplusType !~ /\&/ ) {
		if ( $cplusplusType =~ /(int\*|TQRgb\*)/ ) {
			$jniLocal = "\t$1 _qint;\n";
			$returnCall = "\t_qint = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn QtSupport::fromIntPtr(env, (int*)_qint);\n";
		} else {
			$jniLocal = "\tTQValueList<int> _qintArray;\n";
			$returnCall = "\t_qintArray = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn QtSupport::fromTQIntValueList(env, &_qintArray);\n";
		}
	} elsif ( $javaType =~ /double\[\]/ ) {
		;
	} elsif ( $javaType =~ /^[A-Z]/ ) {
		my $className = $cplusplusType;
		$className =~ s/[\*\&]|const //g;
		$returnCall = "\tjobject xret = QtSupport::objectForQtKey(env, (void*)";
		my $fullyQualifiedReturnType = ($javaType =~ /^Q/ ? "org.kde.qt.$javaType" : "org.kde.koala.$javaType");
		if ($cplusplusType =~ /\*/) {
			$returnCall .= "$functionCall, \"$fullyQualifiedReturnType\");\n";
		} elsif ($cplusplusType =~ /\&/) {
			$returnCall .= "($className *) &$functionCall, \"$fullyQualifiedReturnType\");\n";
		} else {
			$returnCall .= "new $className($functionCall), \"$fullyQualifiedReturnType\", TRUE);\n";
		}
		$returnCall .= "$jniCleanups\treturn xret;\n";
	} elsif ( $javaType =~ /^char\s*/ ) {
		if ( $cplusplusType =~ /(TQChar)(\s*\*)?\s*$/ ) {
			$jniLocal = "\t$const$1 $2 _qchar;\n";
			$returnCall = "\t_qchar = $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn (jchar) QtSupport::fromTQChar(env, (TQChar*) " . ($cplusplusType =~ /\*/ ? "" : "&") . "_qchar);\n";
		} else {
			$returnCall = "\tjchar xret = (jchar) $functionCall;\n$jniCleanups";
			$returnCall .= "\treturn xret;\n";
		}
	} elsif ( $javaType =~ /int\[\]/ && $cplusplusType =~ /\&/ ) {
		$returnCall = "\tjint xret = (jint) $functionCall;\n$jniCleanups";
		$returnCall .= "\treturn xret;\n";
	} elsif ( $javaType =~ /(^boolean|^byte|^short|^int|^long|^float|^double)/ ) {
		$returnCall = "\tj$1 xret = (j$1) $functionCall;\n$jniCleanups";
		$returnCall .= "\treturn xret;\n";
	}
		
	return ($jniLocal, $returnCall);
}

sub writeDoc
{
	( $libname, $rootnode, $outputdir, $opt ) = @_;

	print STDERR "Starting writeDoc for $libname...\n";

	$debug = $main::debuggen;

	mkpath( $outputdir ) unless -f $outputdir;

	# Define TQPtrCollection::Item, for resolveType
	unless ( kdocAstUtil::findRef( $rootnode, "TQPtrCollection::Item" ) ) {
		my $cNode = kdocAstUtil::findRef( $rootnode, "TQPtrCollection" );
		warn "TQPtrCollection not found" if (!$cNode);
		my $node = Ast::New( 'Item' );
		$node->AddProp( "NodeType", "Forward" );
		$node->AddProp( "Source", $cNode->{Source} ) if ($cNode);
		kdocAstUtil::attachChild( $cNode, $node ) if ($cNode);
		$node->AddProp( "Access", "public" );
	}

	print STDERR "Preparsing...\n";

	# Preparse everything, to prepare some additional data in the classes and methods
	Iter::LocalCompounds( $rootnode, sub { preParseClass( shift ); } );

	# Have a look at each class again, to propagate CanBeCopied
	Iter::LocalCompounds( $rootnode, sub { propagateCanBeCopied( shift ); } );

	# Write out smokedata.cpp
	writeSmokeDataFile($rootnode);

	print STDERR "Writing *.java...\n";

	# Generate *java file for each class
	Iter::LocalCompounds( $rootnode, sub { writeClassDoc( shift ); } );

	print STDERR "Done.\n";
}

=head2 preParseClass
	Called for each class
=cut
sub preParseClass
{
	my( $classNode ) = @_;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );

	if( $#{$classNode->{Kids}} < 0 ||
	    $classNode->{Access} eq "private" ||
	    $classNode->{Access} eq "protected" || # e.g. TQPixmap::TQPixmapData
	    exists $classNode->{Tmpl} ||
	    # Don't generate standard bindings for TQString, this class is handled as a native type
	    $className eq 'TQString' ||
	    $className eq 'TQConstString' ||
	    $className eq 'TQCString' ||
	    # Don't map classes which are really arrays
	    $className eq 'TQStringList' ||
            $className eq 'TQCanvasItemList' ||
            $className eq 'TQWidgetList' ||
            $className eq 'TQObjectList' ||
	    $className eq 'TQStrList' ||
	    # Those are template related
        $className eq 'TQTSManip' || # cause compiler errors with several gcc versions
	    $className eq 'TQIconFactory' ||
	    $className eq 'TQGDict' ||
	    $className eq 'TQGList' ||
	    $className eq 'TQGVector' ||
	    $className eq 'TQStrIList' ||
	    $className eq 'TQStrIVec' ||
	    $className eq 'TQByteArray' ||
	    $className eq 'TQBitArray' ||
	    $className eq 'TQWExtra' ||
	    $className eq 'TQTLWExtra' ||
	    $className eq 'TQMetaEnum::Item' ||
	    $className eq 'TQWidgetContainerPlugin' ||
	    $className eq 'TQGArray::array_data' ||
	    $className eq 'KBookmarkMenu::DynMenuInfo' ||
	    $className eq 'KCompletionMatches' ||
	    $className eq 'KDEDesktopMimeType::Service' ||
	    $className eq 'KGlobalSettings::KMouseSettings' ||
	    $className eq 'KMimeType::Format' ||
	    $className eq 'KNotifyClient::Instance' ||
	    $className eq 'KParts::Plugin::PluginInfo' ||
	    $className eq 'KProtocolInfo::ExtraField' ||
	    $className eq 'KXMLGUIClient::StateChange' ||
	    $className eq 'KIconTheme' ||
	    $className eq 'KEditListBox::CustomEditor' ||
		$className eq 'KIO::KBookmarkMenuNSImporter' ||
	    $className eq 'KPerDomainSettings' ||
	    $className eq 'KApplicationPropsPlugin' ||
	    $className eq 'KPrinter' ||
	    $className eq 'KPty' ||
	    $className eq 'KOpenWithHandler' ||
	    $className eq 'KFileOpenWithHandler' ||
	    $className eq 'KBindingPropsPlugin' ||
	    $className eq 'KPropsDlgPlugin' ||
	    $className eq 'KFileSharePropsPlugin' ||
	    $className eq 'KBookmarkMenuNSImporter' ||
	    $className eq 'KDevicePropsPlugin' ||
	    $className eq 'KWin::WindowInfo' ||
	    $className eq 'KDEDModule' ||
	    $className eq 'KFileMetaInfoProvider' ||
	    $className eq 'KFileMimeTypeInfo' ||
	    $className eq 'KExecPropsPlugin' ||
	    $className eq 'KFilePermissionsPropsPlugin' ||
	    $className eq 'KImageFilePreview' ||
	    $className eq 'KBookmarkManager' ||
	    $className eq 'KBookmarkNotifier' ||
	    $className eq 'KOCRDialogFactory' ||
	    $className eq 'KExtendedBookmarkOwner' ||
	    $className eq 'KSharedPixmap' ||
	    $className eq 'KSocket' ||
	    $className eq 'KLibrary' ||
	    $className eq 'KScanDialogFactory' ||
	    $className eq 'KDictSpellingHighlighter' ||
		$className eq 'KPropertiesDialog' ||
	    $className eq 'ProgressItem' ||
	    $className eq 'KIO::ChmodInfo' ||
	    $className eq 'KIO::MetaData' ||
	    $className eq 'KFileMimeTypeInfo::ItemInfo' ||
	    $className eq 'KIO::UDSAtom' ||
	    $className eq 'khtml::DrawContentsEvent' || # the khtml:: classes build, but don't link
	    $className eq 'khtml::MouseDoubleClickEvent' ||
	    $className eq 'khtml::MouseMoveEvent' ||
	    $className eq 'khtml::MousePressEvent' ||
	    $className eq 'khtml::MouseReleaseEvent' ||
	    $className eq 'khtml::MouseEvent' ||
	    $className eq 'KURL::List' ||
	    $className eq 'KWin::Info' ||
	    $className eq 'TerminalInterface' ||
	    $className =~ /.*Private$/ || # Ignore any classes which aren't for public consumption
	    $className =~ /.*Impl$/ ||
	    $className =~ /.*Internal.*/ ||
#	    $classNode->{Deprecated} ||
	    $classNode->{NodeType} eq 'union'  # Skip unions for now, e.g. TQPDevCmdParam	  
	) {
	    print STDERR "Skipping $className\n" if ($debug);
	    print STDERR "Skipping union $className\n" if ( $classNode->{NodeType} eq 'union');
	    $skippedClasses{$className} = 1;
	    delete $classNode->{Compound}; # Cheat, to get it excluded from Iter::LocalCompounds
	    return;
	}

	my $signalCount = 0;
	my $eventHandlerCount = 0;
	my $defaultConstructor = 'none'; #  none, public, protected or private. 'none' will become 'public'.
	my $constructorCount = 0; # total count of _all_ ctors
	# If there are ctors, we need at least one public/protected one to instanciate the class
	my $hasPublicProtectedConstructor = 0;
	# We need a public dtor to destroy the object --- ### aren't protected dtors ok too ??
	my $hasPublicDestructor = 1; # by default all classes have a public dtor!
	#my $hasVirtualDestructor = 0;
	my $hasDestructor = 0;
	my $hasPrivatePureVirtual = 0;
	my $hasCopyConstructor = 0;
	my $hasPrivateCopyConstructor = 0;
	# Note: no need for hasPureVirtuals. $classNode{Pure} has that.

        my $doPrivate = $main::doPrivate;
	$main::doPrivate = 1;
	# Look at each class member (looking for methods and enums in particular)
	Iter::MembersByType ( $classNode, undef,
		sub {

	my( $classNode, $m ) = @_;
	my $name = $m->{astNodeName};

	if( $m->{NodeType} eq "method" ) {
	    if ( $m->{ReturnType} eq 'typedef' # TQFile's EncoderFn/DecoderFn callback, very badly parsed
	       ) {
		$m->{NodeType} = 'deleted';
		next;
	    }

	    print STDERR "preParseClass: looking at $className\::$name  $m->{Params}\n" if ($debug);

	    if ( $name eq $classNode->{astNodeName} ) {
		if ( $m->{ReturnType} =~ /~/  ) {
		    # A destructor
		    $hasPublicDestructor = 0 if $m->{Access} ne 'public';
		    #$hasVirtualDestructor = 1 if ( $m->{Flags} =~ "v" && $m->{Access} ne 'private' );
		    $hasDestructor = 1;
		} else {
		    # A constructor
		    $constructorCount++;
		    $defaultConstructor = $m->{Access} if ( $m->{Params} eq '' );
		    $hasPublicProtectedConstructor = 1 if ( $m->{Access} ne 'private' );

		    # Copy constructor?
		    if ( $#{$m->{ParamList}} == 0 ) {
			my $theArgType = @{$m->{ParamList}}[0]->{ArgType};
			if ($theArgType =~ /$className\s*\&/) {
			    $hasCopyConstructor = 1;
			    $hasPrivateCopyConstructor = 1 if ( $m->{Access} eq 'private' );
			}
		    }
		    # Hack the return type for constructors, since constructors return an object pointer
		    $m->{ReturnType} = $className."*";
		}
	    }

	    if ( $name =~ /~$classNode->{astNodeName}/ && $m->{Access} ne "private" ) { # not used
		$hasPublicDestructor = 0 if $m->{Access} ne 'public';
		#$hasVirtualDestructor = 1 if ( $m->{Flags} =~ "v" );
		$hasDestructor = 1;
	    }

	    if ( $m->{Flags} =~ "p" && $m->{Access} =~ /private/ ) {
                $hasPrivatePureVirtual = 1; # ouch, can't inherit from that one
	    }

	    # All we want from private methods is to check for virtuals, nothing else
	    next if ( $m->{Access} =~ /private/ );

		# Don't generate code for deprecated methods, 
		# or where the code won't compile/link for obscure reasons. Or even obvious reasons..
		if ( ($classNode->{astNodeName} eq 'KCharSelectTable' and $name eq 'paintCell')
			|| ($classNode->{astNodeName} eq 'KAnimWidget' and $name eq 'KAnimWidget' and @{$m->{ParamList}} == 2)
			|| ($classNode->{astNodeName} eq 'KDCOPActionProxy' and $name eq 'actions')
			|| ($classNode->{astNodeName} eq 'KFileDialog' and $name eq 'addDirEntry')
			|| ($classNode->{astNodeName} eq 'KFileDialog' and $name eq 'getDirEntry')
			|| ($classNode->{astNodeName} eq 'KFileView' and $name eq 'selectionMode')
			|| ($classNode->{astNodeName} eq 'KFind' and $name eq 'KFind' and @{$m->{ParamList}} == 4)
			|| ($classNode->{astNodeName} eq 'KGlobalAccel' and $name eq 'setEnabled')
			|| ($classNode->{astNodeName} eq 'KCharsets' and $name eq 'encodingsForLanguage')
			|| ($classNode->{astNodeName} eq 'KInputDialog' and $name eq 'getInteger')
			|| ($classNode->{astNodeName} eq 'KIO' and $name eq 'buildHTMLErrorString')
			|| ($classNode->{astNodeName} eq 'KIO' and $name eq 'calculateRemainingSeconds')
			|| ($classNode->{astNodeName} eq 'SlaveBase' and $name eq 'checkCachedAuthentication')
			|| ($classNode->{astNodeName} eq 'SlaveBase' and $name eq 'cacheAuthentication')
			|| ($classNode->{astNodeName} eq 'KInputDialog' and $name eq 'getDouble')
			|| ($classNode->{astNodeName} eq 'KToolBar' and $name eq 'enable')
			|| ($classNode->{astNodeName} eq 'KAccel' and $name eq 'insert' and @{$m->{ParamList}} == 2)
			|| ($classNode->{astNodeName} eq 'KAccel' and $name eq 'autoupdate')
			|| ($classNode->{astNodeName} eq 'KAccel' and $name eq 'getAutoUpdate')
			|| ($classNode->{astNodeName} eq 'KStdAccel' and $name eq 'insert')
			|| ($classNode->{astNodeName} eq 'KBookmarkMenu' and $name eq 'invalid')
			|| ($classNode->{astNodeName} eq 'KCharsets' and $name eq 'languages')
			|| ($classNode->{astNodeName} eq 'KCombiView' and $name eq 'setDropOptions')
			|| ($classNode->{astNodeName} eq 'KFileMetaInfoItem' and $name eq 'unit')
			|| ($classNode->{astNodeName} eq 'KInstance' and $name eq 'charsets')
			|| ($classNode->{astNodeName} eq 'KInstance' and $name eq 'KInstance' and $m->{Access} =~ /protected/)
			|| ($classNode->{astNodeName} eq 'KKey' and $name eq 'isValidQt')
			|| ($classNode->{astNodeName} eq 'KKey' and $name eq 'isValidNative')
			|| ($classNode->{astNodeName} eq 'KKeySequence' and $name eq 'init')
			|| ($classNode->{astNodeName} eq 'KKeySequence' and $name eq 'setTriggerOnRelease')
			|| ($classNode->{astNodeName} eq 'KEMailSettings' and $name eq 'getExtendedSetting')
			|| ($classNode->{astNodeName} eq 'KEMailSettings' and $name eq 'setExtendedSetting')
			|| ($classNode->{astNodeName} eq 'KHTMLSettings' and $name eq 'fallbackAccessKeysAssignments')
			|| ($classNode->{astNodeName} eq 'KProtocolManager' and $name eq 'defaultConnectTimeout')
			|| ($classNode->{astNodeName} eq 'KMD5' and $name eq 'transform')
			|| ($classNode->{astNodeName} eq 'KSSLCertificate' and $name eq 'operator!=')
			|| ($classNode->{astNodeName} eq 'KSSLPKCS7' and $name eq 'validate')
			|| ($classNode->{astNodeName} eq 'KSSLPKCS7' and $name eq 'revalidate')
			|| ($classNode->{astNodeName} eq 'KSSLSession' and $name eq 'KSSLSession' and @{$m->{ParamList}} == 1)
			|| ($classNode->{astNodeName} eq 'KSimpleFileFilter' and $name eq 'nameFilters')
			|| ($classNode->{astNodeName} eq 'KTabWidget' and $name eq 'isTabReorderingEnabled')
			|| ($classNode->{astNodeName} eq 'KTabWidget' and $name eq 'hoverCloseButton')
			|| ($classNode->{astNodeName} eq 'KTar' and $name eq 'writeFile_impl')

			# Various methods to skip in Qt/E (Qt 2.3.x)
			|| ($main::qt_embedded
				&& ( ($classNode->{astNodeName} eq 'TQUriDrag' and $name =~ /^decode$|decodeLocalFiles|decodeToUnicodeUris/)
				|| ($classNode->{astNodeName} eq 'TQApplication' and $name =~ /^qwsSetCustomColors|^setArgs$|^winMouseButtonUp|^winFocus|^winMouseButtonUP$|^winVersion$/)
				|| ($classNode->{astNodeName} eq 'TQPrinter' and $name =~ /^setIdle$|^setActive$/)
				|| ($classNode->{astNodeName} eq 'TQDragObject' and $name eq 'dragLink')
				|| ($classNode->{astNodeName} eq 'TQFont' and $name eq 'qwsRenderToDisk')
				|| ($classNode->{astNodeName} eq 'TQFontInfo' and $name eq 'font')
				|| ($classNode->{astNodeName} eq 'TQLineEdit' and $name eq 'getSelection')
				|| ($classNode->{astNodeName} eq 'TQMainWindow' and $name eq 'toolBars')
				|| ($classNode->{astNodeName} eq 'TQMovie' and $name eq 'setDisplayWidget')
				|| ($classNode->{astNodeName} eq 'TQMetaObject' and $name =~ /^new_metaenum_item$|^new_metaaccess$/)
				|| ($classNode->{astNodeName} eq 'TQPainter' and $name eq 'pos')
				|| ($classNode->{astNodeName} eq 'TQPixmap' and $name =~ /^allocCell$|^clut$|^freeCell|^hbm|^isMultiCellPixmap|^multiCellPixmap|^multiCellBitmap|^multiCellHandle|^multiCellOffset|^numCols/)
				|| ($name eq 'handle')
				|| ($name eq 'resetInputContext')
				|| ($name eq 'propagateUpdates')
				|| ($name eq 'bytesPerLine')
				|| ($name eq 'scanLine')
				|| ($name eq 'hPal')
				|| ($name eq 'copyX11Data')
				|| ($name eq 'getX11Data')
				|| ($name eq 'setX11Data')
				|| ($name eq 'realizePal')
				|| ($name eq 'qwsDisplay')
				|| ($name eq 'fixport')
				|| ($name eq 'hack_strrchr')
				|| ($name eq 'hack_strchr')
				|| ($name eq 'hack_strstr') ) )			
						
			|| ($name eq 'virtual_hook')
			|| ($name =~ /_KShared_/)
			|| ($name eq 'qObject')
			|| ($name =~ /argv/)
			|| ($name =~ /argc/)
			|| ($name eq 'qt_emit')
			|| ($name eq 'qt_invoke')
			|| ($name eq 'qt_cast')
			|| ($name eq 'qt_property')
			|| ($name eq 'staticMetaObject')
			# Assume only Qt classes have tr() and trUtf8() in their Q_OBJECT macro
			|| ($classNode->{astNodeName} !~ /^Q/ and $name eq 'tr')
			|| ($classNode->{astNodeName} !~ /^Q/ and $name eq 'trUtf8')
				|| $name eq 'trUtf8'
				|| $m->{Deprecated} ) {
		    $m->{NodeType} = 'deleted';
			next;
		}
			    
		my $argId = 0;
	    my $firstDefaultParam;
	    foreach my $arg ( @{$m->{ParamList}} ) {
		# Look for first param with a default value
		if ( defined $arg->{DefaultValue} && !defined $firstDefaultParam ) {
		    $firstDefaultParam = $argId;
		}

		if ( $arg->{ArgType} eq '...' # refuse a method with variable arguments
		     or $arg->{ArgType} eq 'image_io_handler' # TQImage's callback
		     or $arg->{ArgType} eq 'DecoderFn' # TQFile's callback
		     or $arg->{ArgType} eq 'EncoderFn' # TQFile's callback
		     or $arg->{ArgType} =~ /bool \(\*\)\(TQObject/ # TQMetaObject's ctor
		     or $arg->{ArgType} eq 'QtStaticMetaObjectFunction' # TQMetaObjectCleanUp's ctor with func pointer
		     or $arg->{ArgType} eq 'const TQTextItem&' # ref to a private class in 3.2.0b1
		     or $arg->{ArgType} eq 'FILE*' # won't be able to handle that I think
		     or $arg->{ArgType} eq 'const KKeyNative&' #
		) {
		    $m->{NodeType} = 'deleted';
		}
		else
		{
		    # Resolve type in full, e.g. for TQSessionManager::RestartHint
		    # (TQSessionManagerJBridge doesn't inherit TQSessionManager)
		    $arg->{ArgType} = kalyptusDataDict::resolveType($arg->{ArgType}, $classNode, $rootnode);
		    registerType( $arg->{ArgType} );
		    $argId++;
		}
	    }
	    $m->AddProp( "FirstDefaultParam", $firstDefaultParam );
	    $m->{ReturnType} = kalyptusDataDict::resolveType($m->{ReturnType}, $classNode, $rootnode) if ($m->{ReturnType});
	    registerType( $m->{ReturnType} );
	}
	elsif( $m->{NodeType} eq "enum" ) {
		if ( ! $m->{astNodeName} ) {
			$m->{Access} = 'protected';
		}
		my $fullEnumName = $className."::".$m->{astNodeName};
		if ( ($fullEnumName eq 'KMimeType::Format' and $name eq 'compression')
				|| $m->{Deprecated} ) {
		    $m->{NodeType} = 'deleted';
			next;
		}
	    
		$classNode->{enumerations}{$m->{astNodeName}} = $fullEnumName;
#		if $m->{astNodeName} and $m->{Access} ne 'private';
#		if $m->{astNodeName} ;

	    # Define a type for this enum
	    registerType( $fullEnumName );

	    # Remember that it's an enum
	    findTypeEntry( $fullEnumName )->{isEnum} = 1;
 	}
	elsif( $m->{NodeType} eq 'var' ) {
	    my $varType = $m->{Type};
	    # We are interested in public static vars, like TQColor::blue
	    if ( $varType =~ s/static\s+// && $m->{Access} ne 'private'
			&& $className."::".$m->{astNodeName} ne "KSpell::modalListText" )
	    {
		$varType =~ s/const\s+(.*)\s*&/$1/;
		$varType =~ s/\s*$//;
		print STDERR "var: $m->{astNodeName} '$varType'\n" if ($debug);

		# Register the type
		registerType( $varType );

	    } else {
		# To avoid duplicating the above test, we just get rid of any other var
		$m->{NodeType} = 'deleted';
	    }
	}
		},
		undef
	);
	$main::doPrivate = $doPrivate;

	print STDERR "$className: ctor count: $constructorCount, hasPublicProtectedConstructor: $hasPublicProtectedConstructor, hasCopyConstructor: $hasCopyConstructor:, defaultConstructor: $defaultConstructor, hasPublicDestructor: $hasPublicDestructor, hasPrivatePureVirtual:$hasPrivatePureVirtual\n" if ($debug);

	# Note that if the class has _no_ constructor, the default ctor applies. Let's even generate it.
	if ( !$constructorCount && $defaultConstructor eq 'none' && !$hasPrivatePureVirtual ) {
	    # Create a method node for the constructor
	    my $methodNode = Ast::New( $classNode->{astNodeName} );
	    $methodNode->AddProp( "NodeType", "method" );
	    $methodNode->AddProp( "Flags", "" );
	    $methodNode->AddProp( "Params", "" );
            $methodNode->AddProp( "ParamList", [] );
	    kdocAstUtil::attachChild( $classNode, $methodNode );

	    # Hack the return type for constructors, since constructors return an object pointer
	    $methodNode->AddProp( "ReturnType", $className."*" );
	    registerType( $className."*" );
	    $methodNode->AddProp( "Access", "public" ); # after attachChild
	    $defaultConstructor = 'public';
	    $hasPublicProtectedConstructor = 1;
	}

	# Also, if the class has no explicit destructor, generate a default one.
	if ( !$hasDestructor && !$hasPrivatePureVirtual ) {
	    my $methodNode = Ast::New( "$classNode->{astNodeName}" );
	    $methodNode->AddProp( "NodeType", "method" );
	    $methodNode->AddProp( "Flags", "" );
	    $methodNode->AddProp( "Params", "" );
	    $methodNode->AddProp( "ParamList", [] );
	    kdocAstUtil::attachChild( $classNode, $methodNode );

	    $methodNode->AddProp( "ReturnType", "~" );
	    $methodNode->AddProp( "Access", "public" );
	}

	# If we have a private pure virtual, then the class can't be instanciated (e.g. TQCanvasItem)
	# Same if the class has only private constructors (e.g. TQInputDialog)
	$classNode->AddProp( "CanBeInstanciated", $hasPublicProtectedConstructor 
#												&& !$hasPrivatePureVirtual
												&& (!$classNode->{Pure} or $classNode->{astNodeName} eq 'TQValidator')
												&& !($classNode->{NodeType} eq 'namespace')
												&& ($classNode->{astNodeName} !~ /^DrawContentsEvent$|^MouseEvent$|^MouseDoubleClickEvent$|^MouseMoveEvent$|^MouseReleaseEvent$|^MousePressEvent$/)
												&& ($classNode->{astNodeName} !~ /TQMetaObject|TQDragObject|Slave|CopyJob|KMdiChildFrm|KNamedCommand/) );

	# We will derive from the class only if it has public or protected constructors.
	# (_Even_ if it has pure virtuals. But in that case the *.cpp class can't be instantiated either.)
	$classNode->AddProp( "BindingDerives", $hasPublicProtectedConstructor );

	# We need a public dtor to destroy the object --- ### aren't protected dtors ok too ??
	$classNode->AddProp( "HasPublicDestructor", $hasPublicDestructor );

	# Hack for TQAsyncIO. We don't implement the "if a class has no explicit copy ctor,
	# then all of its member variables must be copiable, otherwise the class isn't copiable".
	$hasPrivateCopyConstructor = 1 if ( $className eq 'TQAsyncIO' );

	# Remember if this class can't be copied - it means all its descendants can't either
	$classNode->AddProp( "CanBeCopied", !$hasPrivateCopyConstructor );
	$classNode->AddProp( "HasCopyConstructor", $hasCopyConstructor );
}

sub propagateCanBeCopied($)
{
	my $classNode = shift;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	my @super = superclass_list($classNode);
	# A class can only be copied if none of its ancestors have a private copy ctor.
	for my $s (@super) {
	    if (!$s->{CanBeCopied}) {
		$classNode->{CanBeCopied} = 0;
		print STDERR "$classNode->{astNodeName} cannot be copied\n" if ($debug);
		last;
	    }
	}

	# Prepare the {case} dict for the class
	prepareCaseDict( $classNode );
}

=head2 writeClassDoc

	Called by writeDoc for each class to be written out

=cut

sub writeClassDoc
{
	my( $node ) = @_;
	my $className = join( "::", kdocAstUtil::heritage($node) );
	my $javaClassName = $node->{astNodeName};
	# Makefile doesn't like '::' in filenames, so use __
	my $fileName  = $node->{astNodeName};
#	my $fileName  = join( "__", kdocAstUtil::heritage($node) );
	print "Enter: $className\n" if $debug;
	
	my $typeprefix = ($className =~ /^Q/ ? "qt_" : "kde_");
	my $packagename = ($typeprefix eq 'qt_' ? "org.kde.qt" : "org.kde.koala");
	
	# Write out the *.java file
	my $classFile = "$outputdir/$fileName.java";
	open( CLASS, ">$classFile" ) || die "Couldn't create $classFile\n";
	print STDERR "Writing $fileName.java\n" if ($debug);
	
	print CLASS "//Auto-generated by $0. DO NOT EDIT.\n";
	
	print CLASS "package $packagename;\n\n";
	
	# And write out the *.cpp file
	my $jniFile = "$outputdir/$fileName.cpp";
	open( JNISOURCE, ">$jniFile" ) || die "Couldn't create $jniFile\n";
	print STDERR "Writing $fileName.cpp\n" if ($debug);
	
	print JNISOURCE "//Auto-generated by $0. DO NOT EDIT.\n";

	my %javaMethods = ();
	my %jniMethods = ();
	my $jniCode;
	my %addImport = ();
	my %addInclude = ();
	
	my @ancestors = ();
	my @ancestor_nodes = ();
	Iter::Ancestors( $node, $rootnode, undef, undef, sub { 
				my ( $ances, $name, $type, $template ) = @_;
				if ( $name ne "TQMemArray" and $name ne "TQArray" and $name ne "TQSqlFieldInfoList" ) {
					push @ancestor_nodes, $ances;
					push @ancestors, $name;
				}
			},
			undef
		);
        
	my ($methodCode, $interfaceCode, $signalCode, $jbridgeCode) = generateAllMethods( $node, $#ancestors + 1, 
																		\%javaMethods, \%jniMethods, 
																		$node, 
																		($node->{NodeType} eq 'namespace' ? 0 : 1), 
																		\%addImport, \%addInclude );

	my $signalFile = "$outputdir/$fileName" . "Signals.java";
	if ( $signalCode ne '' ) {
		open( SIGNALS, ">$signalFile" ) || die "Couldn't create $signalFile\n";
		print SIGNALS "//Auto-generated by $0. DO NOT EDIT.\n";
 		print SIGNALS "package $packagename;\n\n";
	}
	
	my $tempMethodNumber = $methodNumber;
	
	# Add method calls for the interfaces implemented by the class
	foreach my $ancestor_node ( @ancestor_nodes ) {
		if ( kalyptusDataDict::interfacemap($ancestor_node->{astNodeName}) ne () && ($#ancestors > 0) ) {
			my ($meth, $interf, $sig, $jbridge) = generateAllMethods( $ancestor_node, 0, \%javaMethods, \%jniMethods, $node, 0, \%addImport, \%addInclude );
			$methodCode .= $meth;
			$jbridgeCode .= $jbridge;
		}
	}

		
	if ( $className eq 'Qt' or $className eq 'KDE' ) {
		my $globalSpace = kdocAstUtil::findRef( $rootnode, $main::globalSpaceClassName );
		my ($meth, $interf, $sig, $jbridge) = generateAllMethods( $globalSpace, 0, \%javaMethods, \%jniMethods, $node, 0, \%addImport, \%addInclude );
		$methodCode .= $meth;
		$jbridgeCode .= $jbridge;
	}
	
	
	$jbridgeCode .= virtualMethodCallbacks( $node );
	
	$methodNumber = $tempMethodNumber;
		
	if ( $className eq 'Qt' ) {
	    print CLASS "import java.io.*;\n";
	    print CLASS "import java.text.MessageFormat;\n";
	    print CLASS "import java.lang.reflect.*;\n";
	} else {
		if ( $className eq 'TQListView' or $className eq 'TQListViewItem' or $className eq 'TQUriDrag' ) {
			# Special case these two classes as they have methods that use ArrayList added as 'extras'
	    	print CLASS "import java.util.ArrayList;\n";
		}
	    print CLASS "import org.kde.qt.Qt;\n";
	}
	
	if ( kalyptusDataDict::interfacemap($javaClassName) ne () ) {
		my $interfaceFile = "$outputdir/" . kalyptusDataDict::interfacemap($javaClassName) . ".java";
		open( INTERFACE, ">$interfaceFile" ) || die "Couldn't create $interfaceFile\n";
		print INTERFACE "//Auto-generated by $0. DO NOT EDIT.\n";
 		print INTERFACE "package $packagename;\n\n";
	}
	
	foreach my $imp (keys %addImport) {
	    die if $imp eq '';
		# Ignore any imports for classes in the same package as the current class
		if ($imp !~ /$packagename/) {
	    	print CLASS "import $imp;\n";
	    	print INTERFACE "import $imp;\n";
	    	print SIGNALS "import $imp;\n" unless $signalCode eq '';;
		}
	}	
	
	if ( kalyptusDataDict::interfacemap($javaClassName) ne () ) {
		print INTERFACE "\npublic interface " . kalyptusDataDict::interfacemap($javaClassName) . " {\n";
		print INTERFACE $interfaceCode;
		print INTERFACE "}\n";
		close INTERFACE;
	}
	
	my $classdec;
	if ($node->{NodeType} eq 'namespace') {
		$classdec = "public class $javaClassName {\n";
	} elsif ( $#ancestors < 0 ) {
		$classdec = "public class $javaClassName implements QtSupport";
		if ( kalyptusDataDict::interfacemap($javaClassName) ne () ) {
			$classdec .= ", " . kalyptusDataDict::interfacemap($javaClassName);
		}

		$classdec .= " {\n\tprivate long _qt;\n";
		$classdec .= "\tprivate boolean _allocatedInJavaWorld = true;\n";
		$classdec .= "\tprotected $javaClassName(Class dummy){}\n\n";
	} else {
		$classdec = "public class $javaClassName extends ";
		my $ancestor;
		foreach $ancestor ( @ancestors ) {
			if ( kalyptusDataDict::interfacemap($ancestor) eq () or $ancestor eq @ancestors[$#ancestors] ) {
				$ancestor =~ s/^.*:://;
				$classdec .= "$ancestor ";
				if ( $typeprefix ne 'qt_' and $ancestor =~ /^Q/ ) {
					print CLASS "import org.kde.qt.$ancestor;\n";
				}
				last;
			}
		}

		my @implements = ();
		if ( $#ancestors >= 1 ) {
			foreach $ancestor ( @ancestors ) {
				if ( kalyptusDataDict::interfacemap($ancestor) ne () ) {
					push(@implements, kalyptusDataDict::interfacemap($ancestor));
				}
			}
	    }
	
		if ($#implements >= 0) {
			$classdec .= "implements ";
			$classdec .= join(", ", @implements);
		}
		
		$classdec .= " {\n";
		$classdec .= "\tprotected $javaClassName(Class dummy){super((Class) null);}\n";
	}
		
	print CLASS "\n";
	if ( $javaClassName !~ /^Q/ or $signalCode ne '' ) {
		my $signalLink = '';
 		if ( $signalCode ne '' ) {
			print SIGNALS "\npublic interface $javaClassName" . "Signals {\n";
			print SIGNALS $signalCode;
			print SIGNALS "}\n";
			close SIGNALS;

			$signalLink = " See {\@link $javaClassName" . "Signals} for signals emitted by $javaClassName\n";
		}
		my $docnode = $node->{DocNode};
		print CLASS "/**\n";
		if ( defined $docnode ) { 
			print CLASS printJavadocComment( $docnode, "", "", $signalLink ) . "\n" 
		} else {
			print CLASS $signalLink;
		}
		print CLASS "*/\n";
	}
	
	print CLASS $classdec;
    print CLASS $methodCode;
	
	my %jniNames;
	my $name;
	foreach my $methodName (keys %jniMethods) {
	    die if $methodName eq '';
		$name = $methodName;
		$name =~ s/(.*[^_])__[^1].*/$1/;
		$name =~ s/(.*[^_])__$/$1/;
		if (defined $jniNames{$name}) {
			$jniNames{$name}++;
		} else {
			$jniNames{$name} = 1;
		}
	}	
	
	# Add the JNI functions sorted by name. And with the correct
	# signature minus the arg types if name not duplicated
	foreach my $methodName (sort keys %jniMethods) {
	    die if $methodName eq '';
		my $methodCode = $jniMethods{$methodName};
		$methodName =~ s/(.*[^_])__[^1].*/$1/;
		$methodName =~ s/(.*[^_])__$/$1/;
		if ($jniNames{$methodName} == 1) {
			$methodCode =~ s/__\(/\(/;
			$methodCode =~ s/__[^1][^\(]*\(/\(/;
		}
		$jniCode .= $methodCode;
	}	
	
	if ( $className eq 'Qt' ) {
		if ($main::qt_embedded) {
			$qtExtras =~ s/public static native TQCursor whatsThisCursor\(\);//;
			$qtjniExtras =~ s/JNIEXPORT jobject JNICALL\nJava_org_kde_qt_Qt_whatsThisCursor[^}]*}//;
		}
		print CLASS $qtExtras;
		$jniCode .= $qtjniExtras;
	} elsif ( $className eq 'TQApplication' ) {
		print CLASS $qapplicationExtras;
		$jniCode .= $qapplicationjniExtras;
	} elsif ( $className eq 'TQBitmap' ) {
		print CLASS $qbitmapExtras;
		$jniCode .= $qbitmapjniExtras;
	} elsif ( $className eq 'TQDropEvent' ) {
		print CLASS $qdropeventExtras;
		$jniCode .= $qdropeventjniExtras;
	} elsif ( $className eq 'TQDragObject' ) {
		print CLASS $qdragobjectExtras;
		$jniCode .= $qdragobjectjniExtras;
	} elsif ( $className eq 'TQObject' ) {
		print CLASS $qobjectExtras;
		$jniCode .= $qobjectjniExtras;
	} elsif ( $className eq 'TQImage' ) {
		$jniCode .= $qimagejniExtras;
	} elsif ( $className eq 'TQListView' ) {
		print CLASS $qlistviewExtras;
		$jniCode .= $qlistviewjniExtras;
	} elsif ( $className eq 'TQListViewItem' ) {
		print CLASS $qlistviewitemExtras;
		$jniCode .= $qlistviewitemjniExtras;
	} elsif ( $className eq 'TQMenuBar' ) {
		if ($main::qt_embedded) {
			$qmenubarjniExtras =~ s/jobject accel/jlong accel/;
		}
		$jniCode .= $qmenubarjniExtras;
	} elsif ( $className eq 'TQMenuData' ) {
		if ($main::qt_embedded) {
			$qmenudatajniExtras =~ s/jobject accel/jlong accel/;
		}
		$jniCode .= $qmenudatajniExtras;
	} elsif ( $className eq 'TQMimeSource' ) {
		print CLASS $qmimesourceExtras;
		$jniCode .= $qmimesourcejniExtras;
	} elsif ( $className eq 'TQPopupMenu' ) {
		if ($main::qt_embedded) {
			$qpopupmenujniExtras =~ s/jobject accel/jlong accel/;
		}
		$jniCode .= $qpopupmenujniExtras;
	} elsif ( $className eq 'TQWidget' ) {
		print CLASS $qwidgetExtras;
		$jniCode .= $qwidgetjniExtras;
	} elsif ( $className eq 'TQPaintDevice' ) {
		print CLASS $qpaintdeviceExtras;
		$jniCode .= $qpaintdevicejniExtras;
	} elsif ( $className eq 'TQPixmap' ) {
		print CLASS $qpixmapExtras;
		$jniCode .= $qpixmapjniExtras;
	} elsif ( $className eq 'TQIODevice' ) {
		print CLASS $qiodeviceExtras;
	} elsif ( $className eq 'TQPointArray' ) {
		print CLASS $qpointarrayExtras;
		$jniCode .= $qpointarrayjniExtras;
	} elsif ( $className eq 'TQUriDrag' ) {
		print CLASS $quridragExtras;
		$jniCode .= $quridragjniExtras;
	} elsif ( $className eq 'KCmdLineArgs' ) {
		$jniCode .= $kcmdlineargsjniExtras;
	} elsif ( $className eq 'KIO::Scheduler' ) {
		$jniCode .= $schedulerjniExtras;
	} elsif ( $className eq 'KApplication' ) {
		print CLASS $kapplicationExtras;
		$jniCode .= $kapplicationjniExtras;
	} elsif ( $className eq 'KMainWindow' ) {
		print CLASS $kmainwindowExtras;
		$jniCode .= $kmainwindowjniExtras;
	}
	
    print CLASS "}\n";
	close CLASS;
	
	foreach my $incl (keys %addInclude) {
	    die if $incl eq '';
	    print JNISOURCE "#include <$incl>\n";
	}	
	
	print JNISOURCE "\n";
	print JNISOURCE "#include <qtjava/QtSupport.h>\n";
	
	if ($jniCode =~ /JavaSlot/) {
		print JNISOURCE "#include <qtjava/JavaSlot.h>\n";
	}
	
	if ( $typeprefix eq "qt_" ) {
		print JNISOURCE "#include <qtjava/$javaClassName" . ".h>\n";
	} else {
		print JNISOURCE "#include <kdejava/KDESupport.h>\n";
		print JNISOURCE "#include <kdejava/$javaClassName" . ".h>\n";
	}
	
	if ($javaClassName eq 'KIO') {
		# Hack: namespaces can be defined in several source files, which doesn't work, so this..
		print JNISOURCE "#include <kio/job.h>\n";
		print JNISOURCE "#include <kio/davjob.h>\n";
		print JNISOURCE "#include <kio/metainfojob.h>\n";
		print JNISOURCE "#include <kio/previewjob.h>\n";
		print JNISOURCE "#include <kio/paste.h>\n";
	}
	
	print JNISOURCE "\n";
	
	if ($jbridgeCode ne '' && $node->{CanBeInstanciated}) {
		print JNISOURCE "class $javaClassName" . "JBridge : public $className\n";
		print JNISOURCE "{\npublic:\n";
		print JNISOURCE $jbridgeCode;
		print JNISOURCE "};\n\n"
	}
	print JNISOURCE $jniCode;
	close JNISOURCE;
}


# Generate the prototypes for a method (one per arg with a default value)
# Helper for makeprotos
sub iterproto($$$$$) {
    my $classidx = shift; # to check if a class exists
    my $method = shift;
    my $proto = shift;
    my $idx = shift;
    my $protolist = shift;

    my $argcnt = scalar @{ $method->{ParamList} } - 1;
    if($idx > $argcnt) {
	push @$protolist, $proto;
	return;
    }
    if(defined $method->{FirstDefaultParam} and $method->{FirstDefaultParam} <= $idx) {
	push @$protolist, $proto;
    }

    my $arg = $method->{ParamList}[$idx]->{ArgType};

    my $typeEntry = findTypeEntry( $arg );
    my $realType = $typeEntry->{realType};

    # A scalar ?
    $arg =~ s/\bconst\b//g;
    $arg =~ s/\s+//g;
    if($typeEntry->{isEnum} || $allTypes{$realType}{isEnum} || exists $typeunion{$realType} || exists $mungedTypeMap{$arg})
    {
	my $id = '$'; # a 'scalar
	$id = '?' if $arg =~ /[*&]{2}/;
	$id = $mungedTypeMap{$arg} if exists $mungedTypeMap{$arg};
	iterproto($classidx, $method, $proto . $id, $idx + 1, $protolist);
	return;
    }

    # A class ?
    if(exists $classidx->{$realType}) {
	iterproto($classidx, $method, $proto . '#', $idx + 1, $protolist);
	return;
    }

    # A non-scalar (reference to array or hash, undef)
    iterproto($classidx, $method, $proto . '?', $idx + 1, $protolist);
    return;
}

# Generate the prototypes for a method (one per arg with a default value)
sub makeprotos($$$) {
    my $classidx = shift;
    my $method = shift;
    my $protolist = shift;
    iterproto($classidx, $method, $method->{astNodeName}, 0, $protolist);
}

# Return the string containing the signature for this method (without return type).
# If the 2nd arg is not the size of $m->{ParamList}, this method returns a
# partial signature (this is used to handle default values).
sub methodSignature($$) {
    my $method = shift;
    my $last = shift;
    my $sig = $method->{astNodeName};
    my @argTypeList;
    my $argId = 0;
    foreach my $arg ( @{$method->{ParamList}} ) {
	last if $argId > $last;
	push @argTypeList, $arg->{ArgType};
	$argId++;
    }
    $sig .= "(". join(", ",@argTypeList) .")";
    $sig .= " const" if $method->{Flags} =~ "c";
    return $sig;
}

# Return the string containing the java signature for this method (without return type).
# If the 2nd arg is not the size of $m->{ParamList}, this method returns a
# partial signature (this is used to handle default values).
sub javaMethodSignature($$) {
    my $method = shift;
    my $last = shift;
    my $sig = $method->{astNodeName};
    my @argTypeList;
    my $argId = 0;
    foreach my $arg ( @{$method->{ParamList}} ) {
	$argId++;
	last if $argId > $last;
	push @argTypeList, "arg" . "$argId ". cplusplusToJava( $arg->{ArgType} );
    }
    $sig .= "(". join(", ",@argTypeList) .")";
    return $sig;
}

# Return the string containing the JNI signature for this method (without return type).
# If the 2nd arg is not the size of $m->{ParamList}, this method returns a
# partial signature (this is used to handle default values).
sub jniMethodSignature($$$$$) {
    my $method = shift;
	my $methodname = shift;
    my $last = shift;
	my $javaClassName = shift;
	my $javaArgList = shift;
	
	my $sig = ($javaClassName =~ /^Q/ ? "Java_org_kde_qt_" : "Java_org_kde_koala_");
    $sig .= $javaClassName . "_";
	$methodname =~ s/_/_1/g;
	$sig .= $methodname . "__";
    my @argTypeList;
    my @argList;
	my $javaStatic = ($method->{Flags} =~ "s" or $method->{Parent}->{NodeType} eq 'namespace');
	push @argTypeList, "JNIEnv*";
	push @argTypeList, ($javaStatic ? "jclass" : "jobject");
	push @argList, "JNIEnv* env";
	push @argList, ($javaStatic ? "jclass cls" : "jobject obj");
    my $argId = 0;
    foreach my $arg ( @{$method->{ParamList}} ) {
	$argId++;
	last if $argId > $last;
	push @argTypeList, cplusplusToJNI( $arg->{ArgType} );
	push @argList, cplusplusToJNI( $arg->{ArgType} ) . " " . $javaArgList->[$argId - 1];
	$sig .= cplusplusToJNISignature( $arg->{ArgType} );
    }
	my $call = $sig;
    $sig .= "(" . join(", ",@argTypeList) .")";
    $call .= "(" . join(", ",@argList) .")";
    return ( $sig, $call );
}

sub coerce_type($$$$) {
    #my $m = shift;
    my $union = shift;
    my $var = shift;
    my $type = shift;
    my $new = shift; # 1 if this is a return value, 0 for a normal param

    my $typeEntry = findTypeEntry( $type );
    my $realType = $typeEntry->{realType};

    my $unionfield = $typeEntry->{typeId};
#    die "$type" unless defined( $unionfield );
	if ( ! defined( $unionfield ) ) {
		print STDERR "type field not defined: $type\n";
		return "";
	}
	
    $unionfield =~ s/t_/s_/;

    $type =~ s/\s+const$//; # for 'char* const'
    $type =~ s/\s+const\s*\*$/\*/; # for 'char* const*'

    my $code = "$union.$unionfield = ";
    if($type =~ /&$/) {
	$code .= "(void*)&$var;\n";
    } elsif($type =~ /\*$/) {
	$code .= "(void*)$var;\n";
    } else {
	if ( $unionfield eq 's_class' 
		or ( $unionfield eq 's_voidp' and $type ne 'void*' )
		or $type eq 'TQString' ) { # hack
	    $type =~ s/^const\s+//;
	    if($new) {
	        $code .= "(void*)new $type($var);\n";
	    } else {
	        $code .= "(void*)&$var;\n";
	    }
	} else {
	    $code .= "$var;\n";
	}
    }

    return $code;
}

# Generate the list of args casted to their real type, e.g.
# (TQObject*)x[1].s_class,(TQEvent*)x[2].s_class,x[3].s_int
sub makeCastedArgList
{
    my @castedList;
    my $i = 1; # The args start at x[1]. x[0] is the return value
    my $arg;
    foreach $arg (@_) {
	my $type = $arg;
	my $cast;

	my $typeEntry = findTypeEntry( $type );
	my $unionfield = $typeEntry->{typeId};
#	die "$type" unless defined( $unionfield );
	if ( ! defined( $unionfield ) ) {
		print STDERR "type field not defined: $type\n";
		return "";
	}
	$unionfield =~ s/t_/s_/;

	$type =~ s/\s+const$//; # for 'char* const'
	$type =~ s/\s+const\s*\*$/\*/; # for 'char* const*'

	my $v .= " arg$i";
	if($type =~ /&$/) {
	    $cast = "*($type *)";
	} elsif($type =~ /\*$/) {
	    $cast = "($type)";
        } elsif($type =~ /\(\*\)\s*\(/) { # function pointer ... (*)(...)
            $cast = "($type)";
	} else {
	    if ( $unionfield eq 's_class'
		or ( $unionfield eq 's_voidp' and $type ne 'void*' )
		or $type eq 'TQString' ) { # hack
	        $cast = "*($type *)";
	    } else {
	        $cast = "($type)";
	    }
	}
	push @castedList, "$type$v";
	$i++;
    }
    return @castedList;
}

# Adds the header for node $1 to be included in $2 if not already there
# Prints out debug stuff if $3
sub addIncludeForClass($$$)
{
    my ( $node, $addInclude, $debugMe ) = @_;
    my $sourcename = $node->{Source}->{astNodeName};
    if ( $sourcename !~ s!.*(kio/|kparts/|dom/|kabc/|ksettings/|kjs/|ktexteditor/|tdeprint/|tdesu/)(.*)!$1$2!m ) {
    	$sourcename =~ s!.*/(.*)!$1!m;
	}
#    die "Empty source name for $node->{astNodeName}" if ( $sourcename eq '' );
    return if ( $sourcename eq '' );
    unless ( defined $addInclude->{$sourcename} ) {
	print "  Including $sourcename\n" if ($debugMe);
	$addInclude->{$sourcename} = 1;
    }
    else { print "  $sourcename already included.\n" if ($debugMe); }
}

sub checkIncludesForObject($$)
{
    my $type = shift;
    my $addInclude = shift;

    my $debugCI = 0; #$debug
    #print "checkIncludesForObject $type\n";
    $type =~ s/const\s+//;
    my $it = $type;
    if (!($it and exists $typeunion{$it}) and $type !~ /\*/ and $type ne ""
         #and $type !~ /&/  # in fact we also want refs, due to the generated code
        ) {
	$type =~ s/&//;
	print "  Detecting an object by value/ref: $type\n" if ($debugCI);
	my $node = kdocAstUtil::findRef( $rootnode, $type );
	if ($node) {
	    addIncludeForClass( $node, $addInclude, $debugCI );
	}
	else { print " No header found for $type\n" if ($debugCI); }
    }
}



# Adds the import for node $1 to be imported in $2 if not already there
# Prints out debug stuff if $3
sub addImportForClass($$$)
{
    my ( $node, $addImport, $debugMe ) = @_;
    my $importname = javaImport( $node->{astNodeName} );
#	print "  Importing $importname for node name: " . $node->{astNodeName} . "\n";
	# No import needed, so return
    return if ( $importname eq '' );
    unless ( defined $addImport->{$importname} ) {
	print "  Importing $importname\n" if ($debugMe);
	$addImport->{$importname} = 1;
	if ( kalyptusDataDict::interfacemap($node->{astNodeName}) ) {
		$addImport->{$importname . "Interface"} = 1;
	}
    }
    else { print "  $importname already imported.\n" if ($debugMe); }
}

sub checkImportsForObject($$)
{
    my $type = shift;
    my $addImport = shift;

    my $debugCI = 0; #$debug
    # print "checkImportsForObject $type\n";
    $type =~ s/const\s+//;
    my $it = $type;
    if (!($it and exists $typeunion{$it}) and $type ne ""
         #and $type !~ /&/  # in fact we also want refs, due to the generated code
        ) {
	$type =~ s/&//;
	$type =~ s/[*]//;
	print "  Detecting an object by value/ref: $type\n" if ($debugCI);
	my $node = kdocAstUtil::findRef( $rootnode, $type );
	if ($node and $node->{NodeType} eq "class" ) {
		print "  NodeType: " . $node->{NodeType} . "\n" if ($debugCI);
	    addImportForClass( $node, $addImport, $debugCI );
	}
	else {
		if ( cplusplusToJava($it) eq 'ArrayList' ) {
			$addImport->{"java.util.ArrayList"} = 1;
		} else {
			print " No import found for $type\n" if ($debugCI); 
		} 
 	}
    }
}

sub generateVirtualMethod($$$$$)
{
    # Generating methods for $class.
    # $m: method node. $methodClass: the node of the class in which the method is really declared
    # (can be different from $class when the method comes from a super class)
    # This is important because of $allMethods, which has no entry for class::method in that case.

    my( $classNode, $signature, $m, $methodClass, $addImport ) = @_;
    my $methodCode = '';                    # output
    my $returnType = $m->{ReturnType};
    return ('', '') if $returnType eq '~'; # skip destructors

    my $className = $classNode->{astNodeName};
    my $flags = $m->{Flags};
    my @argList = @{$m->{ParamList}};

    print "generateVirtualMethod $className: $signature  ($m->{Access})\n" if ($debug);

    # Detect objects returned by value
    checkImportsForObject( $returnType, $addImport ) if ($returnType ne 'void');

    # Generate a matching virtual method in the x_ class
    $methodCode .= "\tvirtual $returnType $m->{astNodeName}(";
    my $i = 0;
    foreach my $arg ( @argList ) {
        $methodCode .= ", " if $i++;
        $methodCode .= $arg->{ArgType};
        $methodCode .= " x$i";

	# Detect objects passed by value
	checkImportsForObject( $arg->{ArgType}, $addImport );
    }
    $methodCode .= ") ";
    $methodCode .= "const " if ($flags =~ "c");
    $methodCode .= "\{\n";

    # Now the code of the method
    my $this = $classNode->{BindingDerives} > 0 ? "this" : "xthis";

    $i++; # Now the number of args
    $methodCode .= "\tSmoke::StackItem x[$i];\n";
    $i = 1;
    for my $arg (@argList) {
	$methodCode .= "\t";
	$methodCode .= coerce_type("x[$i]", "x$i", $arg->{ArgType}, 0);
	$i++;
    }

    my $sig = $methodClass->{astNodeName} . "::" . $signature;
    my $idx = $allMethods{$sig};
#    die "generateVirtualMethod: $className: No method found for $sig\n" if !defined $idx;
	if ( !defined $idx ) {
		print STDERR "generateVirtualMethod: $className: No method found for $sig\n";
		return "";
	}
	
    if($flags =~ "p") { # pure virtual
	$methodCode .= "\t${libname}_Smoke->binding->callMethod($idx, (void*)$this, x, true /*pure virtual*/);\n";
    } else {
	$methodCode .= "\tif(${libname}_Smoke->binding->callMethod($idx, (void*)$this, x)) ";
    }

    $returnType = undef if ($returnType eq 'void');
    if($returnType) {
	my $arg = $returnType;
	my $it = $arg;
	my $cast;
	my $v = "x[0]";
	my $indent = ($flags =~ "p") ? "\t" : "";
	if($it and exists $typeunion{$it}) {
	    $v .= ".$typeunion{$it}";
	    $cast = "($arg)";
	    $methodCode .= "${indent}return $cast$v;\n";
	} else {
	    $v .= ".s_class";
	    if($arg =~ s/&//) {
		$cast = "*($arg *)";
		$methodCode .= "${indent}return $cast$v;\n";
	    } elsif($arg !~ /\*/) {
		unless($flags =~ "p") {
		    $indent = "\t    ";
		    $methodCode .= "{\n";
		}
		# we assume it's a new thing, and handle it
		$methodCode .= "${indent}$arg *xptr = ($arg *)$v;\n";
		$methodCode .= "${indent}$arg xret(*xptr);\n";
		$methodCode .= "${indent}delete xptr;\n";
		$methodCode .= "${indent}return xret;\n";
		$methodCode .= "\t}\n" unless $flags =~ "p";
	    } else {
		$cast = "($arg)";
		$methodCode .= "${indent}return $cast$v;\n";
	    }
	}
    } else {
	$methodCode .= "\t" if $flags =~ "p";
	$methodCode .= "return;\n";
    }
    if($flags =~ "p") {
	$methodCode .= "\t// ABSTRACT\n";
	$methodCode .= "    }\n";
	return ( $methodCode );
    }
    $methodCode .= "\t";
    if($returnType) {
	$methodCode .= "return ";
    }
    $methodCode .= "$this\->$methodClass->{astNodeName}\::$m->{astNodeName}(";
    $i = 0;
    for my $arg (@argList) {
	$methodCode .= ", " if $i++;
	$methodCode .= "x$i";
    }
    $methodCode .= ");\n";
    $methodCode .= "\t}\n";
    return ( $methodCode );
}

sub generateMethod($$$$$$$$$)
{
    my( $classNode, $m, $addImport, $addInclude, $ancestorCount, $javaMethods, $jniMethods, $mainClassNode, $generateConstructors ) = @_;	# input
    my $methodCode = '';	# output
    my $interfaceCode = '';	# output
    my $signalCode = '';	# output
    my $jbridgeCode = '';	# output
	
    my $jniCode;
    my $name = $m->{astNodeName}; # method name
    
	my @heritage = kdocAstUtil::heritage($classNode);
    my $className  = join( "::", @heritage );
    
	@heritage = kdocAstUtil::heritage($mainClassNode);
	my $mainClassName  = join( "::", @heritage );

	# The javaClassName might be 'TQWidget', while currentClassName is 'TQRangeControl'
	# and the TQRangeControl methods are being copied into TQWidget.    
	my $javaClassName  = $mainClassNode->{astNodeName};
    my $currentClassName  = $classNode->{astNodeName};
	
	my $bridgeClassName;
	if ($classNode->{astNodeName} eq $main::globalSpaceClassName) {
		$bridgeClassName  = "";
	} elsif (!$mainClassNode->{CanBeInstanciated}) {
		$bridgeClassName  = $className;
	} else {
		$bridgeClassName  = $mainClassNode->{astNodeName} . "JBridge";
	}
	
	my $firstUnknownArgType = 99;
    my $returnType = $m->{ReturnType};

    # Don't use $className here, it's never the fully qualified (A::B) name for a ctor.
    my $isConstructor = ($name eq $classNode->{astNodeName} );
    my $isDestructor = ($returnType eq '~');

    # Don't generate anything for destructors, or constructors for namespaces
    return if $isDestructor 
			or ($classNode->{NodeType} eq 'namespace' and $isConstructor)
			or (!$mainClassNode->{CanBeInstanciated} and $m->{Access} =~ /protected/);
    
	# Rename operator methods 'op_...'
	if ( $name =~ /^operator.*/ ) {
		$methodNumber++;
		$name =~ s/ //;
		if (! exists $operatorNames{$name} ) {
			return;
		}
		$name = $operatorNames{$name};
	}
	
	if ($classNode->{astNodeName} eq $main::globalSpaceClassName) {
		my $sourcename = $m->{Source}->{astNodeName};
		# Only put Global methods which came from sources beginning with q into class Qt
		# Skip any methods in qstring.h/qcstring.h apart from TQByteArray compress/uncompress
		if ($javaClassName eq 'Qt' 
		and ( $sourcename !~ /\/q[^\/]*$/ or ($sourcename =~ /string.h$/ and $name !~ /[Cc]ompress/) )) {
			return;
		}
		# ..and any other global methods into KDE
		if ($javaClassName eq 'KDE' and $m->{Source}->{astNodeName} =~ /\/q[^\/]*$/) {
			return;
		}

		if ( $sourcename !~ s!.*(kio/|kparts/|dom/|kabc/|ksettings/|kjs/|ktexteditor/|tdeprint/|tdesu/)(.*)!$1$2!m ) {
			$sourcename =~ s!.*/(.*)!$1!m;
		}
		if ( $sourcename eq '' ) {
			return;
		}
		$addInclude->{$sourcename} = 1;
	}
	
    if ($returnType eq 'void') {
    	$returnType = undef;
	} else {
	    # Detect objects returned by value
    	checkImportsForObject( $returnType, $addImport );
    	checkIncludesForObject( $returnType, $addInclude );
	}
	
	my $hasDuplicateSignature = 0;
	my $isStatic = $m->{Flags} =~ "s";
	my $isPure = $m->{Flags} =~ "p";
	
    return if ( $m->{SkipFromSwitch} && $m->{Flags} !~ "p" ); 

#    # Skip internal methods, which return unknown types
#    # Hmm, the C# bindings have a list of those too.
#    return if ( $returnType =~ m/TQGfx\s*\*/ );
#    return if ( $returnType eq 'CGContextRef' );
#    return if ( $returnType eq 'TQWSDisplay *' );
#    # This stuff needs callback, or **
#    return if ( $name eq 'defineIOHandler' or $name eq 'qt_init_internal' );
#    # Skip casting operators, but not == < etc.
#    return if ( $name =~ /operator \w+/ );
#    # TQFile's EncoderFn/DecoderFn
#    return if ( $name =~ /set[ED][ne]codingFunction/ );
#    # How to implement this? (TQXmlDefaultHandler/TQXmlEntityResolver::resolveEntity, needs A*&)
#    return if ( $name eq 'resolveEntity' and $className =~ /^TQXml/ );
#    return if ( $className eq 'TQBitArray' && $m->{Access} eq 'protected' );

    #print STDERR "Tests passed, generating.\n";


    my $argId = 0;

    my @argTypeList=();
    my @javaArgTypeList=();
    my @javaArgList = ();
    my @jniArgList = ();
    my @jniArgLocals = ();
    my @jniCleanups = ();
    my @namedArgTypeList=();
	
    foreach my $arg ( @{$m->{ParamList}} ) {
		$argId++;
	
		if ( $arg->{ArgName} =~ /^super$|^int$|^env$|^cls$|^obj$|^byte$/ ) {
			$arg->{ArgName} = "";
		}

		if ( $arg->{ArgName} =~ /^short$|^long$/ ) {
			# Oops looks like a parser error
			$arg->{ArgType} = $arg->{ArgName};
			$arg->{ArgName} = "";
		}
	
	print STDERR "  Param ".$arg->{astNodeName}." type: ".$arg->{ArgType}." name:".$arg->{ArgName}." default: ".$arg->{DefaultValue}." java: ".cplusplusToJava($arg->{ArgType})."\n" if ($debug);
		
	my $argType = $arg->{ArgType};
	my $namedArgType;
	my $javaArgType;
	my $javaArg;
	my $jniArg;
	my $jniLocal;
	my $jniCleanup;
	my $argName;
	
	if ( cplusplusToJava($argType) eq "" && $firstUnknownArgType > $argId ) {
		$firstUnknownArgType = $argId;
	}
	
	$javaArg = ($arg->{ArgName} eq "" ? "arg" . $argId : $arg->{ArgName});
	$namedArgType = $argType . " " . $javaArg;
	$javaArgType = cplusplusToJava($argType) . " " . $javaArg;
	($jniLocal, $jniArg, $jniCleanup) = jniArgTocplusplus($argType, $javaArg);
	
	push @argTypeList, $argType;
	push @javaArgTypeList, $javaArgType;
	push @javaArgList, $javaArg;
	push @jniArgLocals, $jniLocal;
	push @jniCleanups, $jniCleanup;
	push @jniArgList, $jniArg;
	push @namedArgTypeList, $namedArgType;
	
	# Detect objects passed by value
	checkImportsForObject( $argType, $addImport );
	checkIncludesForObject( $argType, $addInclude );
    }

	if ( $name eq 'TQApplication' or ($javaClassName eq 'KCmdLineArgs' and $name eq 'init' and scalar(@javaArgList) > 1) ) {
		# Junk the 'int argc' parameter
		shift @javaArgTypeList;
		shift @javaArgList;
	}

    my @castedArgList = makeCastedArgList( @argTypeList );
     
    # We iterate as many times as we have default params
    my $firstDefaultParam = $m->{FirstDefaultParam};
    $firstDefaultParam = scalar(@argTypeList) unless defined $firstDefaultParam;
    my $iterationCount = scalar(@argTypeList) - $firstDefaultParam;

	my $jniReturnType = cplusplusToJNI($m->{ReturnType});
	# ArrayLists are jobjectArrays in args, but jobjects in return types
	$jniReturnType =~ s/jobjectArray/jobject/;
	
	my $javaReturnType = cplusplusToJava($m->{ReturnType});
	if ( $javaReturnType =~ s/StringBuffer/String/ ) {
		$jniReturnType =~ s/jobject/jstring/;
	} elsif ( $javaReturnType =~ s/String\[\]/ArrayList/ ) {
		$addImport->{"java.util.ArrayList"} = 1;
	}
	
	if ($m->{ReturnType} =~ /^int\&/) {
		$javaReturnType = 'int';
		$jniReturnType =~ s/jintArray/jint/;
	}
	
	if ($javaReturnType eq "") {
		$firstUnknownArgType = 0;
	}

    print STDERR "  ". ($iterationCount+1). " iterations for $name\n" if ($debug);
	
	my $javaSignature = javaMethodSignature( $m, @argTypeList );
	
	if ( defined $javaMethods->{$javaSignature} ) {
		$hasDuplicateSignature = 1;
	}
	
	my $docnode = $m->{DocNode};
	if ( $firstUnknownArgType >= 0 && $m->{Access} !~ /signals/ && ! $hasDuplicateSignature
		&& defined $docnode && ($generateConstructors || !$isConstructor) ) 
	{
		my $javadocComment = printJavadocComment( $docnode, "", "\t", "" );
		$methodCode .=  "\t/**" . $javadocComment . "*/\n" unless $javadocComment =~ /^\s*$/;
	}

    while($iterationCount >= 0) {
	
	$javaMethods->{$javaSignature} = 1;

	local($") = ",";
	
	if($firstUnknownArgType <= scalar(@argTypeList) || $hasDuplicateSignature || ($name =~ /^qObject$/) || $m->{Access} =~ /dcop/ ) {
		if ( $firstUnknownArgType <= scalar(@argTypeList) || $m->{Access} =~ /dcop/ ) {
			my $failedConversion = "\t// " . $m->{ReturnType} . " $name(@castedArgList[0..$#argTypeList]); >>>> NOT CONVERTED\n";
			if ( $m->{Access} =~ /signals/ ) {
				$signalCode .= $failedConversion;
			} else {
				$methodCode .= $failedConversion;
			}
		}
	} else {

#	    $jniCode .= "\tcase $methodNumber: ";
#	    if ($flags =~ "s" || $isConstructor) { # static or constructor
#	        $jniCode .= "$bridgeClassName\::";
#	    } else {
#	        $jniCode .= "xself->"
#	    }
#	    $jniCode .= "x_$methodNumber(args);";
#	    $jniCode .= "\tbreak;\n";

		if ($name eq 'find' and $javaClassName eq 'TQButtonGroup') {
			# Can't override a static method find() in TQWidget
			$name = "findButton";
		} elsif ( $name eq 'null' ) {
			$name = "nil";
		} elsif ( $name eq 'form' and $javaClassName =~ /^HTML/ ) {
			$name = "formElement";
		} elsif ( $name eq 'wait' and $javaClassName eq 'KProcess' ) {
			$name = "waitThread";
		} elsif ( $name eq 'finalize' and $javaClassName eq 'KMD5' ) {
			$name = "finalizeDigest";
		} elsif ( $name eq 'icon' and $javaClassName eq 'TQMessageBox' ) {
			$name = "iconId";
		} elsif ( $name eq 'icon' and $javaClassName eq 'KURLBarItemDialog' ) {
			$name = "iconName";
		} elsif ( $name eq 'iconText' and $javaClassName eq 'KToolBar' ) {
			$name = "iconTextId";
		} elsif ( $name eq 'reset' and $javaClassName eq 'KExtendedSocket' ) {
			$name = "resetSocket";
		} elsif ( $name eq 'palette' and $javaClassName eq 'KPaletteTable' ) {
			$name = "paletteName";
		} elsif ( $name eq 'size' and $javaClassName eq 'KAnimWidget' ) {
			$name = "iconSize";
		} elsif ( $name eq 'size' and $javaClassName eq 'KFontCombo' ) {
			$name = "pointSize";
		} elsif ($javaSignature eq "icon()" and $javaClassName eq 'KIconButton') {
			$name = "iconName";
		} elsif ($javaSignature eq "close()" and $javaClassName eq 'KDirOperator') {
			$name = "closeLoading";
		} elsif ($javaSignature eq "font()" and $javaClassName eq 'KCharSelect') {
			$name = "fontName";
		} elsif ($javaSignature eq "layout()" and $javaReturnType eq 'void') {
			$name = "updateLayout";
		} elsif ( $name eq 'sorting' and $javaReturnType eq 'boolean' ) {
			$name = "sortOnInsert";
		} elsif ($javaSignature eq "statusBar()" and $javaClassName =~ /^K/ ) {
	    	$name = "kstatusBar";
		} elsif ($javaSignature eq "menuBar()" and $javaClassName =~ /^K/ ) {
	    	$name = "kmenuBar";
		} elsif ( $name eq 'addLabel' and $javaClassName eq 'TQTableHeader' ) {
			$name = "addHeaderLabel";
		}

	    my $javaparams = join( ", ", @javaArgTypeList );
		my ( $jniSignature, $jniCall ) = jniMethodSignature( $m, 
															($isConstructor ? "new$name" : $name), 
															@argTypeList, $javaClassName, \@javaArgList );
			    
		my $cplusplusparams;
		my $i = 0;
		for my $arg (@argTypeList) {
			$cplusplusparams .= "," if $i++;
			$cplusplusparams .= "arg" . $i;
		}
	
	    if ($isConstructor) {
			if ( $generateConstructors && $mainClassNode->{CanBeInstanciated} ) {
	        	$jbridgeCode .= "\t$bridgeClassName(@castedArgList[0..$#argTypeList]) : $className($cplusplusparams) {};\n";
	        	
				$methodCode .= "\tpublic $javaClassName($javaparams) {\n";
				if ( $ancestorCount > 0 ) {
	        		$methodCode .= "\t\tsuper((Class) null);\n"
				}
				$methodCode .= "\t\tnew$javaClassName(@javaArgList[0..$#javaArgTypeList]);\n";
				$methodCode .= "\t}\n";
	    		$methodCode .= "\tprivate native void new$javaClassName($javaparams);\n";
	    		
				$jniCode = "JNIEXPORT void JNICALL\n";
	    		$jniCode .=  "$jniCall\n";
	    		$jniCode .= "{\n";
	    		$jniCode .= join( "", @jniArgLocals );
				$jniCode .= "\tif (QtSupport::getQt(env, obj) == 0) {\n";
	    		$jniCode .= "\t\tQtSupport::setQt(env, obj, new $bridgeClassName(" . join( ", ", @jniArgList ). "));\n";
	    		$jniCode .= "\t\tQtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));\n";
	    		$jniCode .= join( "", @jniCleanups );
	    		$jniCode .= "\t}\n\treturn;\n}\n\n";
				
				# Look for args which are are a TQQbject/slot string pair and replace with a java proxy slot
				if ($jniCode =~ s/QtSupport::getQt\(env, (receiver|recvr|pObjSlot)\), \(const char\*\) QtSupport::toCharString\(env, (member|slot|psMethodSlot), \&_qstring_(member|slot|psMethodSlot)\)/QtSupport::slotForReceiver(env, $1, $2), "1invoke()"/) {
					$jniCode =~ s/static TQCString\* _qstring_(member|slot|psMethodSlot) = 0;\n//;
				}
				
				$jniSignature =~ /^([^\)]*)\(.*/;
				if ($skippedJniMethods{$1}) {
					# Don't generate code for jni methods added as 'extras'
					$jniMethods->{$jniSignature} = "";
				} else {
					$jniMethods->{$jniSignature} = $jniCode;
				}
			}
	    } else {
			my $access = $m->{Access};
			$access =~ s/_slots//;
			
			if ( $access eq 'public' or $access eq 'protected' ) {
				if ( $name =~ /^takeItem$|^setPixmap$|^clearCell$|^setItem$|^item$|^minimumSize$/
					or $name =~ /^stepUp$|^stepDown$|^sectionFormattedText$|^addNumber$|^removeLastNumber$/
					or $name =~ /^cancel$|^setSource$|^paintCell$|^updateContents$|^sizeHint$|^setFocusSection$/
					or $name =~ /^event$|^eventFilter$|^copy$|^detach$|^showEvent$|^format$|^encodedData$/
					or $name =~ /^styleChange$|^insertItem$|^setStatus$|^setState$|^minimumSizeHint$/
					or $name =~ /^bytesPerLine$|^paintBranches$|^scanLine$|^ensureCursorVisible$|^setCursor$/
					or $name =~ /^updateGeometry$|^setState$|^exec$|^pixmap$|^areaPoints$|^draw$|^writeDir$/ ) {
					# These methods are public in some places, but protected in others,
					# so make them all public.
					$access = "public";
				}
				
				$methodCode .= "\t" . $access . (($isStatic or $classNode->{NodeType} eq 'namespace') ? " static " : " ") . "native ";
#	    		$methodCode .= ( $m->{Flags} =~ "v" || $isStatic ? "" : "final " );

				my $altReturnType = undef;
				if ($name =~ /^xForm$/ ) {
	    			$javaReturnType = "Object";
				} elsif ($javaSignature eq "layout()" and $javaReturnType ne 'void') {
	    			$altReturnType = "TQLayout";
				} elsif ($javaSignature eq "defaultFactory()" and $javaReturnType eq 'TQSqlEditorFactory') {
	    			$javaReturnType = "TQEditorFactory";
				} elsif ($javaSignature =~ /^bits|^scanLine/) {
	    			$javaReturnType = "byte[]";
				} elsif ($javaSignature eq "at()" and $javaClassName eq 'KFilterDev') {
	    			$javaReturnType = "long";
				} elsif ($javaSignature =~ /copyTo/ and $javaClassName eq "KDesktopFile" ) {
	    			$altReturnType = "KConfig";
				}
				
				if ( defined $altReturnType ) {
					checkImportsForObject( $altReturnType, $addImport );
					$javaReturnType = $altReturnType;
				}
	    		$methodCode .= $javaReturnType;
	    		$methodCode .= " $name($javaparams);\n";
				
				if ($access eq 'public' and !$isStatic) {
	    			$interfaceCode .= "\t\t$javaReturnType $name($javaparams);\n";
				}
				
				my $methodName = $m->{astNodeName};
				# Hack to stop calling super for TQWidget::polish() from looping
				if (	$m->{Access} =~ /public/ 
						&& $returnType eq '' 
						&& $m->{Flags} =~ "v" 
						&& $cplusplusparams eq ''
						&& $bridgeClassName  ne $className ) 
				{
					$methodName = "public_" . $m->{astNodeName};
	    			$jbridgeCode .= "\t";
	    			$jbridgeCode .= "void $methodName() {\n";
	    			$jbridgeCode .= "\t\t$className" . "::" . $m->{astNodeName} . "();\n";
	    			$jbridgeCode .= "\t\treturn;\n";
	    			$jbridgeCode .= "\t}\n";
				}
				
				if ($m->{Access} =~ /protected/) {
					$methodName = "protected_" . $m->{astNodeName};
	    			$jbridgeCode .= (($isStatic or $classNode->{NodeType} eq 'namespace') ? "\tstatic " : "\t");
					if ( $returnType eq '' ) {
	    				$jbridgeCode .= "void $methodName(@castedArgList[0..$#argTypeList]) {\n";
	    				$jbridgeCode .= "\t\t$className" . "::" . $m->{astNodeName} . "($cplusplusparams);\n";
	    				$jbridgeCode .= "\t\treturn;\n";
					} else {
	    				$jbridgeCode .= "$returnType $methodName(@castedArgList[0..$#argTypeList]) {\n";
	    				$jbridgeCode .= "\t\treturn ($returnType) $className" . "::" . $m->{astNodeName} . "($cplusplusparams);\n";
					}
	    			$jbridgeCode .= "\t}\n";
				
				}
				
				$jniCode = "JNIEXPORT $jniReturnType JNICALL\n";
				$jniCode .=  "$jniCall\n";
				$jniCode .= "{\n";
				my $selfstring;
				if ( $isStatic or $classNode->{NodeType} eq 'namespace' ) {
					$selfstring = $bridgeClassName . "::" . $methodName;
				} else {
					if ($m->{Access} =~ /protected/ || $methodName =~ /^public_/) {
						$selfstring = "(($bridgeClassName*) QtSupport::getQt(env, obj))->$methodName";
					} else {
						$selfstring = "(($className*)" . ($mainClassName eq $className ? "" : "($mainClassName*)") . " QtSupport::getQt(env, obj))->" . $m->{astNodeName};
					}
				}
				my ($locals, $fcall) = jniToReturnValue( $m->{ReturnType}, "$selfstring(" . join( ", ", @jniArgList ). ")", join( "", @jniCleanups ) );
				# Add dummy statements to avoid compiler warnings if needed
				$locals .= ($jniSignature =~ /jclass/ ? "\t(void) cls;\n" : "");
				$locals .= ($fcall !~ /env/ ? "\t(void) env;\n" : "");

				my $slotArgType = '';
				if ($name eq 'insertAnimatedWidget' or $name eq 'connectStatus' or $name eq 'disconnectStatus') {
					$slotArgType = 'int';
				} elsif ($name eq 'connectResize' or $name eq 'disconnectResize') {
					$slotArgType = 'const TQSize&';
				} elsif ($name eq 'connectUpdate' or $name eq 'disconnectUpdate') {
					$slotArgType = 'const TQRect&';
				}
				# Look for args which are are a TQQbject/slot string pair and replace with a java proxy slot
				
				$locals .= join( "", @jniArgLocals );
				
				if ($fcall =~ s/QtSupport::getQt\(env, (receiver|recvr|pObjSlot)\), \(const char\*\) QtSupport::toCharString\(env, (member|slot|psMethodSlot), \&_qstring_(member|slot|psMethodSlot)\)/QtSupport::slotForReceiver(env, $1, $2), "1invoke($slotArgType)"/) {
					$locals =~ s/static TQCString\* _qstring_(member|slot|psMethodSlot) = 0;\n//;
				}
				
				$jniCode .= $locals;
				
				if ($name eq 'readBlock') {
					$interfaceCode =~ s/String /StringBuffer /;
					$methodCode =~ s/String /StringBuffer /;
					$jniCode =~ s/jstring/jobject/;
					$jniCode =~ /(jlong|jint) (\w+)\)/;
					my $arg2 = $2;
					$jniCode =~ s/_qstring_(\w+) = 0;\n/_qstring_$1 = 0;\n\tif \(_qstring_$1 == 0\) { _qstring_$1 = new TQCString\(\); }\n\t_qstring_$1->resize\(\(uint\) $arg2\);\n/;
					my $arg1 = $1;
					$fcall =~ s/QtSupport::toCharString\([^\)]*\)/_qstring_$arg1->data()/;
					$fcall =~ s/return xret;/QtSupport::fromTQCStringToStringBuffer(env, _qstring_$arg1, $arg1);\n\treturn xret;/;
				}

				$jniCode .= $fcall;
				$jniCode .= "}\n\n";
				
				if ($isPure && $m->{Access} =~ /protected/) {
					# Can't do a lot with implementing these, so give up
					$jniCode = "";
					$jbridgeCode = "";
				}
				
				$jniSignature =~ /^([^\)]*)\(.*/;
				if ($skippedJniMethods{$1}) {
					# Don't generate code for jni methods added as 'extras'
					$jniMethods->{$jniSignature} = "";
				} else {
					$jniMethods->{$jniSignature} = $jniCode;
				}
			} else {
				if ( $access =~ /signals/ )  {
					my $docnode = $m->{DocNode};
					if ( defined $docnode ) {
						my $javadocComment = printJavadocComment( $docnode, "", "\t", "" );
						$signalCode .=  "\t/**" . $javadocComment . "*/\n" unless $javadocComment =~ /^\s*$/;
					}
	    			$signalCode .= "\tvoid $name($javaparams);\n";
				}
			}
	    }
    }

	pop @argTypeList;
	pop @javaArgTypeList;
	pop @javaArgList;
	pop @jniArgList;
	pop @jniArgLocals;
	pop @jniCleanups;
	
	$javaSignature = javaMethodSignature( $m, @argTypeList );
	$hasDuplicateSignature = (defined $javaMethods->{$javaSignature} ? 1 : 0);
	
	$methodNumber++;
	$iterationCount--;
    } # Iteration loop

    return ( $methodCode, $interfaceCode, $signalCode, $jbridgeCode );
}


sub generateEnum($$$)
{
    my( $classNode, $m, $generateAnonymous ) = @_;	# input
    my $methodCode = '';	# output

    my @heritage = kdocAstUtil::heritage($classNode);
    my $className  = join( "::", @heritage );
    my $javaClassName  = $classNode->{astNodeName};

	if ( ($generateAnonymous and $m->{astNodeName} ) or (! $generateAnonymous and ! $m->{astNodeName}) ) {
		return;
	}
	
	if ( defined $m->{DocNode} ) {
		my $javadocComment = printJavadocComment( $m->{DocNode}, "", "\t", "" );
		$methodCode .=  "\t/**" . $javadocComment . "*/\n" unless $javadocComment =~ /^\s*$/;
	}
	
	my @enums = split(",", $m->{Params});
	my $enumCount = 0;
	foreach my $enum ( @enums ) {
		$enum =~ s/\s//g;
		$enum =~ s/::/./g;
		$enum =~ s/\(mode_t\)//;
		if ( $enum =~ /(.*)=([-0-9]+)$/ ) {
			$methodCode .= "\tpublic static final int $1 = $2;\n";
			$enumCount = $2;
			$enumCount++;
		} elsif ( $enum =~ /(.*)=(.*)/ ) {
			$methodCode .= "\tpublic static final int $1 = $2;\n";
		} else {
			$methodCode .= "\tpublic static final int $enum = $enumCount;\n";
			$enumCount++;
		}
	}
		
	$methodCode .= "\n";
	$methodNumber++;
		
    return ( $methodCode );
}

sub generateVar($$$)
{
    my( $classNode, $m, $addImport ) = @_;	# input
    my $methodCode = '';	# output
    my $interfaceCode = '';	# output

    my @heritage = kdocAstUtil::heritage($classNode);
    my $className  = join( "::", @heritage );
    my $javaClassName  = $classNode->{astNodeName};

    my $name = $m->{astNodeName};
    my $varType = $m->{Type};
    $varType =~ s/static\s//;
    $varType =~ s/const\s+(.*)\s*&/$1/;
    $varType =~ s/\s*$//;
    my $fullName = "$className\::$name";

    checkImportsForObject( $varType, $addImport );

#    die "Invalid index for $fullName: $classNode->{case}{$fullName} instead of $methodNumber" if $classNode->{case}{$fullName} != $methodNumber;
#    $methodCode .= "    static void x_$methodNumber(Smoke::Stack x) {\n";
#    $methodCode .= "\tx[0].s_class = (void*)new $varType($fullName);\n";
#    $methodCode .= "    }\n";
    
#	if ( ($name !~ /^null$/) && (cplusplusToJava($varType) ne "") ) {
	if ( ($name !~ /^null$/) && (cplusplusToJava($varType) ne "" ) ) {
#		$interfaceCode .= "\t\t". cplusplusToJava($varType) . " $name();\n";
	
#		$methodCode .= "\tpublic native static ". cplusplusToJava($varType) . " $name();\n";
    }

	$methodNumber++;
    return ( $methodCode, $interfaceCode );
}

## Called by writeClassDoc
sub generateAllMethods($$$$$$$$)
{
    my ($classNode, $ancestorCount, $javaMethods, $jniMethods, $mainClassNode, $generateConstructors, $addImport, $addInclude) = @_;
    my $methodCode = '';
	my $interfaceCode = '';
    my $signalCode = '';
    my $jbridgeCode = '';
    $methodNumber = 0;
    #my $className = $classNode->{astNodeName};
    my $className = join( "::", kdocAstUtil::heritage($classNode) );
	my $javaClassName = $mainClassNode->{astNodeName};
    my $jniClassName = ($classNode->{astNodeName} =~ /^Q/ ? "Java_org_kde_qt_" : "Java_org_kde_koala_") . $classNode->{astNodeName};
	# If the C++ class had multiple inheritance, then the code for all but one of the
	# parents must be copied into the code for javaClassName. Hence, for TQWidget current
	# classname might be TQPaintDevice, as its methods are needed in TQWidget.
	my $currentClassName = join( ".", kdocAstUtil::heritage($classNode) );

    my $sourcename = $classNode->{Source}->{astNodeName};
    
	if ( $sourcename !~ s!.*(kio/|kparts/|dom/|kabc/|ksettings/|kjs/|ktexteditor/|tdeprint/|tdesu/)(.*)!$1$2!m ) {
    	$sourcename =~ s!.*/(.*)!$1!m;
	}
#    die "Empty source name for $classNode->{astNodeName} $classNode->{Source}->{astNodeName}" if ( $sourcename eq '' );
	
	if ($classNode->{astNodeName} ne $main::globalSpaceClassName && $sourcename ne '') {
    	$addInclude->{$sourcename} = 1;
#		my $s;
#        for my $sn( @{$classNode->{Sources}} ) {
#    	if ( ($s = $sn->{astNodeName}) !~ s!.*(kio/|kparts/|dom/|kabc/|ksettings/|kjs/|ktexteditor/|tdeprint/|tdesu/)(.*)!$1$2!m ) {
#    		$s =~ s!.*/(.*)!$1!m;
#		}
#		$addInclude->{$s} = 1;
#        }
	}
	
    $addImport->{"org.kde.qt.QtSupport"} = 1;
	
    # Do all enums first, anonymous ones and then named enums
    Iter::MembersByType ( $classNode, undef,
			  sub {	my ($classNode, $methodNode ) = @_;
				
	if ( $methodNode->{NodeType} eq 'enum' and $currentClassName eq $javaClassName ) {
	    my ($meth) = generateEnum( $classNode, $methodNode, 1 );
	    $methodCode .= $meth;
	}
				}, undef );
				
    Iter::MembersByType ( $classNode, undef,
			  sub {	my ($classNode, $methodNode ) = @_;
				
	if ( $methodNode->{NodeType} eq 'enum' and $currentClassName eq $javaClassName ) {
	    my ($meth) = generateEnum( $classNode, $methodNode, 0 );
	    $methodCode .= $meth;
	}
				}, undef );

    # Then all static vars
    Iter::MembersByType ( $classNode, undef,
			  sub {	my ($classNode, $methodNode ) = @_;
				
	if ( $methodNode->{NodeType} eq 'var' and $currentClassName eq $javaClassName ) {
	    my ($meth, $interface) = generateVar( $classNode, $methodNode, $addImport );
	    $methodCode .= $meth;
#	    $interfaceCode .= $interface;
	}
				}, undef );

    # Then all methods
    Iter::MembersByType ( $classNode, undef,
			  sub {	my ($classNode, $methodNode ) = @_;

        if ( $methodNode->{NodeType} eq 'method' ) {
	    	my ($meth, $interf, $signals, $jbridge) = generateMethod( $classNode, $methodNode, $addImport, $addInclude, $ancestorCount, $javaMethods, $jniMethods, $mainClassNode, $generateConstructors );
	    	$methodCode .= $meth;
			$interfaceCode .= $interf;
			$signalCode .= $signals;
	    	$jbridgeCode .= $jbridge;
#	    	$jniCode .= $jni;
		}
			      }, undef );
    
	# Virtual methods
#    if ($classNode->{BindingDerives}) {
#	my %virtualMethods;
#	allVirtualMethods( $classNode, \%virtualMethods );

#	for my $sig (sort keys %virtualMethods) {
#            my ($meth) = generateVirtualMethod( $classNode, $sig, $virtualMethods{$sig}{method}, $virtualMethods{$sig}{class}, \%addImport );
#	    $methodCode .= $meth;
#	}
#    }

    # Destructor
    # "virtual" is useless, if the base class has a virtual destructor then the x_* class too.
    #if($classNode->{HasVirtualDestructor} and $classNode->{HasDestructor}) {
    #	$methodCode .= "    virtual ~$bridgeClassName() {}\n";
    #}
    # We generate a dtor though, because we might want to add stuff into it
	
    if ($currentClassName eq $javaClassName and $classNode->{CanBeInstanciated} and $classNode->{HasPublicDestructor}) {
    	if ( $generateConstructors ) {
			my $jniCode;
			my $jniSignature;
			
			$jbridgeCode .= "\t~$className" . "JBridge() {QtSupport::qtKeyDeleted(this);}\n";
			$methodCode .= "\t/** Deletes the wrapped C++ instance */\n";
			$methodCode .= "\tprotected native void finalize() throws InternalError;\n";
			
			$jniSignature = $jniClassName . "_finalize";
			$jniCode = "JNIEXPORT void JNICALL\n$jniSignature(JNIEnv* env, jobject obj)\n{";

			if ( is_kindof($classNode, 'TQCheckListItem') ) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQCheckListItem*)($className*)QtSupport::getQt(env, obj))->parent() == 0 && ((TQCheckListItem*)($className*)QtSupport::getQt(env, obj))->listView() == 0) {\n";
			} elsif ( $classNode->{astNodeName} =~ /^KFileTreeViewToolTip$/ ) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && (($className*)QtSupport::getQt(env, obj))->parentWidget() == 0) {\n";
			} elsif ( is_kindof($classNode, 'TQTableItem')) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQTableItem*)($className*)QtSupport::getQt(env, obj))->table() == 0) {\n";
			} elsif ( is_kindof($classNode, 'TQPopupMenu')) {
				if ($main::qt_embedded) {
					$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQPopupMenu*)($className*)QtSupport::getQt(env, obj))->parentWidget() == 0) {\n";
				} else {
					$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQPopupMenu*)($className*)QtSupport::getQt(env, obj))->parentWidget(FALSE) == 0) {\n";
				}
			} elsif ( is_kindof($classNode, 'TQListViewItem') ) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQListViewItem*)($className*)QtSupport::getQt(env, obj))->parent() == 0 && ((TQListViewItem*)($className*)QtSupport::getQt(env, obj))->listView() == 0) {\n";
			} elsif ( is_kindof($classNode, 'TQIconViewItem')) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQIconViewItem*)($className*)QtSupport::getQt(env, obj))->iconView() == 0) {\n";
			} elsif ( is_kindof($classNode, 'TQLayoutItem')) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQLayoutItem*)($className*)QtSupport::getQt(env, obj))->layout() == 0 && ((TQLayoutItem*)($className*)QtSupport::getQt(env, obj))->widget() == 0 && ((TQLayoutItem*)($className*)QtSupport::getQt(env, obj))->spacerItem() == 0) {\n";
			} elsif ( $classNode->{astNodeName} =~ /^KSpell$|^KReplace$/ ) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj)) {\n";
			} elsif ( $classNode->{astNodeName} =~ /^TQWidget$/  || defined kdocAstUtil::findOverride( $rootnode, $classNode, "parentWidget" ) ) {
				if ($main::qt_embedded) {
					$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQWidget*)($className*)QtSupport::getQt(env, obj))->parentWidget() == 0) {\n";
				} else {
					$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && ((TQWidget*)($className*)QtSupport::getQt(env, obj))->parentWidget(TRUE) == 0) {\n";
				}
			} elsif ( $classNode->{astNodeName} =~ /^TQObject$/  || defined kdocAstUtil::findOverride( $rootnode, $classNode, "parent" ) ) {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj) && (($className*)QtSupport::getQt(env, obj))->parent() == 0) {\n";
			} else {
				$jniCode .= "\n\tif (QtSupport::allocatedInJavaWorld(env, obj)) {\n";
			}
			
			if ($classNode->{astNodeName} !~ /^Q.*Style$/) {
				$jniCode .= "\t\tdelete ($className*)QtSupport::getQt(env, obj);\n";
			}
			
			$jniCode .= "\t\tQtSupport::setQt(env, obj, 0);\n\t}\n\treturn;\n}\n\n";
			$jniMethods->{$jniSignature} = $jniCode;
    
#			$interfaceCode .= "\t\tvoid dispose();\n";
			$methodCode .= "\t/** Delete the wrapped C++ instance ahead of finalize() */\n";
			$methodCode .= "\tpublic native void dispose();\n";
    
#			$interfaceCode .= "\t\tboolean isDisposed();\n";
			$methodCode .= "\t/** Has the wrapped C++ instance been deleted? */\n";
			$methodCode .= "\tpublic native boolean isDisposed();\n";
			

			$jniSignature = $jniClassName . "_dispose";
			$jniCode = "JNIEXPORT void JNICALL\n$jniSignature(JNIEnv* env, jobject obj)\n{";
			$jniCode .= "\n\t$jniClassName" . "_finalize(env, obj);\n\treturn;\n}\n\n";
			$jniMethods->{$jniSignature} = $jniCode;
			
			$jniSignature = $jniClassName . "_isDisposed";
			$jniCode = "JNIEXPORT jboolean JNICALL\n$jniSignature(JNIEnv* env, jobject obj)\n{";
			$jniCode .= "\n\treturn (QtSupport::getQt(env, obj) == 0);\n}\n\n";
			$jniMethods->{$jniSignature} = $jniCode;
		}
#	die "$className destructor: methodNumber=$methodNumber != case entry=".$classNode->{case}{"~$className()"}."\n"
#	     if $methodNumber != $classNode->{case}{"~$className()"};
			$methodNumber++;
    }
                                                               
    return ( $methodCode, $interfaceCode, $signalCode, $jbridgeCode );
}

sub virtualMethodCallbacks
{
	my( $node ) = @_;
	my $jbridgeCode = ''; # output
	my %allmem = ();
	my $key;

	my $m;
	my $name;
	my $isTQObject = is_kindof($node, 'TQObject');
	
	kdocAstUtil::allMembers( \%allmem, $node );

	foreach $key (keys (%allmem)) {
		$m = $allmem{$key};
		$name = $m->{astNodeName} ;
		my $type = $m->{NodeType};
		my $docnode = $m->{DocNode};
		my $parent = $m->{Parent};
		
		if (	$type eq "method" && ($m->{Flags} =~ "v" || $name =~ /^.*Event$/) && !$m->{SkipFromSwitch}
				&& $m->{Access} =~ /public|protected/
				&& $name !~ /qwsEvent/ && $name !~ /x11Event/ && $name !~ /winEvent/ 
				&& $name !~ /macEvent/ && $name !~ /movableDropEvent/ ) 
		{
			my @argTypeList = ();
			my @castedArgList;
			my $i = 0;
			my $cplusplusparams;
			foreach my $arg ( @{$m->{ParamList}} ) {
				my $argType = $arg->{ArgType};
				push @argTypeList, $argType;
				$cplusplusparams .= "," if $i++;
				$cplusplusparams .= "arg" . $i;
			}

			my $qobjectType = $node->{astNodeName};
			$qobjectType =~ s/(.*)\*.*$/$1/;
			$qobjectType =~ s/^([^Q].*)/org.kde.koala.$1/;
			$qobjectType =~ s/^(Q.*)/org.kde.qt.$1/;
			if( $m->{ReturnType} eq 'void' && $#argTypeList eq 0 
				&& cplusplusToJNISignature( @argTypeList[0] ) =~ /Lorg_kde/
				&& $isTQObject )
			{
				@castedArgList = makeCastedArgList( @argTypeList );
				my $eventType = cplusplusToJava( @argTypeList[0] );
				$eventType =~ s/(.*)\*.*$/$1/;
				$eventType =~ s/^([^Q].*)/org.kde.koala.$1/;
				$eventType =~ s/^(Q.*)/org.kde.qt.$1/;
				$jbridgeCode .= "\tvoid $name(@castedArgList[0..$#argTypeList]) {\n";
				$jbridgeCode .= "\t\tif (!QtSupport::eventDelegate(this,\"$name\",(void*)" . (@argTypeList[0] =~ /\*/ ? "" : "&") . "arg1,\"$eventType\")) {\n";
				$jbridgeCode .= "\t\t\t" . $parent->{astNodeName} . "::" . "$name(arg1);\n";
				$jbridgeCode .= "\t\t}\n";
				$jbridgeCode .= "\t\treturn;\n\t}\n";
			} elsif( $name =~ /eventFilter$/ and $isTQObject and $#argTypeList eq 1) {
				$jbridgeCode .= "\tbool eventFilter(TQObject* object,TQEvent* event) {\n";
				$jbridgeCode .= "\t\tif (!QtSupport::eventFilterDelegate(this,\"$qobjectType\",object,event)) {\n";
				$jbridgeCode .= "\t\t\treturn " . $parent->{astNodeName} . "::eventFilter(object,event);\n";
				$jbridgeCode .= "\t\t} else {\n";
				$jbridgeCode .= "\t\t\treturn TRUE;\n";
				$jbridgeCode .= "\t\t}\n\t}\n";
			} elsif( $name =~ /^fixup$/ and $node->{astNodeName} eq 'TQValidator' ) {
				$jbridgeCode .= "\tTQValidator::State validate(TQString& input,int& pos) const\n";
				$jbridgeCode .= "\t{\n";
				$jbridgeCode .= "\t\treturn (TQValidator::State) QtSupport::validateDelegate((TQValidator*)this,input,pos);\n";
				$jbridgeCode .= "\t}\n";
				$jbridgeCode .= "\tvoid fixup(TQString& input) const\n";
				$jbridgeCode .= "\t{\n";
				$jbridgeCode .= "\t\tQtSupport::fixupDelegate((TQValidator*) this, input);\n";
				$jbridgeCode .= "\t\treturn;\n\t}\n";
			} elsif( $m->{ReturnType} eq 'void' and $#argTypeList eq -1 and $isTQObject) {
				$jbridgeCode .= "\tvoid $name() {\n";
				$jbridgeCode .= "\t\tif (!QtSupport::voidDelegate(this,\"$qobjectType\",\"$name\")) {\n";
				$jbridgeCode .= "\t\t\t" . $parent->{astNodeName} . "::$name();\n";
				$jbridgeCode .= "\t\t}\n";
				$jbridgeCode .= "\t\treturn;\n\t}\n";
			} elsif( cplusplusToJava( $m->{ReturnType} ) eq 'boolean' and $#argTypeList eq -1 and $isTQObject ) {
				$jbridgeCode .= "\t" . $m->{ReturnType} . " $name() {\n";
				$jbridgeCode .= "\t\treturn QtSupport::booleanDelegate(this,\"$name\");\n";
				$jbridgeCode .= "\t}\n";
			}
		}
	}
	
	return $jbridgeCode;
}

# Return 0 if the class has no virtual dtor, 1 if it has, 2 if it's private
sub hasVirtualDestructor($)
{
    my ( $classNode ) = @_;
    my $className = join( "::", kdocAstUtil::heritage($classNode) );
    return if ( $skippedClasses{$className} );

    my $parentHasIt;
    # Look at ancestors, and (recursively) call hasVirtualDestructor for each
    # It's enough to have one parent with a prot/public virtual dtor
    Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
                     my $vd = hasVirtualDestructor( $_[0] );
                     $parentHasIt = $vd unless $parentHasIt > $vd;
                    } );
    return $parentHasIt if $parentHasIt; # 1 or 2

    # Now look in $classNode - including private methods
    my $doPrivate = $main::doPrivate;
    $main::doPrivate = 1;
    my $result;
    Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;
			return unless( $m->{NodeType} eq "method" && $m->{ReturnType} eq '~' );

			if ( $m->{Flags} =~ /[vp]/ ) {
			    if ( $m->{Access} =~ /private/ ) {
				$result=2; # private virtual
			    } else {
				$result=1; # [protected or public] virtual
			    }
			}
		},
		undef
	);
    $main::doPrivate = $doPrivate;
    $result=0 if (!defined $result);
    return $result;
}

=head2 allVirtualMethods

	Parameters: class node, dict

	Adds to the dict, for all method nodes that are virtual, in this class and in parent classes :
        {method} the method node, {class} the class node (the one where the virtual is implemented)

=cut

sub allVirtualMethods($$)
{
    my ( $classNode, $virtualMethods ) = @_;
    my $className = join( "::", kdocAstUtil::heritage($classNode) );
    return if ( $skippedClasses{$className} );

    # Look at ancestors, and (recursively) call allVirtualMethods for each
    # This is done first, so that virtual methods that are reimplemented as 'private'
    # can be removed from the list afterwards (below)
    Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
			 allVirtualMethods( @_[0], $virtualMethods );
		     }, undef
		   );

    # Now look for virtual methods in $classNode - including private ones
    my $doPrivate = $main::doPrivate;
    $main::doPrivate = 1;
    Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;
			# Only interested in methods, and skip destructors
			return unless( $m->{NodeType} eq "method" && $m->{ReturnType} ne '~' );

			my $signature = methodSignature( $m, $#{$m->{ParamList}} );
			print STDERR $signature . " ($m->{Access})\n" if ($debug);

			# A method is virtual if marked as such (v=virtual p=pure virtual)
			# or if a parent method with same signature was virtual
			if ( $m->{Flags} =~ /[vp]/ or defined $virtualMethods->{$signature} ) {
			    if ( $m->{Access} =~ /private/ ) {
				if ( defined $virtualMethods->{$signature} ) { # remove previously defined
				    delete $virtualMethods->{$signature};
				}
				# else, nothing, just ignore private virtual method
			    } else {
				$virtualMethods->{$signature}{method} = $m;
				$virtualMethods->{$signature}{class} = $classNode;
			    }
			}
		},
		undef
	);
    $main::doPrivate = $doPrivate;
}

# Known typedef? If so, apply it.
sub applyTypeDef($)
{
    my $type = shift;
    # Parse 'const' in front of it, and '*' or '&' after it
    my $prefix = $type =~ s/^const\s+// ? 'const ' : '';
    my $suffix = $type =~ s/\s*([\&\*]+)$// ? $1 : '';

    if (exists $typedeflist{$type}) {
	return $prefix.$typedeflist{$type}.$suffix;
    }
    return $prefix.$type.$suffix;
}

# Register type ($1) into %allTypes if not already there
sub registerType($$) {
    my $type = shift;
    #print "registerType: $type\n" if ($debug);

    $type =~ s/\s+const$//; # for 'char* const'
    $type =~ s/\s+const\s*\*$/\*/; # for 'char* const*'

    return if ( $type eq 'void' or $type eq '' or $type eq '~' );
    die if ( $type eq '...' );     # ouch

    # Let's register the real type, not its known equivalent
    #$type = applyTypeDef($type);

    # Enum _value_ -> get corresponding type
    if (exists $enumValueToType{$type}) {
	$type = $enumValueToType{$type};
    }

    # Already in allTypes
    if(exists $allTypes{$type}) {
        return;
    }

    die if $type eq 'TQTextEdit::UndoRedoInfo::Type';
    die if $type eq '';

    my $realType = $type;

    # Look for references (&) and pointers (* or **)  - this will not handle *& correctly.
    # We do this parsing here because both the type list and iterproto need it
    if($realType =~ s/&$//) {
	$allTypes{$type}{typeFlags} = 'Smoke::tf_ref';
    }
    elsif($realType ne 'void*' && $realType =~ s/\*$//) {
	$allTypes{$type}{typeFlags} = 'Smoke::tf_ptr';
    }
    else {
	$allTypes{$type}{typeFlags} = 'Smoke::tf_stack';
    }

    if ( $realType =~ s/^const\s+// ) { # Remove 'const'
	$allTypes{$type}{typeFlags} .= ' | Smoke::tf_const';
    }

    # Apply typedefs, and store the resulting type.
    # For instance, if $type was Q_UINT16&, realType will be ushort
    $allTypes{$type}{realType} = applyTypeDef( $realType );

    # In the first phase we only create entries into allTypes.
    # The values (indexes) are calculated afterwards, once the list is full.
    $allTypes{$type}{index} = -1;
    #print STDERR "Register $type. Realtype: $realType\n" if($debug);
}

# Get type from %allTypes
# This returns a hash with {index}, {isEnum}, {typeFlags}, {realType}
# (and {typeId} after the types array is written by writeSmokeDataFile)
sub findTypeEntry($) {
    my $type = shift;
    my $typeIndex = -1;
    $type =~ s/\s+const$//; # for 'char* const'
    $type =~ s/\s+const\s*\*$/\*/; # for 'char* const*'

    return undef if ( $type =~ '~' or $type eq 'void' or $type eq '' );

    # Enum _value_ -> get corresponding type
    if (exists $enumValueToType{$type}) {
	$type = $enumValueToType{$type};
    }

    die "type not known: $type" unless defined $allTypes{$type};
    return $allTypes{ $type };
}

# List of all java super-classes for a given class, via single inheritance. 
# Excluding any which are mapped onto interfaces to avoid multiple inheritance.
sub direct_superclass_list($)
{
    my $classNode = shift;
    my @super;
	my $has_ancestor = 0;
	my $direct_ancestor = undef;
	my $name;
	
    Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
			( $direct_ancestor, $name ) = @_;
			if ($name =~ /TQMemArray|TQSqlFieldInfoList/) {
				# Template classes, give up for now..
				$has_ancestor = 1;
			} elsif (kalyptusDataDict::interfacemap($name) eq "") {
				push @super, $direct_ancestor;
				push @super, direct_superclass_list( $direct_ancestor );
				$has_ancestor = 1;
			}
		     }, undef );
	
	if (! $has_ancestor and defined $direct_ancestor) {
		push @super, $direct_ancestor;
    	push @super, direct_superclass_list( $direct_ancestor );
	}
	
	return @super;
}

# List of all super-classes for a given class
sub superclass_list($)
{
    my $classNode = shift;
    my @super;
    Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
			push @super, @_[0];
			push @super, superclass_list( @_[0] );
		     }, undef );
    return @super;
}

sub is_kindof($$)
{
    my $classNode = shift;
	my $className = shift;
	
	if ($classNode->{astNodeName} eq $className) {
		return 1;
	}
	
	my @superclasses = superclass_list($classNode);
	foreach my $ancestor (@superclasses) {
		if ($ancestor->{astNodeName} eq $className) {
			return 1;
		}
	}
	
	return 0;
}

# Store the {case} dict in the class Node (method signature -> index in the "case" switch)
# This also determines which methods should NOT be in the switch, and sets {SkipFromSwitch} for them
sub prepareCaseDict($) {

     my $classNode = shift;
     my $className = join( "::", kdocAstUtil::heritage($classNode) );
     $classNode->AddProp("case", {});
     my $methodNumber = 0;

     # First look at all enums for this class
     Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	next unless $m->{NodeType} eq 'enum';
	foreach my $val ( @{$m->{ParamList}} ) {
	    my $fullEnumName = "$className\::".$val->{ArgName};
	    print STDERR "Enum: $fullEnumName -> case $methodNumber\n" if ($debug);
	    $classNode->{case}{$fullEnumName} = $methodNumber;
	    $enumValueToType{$fullEnumName} = "$className\::$m->{astNodeName}";
	    $methodNumber++;
	}
		      }, undef );

     # Check for static vars
     Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	    next unless $m->{NodeType} eq 'var';
	    my $name = "$className\::".$m->{astNodeName};			
	    print STDERR "Var: $name -> case $methodNumber\n" if ($debug);
	    $classNode->{case}{$name} = $methodNumber;
	    $methodNumber++;

		      }, undef );


     # Now look at all methods for this class
     Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	next unless $m->{NodeType} eq 'method';
	my $name = $m->{astNodeName};
        my $isConstructor = ($name eq $classNode->{astNodeName} );
	if ($isConstructor and ($m->{ReturnType} eq '~')) # destructor
	{
	    # Remember whether we'll generate a switch entry for the destructor
	    $m->{SkipFromSwitch} = 1 unless ($classNode->{CanBeInstanciated} and $classNode->{HasPublicDestructor});
	    next;
	}

        # Don't generate bindings for protected methods (incl. signals) if
        # we're not deriving from the C++ class. Only take public and public_slots
        my $ok = ( $classNode->{BindingDerives} or $m->{Access} =~ /public/ ) ? 1 : 0;

        # Don't generate bindings for pure virtuals - we can't call them ;)
        $ok = 0 if ( $ok && $m->{Flags} =~ "p" );

        # Bugfix for Qt-3.0.4: those methods are NOT implemented (report sent).
        $ok = 0 if ( $ok && $className eq 'TQLineEdit' && ( $name eq 'setPasswordChar' || $name eq 'passwordChar' ) );
        $ok = 0 if ( $ok && $className eq 'TQWidgetItem' && $name eq 'widgetSizeHint' );

        if ( !$ok )
        {
	    #print STDERR "Skipping $className\::$name\n" if ($debug);
	    $m->{SkipFromSwitch} = 1;
	    next;
	}

	my @args = @{ $m->{ParamList} };
	my $last = $m->{FirstDefaultParam};
	$last = scalar @args unless defined $last;
	my $iterationCount = scalar(@args) - $last;
	while($iterationCount >= 0) {
	    my $sig = methodSignature( $m, $#args );
	    $classNode->{case}{$sig} = $methodNumber;
	    #print STDERR "prepareCaseDict: registered case number $methodNumber for $sig in $className()\n" if ($debug);
	    pop @args;
	    $iterationCount--;
	    $methodNumber++;
	}
		    }, undef );

    # Add the destructor, at the end
    if ($classNode->{CanBeInstanciated} and $classNode->{HasPublicDestructor}) {
        $classNode->{case}{"~$className()"} = $methodNumber;
	# workaround for ~Sub::Class() being seen as Sub::~Class()
	$classNode->{case}{"~$classNode->{astNodeName}()"} = $methodNumber;
	#print STDERR "prepareCaseDict: registered case number $methodNumber for ~$className()\n" if ($debug);
    }
}

sub writeSmokeDataFile($) {
    my $rootnode = shift;

    # Make list of classes
    my %allImports; # list of all header files for all classes
    my @classlist;
    push @classlist, ""; # Prepend empty item for "no class"
    my %enumclasslist;
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = $_[0];
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	
	return if $classNode->{NodeType} eq 'namespace';
	
	push @classlist, $className;
	$enumclasslist{$className}++ if keys %{$classNode->{enumerations}};
	$classNode->{ClassIndex} = $#classlist;
	addImportForClass( $classNode, \%allImports, undef );
    } );

    my %classidx = do { my $i = 0; map { $_ => $i++ } @classlist };

    my $file = "$outputdir/smokedata.cpp";
#    open OUT, ">$file" or die "Couldn't create $file\n";

#    foreach my $incl (sort{ 
#                           return 1 if $a=~/qmotif/;  # move qmotif* at bottom (they include dirty X11 headers)
#                           return -1 if $b=~/qmotif/;
#			   return -1 if substr($a,0,1) eq 'q' and substr($b,0,1) ne 'q'; # move Qt headers on top
#			   return 1 if substr($a,0,1) ne 'q' and substr($b,0,1) eq 'q';			   
#                           $a cmp $b
#                          } keys %allIncludes) {
#	die if $imp eq '';
#	print OUT "import $imp;\n";
#    }	

#    print OUT "\n";

    print STDERR "Writing ${libname}_cast function\n" if ($debug);

    # Prepare descendants information for each class
    my %descendants; # classname -> list of descendant nodes
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	# Get _all_ superclasses (up any number of levels)
	# and store that $classNode is a descendant of $s
	my @super = superclass_list($classNode);
	for my $s (@super) {
	    my $superClassName = join( "::", kdocAstUtil::heritage($s) );
	    Ast::AddPropList( \%descendants, $superClassName, $classNode );
	}
    } );

    # Iterate over all classes, to write the xtypecast function
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	# @super will contain superclasses, the class itself, and all descendants
	my @super = superclass_list($classNode);
	push @super, $classNode;
        if ( defined $descendants{$className} ) {
	    push @super, @{$descendants{$className}};
	}
	my $cur = $classidx{$className};
	
	return if $classNode->{NodeType} eq 'namespace';

#	print OUT "      case $cur:\t//$className\n";
#	print OUT "\tswitch(to) {\n";
#	$cur = -1;
#	my %casevalues;
#	for my $s (@super) {
#		my $superClassName = join( "::", kdocAstUtil::heritage($s) );
#		next if !defined $classidx{$superClassName}; # inherits from unknown class, see below
#		next if $classidx{$superClassName} == $cur;    # shouldn't happen in Qt
#		next if $s->kdocAstUtil::inheritsAsVirtual($classNode); # can't cast from a virtual base class
#		$cur = $classidx{$superClassName}; # KDE has MI with diamond shaped cycles (cf. KXMLGUIClient)
#		next if $casevalues{$cur};         # ..so skip any duplicate parents
#		print OUT "\t  case $cur: return (void*)($superClassName*)($className*)xptr;\n";
#		$casevalues{$cur} = 1;
#	}
#	print OUT "\t  default: return xptr;\n";
#	print OUT "\t}\n";
    } );
#    print OUT "      default: return xptr;\n";
#    print OUT "    }\n";
#    print OUT "}\n\n";


    # Write inheritance array
    # Imagine you have "Class : public super1, super2"
    # The inheritlist array will get 3 new items: super1, super2, 0
    my %inheritfinder;  # key = (super1, super2) -> data = (index in @inheritlist). This one allows reuse.
    my %classinherit;   # we store that index in %classinherit{className}
    # We don't actually need to store inheritlist in memory, we write it
    # directly to the file. We only need to remember its current size.
    my $inheritlistsize = 1;

#    print OUT "// Group of class IDs (0 separated) used as super class lists.\n";
#    print OUT "// Classes with super classes have an index into this array.\n";
#    print OUT "static short ${libname}_inheritanceList[] = {\n";
#    print OUT "\t0,\t// 0: (no super class)\n";
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "__", kdocAstUtil::heritage($classNode) );
	
	return if $classNode->{NodeType} eq 'namespace';
	
	print STDERR "inheritanceList: looking at $className\n" if ($debug);

	# Make list of direct ancestors
	my @super;
	Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
			     my $superClassName = join( "::", kdocAstUtil::heritage($_[0]) );
			     push @super, $superClassName;
		    }, undef );
	# Turn that into a list of class indexes
	my $key = '';
	foreach my $superClass( @super ) {
	    if (defined $classidx{$superClass}) {
		$key .= ', ' if ( length $key > 0 );
		$key .= $classidx{$superClass};
	    }
	}
	if ( $key ne '' ) {
	    if ( !defined $inheritfinder{$key} ) {
		print OUT "\t";
		my $index = $inheritlistsize; # Index of first entry (for this group) in inheritlist
		foreach my $superClass( @super ) {
		    if (defined $classidx{$superClass}) {
			print OUT "$classidx{$superClass}, ";
			$inheritlistsize++;
		    }
		}
		$inheritlistsize++;
		my $comment = join( ", ", @super );
		print OUT "0,\t// $index: $comment\n";
		$inheritfinder{$key} = $index;
	    }
	    $classinherit{$className} = $inheritfinder{$key};
	} else { # No superclass
	    $classinherit{$className} = 0;
	}
    } );
#    print OUT "};\n\n";


#    print OUT "// These are the xenum functions for manipulating enum pointers\n";
    for my $className (keys %enumclasslist) {
	my $c = $className;
	$c =~ s/::/__/g;
#	print OUT "void xenum_$c\(Smoke::EnumOperation, Smoke::Index, void*&, long&);\n";
    }
#    print OUT "\n";
#    print OUT "// Those are the xcall functions defined in each x_*.cpp file, for dispatching method calls\n";
    my $firstClass = 1;
    for my $className (@classlist) {
	if ($firstClass) {
	    $firstClass = 0;
	    next;
	}
	my $c = $className;   # make a copy
	$c =~ s/::/__/g;
#	print OUT "void xcall_$c\(Smoke::Index, void*, Smoke::Stack);\n";
    }
#    print OUT "\n";

    # Write class list afterwards because it needs offsets to the inheritance array.
#    print OUT "// List of all classes\n";
#    print OUT "// Name, index into inheritanceList, method dispatcher, enum dispatcher, class flags\n";
#    print OUT "static Smoke::Class ${libname}_classes[] = {\n";
    my $firstClass = 1;
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "__", kdocAstUtil::heritage($classNode) );
	
	return if $classNode->{NodeType} eq 'namespace';

	if ($firstClass) {
	    $firstClass = 0;
	    print OUT "\t{ 0L, 0, 0, 0, 0 }, \t// 0 (no class)\n";
	}
	my $c = $className;
	$c =~ s/::/__/g;
	my $xcallFunc = "xcall_$c";
	my $xenumFunc = "0";
	$xenumFunc = "xenum_$c" if exists $enumclasslist{$className};
	# %classinherit needs Foo__Bar, not Foo::Bar?
	die "problem with $className" unless defined $classinherit{$c};

	my $xClassFlags = 0;
	$xClassFlags .= "|Smoke::cf_constructor" if $classNode->{CanBeInstanciated}; # correct?
	$xClassFlags .= "|Smoke::cf_deepcopy" if $classNode->{CanBeCopied}; # HasCopyConstructor would be wrong (when it's private)
	$xClassFlags .= "|Smoke::cf_virtual" if hasVirtualDestructor($classNode) == 1;
	# $xClassFlags .= "|Smoke::cf_undefined" if ...;
	$xClassFlags =~ s/0\|//; # beautify
#	print OUT "\t{ \"$className\", $classinherit{$c}, $xcallFunc, $xenumFunc, $xClassFlags }, \t//$classidx{$className}\n";
    } );
#    print OUT "};\n\n";


#    print OUT "// List of all types needed by the methods (arguments and return values)\n";
#    print OUT "// Name, class ID if arg is a class, and TypeId\n";
#    print OUT "static Smoke::Type ${libname}_types[] = {\n";
    my $typeCount = 0;
    $allTypes{''}{index} = 0; # We need an "item 0"
    for my $type (sort keys %allTypes) {
	$allTypes{$type}{index} = $typeCount;      # Register proper index in allTypes
	if ( $typeCount == 0 ) {
#	    print OUT "\t{ 0, 0, 0 },\t//0 (no type)\n";
	    $typeCount++;
	    next;
	}
	my $isEnum = $allTypes{$type}{isEnum};
	my $typeId;
	my $typeFlags = $allTypes{$type}{typeFlags};
	my $realType = $allTypes{$type}{realType};
	die "$type" if !defined $typeFlags;
#	die "$realType" if $realType =~ /\(/;
	# First write the name
#	print OUT "\t{ \"$type\", ";
	# Then write the classId (and find out the typeid at the same time)
	if(exists $classidx{$realType}) { # this one first, we want t_class for TQBlah*
	    $typeId = 't_class';
#	    print OUT "$classidx{$realType}, ";
	}
	elsif($type =~ /&$/ || $type =~ /\*$/) {
	    $typeId = 't_voidp';
#	    print OUT "0, "; # no classId
	}
	elsif($isEnum || $allTypes{$realType}{isEnum}) {
	    $typeId = 't_enum';
	    if($realType =~ /(.*)::/) {
		my $c = $1;
		if($classidx{$c}) {
#		    print OUT "$classidx{$c}, ";
		} else {
#		    print OUT "0 /* unknown class $c */, ";
		}
	    } else {
#		print OUT "0 /* unknown $realType */, "; # no classId
	    }
	}
	else {
	    $typeId = $typeunion{$realType};
	    if (defined $typeId) {
		$typeId =~ s/s_/t_/; # from s_short to t_short for instance
	    }
	    else {
		# Not a known class - ouch, this happens quite a lot
		# (private classes, typedefs, template-based types, etc)
		if ( $skippedClasses{$realType} ) {
#		    print STDERR "$realType has been skipped, using t_voidp for it\n";
		} else {
		    unless( $realType =~ /</ ) { # Don't warn for template stuff...
			print STDERR "$realType isn't a known type (type=$type)\n";
		    }
		}
		$typeId = 't_voidp'; # Unknown -> map to a void *
	    }
#	    print OUT "0, "; # no classId
	}
	# Then write the flags
	die "$type" if !defined $typeId;
#	print OUT "Smoke::$typeId | $typeFlags },";
#	print OUT "\t//$typeCount\n";
	$typeCount++;
	# Remember it for coerce_type
	$allTypes{$type}{typeId} = $typeId;
    }
#    print OUT "};\n\n";


    my %arglist; # registers the needs for argumentList (groups of type ids)
    my %methods;
    # Look for all methods and all enums, in all classes
    # And fill in methods and arglist. This loop writes nothing to OUT.
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	print STDERR "writeSmokeDataFile: arglist: looking at $className\n" if ($debug);

	Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	my $methName = $m->{astNodeName};
	# For destructors, get a proper signature that includes the '~'
	if ( $m->{ReturnType} eq '~' )
	{
	    $methName = '~' . $methName ;
	    # Let's even store that change, otherwise we have to do it many times
	    $m->{astNodeName} = $methName;
	}
	
	if( $m->{NodeType} eq "enum" ) {

	    foreach my $enum ( @{$m->{ParamList}} ) {
		my $enumName = $enum->{ArgName};
	        $methods{$enumName}++;
	    }

        } elsif ( $m->{NodeType} eq 'var' ) {

	    $methods{$m->{astNodeName}}++;

	} elsif( $m->{NodeType} eq "method" ) {

	    $methods{$methName}++;
	    my @protos;
	    makeprotos(\%classidx, $m, \@protos);

	    #print "made @protos from $className $methName $m->{Signature})\n" if ($debug);
	    for my $p (@protos) {
		$methods{$p}++;
		my $argcnt = 0;
		$argcnt = length($1) if $p =~ /([\$\#\?]+)/;
		my $sig = methodSignature($m, $argcnt-1);
		# Store in a class hash named "proto", a proto+signature => method association
		$classNode->{proto}{$p}{$sig} = $m;
		#$classNode->{signature}{$sig} = $p;
		# There's probably a way to do this better, but this is the fastest way
		# to get the old code going: store classname into method
		$m->{class} = $className;
	    }

	    my $firstDefaultParam = $m->{FirstDefaultParam};
	    $firstDefaultParam = scalar(@{ $m->{ParamList} }) unless defined $firstDefaultParam;
	    my $argNames = '';
	    my $args = '';
	    for(my $i = 0; $i < @{ $m->{ParamList} }; $i++) {
		$args .= ', ' if $i;
		$argNames .= ', ' if $i;
		my $argType = $m->{ParamList}[$i]{ArgType};
		my $typeEntry = findTypeEntry( $argType );
		$args .= defined $typeEntry ? $typeEntry->{index} : 0;
		$argNames .= $argType;

		if($i >= ($firstDefaultParam - 1)) {
		    #print "arglist entry: $args\n";
		    $arglist{$args} = $argNames;
		}
		
	    }
	    # create an entry for e.g. "arg0,arg1,arg2" where argN is index in allTypes of type for argN
	    # The value, $argNames, is temporarily stored, to be written out as comment
	    # It gets replaced with the index in the next loop.
	    #print "arglist entry : $args\n";
	    $arglist{$args} = $argNames;
	}
		    }, # end of sub
	undef
       );
    });


    $arglist{''} = 0;
    # Print arguments array
#    print OUT "static Smoke::Index ${libname}_argumentList[] = {\n";
    my $argListCount = 0;
    for my $args (sort keys %arglist) {
	my @dunnohowtoavoidthat = split(',',$args);
	my $numTypes = $#dunnohowtoavoidthat;
	if ($args eq '') {
#	    print OUT "\t0,\t//0  (void)\n";
	} else {
	    # This is a nice trick : args can be written in one go ;)
#	    print OUT "\t$args, 0,\t//$argListCount  $arglist{$args}  \n";
	}
	$arglist{$args} = $argListCount;      # Register proper index in argList
	$argListCount += $numTypes + 2;       # Move forward by as much as we wrote out
    }
#    print OUT "};\n\n";

    $methods{''} = 0;
    my @methodlist = sort keys %methods;
    my %methodidx = do { my $i = 0; map { $_ => $i++ } @methodlist };

#    print OUT "// Raw list of all methods, using munged names\n";
#    print OUT "static const char *${libname}_methodNames[] = {\n";
    my $methodNameCount = $#methodlist;
    for my $m (@methodlist) {
#	print OUT qq(    "$m",\t//$methodidx{$m}\n);
    }
#    print OUT "};\n\n";

#    print OUT "// (classId, name (index in methodNames), argumentList index, number of args, method flags, return type (index in types), xcall() index)\n";
#    print OUT "static Smoke::Method ${libname}_methods[] = {\n";
    my @methods;
    %allMethods = ();
    my $methodCount = 0;
    # Look at all classes and all enums again
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	return if $classNode->{NodeType} eq 'namespace';
	
	my $classIndex = $classidx{$className};
	print STDERR "writeSmokeDataFile: methods: looking at $className\n" if ($debug);

	Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	if( $m->{NodeType} eq "enum" ) {

	    foreach my $enum ( @{$m->{ParamList}} ) {
		my $enumName = $enum->{ArgName};
		my $fullEnumName = "$className\::$enumName";
		my $sig = "$className\::$enumName\()";
		my $xmethIndex = $methodidx{$enumName};
		die "'Method index' for enum $sig not found" unless defined $xmethIndex;
		my $typeId = findTypeEntry( $fullEnumName )->{index};
		die "enum has no {case} value in $className: $fullEnumName" unless defined $classNode->{case}{$fullEnumName};
#		print OUT "\t{$classIndex, $xmethIndex, 0, 0, Smoke::mf_static, $typeId, $classNode->{case}{$fullEnumName}},\t//$methodCount $fullEnumName (enum)\n";
		$allMethods{$sig} = $methodCount;
		print STDERR "Added entry for " . $sig . " into \$allMethods\n" if ($debug);
		$methods[$methodCount] = {
				c => $classIndex,
				methIndex => $xmethIndex,
				argcnt => '0',
				args => 0,
				retTypeIndex => 0,
				idx => $classNode->{case}{$fullEnumName}
			       };
		$methodCount++;
	    }

	} elsif( $m->{NodeType} eq 'var' ) {

	    my $name = $m->{astNodeName};
	    my $fullName = "$className\::$name";
	    my $sig = "$fullName\()";
	    my $xmethIndex = $methodidx{$name};
	    die "'Method index' for var $sig not found" unless defined $xmethIndex;
	    my $varType = $m->{Type};
	    $varType =~ s/static\s//;
	    $varType =~ s/const\s+(.*)\s*&/$1/;
	    $varType =~ s/\s*$//;
	    my $typeId = findTypeEntry( $varType )->{index};
	    die "var has no {case} value in $className: $fullName" unless defined $classNode->{case}{$fullName};
#	    print OUT "\t{$classIndex, $xmethIndex, 0, 0, Smoke::mf_static, $typeId, $classNode->{case}{$fullName}},\t//$methodCount $fullName (static var)\n";
            $allMethods{$sig} = $methodCount;
	    print STDERR "Added entry for " . $sig . " into \$allMethods\n" if ($debug);
	    $methods[$methodCount] = {
				c => $classIndex,
				methIndex => $xmethIndex,
				argcnt => '0',
				args => 0,
				retTypeIndex => 0,
				idx => $classNode->{case}{$fullName}
			       };
	    $methodCount++;


	} elsif( $m->{NodeType} eq "method" ) {

	    # We generate a method entry only if the method is in the switch() code
	    # BUT: for pure virtuals, they need to have a method entry, even though they
	    # do NOT have a switch code.
	    return if ( $m->{SkipFromSwitch} && $m->{Flags} !~ "p" );

	    # No switch code for destructors if we didn't derive from the class (e.g. it has private ctors only)
    	    return if ( $m->{ReturnType} eq '~' && ! ( $classNode->{BindingDerives} and $classNode->{HasPublicDestructor}) );

            # Is this sorting really important?
	    #for my $m (sort {$a->{name} cmp $b->{name}} @{ $self->{$c}{method} }) {

	    my $methName = $m->{astNodeName};
	    my $def = $m->{FirstDefaultParam};
	    $def = scalar(@{ $m->{ParamList} }) unless defined $def;
	    my $last = scalar(@{ $m->{ParamList} }) - 1;
	    #print STDERR "writeSmokeDataFile: methods: generating for method $methName, def=$def last=$last\n" if ($debug);

	    while($last >= ($def-1)) {
		last if $last < -1;
		my $args = [ @{ $m->{ParamList} }[0..$last] ];
		my $sig = methodSignature($m, $last);
		#my $methodSig = $classNode->{signature}{$sig}; # Munged signature
		#print STDERR "writeSmokeDataFile: methods: sig=$className\::$sig methodSig=$methodSig\n" if ($debug);
		#my $methodIndex = $methodidx{$methodSig};
		#die "$methodSig" if !defined $methodIndex;

		my $methodIndex = $methodidx{$methName};
		die "$methName" if !defined $methodIndex;
		my $case = $classNode->{case}{$sig};
		my $typeEntry = findTypeEntry( $m->{ReturnType} );
		my $retTypeIndex = defined $typeEntry ? $typeEntry->{index} : 0;

		my $i = 0;
		my $t = '';
		for my $arg (@$args) {
		    $t .= ', ' if $i++;
		    my $typeEntry = findTypeEntry( $arg->{ArgType} );
		    $t .= defined $typeEntry ? $typeEntry->{index} : 0;
		}
		my $arglist = $t eq '' ? 0 : $arglist{$t};
		die "arglist for $t not found" unless defined $arglist;
		if ( $m->{Flags} =~ "p" ) {
		    # Pure virtuals don't have a {case} number, that's normal
		    die if defined $case;
		    $case = -1; # This remains -1, not 0 !
		} else {
			;
#		    die "$className\::$methName has no case number for sig=$sig" unless defined $case;
		}
		my $argcnt = $last + 1;
		my $methodFlags = '0';
		$methodFlags .= "|Smoke::mf_static" if $m->{Flags} =~ "s";
		$methodFlags .= "|Smoke::mf_const" if $m->{Flags} =~ "c"; # useful?? probably not
		$methodFlags =~ s/0\|//; # beautify
		
#		print OUT "\t{$classIndex, $methodIndex, $arglist, $argcnt, $methodFlags, $retTypeIndex, $case},\t//$methodCount $className\::$sig";
#		print OUT " [pure virtual]" if ( $m->{Flags} =~ "p" ); # explain why $case = -1 ;)
#		print OUT "\n";
		
		$allMethods{$className . "::" . $sig} = $methodCount;
		$methods[$methodCount] = {
					  c => $classIndex,
					  methIndex => $methodIndex,
					  argcnt => $argcnt,
					  args => $arglist,
					  retTypeIndex => $retTypeIndex,
					  idx => $case
					 };
		$methodCount++;
		$last--;
	    } # while
	} # if method
      } ); # Method Iter
    } ); # Class Iter
#    print OUT "};\n\n";

    my @protos;
    Iter::LocalCompounds( $rootnode, sub {
	my $classNode = shift;
	my $className = join( "::", kdocAstUtil::heritage($classNode) );
	
	return if $classNode->{NodeType} eq 'namespace';
	
	my $classIndex = $classidx{$className};
	print STDERR "writeSmokeDataFile: protos: looking at $className\n" if ($debug);

	Iter::MembersByType ( $classNode, undef,
		sub {	my ($classNode, $m ) = @_;

	if( $m->{NodeType} eq "enum" ) {
	    foreach my $enum ( @{$m->{ParamList}} ) {
		my $enumName = $enum->{ArgName};
		my $sig = "$className\::$enumName\()";
		my $xmeth = $allMethods{$sig};
		die "'Method' for enum $sig not found" unless defined $xmeth;
		my $xmethIndex = $methodidx{$enumName};
		die "'Method index' for enum $enumName not found" unless defined $xmethIndex;
		push @protos, {
			       methIndex => $xmethIndex,
			       c => $classIndex,
			       over => {
					$sig => {
						 sig => $sig,
						}
				       },
			       meth => $xmeth
			      };
	    }

	} elsif( $m->{NodeType} eq 'var' ) {

	    my $name = $m->{astNodeName};
	    my $fullName = "$className\::$name";
	    my $sig = "$fullName\()";
	    my $xmeth = $allMethods{$sig};
	    die "'Method' for var $sig not found" unless defined $xmeth;
	    my $xmethIndex = $methodidx{$name};
	    die "'Method index' for var $name not found" unless defined $xmethIndex;
	    push @protos, {
			       methIndex => $xmethIndex,
			       c => $classIndex,
			       over => {
					$sig => {
						 sig => $sig,
						}
				       },
			       meth => $xmeth
			  };

	}
		    });

	for my $p (keys %{ $classNode->{proto} }) {
	    # For each prototype
	    my $scratch = { %{ $classNode->{proto}{$p} } }; # sig->method association
	    # first, grab all the superclass voodoo
	    for my $supNode (superclass_list($classNode)) {
		my $i = $supNode->{proto}{$p};
		next unless $i;
		for my $k (keys %$i) {
		    $scratch->{$k} = $i->{$k} unless exists $scratch->{$k};
		}
	    }

	    # Ok, now we have a full list
	    #if(scalar keys %$scratch > 1) {
		#print STDERR "Overload: $p (@{[keys %$scratch]})\n" if ($debug);
	    #}
	    my $xmethIndex = $methodidx{$p};
	    my $classIndex = $classidx{$className};
	    for my $sig (keys %$scratch) {
		#my $xsig = $scratch->{$sig}{class} . "::" . $sig;
		my $xsig = $className . "::" . $sig;
		$scratch->{$sig}{sig} = $xsig;
		delete $scratch->{$sig}
		    if $scratch->{$sig}{Flags} =~ "p" # pure virtual
			or not exists $allMethods{$xsig};
	    }
	    push @protos, {
		methIndex => $xmethIndex,
		c => $classIndex,
		over => $scratch
	    } if scalar keys %$scratch;
	}
    });

    my @protolist = sort { $a->{c} <=> $b->{c} || $a->{methIndex} <=> $b->{methIndex} } @protos;
#for my $abc (@protos) {
#print "$abc->{methIndex}.$abc->{c}\n";
#}

    print STDERR "Writing methodmap table\n" if ($debug);
    my @resolve = ();
#    print OUT "// Class ID, munged name ID (index into methodNames), method def (see methods) if >0 or number of overloads if <0\n";
    my $methodMapCount = 1;
#    print OUT "static Smoke::MethodMap ${libname}_methodMaps[] = {\n";
#    print OUT "\t{ 0, 0, 0 },\t//0 (no method)\n";
    for my $cur (@protolist) {
	if(scalar keys %{ $cur->{over} } > 1) {
#	    print OUT "\t{$cur->{c}, $cur->{methIndex}, -@{[1+scalar @resolve]}},\t//$methodMapCount $classlist[$cur->{c}]\::$methodlist[$cur->{methIndex}]\n";
	    $methodMapCount++;
	    for my $k (keys %{ $cur->{over} }) {
	        my $p = $cur->{over}{$k};
	        my $xsig = $p->{class} ? "$p->{class}\::$k" : $p->{sig};
	        push @resolve, { k => $k, p => $p, cur => $cur, id => $allMethods{$xsig} };
	    }
	    push @resolve, 0;
	} else {
	    for my $k (keys %{ $cur->{over} }) {
	        my $p = $cur->{over}{$k};
	        my $xsig = $p->{class} ? "$p->{class}\::$k" : $p->{sig};
#	        print OUT "\t{$cur->{c}, $cur->{methIndex}, $allMethods{$xsig}},\t//$methodMapCount $classlist[$cur->{c}]\::$methodlist[$cur->{methIndex}]\n";
	        $methodMapCount++;
	    }
	}
    }
#    print OUT "};\n\n";


    print STDERR "Writing ambiguousMethodList\n" if ($debug);
#    print OUT "static Smoke::Index ${libname}_ambiguousMethodList[] = {\n";
#    print OUT "    0,\n";
    for my $r (@resolve) {
	unless($r) {
#	    print OUT "    0,\n";
	    next;
	}
	my $xsig = $r->{p}{class} ? "$r->{p}{class}\::$r->{k}" : $r->{p}{sig};
	die "ambiguousMethodList: no method found for $xsig\n" if !defined $allMethods{$xsig};
#	print OUT "    $allMethods{$xsig},  // $xsig\n";
    }
#    print OUT "};\n\n";

#    print OUT "extern \"C\" { // needed?\n";
#    print OUT "    void init_${libname}_Smoke();\n";
#    print OUT "}\n";
#    print OUT "\n";
#    print OUT "Smoke* qt_Smoke = 0L;\n";
#    print OUT "\n";
#    print OUT "// Create the Smoke instance encapsulating all the above.\n";
#    print OUT "void init_${libname}_Smoke() {\n";
#    print OUT "    qt_Smoke = new Smoke(\n";
#    print OUT "        ${libname}_classes, ".$#classlist.",\n";
#    print OUT "        ${libname}_methods, $methodCount,\n";
#    print OUT "        ${libname}_methodMaps, $methodMapCount,\n";
#    print OUT "        ${libname}_methodNames, $methodNameCount,\n";
#    print OUT "        ${libname}_types, $typeCount,\n";
#    print OUT "        ${libname}_inheritanceList,\n";
#    print OUT "        ${libname}_argumentList,\n";
#    print OUT "        ${libname}_ambiguousMethodList,\n";
#    print OUT "        ${libname}_cast );\n";
#    print OUT "}\n";
#    close OUT;

#print "@{[keys %allMethods ]}\n";
}
=head2 printJavadocComment

	Parameters: docnode filehandle

	Converts a kdoc comment to javadoc format.
	@ref's are converted to @link's; @p's and @em's are converted
	to inline HTML.

=cut

sub printJavadocComment($$$$)
{
	my( $docnode, $name, $indent, $signalLink ) = @_;

	my $node;
	my $returntext = '';
	foreach $node ( @{$docnode->{Text}} ) {
		next if $node->{NodeType} ne "DocText" and $node->{NodeType} ne "ListItem" 
		and $node->{NodeType} ne "Param";
		my $line = '';
		
		if ($node->{NodeType} eq "Param") {
			if ($node->{Name} !~ /argc/) {
				$line = "\@param " . $node->{Name} . " " . $node->{astNodeName};
			}
		} else {
			$line = $node->{astNodeName};
		}
		$line =~ s/argc, ?argv/args/g;
		$line =~ s/int argc, ?char ?\* ?argv(\[\])?/String[] args/g;
		$line =~ s/int argc, ?char ?\*\* ?argv/String[] args/g;
		if ($node->{NodeType} eq "Param") {
			$line =~ s/(const )?QC?StringList(\s*&)?/String[]/g;
		} else {
			$line =~ s/(const )?QC?StringList(\s*&)?/ArrayList/g;
		}
		$line =~ s/NodeList|KTrader::OfferList/ArrayList/g;
		$line =~ s/(const )?TQDate(Time)?(\s*&)?/Calendar/g;
		$line =~ s/(const )?TQTime([^r])/Date$1/g;
		$line =~ s/TQString::null/null/g;
		$line =~ s/(const )?QC?String(\s*&)?/String/g;
		$line =~ s/TQByteArray/byte[]/g;
		$line =~ s/(const )?KCmdLineOptions\s*(\w+)\[\]/String[][] $2/;
		$line =~ s/KCmdLineLastOption//g;
		$line =~ s/virtual //g;
		$line =~ s/~\w+\(\)((\s*{\s*})|;)//g;
		$line =~ s/0L/null/g;
		$line =~ s/(\([^\)]*\))\s*:\s*\w+\([^\)]*\)/$1/g;
		$line =~ s/\(void\)//g;
		$line =~ s/const char/String/g;
		$line =~ s/const (\w+)\&/$1/g;
		$line =~ s/bool/boolean/g;
		$line =~ s/SLOT\(\s*([^\)]*)\) ?\)/SLOT("$1)")/g;
		$line =~ s/SIGNAL\(\s*([^\)]*)\) ?\)/SIGNAL("$1)")/g;
		$line =~ s/Q_OBJECT\n//g;
		$line =~ s/class\s+([\w]+)\s*:\s*public/public class $1 implements/g;
		$line =~ s/public\s*(slots)?:\n/public /g;
		$line =~ s/([^0-9"]\s*)\*(\s*[^0-9"-])/$1$2/g;
		$line =~ s/^(\s*)\*/$1/g;
		$line =~ s/\n \*/\n /g;
		$line =~ s/\@ref\s+([\w]+)::([\w]+)\s*(\([^\)]*\))(\.)?/{\@link $1#$2}$4/g;
		$line =~ s/\@ref\s+#([\w:]+)(\(\))?/{\@link #$1}/g;
		$line =~ s/\@ref\s+([\w]+)\s*(\([^\)]*\))/{\@link #$1}/g;
		$line =~ s/\@ref\s+([\w]+)::([\w]+)/{\@link $1#$2}/g;
		$line =~ s/\@ref\s+([a-z][\w]+)/{\@link #$1}/g;
		$line =~ s/\@ref\s+([\w]+)/{\@link $1}/g;
		while ($line =~ /\@c\s+([\w#\\\.<>]+)/ ) {
			my $code = $1;
			$code =~ s!<!&lt;!g;
			$code =~ s!>!&gt;!g;
			$code =~ s!\\#!#!g;
			$line =~ s!\@c\s+([\w#\\\.<>]+)!<code>$code</code>!;
		}
		$line =~ s!\@em\s+(\w+)!<b>$1</b>!g;
		$line =~ s!\@p\s+([\w\._]*)!<code>$1</code>!g;
		$line =~ s!\\paragraph\s+[\w]+\s([\w]+)!<li><b>$1</b></li>!g;
		$line =~ s!\\b\s+([\w -]+)\\n!<li><b>$1</b></li>!g;
		$line =~ s!\\c\s+([\w\@&\\?;-]+)!<code>$1</code>!g;
		$line =~ s!\\p\s+([\w\@]+)!<pre>$1</pre>!g;
		$line =~ s!\\li\s+([\w\@]+)!<li>$1</li>!g;
		$line =~ s!<b>([\w\t \(\)-]*:?)</b>\\n!<li><b>$1</b></li>!g;
		$line =~ s!static_cast<\s*([\w\.]*)\s*>!($1)!g;
		if ($name ne "") {
			$line =~ s/\@link #/\@link $name\#/g;
		}
		
		if ($node->{NodeType} eq "ListItem") {
			$line =~ s/^/\n<li>\n/;
			$line =~ s!$!\n</li>!;
			$line =~ s/\n/\n$indent\t/g;
		} else {
			$line =~ s/^/$indent/;
			$line =~ s/\n/\n$indent/g;
		}
		
		$line =~ s/\n/\n$indent/g;
		$returntext .= $line;
	}
	
	$returntext .= $signalLink;
	
	if ( defined $docnode->{Returns} ) {
		my $text = $docnode->{Returns};
		$text =~ s/TQString::null/null/g;
		$returntext .=  "\t\t\@return $text\n";
	}
		
	if ( defined $docnode->{Author} ) { 
		$returntext .= "\t\t\@author " . $docnode->{Author} . "\n" 
	}
		
	if ( defined $docnode->{Version} ) {
		my $versionStr = $docnode->{Version};
		$versionStr =~ s/\$\s*Id:([^\$]*) Exp \$/$1/;
		$returntext .= "\t\t\@version $versionStr\n";
	}
		
	if ( defined $docnode->{ClassShort} ) { 
		my $shortText = $docnode->{ClassShort};
		$shortText =~ s![\*\n]! !g;
		$returntext .= "\t\t\@short $shortText\n";
	}
	
	if ( defined $docnode->{See} ) {
		foreach my $text ( @{$docnode->{See}} ) {
			next if ($text =~ /TQString|^\s*and\s*$|^\s*$|^[^\w]*$/);
			$text =~ s/KIO:://g;
			$text =~ s/KParts:://g;
			$text =~ s/bool/boolean/g;
			$text =~ s/::/#/g;
			$text =~ s/->/#/g;
			$text =~ s/\./#/g;
			$text =~ s/\(\)//g;
			$text =~ s/^\s*([a-z].*)/#$1/g;
			$text =~ s/^\s*Q/org.kde.qt.Q/g;
#			$text =~ s/^\s*K/org.kde.koala.K/g;
			$returntext .= "\t\t\@see $text\n";
		}
	}	

	$returntext =~ s/DOM#([A-Z])/$1/g;
	$returntext =~ s/KIO#([A-Z])/$1/g;
	$returntext =~ s/KParts#([A-Z])/$1/g;
	$returntext =~ s/const\s+(\w+)\s*\&/$1/g;
	$returntext =~ s/TQChar/char/g;
	$returntext =~ s/TQStringList/ArrayList/g;
	$returntext =~ s/([Aa]) ArrayList/$1n ArrayList/g;
	$returntext =~ s/TQString/String/g;
	$returntext =~ s/KCmdLineOptions/String[][]/;
	$returntext =~ s!\\note!<b>Note:<\b>!g;
	$returntext =~ s!\\(code|verbatim)!<pre>!g;
	$returntext =~ s!\\(endcode|endverbatim)!</pre>!g;
	$returntext =~ s!\\addtogroup\s+[\w]+\s+"([^"\@]+)"\s+\@{!<li><b>$1</b></li>!g;
	$returntext =~ s![\\\@]relates\s+([a-z][\w]*)!{\@link #$1}!g;
	$returntext =~ s![\\\@]relates\s+(\w+)::(\w+)!{\@link $1#$2}!g;
	$returntext =~ s![\\\@]relates\s+(#?\w+)!{\@link $1}!g;
	$returntext =~ s!\\c\s+([\w\@&\\?";-]+)!<code>$1</code>!g;
	$returntext =~ s!\@p\s+([\w\._]*)!<code>$1</code>!g;
	$returntext =~ s!\@a\s+([:\w]+)!<b>$1</b>!g;
	$returntext =~ s![\@\\]b\s+[:\w]!<b>$1</b>!g;
	$returntext =~ s/};/}/g;
	$returntext =~ s/::/./g;
	$returntext =~ s/->/./g;
	
	$returntext =~ s/\s*$//;
	return $returntext . "\n" . $indent;
}

1;