summaryrefslogtreecommitdiffstats
path: root/python
ModeNameSize
-rw-r--r--README337logstatsplain
d---------doc187logstatsplain
d---------examples110logstatsplain
d---------netlink276logstatsplain
-rw-r--r--setup.py.in1388logstatsplain
d---------tests49logstatsplain
id='n117' href='#n117'>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
This file is part of MXE. See LICENSE.md for licensing information.

Contains ad hoc patches for cross building.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tony Theodore <tonyt@logyst.com>
Date: Sat, 18 Nov 2017 20:43:52 +1100
Subject: [PATCH 1/2] fixes

This patch has been taken from: https://bitbucket.org/msys2/coin/commits/69e9990b05cee506f5fa16c6edad02a7808bc610/raw/

It was modified to work with Coin 3.1.3.
(The order of the template arguments of SbHash was switched.)

diff --git a/include/Inventor/C/glue/spidermonkey.h b/include/Inventor/C/glue/spidermonkey.h
index 1111111..2222222 100644
--- a/include/Inventor/C/glue/spidermonkey.h
+++ b/include/Inventor/C/glue/spidermonkey.h
@@ -47,7 +47,7 @@ extern "C" {
    Structs and defines.
 */
 typedef int JSBool;
-typedef long jsword;
+typedef intmax_t jsword;
 typedef jsword jsval;
 typedef jsword jsid;
 typedef int intN;
diff --git a/include/Inventor/C/glue/spidermonkey.h.orig b/include/Inventor/C/glue/spidermonkey.h.orig
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/include/Inventor/C/glue/spidermonkey.h.orig
@@ -0,0 +1,470 @@
+#ifndef COIN_GLUE_SPIDERMONKEY_H
+#define COIN_GLUE_SPIDERMONKEY_H
+
+/**************************************************************************\
+ *
+ *  This file is part of the Coin 3D visualization library.
+ *  Copyright (C) by Kongsberg Oil & Gas Technologies.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  ("GPL") version 2 as published by the Free Software Foundation.
+ *  See the file LICENSE.GPL at the root directory of this source
+ *  distribution for additional information about the GNU GPL.
+ *
+ *  For using Coin with software that can not be combined with the GNU
+ *  GPL, and for taking advantage of the additional benefits of our
+ *  support services, please contact Kongsberg Oil & Gas Technologies
+ *  about acquiring a Coin Professional Edition License.
+ *
+ *  See http://www.coin3d.org/ for more information.
+ *
+ *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
+ *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
+ *
+\**************************************************************************/
+
+#include <Inventor/C/basic.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if 0 /* to get proper auto-indentation in emacs */
+}
+#endif /* emacs indentation */
+
+
+/*
+  This is used to detect whether the 'jsapi.h' was included by the
+  user or not. The JSVERSION_IS_ECMA is defined in the 'jspubtd.h'
+  file in the SpiderMonkey header directory. 
+*/
+#ifndef JSVERSION_IS_ECMA
+
+
+/*
+   Structs and defines.
+*/
+typedef int JSBool;
+typedef long jsword;
+typedef jsword jsval;
+typedef jsword jsid;
+typedef int intN;
+typedef unsigned int uintN;
+typedef uint16_t jschar;
+
+typedef int32_t jsrefcount;
+typedef uint8_t jsbytecode;
+typedef uint32_t JSHashNumber;
+typedef uint32_t jsatomid;
+
+typedef enum JSType {
+  JSTYPE_VOID,
+  JSTYPE_OBJECT,
+  JSTYPE_FUNCTION,
+  JSTYPE_STRING,
+  JSTYPE_NUMBER,
+  JSTYPE_BOOLEAN,
+  JSTYPE_LIMIT
+} JSType;
+
+typedef enum JSAccessMode {
+  JSACC_PROTO = 0,
+  JSACC_PARENT = 1,
+  JSACC_IMPORT = 2,
+  JSACC_WATCH = 3,
+  JSACC_READ = 4,
+  JSACC_WRITE = 8,
+  JSACC_LIMIT
+} JSAccessMode;
+
+typedef enum JSGCStatus {
+  JSGC_BEGIN,
+  JSGC_END,
+  JSGC_MARK_END,
+  JSGC_FINALIZE_END
+} JSGCStatus;
+
+struct JSIdArray {
+    int32_t length;
+    jsid vector[1];
+};
+
+typedef void JSRuntime;
+typedef void JSContext;
+typedef void JSObject;
+typedef void JSObjectOps;
+typedef void JSXDRState;
+typedef void JSString;
+typedef struct JSClass JSClass;
+typedef struct JSPropertySpec JSPropertySpec;
+typedef int JSVersion;
+typedef void JSFunction;
+typedef struct JSFunctionSpec JSFunctionSpec;
+typedef struct JSErrorReport JSErrorReport;
+typedef void JSScript;
+
+#define JS_DLL_CALLBACK /* FIXME: set up this define properly. 20050601 mortene. */
+
+typedef JSBool (* JS_DLL_CALLBACK JSPropertyOp)(JSContext *, JSObject *, jsval, jsval *);
+typedef JSBool (* JS_DLL_CALLBACK JSEnumerateOp)(JSContext *, JSObject *);
+typedef JSBool (* JS_DLL_CALLBACK JSResolveOp)(JSContext *, JSObject *, jsval);
+typedef JSBool (* JS_DLL_CALLBACK JSConvertOp)(JSContext *, JSObject *, JSType, jsval *);
+typedef void (* JS_DLL_CALLBACK JSFinalizeOp)(JSContext *, JSObject *);
+typedef JSObjectOps * (* JS_DLL_CALLBACK JSGetObjectOps)(JSContext *, JSClass *);
+typedef JSBool (* JS_DLL_CALLBACK JSCheckAccessOp)(JSContext *, JSObject *, jsval, JSAccessMode, jsval *);
+typedef JSBool (* JS_DLL_CALLBACK JSNative)(JSContext *, JSObject *, uintN, jsval *, jsval *);
+typedef JSBool (* JS_DLL_CALLBACK JSXDRObjectOp)(JSXDRState *, JSObject **);
+typedef JSBool (* JS_DLL_CALLBACK JSHasInstanceOp)(JSContext *, JSObject *, jsval, JSBool *);
+typedef uint32_t (* JS_DLL_CALLBACK JSMarkOp)(JSContext *, JSObject *, void *);
+
+struct JSClass {
+  const char * name;
+  uint32_t flags;
+  JSPropertyOp addProperty;
+  JSPropertyOp delProperty;
+  JSPropertyOp getProperty;
+  JSPropertyOp setProperty;
+  JSEnumerateOp enumerate;
+  JSResolveOp resolve;
+  JSConvertOp convert;
+  JSFinalizeOp finalize;
+  JSGetObjectOps getObjectOps;
+  JSCheckAccessOp checkAccess;
+  JSNative call;
+  JSNative construct;
+  JSXDRObjectOp xdrObject;
+  JSHasInstanceOp hasInstance;
+  JSMarkOp mark;
+  jsword spare;
+};
+
+struct JSPropertySpec {
+  const char * name;
+  int8_t tinyid;
+  uint8_t flags;
+  JSPropertyOp getter;
+  JSPropertyOp setter;
+};
+
+struct JSFunctionSpec {
+  const char *name;
+  JSNative call;
+  uint8_t nargs;
+  uint8_t flags;
+  uint16_t extra;
+};
+
+struct JSErrorReport {
+  const char * filename;
+  uintN lineno;
+  const char * linebuf;
+  const char * tokenptr;
+  const jschar * uclinebuf;
+  const jschar * uctokenptr;
+  uintN flags;
+  uintN errorNumber;
+  const jschar * ucmessage;
+  const jschar ** messageArgs;
+};
+
+
+/* Defines and macros. ************************************************** */
+
+#define JSVAL_OBJECT 0x0
+#define JSVAL_INT 0x1
+#define JSVAL_DOUBLE 0x2
+#define JSVAL_STRING 0x4
+#define JSVAL_BOOLEAN 0x6
+
+#define JS_BIT(n)       ((uint32_t)1 << (n))
+#define JS_BITMASK(n)   (JS_BIT(n) - 1)
+
+#define JSVAL_TAGBITS 3
+#define JSVAL_TAGMASK           JS_BITMASK(JSVAL_TAGBITS)
+#define JSVAL_TAG(v)            ((v) & JSVAL_TAGMASK)
+#define JSVAL_SETTAG(v,t) ((v) | (t))
+#define JSVAL_CLRTAG(v)         ((v) & ~(jsval)JSVAL_TAGMASK)
+
+#define JSVAL_IS_PRIMITIVE(v)   (!JSVAL_IS_OBJECT(v) || JSVAL_IS_NULL(v))
+#define JSVAL_IS_OBJECT(v)      (JSVAL_TAG(v) == JSVAL_OBJECT)
+#define JSVAL_IS_NUMBER(v)      (JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v))
+#define JSVAL_IS_INT(v)         (((v) & JSVAL_INT) && (v) != JSVAL_VOID)
+#define JSVAL_IS_DOUBLE(v)      (JSVAL_TAG(v) == JSVAL_DOUBLE)
+#define JSVAL_IS_STRING(v)      (JSVAL_TAG(v) == JSVAL_STRING)
+#define JSVAL_IS_BOOLEAN(v)     (JSVAL_TAG(v) == JSVAL_BOOLEAN)
+#define JSVAL_IS_NULL(v)        ((v) == JSVAL_NULL)
+#define JSVAL_IS_VOID(v)        ((v) == JSVAL_VOID)
+
+#define BOOLEAN_TO_JSVAL(b) JSVAL_SETTAG((jsval)(b) << JSVAL_TAGBITS, JSVAL_BOOLEAN)
+#define JSVAL_TO_BOOLEAN(v) ((JSBool)((v) >> JSVAL_TAGBITS))
+
+#define JSVAL_INT_BITS          31
+#define JSVAL_INT_POW2(n)       ((jsval)1 << (n))
+#define JSVAL_INT_MIN           ((jsval)1 - JSVAL_INT_POW2(30))
+#define JSVAL_INT_MAX           (JSVAL_INT_POW2(30) - 1)
+#define INT_FITS_IN_JSVAL(i)    ((uint32_t)((i)+JSVAL_INT_MAX) <= 2*JSVAL_INT_MAX)
+#define JSVAL_TO_INT(v)         ((int32_t)(v) >> 1)
+#define INT_TO_JSVAL(i)         (((jsval)(i) << 1) | JSVAL_INT)
+
+#define JSVAL_TO_GCTHING(v)     ((void *)JSVAL_CLRTAG(v))
+#define JSVAL_TO_OBJECT(v)      ((JSObject *)JSVAL_TO_GCTHING(v))
+#define JSVAL_TO_DOUBLE(v)      ((double *)JSVAL_TO_GCTHING(v))
+#define JSVAL_TO_STRING(v)      ((JSString *)JSVAL_TO_GCTHING(v))
+#define OBJECT_TO_JSVAL(obj)    ((jsval)(obj))
+#define DOUBLE_TO_JSVAL(dp)     JSVAL_SETTAG((jsval)(dp), JSVAL_DOUBLE)
+#define STRING_TO_JSVAL(str)    JSVAL_SETTAG((jsval)(str), JSVAL_STRING)
+#define JSVAL_TO_PRIVATE(v)     ((void *)((v) & ~JSVAL_INT))
+#define PRIVATE_TO_JSVAL(p)     ((jsval)(p) | JSVAL_INT)
+
+#define JSPROP_ENUMERATE 0x01
+#define JSPROP_READONLY 0x02
+#define JSPROP_PERMANENT 0x04
+#define JSPROP_EXPORTED 0x08
+#define JSPROP_GETTER 0x10
+#define JSPROP_SETTER 0x20
+#define JSPROP_SHARED 0x40
+#define JSPROP_INDEX 0x80
+
+#define JS_FALSE (int)0
+#define JS_TRUE (int)1
+
+#define JSVAL_VOID   INT_TO_JSVAL(0 - JSVAL_INT_POW2(30))
+#define JSVAL_NULL   OBJECT_TO_JSVAL(0)
+#define JSVAL_ZERO   INT_TO_JSVAL(0)
+#define JSVAL_ONE    INT_TO_JSVAL(1)
+#define JSVAL_FALSE  BOOLEAN_TO_JSVAL(JS_FALSE)
+#define JSVAL_TRUE   BOOLEAN_TO_JSVAL(JS_TRUE)
+
+#define JSCLASS_HAS_PRIVATE             (1<<0)
+#define JSCLASS_NEW_ENUMERATE           (1<<1)
+#define JSCLASS_NEW_RESOLVE             (1<<2)
+#define JSCLASS_PRIVATE_IS_NSISUPPORTS  (1<<3)
+#define JSCLASS_SHARE_ALL_PROPERTIES    (1<<4)
+#define JSCLASS_NEW_RESOLVE_GETS_START  (1<<5)
+
+#define JSFUN_BOUND_METHOD 0x40
+
+#define JSOPTION_STRICT                 JS_BIT(0)
+#define JSOPTION_WERROR                 JS_BIT(1)
+#define JSOPTION_VAROBJFIX              JS_BIT(2)
+#define JSOPTION_PRIVATE_IS_NSISUPPORTS JS_BIT(3)
+#define JSOPTION_COMPILE_N_GO           JS_BIT(4)
+
+
+/* Function typedefs. *************************************************** */
+
+typedef void (* JS_DLL_CALLBACK JSErrorReporter)(JSContext *, const char *, JSErrorReport *);
+typedef JSBool (* JS_DLL_CALLBACK JSGCCallback)(JSContext *, JSGCStatus);
+
+#endif /* !JSVERSION_IS_ECMA */
+
+typedef JSBool (* JS_EvaluateScript_t)(JSContext *, JSObject *, const char *, uintN, const char *, uintN, jsval *);
+typedef JSString * (* JS_ValueToString_t)(JSContext *, jsval);
+typedef char * (* JS_GetStringBytes_t)(JSString *);
+typedef JSBool (* JS_SetProperty_t)(JSContext *, JSObject *, const char *, jsval *);
+typedef JSBool (* JS_GetProperty_t)(JSContext *, JSObject *, const char *, jsval *);
+typedef JSBool (* JS_CallFunctionName_t)(JSContext *, JSObject *, const char *, uintN, jsval *, jsval *);
+typedef JSBool (* JS_CallFunctionValue_t)(JSContext *, JSObject *, jsval, uintN, jsval *, jsval *);
+typedef JSObject * (* JS_ConstructObjectWithArguments_t)(JSContext *, JSClass *, JSObject *, JSObject *, uintN, jsval *);
+typedef JSRuntime * (* JS_NewRuntime_t)(uint32_t);
+typedef void (* JS_DestroyRuntime_t)(JSRuntime *);
+typedef JSContext * (* JS_NewContext_t)(JSRuntime *, size_t);
+typedef void (* JS_DestroyContext_t)(JSContext *);
+typedef void (* JS_ShutDown_t)(void);
+typedef JSObject * (* JS_NewObject_t)(JSContext *, JSClass *, JSObject *, JSObject *);
+typedef JSBool (* JS_InitStandardClasses_t)(JSContext *, JSObject *);
+typedef JSErrorReporter (* JS_SetErrorReporter_t)(JSContext *, JSErrorReporter);
+typedef JSBool (* JS_PropertyStub_t)(JSContext *, JSObject *, jsval, jsval *);
+typedef JSBool (* JS_EnumerateStub_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_ResolveStub_t)(JSContext *, JSObject *, jsval);
+typedef JSBool (* JS_ConvertStub_t)(JSContext *, JSObject *, JSType, jsval *);
+typedef void (* JS_FinalizeStub_t)(JSContext *, JSObject *);
+typedef const char * (* JS_GetImplementationVersion_t)(void);
+typedef void * (* JS_GetPrivate_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_SetPrivate_t)(JSContext *, JSObject *, void *);
+typedef JSFunction * (* JS_NewFunction_t)(JSContext *, JSNative, uintN, uintN flags, JSObject *, const char *);
+typedef JSObject * (* JS_GetFunctionObject_t)(JSFunction *);
+typedef JSObject * (* JS_DefineObject_t)(JSContext *, JSObject *, const char *, JSClass *, JSObject *, uintN);
+typedef JSBool (* JS_DefineProperties_t)(JSContext *, JSObject *, JSPropertySpec *);
+typedef JSObject * (* JS_GetParent_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_SetParent_t)(JSContext *, JSObject *, JSObject *);
+typedef JSBool (* JS_DefineFunctions_t)(JSContext *, JSObject *, JSFunctionSpec *);
+typedef JSString * (* JS_NewStringCopyZ_t)(JSContext *, const char *);
+typedef JSType (* JS_TypeOfValue_t)(JSContext *, jsval);
+typedef const char * (* JS_GetTypeName_t)(JSContext *, JSType);
+typedef JSBool (* JS_InstanceOf_t)(JSContext *, JSObject *, JSClass *, jsval *);
+typedef JSObject * (* JS_InitClass_t)(JSContext *, JSObject *, JSObject *, JSClass *,
+                                      JSNative, uintN, JSPropertySpec *, JSFunctionSpec *,
+                                      JSPropertySpec *, JSFunctionSpec *);
+typedef JSBool (* JS_NewDoubleValue_t)(JSContext *, double, jsval *);
+typedef void * (* JS_GetContextPrivate_t)(JSContext *);
+typedef void (* JS_SetContextPrivate_t)(JSContext *, void *);
+typedef JSBool (* JS_ValueToBoolean_t)(JSContext *, jsval, JSBool *);
+typedef JSBool (* JS_ValueToNumber_t)(JSContext *, jsval, double *);
+typedef JSObject * (* JS_NewArrayObject_t)(JSContext *, int32_t, jsval *);
+typedef JSBool (* JS_GetArrayLength_t)(JSContext *, JSObject *, uint32_t *);
+typedef JSBool (* JS_SetArrayLength_t)(JSContext *, JSObject *, uint32_t);
+typedef JSBool (* JS_HasArrayLength_t)(JSContext *, JSObject *, uint32_t *);
+typedef JSBool (* JS_GetElement_t)(JSContext *, JSObject *, int32_t, jsval *);
+typedef JSBool (* JS_SetElement_t)(JSContext *, JSObject *, int32_t, jsval *);
+typedef JSBool (* JS_AddRoot_t)(JSContext *, void *);
+typedef JSBool (* JS_RemoveRoot_t)(JSContext *, void *);
+typedef size_t (* JS_GetStringLength_t)(JSString *);
+typedef JSBool (* JS_LookupProperty_t)(JSContext *, JSObject *, const char *, jsval *);
+typedef JSBool (* JS_DefineProperty_t)(JSContext *, JSObject *, const char *, jsval, JSPropertyOp, JSPropertyOp, uintN);
+typedef JSScript * (* JS_CompileFile_t)(JSContext *, JSObject *, const char *);
+typedef JSBool (* JS_ValueToObject_t)(JSContext *, jsval, JSObject **);
+typedef JSBool (* JS_ExecuteScript_t)(JSContext *, JSObject *, JSScript *, jsval *);
+typedef JSBool (* JS_IsExceptionPending_t)(JSContext *);
+typedef JSBool (* JS_GetPendingException_t)(JSContext *, jsval *);
+typedef void (* JS_SetPendingException_t)(JSContext *, jsval);
+typedef void (* JS_ClearPendingException_t)(JSContext *);
+typedef double * (* JS_NewDouble_t)(JSContext *, double);
+typedef JSBool (* JS_CallFunction_t)(JSContext *, JSObject *, JSFunction *, uintN, jsval *, jsval *);
+typedef JSFunction * (* JS_ValueToFunction_t)(JSContext *, jsval);
+typedef void (* JS_ReportError_t)(JSContext *, const char *, ...);
+typedef JSBool (* JS_IsArrayObject_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_ObjectIsFunction_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_ValueToECMAInt32_t)(JSContext *, jsval, int32_t *);
+typedef JSFunction * (* JS_DefineFunction_t)(JSContext *, JSObject *, const char *, JSNative, uintN, uintN);
+typedef JSObject * (* JS_GetGlobalObject_t)(JSContext *);
+typedef JSGCCallback (* JS_SetGCCallback_t)(JSContext *, JSGCCallback);
+typedef void (* JS_GC_t)(JSContext *);
+typedef void (* JS_MaybeGC_t)(JSContext *);
+typedef JSBool (* JS_IsRunning_t)(JSContext *);
+typedef JSBool (* JS_DeleteProperty_t)(JSContext *, JSObject *, const char *);
+typedef JSScript * (* JS_CompileScript_t)(JSContext *, JSObject *,
+                                          const char *, size_t,
+                                          const char *, uintN);
+typedef jsval (* JS_GetNaNValue_t)(JSContext *);
+typedef jsval (* JS_GetNegativeInfinityValue_t)(JSContext *);
+typedef jsval (* JS_GetPositiveInfinityValue_t)(JSContext *);
+typedef jsval (* JS_GetEmptyStringValue_t)(JSContext *);
+typedef JSBool (* JS_SetPropertyAttributes_t)(JSContext *, JSObject *, const char *, uintN, JSBool *);
+typedef JSBool (* JS_GetPropertyAttributes_t)(JSContext *, JSObject *, const char *, uintN *, JSBool *);
+typedef JSClass * (* JS_GetClass_t)(JSObject *);
+typedef JSObject * (* JS_GetPrototype_t)(JSContext *, JSObject *);
+typedef JSObject * (* JS_SetPrototype_t)(JSContext *, JSObject *, JSObject *);
+typedef intN (* JS_CompareStrings_t)(JSString *, JSString *);
+typedef uint32_t (* JS_GetOptions_t)(JSContext *);
+typedef uint32_t (* JS_SetOptions_t)(JSContext *, uint32_t);
+typedef uint32_t (* JS_ToggleOptions_t)(JSContext *, uint32_t);
+typedef struct JSIdArray * (* JS_Enumerate_t)(JSContext *, JSObject *);
+typedef JSBool (* JS_IdToValue_t)(JSContext *, jsid, jsval *);
+typedef const char * (* JS_GetFunctionName_t)(JSFunction *);
+typedef JSObject * (* JS_GetConstructor_t)(JSContext *, JSObject *);
+typedef void (* JS_DestroyIdArray_t)(JSContext *, struct JSIdArray *);
+
+
+/* Access interface. **************************************************** */
+
+typedef struct {
+  int available;
+
+  JS_CallFunctionName_t JS_CallFunctionName;
+  JS_CallFunctionValue_t JS_CallFunctionValue;
+  JS_ConstructObjectWithArguments_t JS_ConstructObjectWithArguments;
+  JS_ConvertStub_t JS_ConvertStub;
+  JS_DestroyContext_t JS_DestroyContext;
+  JS_DestroyRuntime_t JS_DestroyRuntime;
+  JS_EnumerateStub_t JS_EnumerateStub;
+  JS_EvaluateScript_t JS_EvaluateScript;
+  JS_FinalizeStub_t JS_FinalizeStub;
+  JS_GetClass_t JS_GetClass;
+  JS_GetImplementationVersion_t JS_GetImplementationVersion;
+  JS_GetProperty_t JS_GetProperty;
+  JS_GetStringBytes_t JS_GetStringBytes;
+  JS_InitStandardClasses_t JS_InitStandardClasses;
+  JS_NewContext_t JS_NewContext;
+  JS_NewObject_t JS_NewObject;
+  JS_NewRuntime_t JS_NewRuntime;
+  JS_PropertyStub_t JS_PropertyStub;
+  JS_ResolveStub_t JS_ResolveStub;
+  JS_SetErrorReporter_t JS_SetErrorReporter;
+  JS_SetProperty_t JS_SetProperty;
+  JS_ShutDown_t JS_ShutDown;
+  JS_ValueToString_t JS_ValueToString;
+  JS_DefineObject_t JS_DefineObject;
+  JS_DefineProperties_t JS_DefineProperties;
+  JS_GetPrivate_t JS_GetPrivate;
+  JS_SetPrivate_t JS_SetPrivate;
+  JS_NewFunction_t JS_NewFunction;
+  JS_GetFunctionObject_t JS_GetFunctionObject;
+  JS_GetParent_t JS_GetParent;
+  JS_SetParent_t JS_SetParent;
+  JS_DefineFunctions_t JS_DefineFunctions;
+  JS_NewStringCopyZ_t JS_NewStringCopyZ;
+  JS_TypeOfValue_t JS_TypeOfValue;
+  JS_GetTypeName_t JS_GetTypeName;
+  JS_InstanceOf_t JS_InstanceOf;
+  JS_InitClass_t JS_InitClass;
+  JS_NewDoubleValue_t JS_NewDoubleValue;
+  JS_GetContextPrivate_t JS_GetContextPrivate;
+  JS_SetContextPrivate_t JS_SetContextPrivate;
+  JS_ValueToBoolean_t JS_ValueToBoolean;
+  JS_ValueToNumber_t JS_ValueToNumber;
+  JS_NewArrayObject_t JS_NewArrayObject;
+  JS_GetArrayLength_t JS_GetArrayLength;
+  JS_SetArrayLength_t JS_SetArrayLength;
+  JS_HasArrayLength_t JS_HasArrayLength;
+  JS_GetElement_t JS_GetElement;
+  JS_SetElement_t JS_SetElement;
+  JS_AddRoot_t JS_AddRoot;
+  JS_RemoveRoot_t JS_RemoveRoot;
+  JS_GetStringLength_t JS_GetStringLength;
+  JS_LookupProperty_t JS_LookupProperty;
+  JS_DefineProperty_t JS_DefineProperty;
+  JS_CompileFile_t JS_CompileFile;
+  JS_ValueToObject_t JS_ValueToObject;
+  JS_ExecuteScript_t JS_ExecuteScript;
+  JS_IsExceptionPending_t JS_IsExceptionPending;
+  JS_GetPendingException_t JS_GetPendingException;
+  JS_SetPendingException_t JS_SetPendingException;
+  JS_ClearPendingException_t JS_ClearPendingException;
+  JS_NewDouble_t JS_NewDouble;
+  JS_CallFunction_t JS_CallFunction;
+  JS_ValueToFunction_t JS_ValueToFunction;
+  JS_ReportError_t JS_ReportError;
+  JS_IsArrayObject_t JS_IsArrayObject;
+  JS_ObjectIsFunction_t JS_ObjectIsFunction;
+  // Note: We use this function instead of JS_ValueToInt32() since the 
+  // latter is buggy in versions of SpiderMonkey older than 2005-09-29, 
+  // see Mozilla bug #284032.
+  JS_ValueToECMAInt32_t JS_ValueToECMAInt32;
+  JS_DefineFunction_t JS_DefineFunction;
+  JS_GetGlobalObject_t JS_GetGlobalObject;
+  JS_SetGCCallback_t JS_SetGCCallback;
+  JS_GC_t JS_GC;
+  JS_MaybeGC_t JS_MaybeGC;
+  JS_IsRunning_t JS_IsRunning;
+  JS_DeleteProperty_t JS_DeleteProperty;
+  JS_CompileScript_t JS_CompileScript;
+  JS_GetNaNValue_t JS_GetNaNValue;
+  JS_GetNegativeInfinityValue_t JS_GetNegativeInfinityValue;
+  JS_GetPositiveInfinityValue_t JS_GetPositiveInfinityValue;
+  JS_GetEmptyStringValue_t JS_GetEmptyStringValue;
+  JS_SetPropertyAttributes_t JS_SetPropertyAttributes;
+  JS_GetPropertyAttributes_t JS_GetPropertyAttributes;
+  JS_GetPrototype_t JS_GetPrototype;
+  JS_SetPrototype_t JS_SetPrototype;
+  JS_CompareStrings_t JS_CompareStrings;
+  JS_GetOptions_t JS_GetOptions;
+  JS_SetOptions_t JS_SetOptions;
+  JS_ToggleOptions_t JS_ToggleOptions;
+  JS_Enumerate_t JS_Enumerate;
+  JS_IdToValue_t JS_IdToValue;
+  JS_GetFunctionName_t JS_GetFunctionName;
+  JS_GetConstructor_t JS_GetConstructor;
+  JS_DestroyIdArray_t JS_DestroyIdArray;
+
+} SpiderMonkey_t;
+
+COIN_DLL_API const SpiderMonkey_t * spidermonkey(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* !COIN_GLUE_SPIDERMONKEY_H */
diff --git a/src/foreignfiles/SoSTLFileKit.cpp b/src/foreignfiles/SoSTLFileKit.cpp
index 1111111..2222222 100644
--- a/src/foreignfiles/SoSTLFileKit.cpp
+++ b/src/foreignfiles/SoSTLFileKit.cpp
@@ -594,14 +594,14 @@ SoSTLFileKit::addFacet(const SbVec3f & v1, const SbVec3f & v2, const SbVec3f & v
     SO_GET_ANY_PART(this, "facets", SoIndexedFaceSet);
 
   // find existing indexes if any
-  long v1idx = PRIVATE(this)->points->findPoint(v1), v1new = (v1idx == -1);
-  long v2idx = PRIVATE(this)->points->findPoint(v2), v2new = (v2idx == -1);
-  long v3idx = PRIVATE(this)->points->findPoint(v3), v3new = (v3idx == -1);
-  if (!v1new) { v1idx = (long) PRIVATE(this)->points->getUserData(v1idx); }
-  if (!v2new) { v2idx = (long) PRIVATE(this)->points->getUserData(v2idx); }
-  if (!v3new) { v3idx = (long) PRIVATE(this)->points->getUserData(v3idx); }
-  long nidx = PRIVATE(this)->normals->findPoint(n);
-  if (nidx != -1) { nidx = (long) PRIVATE(this)->normals->getUserData(nidx); }
+  intmax_t v1idx = PRIVATE(this)->points->findPoint(v1), v1new = (v1idx == -1);
+  intmax_t v2idx = PRIVATE(this)->points->findPoint(v2), v2new = (v2idx == -1);
+  intmax_t v3idx = PRIVATE(this)->points->findPoint(v3), v3new = (v3idx == -1);
+  if (!v1new) { v1idx = (intmax_t) PRIVATE(this)->points->getUserData(v1idx); }
+  if (!v2new) { v2idx = (intmax_t) PRIVATE(this)->points->getUserData(v2idx); }
+  if (!v3new) { v3idx = (intmax_t) PRIVATE(this)->points->getUserData(v3idx); }
+  intmax_t nidx = PRIVATE(this)->normals->findPoint(n);
+  if (nidx != -1) { nidx = (intmax_t) PRIVATE(this)->normals->getUserData(nidx); }
 
   // toss out invalid facets - facets where two or more points are in
   // the same location.  what are these - are they lines and points or
diff --git a/src/foreignfiles/SoSTLFileKit.cpp.orig b/src/foreignfiles/SoSTLFileKit.cpp.orig
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/src/foreignfiles/SoSTLFileKit.cpp.orig
@@ -0,0 +1,799 @@
+/**************************************************************************\
+ *
+ *  This file is part of the Coin 3D visualization library.
+ *  Copyright (C) by Kongsberg Oil & Gas Technologies.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  ("GPL") version 2 as published by the Free Software Foundation.
+ *  See the file LICENSE.GPL at the root directory of this source
+ *  distribution for additional information about the GNU GPL.
+ *
+ *  For using Coin with software that can not be combined with the GNU
+ *  GPL, and for taking advantage of the additional benefits of our
+ *  support services, please contact Kongsberg Oil & Gas Technologies
+ *  about acquiring a Coin Professional Edition License.
+ *
+ *  See http://www.coin3d.org/ for more information.
+ *
+ *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
+ *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
+ *
+\**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#ifdef HAVE_NODEKITS
+
+#include <ForeignFiles/SoSTLFileKit.h>
+
+#include <Inventor/SbBasic.h>
+#include <Inventor/lists/SbList.h>
+#include <Inventor/errors/SoDebugError.h>
+#include <Inventor/actions/SoCallbackAction.h>
+#include <Inventor/actions/SoReorganizeAction.h>
+#include <Inventor/nodes/SoSeparator.h>
+#include <Inventor/nodes/SoShapeHints.h>
+#include <Inventor/nodes/SoTexture2.h>
+#include <Inventor/nodes/SoNormal.h>
+#include <Inventor/nodes/SoNormalBinding.h>
+#include <Inventor/nodes/SoMaterial.h>
+#include <Inventor/nodes/SoMaterialBinding.h>
+#include <Inventor/nodes/SoCoordinate3.h>
+#include <Inventor/nodes/SoIndexedFaceSet.h>
+#include <Inventor/nodes/SoInfo.h>
+#include <Inventor/SbBSPTree.h>
+#include <Inventor/SoPrimitiveVertex.h>
+
+#include "steel.h"
+#include "nodekits/SoSubKitP.h"
+
+
+#if 0
+  SoCallback         "callbackList"         SoBaseKit
+  SoSeparator        "topSeparator"         SoForeignFileKit
+  SoShapeHints         "shapehints"           SoSTLFileKit
+  SoTexture2           "texture"              SoSTLFileKit
+  SoNormalBinding      "normalbinding"        SoSTLFileKit
+  SoNormal             "normals"              SoSTLFileKit
+  SoMaterialBinding    "materialbinding"      SoSTLFileKit
+  SoMaterial           "material"             SoSTLFileKit
+  SoCoordinate3        "coordinates"          SoSTLFileKit
+  SoIndexedFaceSet     "facets"               SoSTLFileKit
+#endif // 0
+
+class SoSTLFileKitP {
+public:
+  SoSTLFileKitP(SoSTLFileKit * pub)
+  : api(pub) {
+    this->data = new SbList<uint16_t>;
+    this->points = new SbBSPTree;
+    this->normals = new SbBSPTree;
+  }
+  ~SoSTLFileKitP(void) {
+    delete this->data;
+    delete this->points;
+    delete this->normals;
+  }
+
+public:
+  SoSTLFileKit * const api;
+
+  SbList<uint16_t> * data;
+  SbBSPTree * points;
+  SbBSPTree * normals;
+
+  int numfacets;
+  int numvertices;
+  int numnormals;
+  int numsharedvertices;
+  int numsharednormals;
+  int numredundantfacets;
+}; // SoSTLFileKitP
+
+// *************************************************************************
+
+/*!
+  \class SoSTLFileKit SoSTLFileKit.h ForeignFiles/SoSTLFileKit.h
+  \brief SoSTLFileKit is a class for using STL files with Coin.
+
+  Class for using STL files with Coin.  You can use it to read and
+  write STL files, and convert back and forth between Open Inventor
+  scene graphs and SoSTLFileKits.
+
+  STL files are 3D models intended for 3D printers, and is a format
+  supported by a wide variety of computer-aided design programs.  STL
+  models are, because of their intended purpose, always
+  representations of solid objects.  STL is short for
+  Stereolithography, the process used for 3D printing.
+
+  Ordinary STL models do not contain color information.  There are,
+  however, two extensions to the binary file format for specifying
+  color.  Currently neither extension is supported.  This is caused by
+  lack of sample models using the extensions and will be added as soon
+  as such models are found.  We have the specs on the extensions, and
+  it should be pretty straight-forwards to implement, but we want to
+  get it right at once since we have write support (we don't want to
+  inadvertently create a third color extension ;).
+
+  When writing STL files, certain STL model criterias are not enforced
+  by SoSTLFileKit.  These are:
+
+  - STL models should represent complete solids - it is the user's
+    responsibility to give models of solid data to readScene(), and
+    not readScene()'s responsibility to check the incoming data.
+
+  - STL models should have all triangles in counterclockwise order.
+    This is not enforced either.
+
+  - STL models should reside in the positive octant of the coordinate
+    space.  This is also the user's responsibility to ensure, although
+    adding functionality for translating the model should be easy, so
+    it might get implemented.
+
+  Since the color extensions are not supported yet, color information
+  is not collected either when converting Open Inventor scene graphs to
+  SoSTLFileKits.
+
+  \relates foreignfileformats
+  \COIN_CLASS_EXTENSION
+  \since Coin 3.0
+*/
+
+#define PRIVATE(obj) ((obj)->pimpl)
+
+SO_KIT_SOURCE(SoSTLFileKit)
+
+/*!
+  Initializes class and registers file identification functions.
+*/
+
+void
+SoSTLFileKit::initClass(void)
+{
+  SO_KIT_INIT_CLASS(SoSTLFileKit, SoForeignFileKit, SoForeignFileKit);
+
+  SoType type = SoSTLFileKit::getClassTypeId();
+  SoForeignFileKit::registerFileExtension(type, "stl", SoSTLFileKit::identify);
+}
+
+/*!
+  Returns wether or not \a filename is identified as an STL file.
+*/
+
+SbBool
+SoSTLFileKit::identify(const char * filename)
+{
+  assert(filename);
+  stl_reader * reader = stl_reader_create(filename);
+  if ( !reader ) {
+    return FALSE;
+  }
+  stl_reader_destroy(reader);
+  return TRUE;
+}
+
+/*!
+  Constructor.
+*/
+
+SoSTLFileKit::SoSTLFileKit(void)
+{
+  PRIVATE(this) = new SoSTLFileKitP(this);
+
+  SO_KIT_INTERNAL_CONSTRUCTOR(SoSTLFileKit);
+
+  SO_KIT_ADD_FIELD(info, (""));
+  SO_KIT_ADD_FIELD(binary, (FALSE));
+  SO_KIT_ADD_FIELD(colorization, (SoSTLFileKit::GREY));
+
+  SO_KIT_DEFINE_ENUM_VALUE(Colorization, GREY);
+  SO_KIT_DEFINE_ENUM_VALUE(Colorization, MATERIALISE);
+  SO_KIT_DEFINE_ENUM_VALUE(Colorization, TNO_VISICAM);
+
+  SO_KIT_SET_SF_ENUM_TYPE(colorization, Colorization);
+
+  SO_KIT_ADD_CATALOG_ENTRY(facets, SoIndexedFaceSet,
+                           FALSE, topSeparator, \x0, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(coordinates, SoCoordinate3,
+                           FALSE, topSeparator, facets, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(material, SoMaterial,
+                           FALSE, topSeparator, coordinates, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(materialbinding, SoMaterialBinding,
+                           FALSE, topSeparator, material, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(normals, SoNormal,
+                           FALSE, topSeparator, materialbinding, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(normalbinding, SoNormalBinding,
+                           FALSE, topSeparator, normals, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(texture, SoTexture2,
+                           FALSE, topSeparator, normalbinding, FALSE);
+  SO_KIT_ADD_CATALOG_ENTRY(shapehints, SoShapeHints,
+                           FALSE, topSeparator, texture, FALSE);
+
+  SO_KIT_INIT_INSTANCE();
+}
+
+/*!
+  Destructor.
+*/
+
+SoSTLFileKit::~SoSTLFileKit(void)
+{
+  delete PRIVATE(this);
+  PRIVATE(this) = NULL;
+}
+
+// doc in inherited class
+SbBool
+SoSTLFileKit::canReadFile(const char * filename) const
+{
+  if ( !filename ) return TRUE; // we can read STL files, in general
+  return SoSTLFileKit::identify(filename);
+}
+
+/*!
+  Reads in an STL file.  Both ascii and binary files are supported.
+  For binary files, the color extensions are not implemented yet.
+
+  Returns FALSE if \a filename could not be opened or parsed
+  correctly.
+
+  \sa canReadFile, canWriteScene, writeScene
+*/
+
+SbBool
+SoSTLFileKit::readFile(const char * filename)
+{
+  assert(filename);
+
+  this->reset();
+
+  stl_reader * reader = stl_reader_create(filename);
+  if ( !reader ) {
+    SoDebugError::postInfo("SoSTLFileKit::readFile",
+                           "unable to create STL reader for '%s'.",
+                           filename);
+    return FALSE;
+  }
+
+  SbBool binary = (stl_reader_flags(reader) & STL_BINARY) ? TRUE : FALSE;
+
+  SoShapeHints * hints =
+    SO_GET_ANY_PART(this, "shapehints", SoShapeHints);
+  hints->vertexOrdering.setValue(SoShapeHints::UNKNOWN_ORDERING);
+  // what it should have been
+  // hints->vertexOrdering.setValue(SoShapeHints::COUNTERCLOCKWISE);
+  hints->shapeType.setValue(SoShapeHints::SOLID);
+  hints->faceType.setValue(SoShapeHints::UNKNOWN_FACE_TYPE);
+
+  SoNormalBinding * normalbinding =
+    SO_GET_ANY_PART(this, "normalbinding", SoNormalBinding);
+  normalbinding->value = SoNormalBinding::PER_FACE_INDEXED;
+
+  stl_facet * facet = stl_facet_create();
+  SbBool loop = TRUE, success = TRUE;
+  while ( loop ) {
+    const int peekval = stl_reader_peek(reader);
+    if ( peekval == STL_BEGIN ) {
+    } else if ( peekval == STL_INIT_INFO ) {
+      // FIXME: set info
+    } else if ( peekval == STL_EXIT_INFO ) {
+    } else if ( peekval == STL_END ) {
+      loop = FALSE;
+    } else if ( peekval == STL_FACET ) {
+      stl_real x, y, z;
+      stl_reader_fill_facet(reader, facet);
+      stl_facet_get_normal(facet, &x, &y, &z);
+      SbVec3f normal((float) x, (float) y, (float) z);
+      stl_facet_get_vertex1(facet, &x, &y, &z);
+      SbVec3f vertex1((float) x, (float) y, (float) z);
+      stl_facet_get_vertex2(facet, &x, &y, &z);
+      SbVec3f vertex2((float) x, (float) y, (float) z);
+      stl_facet_get_vertex3(facet, &x, &y, &z);
+      SbVec3f vertex3((float) x, (float) y, (float) z);
+      if ( normal.length() == 0.0f ) { // auto-calculate
+        SbVec3f v1(vertex2-vertex1);
+        SbVec3f v2(vertex3-vertex1);
+        normal = v1.cross(v2);
+        float len = normal.length();
+        if ( len > 0 ) normal /= len;
+      }
+      unsigned int data = stl_facet_get_padding(facet);
+
+      SbBool added = this->addFacet(vertex1, vertex2, vertex3, normal);
+
+#if defined(COIN_EXTRA_DEBUG) || 1
+      if ( added && binary ) {
+        // binary contains padding, which might be colorization
+        // colorization is not implemented yet, so therefore some debug
+        // output comes here so colorized models can be detected.
+        PRIVATE(this)->data->append((uint16_t) data);
+        if ( data != 0 ) {
+          fprintf(stderr, "facet %5d - data: %04x\n", PRIVATE(this)->numfacets - 1, data);
+        }
+      }
+#endif // COIN_EXTRA_DEBUG
+    } else if ( peekval == STL_ERROR ) {
+      SoDebugError::post("SoSTLFileKit::readFile",
+                         "error '%s' after %d facets, line %d.",
+                         stl_reader_get_error(reader),
+                         PRIVATE(this)->numfacets,
+                         stl_reader_get_line_number(reader));
+      loop = FALSE;
+      success = FALSE;
+      if (strcmp(stl_reader_get_error(reader), "premature end of file") == 0) {
+        // this one we will accept though - models with missing
+        // end-indicator have been found...
+        success = TRUE;
+      }
+    }
+  }
+
+  // done - no need for the BSP trees to contain data any more
+  PRIVATE(this)->points->clear();
+  PRIVATE(this)->normals->clear();
+
+  stl_facet_destroy(facet);
+  stl_reader_destroy(reader);
+
+  if ( !success ) {
+    this->reset();
+  } else {
+    this->organizeModel();
+  }
+  return success;
+}
+
+// doc in inherited class
+SbBool
+SoSTLFileKit::canReadScene(void) const
+{
+  return TRUE;
+}
+
+/*!
+  Converts a scene graph into an SoSTLFileKit.  Useful for creating
+  STL files.
+
+  \sa canReadScene, canWriteFile, writeFile
+*/
+
+SbBool
+SoSTLFileKit::readScene(SoNode * scene)
+{
+  this->reset();
+
+  scene->ref();
+  SoCallbackAction cba;
+  cba.addTriangleCallback(SoType::fromName("SoNode"), add_facet_cb, this);
+  cba.apply(scene);
+  scene->unrefNoDelete();
+
+  // no need for the BSP trees to contain data any more
+  PRIVATE(this)->points->clear();
+  PRIVATE(this)->normals->clear();
+
+  this->organizeModel();
+
+  return TRUE;
+}
+
+// doc in inherited class
+SbBool
+SoSTLFileKit::canWriteScene(const char * format) const
+{
+  if ( !format ) return TRUE;
+  // FIXME: implement format checking (VRML1, VRML97)
+  return TRUE;
+}
+
+/*!
+  Converts the STL model into a native scene graph.
+
+  \sa canWriteScene
+*/
+
+SbBool
+SoSTLFileKit::writeScene(SoNode *& root, const char * format)
+{
+  static const char default_format[] = "#VRML 1.0"; // syntax for this?
+  if ( !format ) format = default_format;
+
+  SbBool success = true;
+
+  // FIXME: implement format check to specify scene graph setup
+  enum Format {
+    UNKNOWN,
+    VRML1,
+    VRML97
+  };
+
+  Format build = VRML1;
+
+  if ( build == VRML1 ) {
+    // create VRML1 scene
+    SoSeparator * sceneroot = new SoSeparator;
+    sceneroot->ref();
+
+    SoInfo * info = new SoInfo;
+    info->string = "STL model data, created by Coin " COIN_VERSION ".";
+    sceneroot->addChild(info);
+    
+    SoShapeHints * shapehints_orig =
+      SO_GET_ANY_PART(this, "shapehints", SoShapeHints);
+    SoShapeHints * shapehints_copy = new SoShapeHints;
+    shapehints_copy->copyContents(shapehints_orig, FALSE);
+    sceneroot->addChild(shapehints_copy);
+
+    SoTexture2 * texture_orig = SO_GET_ANY_PART(this, "texture", SoTexture2);
+    SoTexture2 * texture_copy = new SoTexture2;
+    texture_copy->copyContents(texture_orig, FALSE);
+    sceneroot->addChild(texture_copy);
+
+    SoNormalBinding * normalbinding_orig =
+      SO_GET_ANY_PART(this, "normalbinding", SoNormalBinding);
+    SoNormalBinding * normalbinding_copy = new SoNormalBinding;
+    normalbinding_copy->copyContents(normalbinding_orig, FALSE);
+    sceneroot->addChild(normalbinding_copy);
+
+    SoNormal * normals_orig = SO_GET_ANY_PART(this, "normals", SoNormal);
+    SoNormal * normals_copy = new SoNormal;
+    normals_copy->copyContents(normals_orig, FALSE);
+    sceneroot->addChild(normals_copy);
+
+    SoMaterialBinding * materialbinding_orig =
+      SO_GET_ANY_PART(this, "materialbinding", SoMaterialBinding);
+    SoMaterialBinding * materialbinding_copy = new SoMaterialBinding;
+    materialbinding_copy->copyContents(materialbinding_orig, FALSE);
+    sceneroot->addChild(materialbinding_copy);
+
+    SoMaterial * material_orig = SO_GET_ANY_PART(this, "material", SoMaterial);
+    SoMaterial * material_copy = new SoMaterial;
+    material_copy->copyContents(material_orig, FALSE);
+    sceneroot->addChild(material_copy);
+
+    SoCoordinate3 * coordinates_orig =
+      SO_GET_ANY_PART(this, "coordinates", SoCoordinate3);
+    SoCoordinate3 * coordinates_copy = new SoCoordinate3;
+    coordinates_copy->copyContents(coordinates_orig, FALSE);
+    sceneroot->addChild(coordinates_copy);
+
+    SoIndexedFaceSet * facets_orig =
+      SO_GET_ANY_PART(this, "facets", SoIndexedFaceSet);
+    SoIndexedFaceSet * facets_copy = new SoIndexedFaceSet;
+    facets_copy->copyContents(facets_orig, FALSE);
+    sceneroot->addChild(facets_copy);
+
+    // optimize/reorganize mesh
+    SoReorganizeAction ra;
+    ra.apply(sceneroot);
+
+    // FIXME: remove redundant scene graph nodes after scene reorganization
+
+    sceneroot->unrefNoDelete();
+    root = sceneroot;
+  } else {
+    SoDebugError::postWarning("SoSTLFileKit::writeScene",
+                              "unsupported format - could not create scene.");
+    success = FALSE;
+  }
+
+  return success;
+}
+
+// doc in inherited class
+SbBool
+SoSTLFileKit::canWriteFile(const char * filename) const
+{
+  return inherited::canWriteFile(filename);
+}
+
+/*!
+  Writes the STL model to an STL file.
+
+  \sa binary, info, canWriteFile, canReadScene
+*/
+
+SbBool
+SoSTLFileKit::writeFile(const char * filename)
+{
+  unsigned int flags = 0;
+  if ( this->binary.getValue() ) {
+    flags |= STL_BINARY;
+    // set up flags for colorization if wanted
+  }
+
+  stl_writer * writer = stl_writer_create(filename, flags);
+  if ( !writer ) {
+    return FALSE;
+  }
+
+  stl_facet * facet = stl_facet_create();
+  assert(facet);
+  stl_writer_set_facet(writer, facet);
+
+  SbString infostring = this->info.getValue();
+  if ( infostring.getLength() > 0 ) {
+    if ( stl_writer_set_info(writer, infostring.getString()) != STL_OK ) {
+      SoDebugError::post("SoSTLFileKit::writeFile",
+                         "error: '%s'",
+                         stl_writer_get_error(writer));
+      return FALSE;
+    }
+  }
+
+  this->ref();
+  SoCallbackAction cba;
+  cba.addTriangleCallback(SoNode::getClassTypeId(), put_facet_cb, writer);
+  cba.apply(this);
+  this->unrefNoDelete();
+
+  stl_writer_destroy(writer);
+
+  return TRUE;
+}
+
+// *************************************************************************
+
+/*!
+  Resets the STL model so it contains nothing.
+*/
+
+void
+SoSTLFileKit::reset(void)
+{
+  PRIVATE(this)->numvertices = 0;
+  PRIVATE(this)->numfacets = 0;
+  PRIVATE(this)->numnormals = 0;
+  PRIVATE(this)->numsharedvertices = 0;
+  PRIVATE(this)->numsharednormals = 0;
+  PRIVATE(this)->numredundantfacets = 0;
+
+  PRIVATE(this)->data->truncate(0);
+  PRIVATE(this)->points->clear();
+  PRIVATE(this)->normals->clear();
+    
+  this->setAnyPart("shapehints", new SoShapeHints);
+  this->setAnyPart("texture", new SoTexture2);
+  this->setAnyPart("normalbinding", new SoNormalBinding);
+  this->setAnyPart("normals", new SoNormal);
+  this->setAnyPart("materialbinding", new SoMaterialBinding);
+  this->setAnyPart("material", new SoMaterial);
+  this->setAnyPart("coordinates", new SoCoordinate3);
+  this->setAnyPart("facets", new SoIndexedFaceSet);
+
+  SoNormalBinding * normalbinding =
+    SO_GET_ANY_PART(this, "normalbinding", SoNormalBinding);
+  normalbinding->value = SoNormalBinding::PER_FACE_INDEXED;
+
+  SoShapeHints * shapehints =
+    SO_GET_ANY_PART(this, "shapehints", SoShapeHints);
+  shapehints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
+  // proper model is
+  //   shapehints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
+  // but many models are not proper
+  shapehints->shapeType = SoShapeHints::SOLID;
+}
+
+/*!
+  Adds one triangle to the STL model.
+
+  \sa reset, organizeModel
+*/
+
+SbBool
+SoSTLFileKit::addFacet(const SbVec3f & v1, const SbVec3f & v2, const SbVec3f & v3, const SbVec3f & n)
+{
+  SoNormal * normals =
+    SO_GET_ANY_PART(this, "normals", SoNormal);
+  SoCoordinate3 * coordinates =
+    SO_GET_ANY_PART(this, "coordinates", SoCoordinate3);
+  SoIndexedFaceSet * facets =
+    SO_GET_ANY_PART(this, "facets", SoIndexedFaceSet);
+
+  // find existing indexes if any
+  long v1idx = PRIVATE(this)->points->findPoint(v1), v1new = (v1idx == -1);
+  long v2idx = PRIVATE(this)->points->findPoint(v2), v2new = (v2idx == -1);
+  long v3idx = PRIVATE(this)->points->findPoint(v3), v3new = (v3idx == -1);
+  if (!v1new) { v1idx = (long) PRIVATE(this)->points->getUserData(v1idx); }
+  if (!v2new) { v2idx = (long) PRIVATE(this)->points->getUserData(v2idx); }
+  if (!v3new) { v3idx = (long) PRIVATE(this)->points->getUserData(v3idx); }
+  long nidx = PRIVATE(this)->normals->findPoint(n);
+  if (nidx != -1) { nidx = (long) PRIVATE(this)->normals->getUserData(nidx); }
+
+  // toss out invalid facets - facets where two or more points are in
+  // the same location.  what are these - are they lines and points or
+  // something?  selection?  borders?  creases?
+  if ((!v1new && !v2new && (v1idx == v2idx)) ||
+      (!v1new && !v3new && (v1idx == v3idx)) ||
+      (!v2new && !v3new && (v2idx == v3idx)) ||
+      (v1new && v2new && (v1 == v2)) ||
+      (v1new && v3new && (v1 == v3)) ||
+      (v2new && v3new && (v2 == v3))) {
+    // the above test is optimized for using vertex indexes if
+    // possible and avoid vec3f-comparisons when index-comparisons
+    // should have sufficed.
+    PRIVATE(this)->numredundantfacets += 1;
+    return FALSE;
+  }
+
+#if 0 // disabled (O(n^2))
+  // toss out redundant facets, if any...
+  if (!v1new && !v2new && !v3new) {
+    int count = facets->coordIndex.getNum();
+    const int32_t * points = facets->coordIndex.getValues(0);
+    int i;
+    for (i = 0; i < count; i++) {
+      if (points[i] == v1idx) {
+        int beg = i - (i % 4);
+        if ( ((points[beg] == v1idx) && (points[beg+1] == v2idx) &&
+              (points[beg+2] == v3idx)) ||
+             ((points[beg] == v2idx) && (points[beg+1] == v3idx) &&
+              (points[beg+2] == v1idx)) ||
+             ((points[beg] == v3idx) && (points[beg+1] == v1idx) &&
+              (points[beg+2] == v2idx)) ) {
+          // same vertices, same vertex ordering (we drop comparing normal)
+          PRIVATE(this)->numredundantfacets += 1;
+          return FALSE;
+        }
+      }
+    }
+  }
+#endif
+
+  // add facet (triangle) to faceset
+  if (v1new) {
+    v1idx = PRIVATE(this)->numvertices;
+    coordinates->point.set1Value(v1idx, v1);
+    PRIVATE(this)->points->addPoint(v1, (void *) v1idx);
+    PRIVATE(this)->numvertices++;
+  } else {
+    PRIVATE(this)->numsharedvertices++;
+  }
+  facets->coordIndex.set1Value(PRIVATE(this)->numfacets*4, v1idx);
+  
+  if (v2new) {
+    v2idx = PRIVATE(this)->numvertices;
+    coordinates->point.set1Value(v2idx, v2);
+    PRIVATE(this)->points->addPoint(v2, (void *) v2idx);
+    PRIVATE(this)->numvertices++;
+  } else {
+    PRIVATE(this)->numsharedvertices++;
+  }
+  facets->coordIndex.set1Value(PRIVATE(this)->numfacets*4+1, v2idx);
+
+  if (v3new) {
+    v3idx = PRIVATE(this)->numvertices;
+    coordinates->point.set1Value(v3idx, v3);
+    PRIVATE(this)->points->addPoint(v3, (void *) v3idx);
+    PRIVATE(this)->numvertices++;
+  } else {
+    PRIVATE(this)->numsharedvertices++;
+  }
+  facets->coordIndex.set1Value(PRIVATE(this)->numfacets*4+2, v3idx);
+  facets->coordIndex.set1Value(PRIVATE(this)->numfacets*4+3, -1);
+
+  if (nidx == -1) {
+    nidx = PRIVATE(this)->numnormals;
+    normals->vector.set1Value(nidx, n);
+    PRIVATE(this)->normals->addPoint(n, (void *) nidx);
+    PRIVATE(this)->numnormals++;
+  } else {
+    PRIVATE(this)->numsharednormals++;
+  }
+  facets->normalIndex.set1Value(PRIVATE(this)->numfacets, nidx);
+
+  PRIVATE(this)->numfacets++;
+  return TRUE;
+}
+
+/*!
+  Should be called after the STL model is completely set up in the
+  SoSTLFileKit through import from a file or from a scene graph.  The
+  model will then be optimized for fast rendering.
+
+  \sa addFacet, reset
+*/
+
+void
+SoSTLFileKit::organizeModel(void)
+{
+#if defined(COIN_EXTRA_DEBUG)
+  SoDebugError::postInfo("SoSTLFileKit::organizeModel",
+                         "model data imported successfully. "
+                         "%d unique vertices, %d reuses. "
+                         "%d unique normals, %d reuses. "
+                         "%d facets, %d redundant facets.",
+                         PRIVATE(this)->numvertices,
+                         PRIVATE(this)->numsharedvertices,
+                         PRIVATE(this)->numnormals,
+                         PRIVATE(this)->numsharednormals,
+                         PRIVATE(this)->numfacets,
+                         PRIVATE(this)->numredundantfacets);
+#endif // COIN_EXTRA_DEBUG
+
+  SoIndexedFaceSet * facets =
+    SO_GET_ANY_PART(this, "facets", SoIndexedFaceSet);
+
+  assert(facets->coordIndex.getNum() == PRIVATE(this)->numfacets*4);
+  assert(facets->normalIndex.getNum() == (PRIVATE(this)->numfacets));
+
+  if ( PRIVATE(this)->numfacets > 300 ) {
+    // FIXME: at some number of facets, reorganization for faster
+    // rendering should really be performed.
+  }
+}
+
+/*!
+  Helper callback for readScene(), calling addFacet() for each
+  triangle in the provided scene graph.
+
+  \sa readScene
+*/
+
+void
+SoSTLFileKit::add_facet_cb(void * closure,
+                           SoCallbackAction * action,
+                           const SoPrimitiveVertex * v1,
+                           const SoPrimitiveVertex * v2,
+                           const SoPrimitiveVertex * v3)
+{
+  assert(closure); assert(v1); assert(v2); assert(v3);
+  SoSTLFileKit * filekit = (SoSTLFileKit *) closure;
+
+  SbVec3f vertex1(v1->getPoint());
+  SbVec3f vertex2(v2->getPoint());
+  SbVec3f vertex3(v3->getPoint());
+
+  SbVec3f vec1(vertex2-vertex1);
+  SbVec3f vec2(vertex3-vertex1);
+  SbVec3f normal(vec1.cross(vec2));
+  float len = normal.length();
+  if ( len > 0.0f && len != 1.0f ) normal /= len;
+  assert(len != 0.0f);
+
+  filekit->addFacet(vertex1, vertex2, vertex3, normal);
+}
+
+/*!
+  Helper callback for writeFile(), writing each triangle in the STL
+  model to the STL file.
+
+  \sa writeFile
+*/
+
+void
+SoSTLFileKit::put_facet_cb(void * closure,
+                           SoCallbackAction * action,
+                           const SoPrimitiveVertex * v1,
+                           const SoPrimitiveVertex * v2,
+                           const SoPrimitiveVertex * v3)
+{
+  assert(closure); assert(v1); assert(v2); assert(v3);
+  stl_writer * writer = (stl_writer *) closure;
+
+  SbVec3f vertex1(v1->getPoint());
+  SbVec3f vertex2(v2->getPoint());
+  SbVec3f vertex3(v3->getPoint());
+
+  SbVec3f vec1(vertex2-vertex1);
+  SbVec3f vec2(vertex3-vertex1);
+  SbVec3f normal(vec1.cross(vec2));
+  float len = normal.length();
+  if ( len > 0 ) normal /= len;
+
+  stl_facet * facet = stl_writer_get_facet(writer);
+  assert(facet);
+  stl_facet_set_vertex1(facet, vertex1[0], vertex1[1], vertex1[2]);
+  stl_facet_set_vertex2(facet, vertex2[0], vertex2[1], vertex2[2]);
+  stl_facet_set_vertex3(facet, vertex3[0], vertex3[1], vertex3[2]);
+  stl_facet_set_normal(facet, normal[0], normal[1], normal[2]);
+  stl_facet_set_padding(facet, 0);
+
+  stl_writer_put_facet(writer, facet);
+}
+
+#undef PRIVATE
+#endif // HAVE_NODEKITS
diff --git a/src/threads/thread.cpp b/src/threads/thread.cpp
index 1111111..2222222 100644
--- a/src/threads/thread.cpp
+++ b/src/threads/thread.cpp
@@ -120,7 +120,7 @@ cc_thread_join(cc_thread * thread,
 void
 cc_sleep(float seconds)
 {
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__MINGW32__)
   /* FIXME: 20011107, thammer: create a configure macro to detect
    * which sleep function is available */
   sleep(floor(seconds));
@@ -154,7 +154,7 @@ cc_thread_id(void)
       assert(0 && "unexpected failure");
     }
   }
-  return (unsigned long) val;
+  return static_cast<unsigned long>(reinterpret_cast<intptr_t>(val));
 }
 
 static void 
diff --git a/src/threads/thread.cpp.orig b/src/threads/thread.cpp.orig
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/src/threads/thread.cpp.orig
@@ -0,0 +1,347 @@
+/**************************************************************************\
+ *
+ *  This file is part of the Coin 3D visualization library.
+ *  Copyright (C) by Kongsberg Oil & Gas Technologies.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  ("GPL") version 2 as published by the Free Software Foundation.
+ *  See the file LICENSE.GPL at the root directory of this source
+ *  distribution for additional information about the GNU GPL.
+ *
+ *  For using Coin with software that can not be combined with the GNU
+ *  GPL, and for taking advantage of the additional benefits of our
+ *  support services, please contact Kongsberg Oil & Gas Technologies
+ *  about acquiring a Coin Professional Edition License.
+ *
+ *  See http://www.coin3d.org/ for more information.
+ *
+ *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
+ *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
+ *
+\**************************************************************************/
+
+#include <Inventor/C/threads/thread.h>
+
+#include <stdlib.h>
+#include <assert.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <Inventor/C/errors/debugerror.h>
+
+#include "threads/threadp.h"
+#include "threads/mutexp.h"
+#include "threads/recmutexp.h"
+#include "threads/syncp.h"
+#include "tidbitsp.h"
+
+
+/* ********************************************************************** */
+
+/*
+ FIXME:
+ - copy struct malloc/free/init/clean setup scheme from cc_string
+ - use static table of cc_thread structures?
+ - use cc_storage to reference self-structure for cc_thread_get_self()?
+*/
+
+/* ********************************************************************** */
+
+#ifdef USE_PTHREAD
+#include "threads/thread_pthread.icc"
+#endif /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+#include "threads/thread_win32.icc"
+#endif /* USE_W32THREAD */
+
+/*
+*/
+
+cc_thread *
+cc_thread_construct(cc_thread_f * func, void * closure)
+{
+  cc_thread * thread;
+  int ok;
+
+  thread = (cc_thread*) malloc(sizeof(cc_thread));
+  assert(thread != NULL);
+  thread->func = func;
+  thread->closure = closure;
+
+  ok = internal_init(thread);
+  if (ok) return thread;
+  assert(0 && "unable to create thread");
+  free(thread);
+  return NULL;
+}
+
+/* ********************************************************************** */
+
+/*
+*/
+
+void
+cc_thread_destruct(cc_thread * thread)
+{
+  int ok;
+  assert(thread != NULL);
+  ok = internal_clean(thread);
+  assert(ok == CC_OK);
+  free(thread);
+}
+
+/* ********************************************************************** */
+
+/*
+*/
+
+int
+cc_thread_join(cc_thread * thread,
+               void ** retvalptr)
+{
+  int ok;
+  assert(thread != NULL);
+
+  ok = internal_join(thread, retvalptr);
+  assert(ok == CC_OK);
+  return ok;
+}
+
+/* ********************************************************************** */
+
+void
+cc_sleep(float seconds)
+{
+#ifndef _WIN32
+  /* FIXME: 20011107, thammer: create a configure macro to detect
+   * which sleep function is available */
+  sleep(floor(seconds));
+#else
+  Sleep((int)(seconds*1000.0));
+#endif
+};
+
+#ifdef USE_PTHREAD
+unsigned long 
+cc_thread_id(void)
+{
+  return (unsigned long) pthread_self();
+}
+#endif /* USE_PTHREAD */
+
+#ifdef USE_W32THREAD
+
+static DWORD win32_threadid_idx;
+
+unsigned long 
+cc_thread_id(void)
+{
+  static unsigned long currentidx = 1;
+  LPVOID val = TlsGetValue(win32_threadid_idx);
+  if (val == 0) { /* not set yet */
+    cc_mutex_global_lock();
+    val = (LPVOID) currentidx++;
+    cc_mutex_global_unlock();
+    if (!TlsSetValue(win32_threadid_idx, (LPVOID)val)) {
+      assert(0 && "unexpected failure");
+    }
+  }
+  return (unsigned long) val;
+}
+
+static void 
+win32_threadid_idx_cleanup(void)
+{
+  TlsFree(win32_threadid_idx);
+}
+
+#endif /* USE_WIN32THREAD */
+
+
+void
+cc_thread_init(void)
+{
+  cc_mutex_init();
+  cc_sync_init();
+#ifdef USE_W32THREAD
+  /* needed to quickly generate a thread-id for each thread */
+  win32_threadid_idx = TlsAlloc();
+  assert(win32_threadid_idx != TLS_OUT_OF_INDEXES); 
+  /* clean-up priority for the thread sub-system in Coin is set so it
+     is done very late at exit */
+  /* FIXME: not sure if this really needs the "- 2", but I added it
+     to keep the same order wrt the other thread-related clean-up
+     functions, since before I changed hard-coded numbers for
+     enumerated values for coin_atexit() invocations. 20060301 mortene. */
+  coin_atexit(win32_threadid_idx_cleanup, CC_ATEXIT_THREADING_SUBSYSTEM_VERYLOWPRIORITY);
+#endif /* USE_WIN32THREAD */ 
+  cc_recmutex_init();
+}
+
+/* ********************************************************************** */
+
+/* maybe use static table of thread structures, reference counted, to be
+   able to implement something like this, if needed */
+/* cc_thread * cc_thread_get_self(void); */
+
+/* ********************************************************************** */
+
+/*
+ * We don't really want to expose internal id types, which would mean we
+ * must include threads-implementation-specific headers in the header files.
+ * It's therefore better to implement the missing/needed functionality for
+ * the cc_thread type, so id peeking won't be necessary.
+ */
+
+/* <id> cc_thread_get_id(cc_thread * thread); */
+/* <id> cc_thread_get_current_id(void); */
+
+/* ********************************************************************** */
+
+/*!
+  \page multithreading_support Multithreading Support in Coin
+
+  The support in Coin for using multiple threads in application
+  programs and the Coin library itself, consists of two main features:
+
+  <ul>
+
+  <li>
+  Coin provides platform-independent thread-handling abstraction
+  classes. These are classes that the application programmer can
+  freely use in her application code to start new threads, control
+  their execution, work with mutexes and do other tasks related to
+  handling multiple threads.
+
+  The classes in question are SbThread, SbMutex, SbStorage, SbBarrier,
+  SbCondVar, SbFifo, SbThreadAutoLock, SbRWMutex, and
+  SbTypedStorage. See their respective documentation for the detailed
+  information.
+
+  The classes fully hides the system-specific implementation, which is
+  either done on top of native Win32 (if on Microsoft Windows), or
+  over POSIX threads (on UNIX and UNIX-like systems).
+  </li>
+
+  <li>
+  The other aspect of our multi-threading support is that Coin can be
+  specially configured so that rendering traversals of the scene graph
+  are done in a thread-safe manner. This means e.g. that it is
+  possible to have Coin render the scene in parallel on multiple CPUs
+  for multiple rendering pipes, to better take advantage of such
+  high-end systems (like CAVE environments, for instance).
+
+  Thread-safe render traversals are \e off by default, because there
+  is a small overhead involved which would make rendering (very)
+  slightly slower on single-threaded invocations.
+
+  To get a Coin library built with thread-safe rendering, one must
+  actively re-configure Coin and build a special, local version. For
+  configure-based builds (UNIX and UNIX-like systems, or with Cygwin
+  on Microsoft Windows) this is done with the option
+  "--enable-threadsafe" to Autoconf configure. For how to change the
+  configuration and re-build with Visual Studio, get in touch with us
+  at "coin-support@coin3d.org".
+  </li>
+
+  </ul>
+
+  There are some restrictions and other issues which it is important
+  to be aware of:
+  
+  <ul>
+
+  <li> We do not yet provide any support for binding the
+  multi-threaded rendering support into the SoQt / SoWin / etc GUI
+  bindings, and neither do we provide bindings against any specific
+  library that handles multi-pipe rendering. This means the
+  application programmer will have to possess some expertise, and put
+  in some effort, to be able to utilize multi-pipe rendering with
+  Coin. </li>
+
+  <li> Rendering traversals is currently the only operation which we
+  publicly support to be thread-safe. There are other aspects of Coin
+  that we know are thread-safe, like most other action traversals
+  beside just rendering, but we make no guarantees in this
+  regard. </li>
+
+  <li> Be careful about using a separate thread for changing Coin
+  structures versus what is used for the application's GUI event
+  thread.
+
+  We are aware of at least issues with Qt (and thereby SoQt), where
+  you should not modify the scene graph in any way in a thread
+  separate from the main Qt thread. This because it will trigger
+  operations where Qt is not thread-safe. </li>
+
+  </ul>
+
+  \since Coin 2.0
+*/
+
+/* ********************************************************************** */
+
+/*!
+  \class SbThread Inventor/threads/SbThread.h
+  \brief A class for managing threads.
+  \ingroup threads
+
+  This class provides a portable framework around the tasks of
+  instantiating, starting, stopping and joining threads.
+
+  It wraps the underlying native thread-handling toolkit in a
+  transparent manner, to make multiplatform threads programming
+  straightforward for the application programmer.
+*/
+
+/*!
+  \fn static SbThread * SbThread::create(void *(*func)(void *), void * closure)
+
+  This function creates a new thread, or returns NULL on failure.
+*/
+
+/*!
+  \fn static void SbThread::destroy(SbThread * thread)
+
+  This function destroys a thread.
+*/
+
+/*!
+  \fn static int SbThread::join(SbThread * thread, void ** retval)
+
+  This function waits on the death of the given thread, returning the thread's
+  return value at the location pointed to by \c retval.
+*/
+
+/*!
+  \fn int SbThread::join(void ** retval)
+
+  This function waits on the death of the given thread, returning the thread's
+  return value at the location pointed to by \c retval.
+*/
+
+/*!
+  \fn SbThread::SbThread(cc_thread * thread)
+
+  Protected constructor handling the internal thread ADT.
+
+  \sa SbThread::create
+*/
+
+/*!
+  \fn SbThread::~SbThread(void)
+
+  Destructor.
+
+  \sa SbThread::destroy
+*/
+
+/* ********************************************************************** */
diff --git a/src/threads/thread_win32.icc b/src/threads/thread_win32.icc
index 1111111..2222222 100644
--- a/src/threads/thread_win32.icc
+++ b/src/threads/thread_win32.icc
@@ -29,7 +29,7 @@ static DWORD WINAPI
 cc_w32thread_thread_proc(LPVOID lpParameter)
 {
   cc_thread *thread = (cc_thread *)lpParameter;
-  return (DWORD) thread->func(thread->closure);
+  return static_cast<DWORD>(reinterpret_cast<intptr_t>(thread->func(thread->closure)));
 }
 
 static int
diff --git a/src/threads/thread_win32.icc.orig b/src/threads/thread_win32.icc.orig
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/src/threads/thread_win32.icc.orig
@@ -0,0 +1,110 @@
+/**************************************************************************\
+ *
+ *  This file is part of the Coin 3D visualization library.
+ *  Copyright (C) by Kongsberg Oil & Gas Technologies.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  ("GPL") version 2 as published by the Free Software Foundation.
+ *  See the file LICENSE.GPL at the root directory of this source
+ *  distribution for additional information about the GNU GPL.
+ *
+ *  For using Coin with software that can not be combined with the GNU
+ *  GPL, and for taking advantage of the additional benefits of our
+ *  support services, please contact Kongsberg Oil & Gas Technologies
+ *  about acquiring a Coin Professional Edition License.
+ *
+ *  See http://www.coin3d.org/ for more information.
+ *
+ *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
+ *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
+ *
+\**************************************************************************/
+
+/* this file should only be included from thread.c */
+
+#include "glue/win32api.h"
+
+static DWORD WINAPI
+cc_w32thread_thread_proc(LPVOID lpParameter)
+{
+  cc_thread *thread = (cc_thread *)lpParameter;
+  return (DWORD) thread->func(thread->closure);
+}
+
+static int
+internal_init(cc_thread * thread)
+{
+  DWORD threadid_unused;
+
+  thread->w32thread.threadhandle = CreateThread(NULL, 0,
+    cc_w32thread_thread_proc, (LPVOID) thread, 0, &threadid_unused);
+
+  /* threadid_unused - see PlatformSDK doc. for CreateThread */
+
+  /* FIXME: thammer 20011108, check PlatformSDK doc for
+   * _beginthreadex, _endthreadex, and note about using these with
+   * LIBCMT.LIB "A thread that uses functions from the C run-time
+   * libraries should use the beginthread and endthread C run-time
+   * functions for thread management rather than CreateThread and
+   * ExitThread. Failure to do so results in small memory leaks when
+   * ExitThread is called. " */
+
+  if (thread->w32thread.threadhandle == NULL) {
+    if (COIN_DEBUG) {
+      cc_win32_print_error("internal_init", "CreateThread()", GetLastError());
+    }
+    return CC_ERROR;
+  }
+  return CC_OK;
+}
+
+static int
+internal_clean(cc_thread * thread_struct)
+{
+  /* FIXME: Is there really nothing to do here? pederb, 2001-12-10 */
+  return CC_OK;
+}
+
+static int
+internal_join(cc_thread * thread,
+               void ** retvalptr)
+{
+  DWORD status;
+  BOOL bstatus;
+  DWORD exitcode;
+
+  status = WaitForSingleObject(thread->w32thread.threadhandle, INFINITE);
+  if (status == WAIT_FAILED) {
+    if (COIN_DEBUG) {
+      cc_win32_print_error("internal_join", "WaitForSingleObject()",
+                           GetLastError());
+    }
+    return CC_ERROR;
+  }
+  else if (status != WAIT_OBJECT_0) {
+    if (COIN_DEBUG) {
+      cc_debugerror_post("internal_join",
+                         "WaitForSingleObject() - unknown return value: %d\n",
+                         status);
+    }
+    return CC_ERROR;
+  }
+  bstatus = GetExitCodeThread(thread->w32thread.threadhandle, &exitcode);
+  if (bstatus == FALSE) {
+    if (COIN_DEBUG) {
+      cc_win32_print_error("internal_join", "GetExitCodeThread()",
+                           GetLastError());
+    }
+  }
+  else if (retvalptr) {
+    *retvalptr = (void *)exitcode;
+  }
+  /* termination could be forced with TerminateThread() - but this
+   * will result in memory leaks - or bigger problems - see Platform
+   * SDK doc. */
+  CloseHandle(thread->w32thread.threadhandle);
+  thread->w32thread.threadhandle = NULL;
+
+  return bstatus ? CC_OK : CC_ERROR;
+}
diff --git a/src/vrml97/JS_VRMLClasses.cpp b/src/vrml97/JS_VRMLClasses.cpp
index 1111111..2222222 100644
--- a/src/vrml97/JS_VRMLClasses.cpp
+++ b/src/vrml97/JS_VRMLClasses.cpp
@@ -100,8 +100,11 @@ struct CoinVrmlJs {
 struct CoinVrmlJs_SensorInfo {
   SbList <JSObject *> objects;
 };
+#if defined(_WIN64)
+SbHash <void *, unsigned long long> * CoinVrmlJs_sensorinfohash = NULL;
+#else
 SbHash <void *, unsigned long> * CoinVrmlJs_sensorinfohash = NULL;
-
+#endif
 
 const char * CoinVrmlJs_SFColorAliases[] = {"r", "g", "b"};
 const char * CoinVrmlJs_SFRotationAliases[] = {"x", "y", "z", "angle"};
@@ -664,7 +667,11 @@ static void SFNode_deleteCB(void * data, SoSensor * sensor)
 {
   SoNode * node = ((SoNodeSensor *) sensor)->getAttachedNode();
   void * tmp;
+#if defined(_WIN64)
+  if(!CoinVrmlJs_sensorinfohash->get((unsigned long long) node, tmp)) {
+#else
   if(!CoinVrmlJs_sensorinfohash->get((unsigned long) node, tmp)) {
+#endif
     assert(FALSE && "Trying to delete an unregistered SoNodeSensor. Internal error.");
     return;
   }
@@ -680,7 +687,11 @@ static void SFNode_deleteCB(void * data, SoSensor * sensor)
 
   // Store the sensor-pointer so that it can be properly deleted later
   nodesensorstobedeleted->append((SoNodeSensor *) sensor);
+#if defined(_WIN64)
+  CoinVrmlJs_sensorinfohash->remove((unsigned long long) node);
+#else
   CoinVrmlJs_sensorinfohash->remove((unsigned long) node);
+#endif
   delete si;
 }
 
@@ -1418,13 +1429,21 @@ static void attachSensorToNode(SoNode * node, JSObject * obj)
 {
   // Has the hash-table been initialized?
   if (!CoinVrmlJs_sensorinfohash) {
+#if defined(_WIN64)
+    CoinVrmlJs_sensorinfohash = new SbHash <void *, unsigned long long>;
+#else
     CoinVrmlJs_sensorinfohash = new SbHash <void *, unsigned long>;
+#endif
     coin_atexit(deleteSensorInfoHash, CC_ATEXIT_NORMAL);
   }
 
   // Is a sensor already attached to this SoNode?
   void * tmp;
+#if defined(_WIN64)
+  if (CoinVrmlJs_sensorinfohash->get((unsigned long long) node, tmp)) {
+#else
   if (CoinVrmlJs_sensorinfohash->get((unsigned long) node, tmp)) {
+#endif
     CoinVrmlJs_SensorInfo * si = (CoinVrmlJs_SensorInfo *) tmp;
     si->objects.append(obj);
   }
@@ -1434,7 +1453,11 @@ static void attachSensorToNode(SoNode * node, JSObject * obj)
     ns->attach(node);
     CoinVrmlJs_SensorInfo * si = new CoinVrmlJs_SensorInfo;
     si->objects.append(obj);
+#if defined(_WIN64)
+    CoinVrmlJs_sensorinfohash->put((unsigned long long) node, si);
+#else
     CoinVrmlJs_sensorinfohash->put((unsigned long) node, si);
+#endif
   }
 }
 
diff --git a/src/vrml97/JS_VRMLClasses.cpp.orig b/src/vrml97/JS_VRMLClasses.cpp.orig
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/src/vrml97/JS_VRMLClasses.cpp.orig
@@ -0,0 +1,2099 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#ifdef HAVE_VRML97
+
+/**************************************************************************\
+ *
+ *  This file is part of the Coin 3D visualization library.
+ *  Copyright (C) by Kongsberg Oil & Gas Technologies.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  ("GPL") version 2 as published by the Free Software Foundation.
+ *  See the file LICENSE.GPL at the root directory of this source
+ *  distribution for additional information about the GNU GPL.
+ *
+ *  For using Coin with software that can not be combined with the GNU
+ *  GPL, and for taking advantage of the additional benefits of our
+ *  support services, please contact Kongsberg Oil & Gas Technologies
+ *  about acquiring a Coin Professional Edition License.
+ *
+ *  See http://www.coin3d.org/ for more information.
+ *
+ *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
+ *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
+ *
+\**************************************************************************/
+
+#include "JS_VRMLClasses.h"
+
+#include <Inventor/actions/SoWriteAction.h>
+#include <Inventor/misc/SoJavaScriptEngine.h>
+#include <Inventor/C/glue/spidermonkey.h>
+#include <Inventor/fields/SoSFBool.h>
+#include <Inventor/fields/SoSFInt32.h>
+#include <Inventor/fields/SoSFEnum.h>
+#include <Inventor/fields/SoSFFloat.h>
+#include <Inventor/fields/SoSFString.h>
+#include <Inventor/fields/SoSFTime.h>
+#include <Inventor/fields/SoSFColor.h>
+#include <Inventor/fields/SoSFNode.h>
+#include <Inventor/fields/SoSFImage.h>
+#include <Inventor/fields/SoSFVec2f.h>
+#include <Inventor/fields/SoSFVec3f.h>
+#include <Inventor/fields/SoSFVec3d.h>
+#include <Inventor/fields/SoSFRotation.h>
+#include <Inventor/fields/SoMFInt32.h>
+#include <Inventor/fields/SoMFFloat.h>
+#include <Inventor/fields/SoMFString.h>
+#include <Inventor/fields/SoMFTime.h>
+#include <Inventor/fields/SoMFColor.h>
+#include <Inventor/fields/SoMFNode.h>
+#include <Inventor/fields/SoMFVec2f.h>
+#include <Inventor/fields/SoMFVec3f.h>
+#include <Inventor/fields/SoMFVec3d.h>
+#include <Inventor/fields/SoMFRotation.h>
+#include <Inventor/nodes/SoGroup.h>
+#include <Inventor/nodes/SoSeparator.h>
+#include <Inventor/SoDB.h>
+#include <Inventor/SoInput.h>
+#include <Inventor/SoOutput.h> 
+#include <Inventor/VRMLnodes/SoVRMLGroup.h>
+#include <Inventor/errors/SoDebugError.h>
+#include <Inventor/sensors/SoNodeSensor.h>
+
+#include "misc/SbHash.h"
+
+// FIXME: toString() missing for all classes
+
+// "namespace" for all vrml classes
+struct CoinVrmlJs {
+  struct ClassDescriptor {
+    JSClass cls;
+    JSFunctionSpec * functions;
+
+  };
+
+  static ClassDescriptor SFColor;
+  static ClassDescriptor SFNode;
+  static ClassDescriptor SFRotation;
+  static ClassDescriptor SFVec2f;
+  static ClassDescriptor SFVec3f;
+  static ClassDescriptor SFVec3d;
+
+  static ClassDescriptor MFColor;
+  static ClassDescriptor MFFloat;
+  static ClassDescriptor MFInt32;
+  static ClassDescriptor MFNode;
+  static ClassDescriptor MFRotation;
+  static ClassDescriptor MFString;
+  static ClassDescriptor MFTime;
+  static ClassDescriptor MFVec2f;
+  static ClassDescriptor MFVec3f;
+  static ClassDescriptor MFVec3d;
+};
+
+// Struct and SbHash for keeping track of SoNodeSensors for recycling
+// purposes.
+struct CoinVrmlJs_SensorInfo {
+  SbList <JSObject *> objects;
+};
+SbHash <void *, unsigned long> * CoinVrmlJs_sensorinfohash = NULL;
+
+
+const char * CoinVrmlJs_SFColorAliases[] = {"r", "g", "b"};
+const char * CoinVrmlJs_SFRotationAliases[] = {"x", "y", "z", "angle"};
+float CoinVrmlJs_SFdefaultValues[] = {0.0, 0.0, 0.0, 0.0};
+double CoinVrmlJs_SFdefaultValuesDouble[] = {0.0, 0.0, 0.0, 0.0};
+float CoinVrmlJs_SFRotationDefaultValues[] = {0.0, 1.0, 0.0, 0.0};
+
+// Macros for instance checking
+#define JSVAL_IS_SFVEC2F(cx, jsval) (JSVAL_IS_OBJECT(jsval) && spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(jsval), &CoinVrmlJs::SFVec2f.cls, NULL))
+#define JSVAL_IS_SFVEC3F(cx, jsval) (JSVAL_IS_OBJECT(jsval) && spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(jsval), &CoinVrmlJs::SFVec3f.cls, NULL))
+#define JSVAL_IS_SFVEC3D(cx, jsval) (JSVAL_IS_OBJECT(jsval) && spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(jsval), &CoinVrmlJs::SFVec3d.cls, NULL))
+#define JSVAL_IS_SFCOLOR(cx, jsval) (JSVAL_IS_OBJECT(jsval) && spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(jsval), &CoinVrmlJs::SFColor.cls, NULL))
+#define JSVAL_IS_SFROTATION(cx, jsval) (JSVAL_IS_OBJECT(jsval) && spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(jsval), &CoinVrmlJs::SFRotation.cls, NULL))
+
+// Handlers
+#define SFColorHandler CoinVrmlJsSFHandler<SbColor, 3, CoinVrmlJs_SFColorAliases, float, CoinVrmlJs_SFdefaultValues>
+#define SFRotationHandler CoinVrmlJsSFHandler<SbVec4f, 4, CoinVrmlJs_SFRotationAliases, float, CoinVrmlJs_SFRotationDefaultValues>
+#define SFVec2fHandler CoinVrmlJsSFHandler<SbVec2f, 2, CoinVrmlJs_SFRotationAliases, float, CoinVrmlJs_SFdefaultValues>
+#define SFVec3fHandler CoinVrmlJsSFHandler<SbVec3f, 3, CoinVrmlJs_SFRotationAliases, float, CoinVrmlJs_SFdefaultValues>
+#define SFVec3dHandler CoinVrmlJsSFHandler<SbVec3d, 3, CoinVrmlJs_SFRotationAliases, double, CoinVrmlJs_SFdefaultValuesDouble>
+
+#define MFColorHandler CoinVrmlJsMFHandler<SoMFColor, SoSFColor, &CoinVrmlJs::MFColor>
+#define MFFloatHandler CoinVrmlJsMFHandler<SoMFFloat, SoSFFloat, &CoinVrmlJs::MFFloat>
+#define MFInt32Handler CoinVrmlJsMFHandler<SoMFInt32, SoSFInt32, &CoinVrmlJs::MFInt32>
+#define MFNodeHandler CoinVrmlJsMFHandler<SoMFNode, SoSFNode, &CoinVrmlJs::MFNode>
+#define MFRotationHandler CoinVrmlJsMFHandler<SoMFRotation, SoSFRotation, &CoinVrmlJs::MFRotation>
+#define MFStringHandler CoinVrmlJsMFHandler<SoMFString, SoSFString, &CoinVrmlJs::MFString>
+#define MFTimeHandler CoinVrmlJsMFHandler<SoMFTime, SoSFTime, &CoinVrmlJs::MFTime>
+#define MFVec2fHandler CoinVrmlJsMFHandler<SoMFVec2f, SoSFVec2f, &CoinVrmlJs::MFVec2f>
+#define MFVec3fHandler CoinVrmlJsMFHandler<SoMFVec3f, SoSFVec3f, &CoinVrmlJs::MFVec3f>
+#define MFVec3dHandler CoinVrmlJsMFHandler<SoMFVec3d, SoSFVec3d, &CoinVrmlJs::MFVec3d>
+
+static JSFunctionSpec MFFunctions[] = {
+//  {"toString", MF_toString, 0, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSBool SFRotationConstructor(JSContext * cx, JSObject * obj,
+                                    uintN argc, jsval * argv, jsval * rval);
+
+// Factory methods for converting to javascript objects
+static JSObject * SFColorFactory(JSContext * cx, const SbColor & self);
+static JSObject * SFNodeFactory(JSContext * cx, SoNode * container);
+static JSObject * SFRotationFactory(JSContext * cx, const SbRotation & self);
+static JSObject * SFVec2fFactory(JSContext * cx, const SbVec2f & self);
+static JSObject * SFVec3fFactory(JSContext * cx, const SbVec3f & self);
+static JSObject * SFVec3dFactory(JSContext * cx, const SbVec3d & self);
+
+static SbList <JSObject *> * garbagecollectedobjects = NULL;
+static SbList <SoNodeSensor *> * nodesensorstobedeleted = NULL;
+
+// getIndex returns -1 if id is not an alias or in range 0-max
+static JSBool getIndex(JSContext * cx, jsval id, const char * aliases[], int max)
+{
+  int index;
+
+  if (JSVAL_IS_INT(id)) {
+    index = JSVAL_TO_INT(id);
+    if (index < 0 || index >= max) {
+      spidermonkey()->JS_ReportError(cx, "index must be between 0 and %d", max);
+      return -1;
+    }
+    return index;
+  }
+  else {
+    JSString * jsstr = spidermonkey()->JS_ValueToString(cx, id);
+    const char * str = spidermonkey()->JS_GetStringBytes(jsstr);
+
+    for (index=0; index<max; ++index) {
+      if (strcmp(str, aliases[index]) == 0) {
+        return index;
+      }
+    }
+    return -1;
+  }
+}
+
+// *************************************************************************
+// handlers
+bool jsval2int(JSContext *cx, const jsval v, int32_t &value) 
+{
+  if (JSVAL_IS_NULL(v)) return false;
+  int32_t tempval;
+  if (!spidermonkey()->JS_ValueToECMAInt32(cx, v, &tempval)) {
+    return false;
+  }
+  value = tempval;
+  return true;
+}
+
+bool jsval2double(JSContext *cx, const jsval v, double &value) 
+{
+  if (JSVAL_IS_NULL(v)) return false;
+  double tempval;
+  if (!spidermonkey()->JS_ValueToNumber(cx, v, &tempval)) {
+    return false;
+  }
+  value = tempval;
+  return true;
+}
+
+
+// FIXME: number of aliases must not be lower than max. This may lead to
+// unsafe programming. 20050721 erikgors.
+template <class Base, int max, const char * aliases[], class basetype, basetype defaultValues[]>
+struct CoinVrmlJsSFHandler {
+  static JSBool get(JSContext * cx, JSObject * obj, jsval id, jsval * rval)
+  {
+    int index = getIndex(cx, id, aliases, max);
+    if (index == -1) {
+      return JS_TRUE;
+    }
+
+    Base * data = (Base *)spidermonkey()->JS_GetPrivate(cx, obj);
+    assert(data != NULL);
+    basetype var = (*data)[index];
+    SbBool ok = spidermonkey()->JS_NewDoubleValue(cx, (double)var, rval);
+    assert(ok && "JS_NewDoubleValue failed");
+    return JS_TRUE;
+  }
+
+  static JSBool set(JSContext * cx, JSObject * obj, jsval id, jsval * val)
+  {
+    int index = getIndex(cx, id, aliases, max);
+    if (index == -1) {
+      return JS_FALSE;
+    }
+
+    Base * data = (Base *)spidermonkey()->JS_GetPrivate(cx, obj);
+    assert(data != NULL);
+
+    // FIXME: number may be NaN, PositiveInfinity and NegativeInfinity.
+    // Should be checked for every time we run JS_ValueToNumber.
+    // ie: "blipp" will become NaN. 20050720 erikgors.
+    double number;
+    spidermonkey()->JS_ValueToNumber(cx, *val, &number);
+    (*data)[index] = (basetype)number;
+    return JS_TRUE;
+  }
+
+  static JSBool constructor(JSContext * cx, JSObject * obj,
+                            uintN argc, jsval * argv, jsval * rval)
+  {
+    basetype vals[max];
+
+    // convert all arguments to numbers or use defaultValues if missing
+    uint32_t i;
+    for (i=0; i<max; ++i) {
+      vals[i] = defaultValues[i];
+      if (i<argc) {
+        double val;
+        if (spidermonkey()->JS_ValueToNumber(cx, argv[i], &val)) {
+          vals[i] = (basetype)val;
+        }
+        else {
+          spidermonkey()->JS_ReportError(cx, "WARNING: failed converting argument %d "
+                                             "to a double", i + 1);
+        }
+      }
+    }
+
+    Base * data = new Base(vals);
+    spidermonkey()->JS_SetPrivate(cx, obj, data);
+    *rval = OBJECT_TO_JSVAL(obj);
+    return JS_TRUE;
+  }
+  static void destructor(JSContext * cx, JSObject * obj)
+  {
+    Base * data = (Base *)spidermonkey()->JS_GetPrivate(cx, obj);
+    // FIXME: We cannot assume this since the class object itself is an
+    // instance of this JSClass. kintel 20050804.
+    //    assert(data != NULL);
+    delete data;
+  }
+};
+
+template <class MFFieldClass, class SFFieldClass, CoinVrmlJs::ClassDescriptor * desc>
+struct CoinVrmlJsMFHandler {
+  static JSBool constructor(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
+  {
+    jsval * val = new jsval;
+    JSObject * array = spidermonkey()->JS_NewArrayObject(cx, 0, NULL);
+    *val = OBJECT_TO_JSVAL(array);
+    SbBool ok = spidermonkey()->JS_AddRoot(cx, val);
+    assert(ok && "JS_AddRoot failed");
+    spidermonkey()->JS_SetPrivate(cx, obj, val);
+
+    SFFieldClass * field = (SFFieldClass *)SFFieldClass::createInstance();
+    uintN i;
+
+    for (i=0; i<argc; ++i) {
+      if (SoJavaScriptEngine::getEngine(cx)->jsval2field(argv[i], field)) {
+        SbBool ok = spidermonkey()->JS_SetElement(cx, array, i, &argv[i]);
+        assert(ok && "JS_SetElement failed");
+      }
+      else {
+        // FIXME: should we insert a default value? 20050727 erikgors.
+        spidermonkey()->JS_ReportError(cx, "argv %d is of wrong type", i);
+      }
+    }
+    delete field;
+    return JS_TRUE;
+  }
+
+  static void destructor(JSContext * cx, JSObject * obj)
+  {
+    jsval * val = (jsval *)spidermonkey()->JS_GetPrivate(cx, obj);
+    if (val != NULL) {
+      SbBool ok = spidermonkey()->JS_RemoveRoot(cx, val);
+      assert(ok && "JS_RemoveRoot failed");
+      delete val;
+    }
+  }
+
+  static JSObject * init(JSContext * cx, JSObject * obj)
+  {
+    return spidermonkey()->JS_InitClass(cx, obj, NULL, &desc->cls,
+                                        constructor, 0,
+                                        NULL, MFFunctions, NULL, NULL);
+  }
+
+  static void resize(JSContext * cx, JSObject * array, uint32_t newLength)
+  {
+    uint32_t length;
+    SbBool ok = spidermonkey()->JS_GetArrayLength(cx, array, &length);
+    assert(ok && "JS_GetArrayLength failed");
+
+    if (length > newLength) {
+      spidermonkey()->JS_SetArrayLength(cx, array, newLength);
+    }
+    else {
+      SoType type = MFFieldClass::getClassTypeId();
+
+      // expand and fill with new objects
+      for (; length<newLength; ++length) {
+        jsval val;
+
+        if (type == SoMFInt32::getClassTypeId() ||
+            type == SoMFFloat::getClassTypeId()) {
+          val = INT_TO_JSVAL(0);
+        }
+        else if (type == SoMFString::getClassTypeId()) {
+          JSString * str = spidermonkey()->JS_NewStringCopyZ(cx, "");
+          val = STRING_TO_JSVAL(str);
+        }
+        else if (type == SoMFNode::getClassTypeId()) {
+          // All elements not explicitly initialized are set to NULL
+          val = JSVAL_VOID;
+        }
+        else if (type == SoMFColor::getClassTypeId()) {
+          JSObject * newObj =
+            spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFColor.cls, NULL, NULL);
+          assert(newObj != NULL);
+          SFColorHandler::constructor(cx, newObj, 0, NULL, &val);
+          val = OBJECT_TO_JSVAL(newObj);
+        }
+        else if (type == SoMFRotation::getClassTypeId()) {
+          JSObject * newObj =
+            spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFRotation.cls, NULL, NULL);
+          assert(newObj != NULL);
+          SFRotationConstructor(cx, newObj, 0, NULL, &val);
+          val = OBJECT_TO_JSVAL(newObj);
+        }
+        else if (type == SoMFVec2f::getClassTypeId()) {
+          JSObject * newObj =
+            spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec2f.cls, NULL, NULL);
+          assert(newObj != NULL);
+          SFVec2fHandler::constructor(cx, newObj, 0, NULL, &val);
+          val = OBJECT_TO_JSVAL(newObj);
+        }
+        else if (type == SoMFVec3f::getClassTypeId()) {
+          JSObject * newObj =
+            spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec3f.cls, NULL, NULL);
+          assert(newObj != NULL);
+          SFVec3fHandler::constructor(cx, newObj, 0, NULL, &val);
+          val = OBJECT_TO_JSVAL(newObj);
+        }
+        else if (type == SoMFVec3d::getClassTypeId()) {
+          JSObject * newObj =
+            spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec3d.cls, NULL, NULL);
+          assert(newObj != NULL);
+          SFVec3dHandler::constructor(cx, newObj, 0, NULL, &val);
+          val = OBJECT_TO_JSVAL(newObj);
+        }
+        else {
+          assert(0 && "this should not happen");
+        }
+        SbBool ok = spidermonkey()->JS_SetElement(cx, array, length, &val);
+        assert(ok && "JS_SetElement failed");
+      }
+    }
+  }
+
+  static JSBool get(JSContext * cx, JSObject * obj, jsval id, jsval * rval)
+  {
+
+    jsval * array = (jsval *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+    if (JSVAL_IS_INT(id)) {
+      assert(array != NULL);
+      int index = JSVAL_TO_INT(id);
+      return spidermonkey()->JS_GetElement(cx, JSVAL_TO_OBJECT(*array), index, rval);
+    }
+    else if (JSVAL_IS_STRING(id)) {
+      const char * str = spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(id));
+      if (SbName("length") == str) {
+        assert(array != NULL);
+        uint32_t length;
+        SbBool ok = spidermonkey()->JS_GetArrayLength(cx, JSVAL_TO_OBJECT(*array), &length);
+        assert(ok && "JS_GetArrayLength failed");
+        *rval = INT_TO_JSVAL(length);
+        return JS_TRUE;
+      }
+    }
+
+    return JS_TRUE;
+  }
+
+  static JSBool set(JSContext * cx, JSObject * obj, jsval id, jsval * val)
+  {
+    jsval * array = (jsval *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+    if (JSVAL_IS_INT(id)) {
+      int index = JSVAL_TO_INT(id);
+
+      // check for bounds
+      if (index < 0) {
+        return JS_FALSE;
+      }
+
+      // resize if necessary
+      uint32_t length;
+      SbBool ok = spidermonkey()->JS_GetArrayLength(cx, JSVAL_TO_OBJECT(*array), &length);
+      assert(ok && "JS_GetArrayLength failed");
+      if (index >= (int)length) {
+        resize(cx, JSVAL_TO_OBJECT(*array), index+1);
+      }
+
+      SFFieldClass * field = (SFFieldClass *)SFFieldClass::createInstance();
+      // Check if val is not of wrong type
+      if (SoJavaScriptEngine::getEngine(cx)->jsval2field(*val, field)) {
+        // assign it
+        SbBool ok = spidermonkey()->JS_SetElement(cx, JSVAL_TO_OBJECT(*array), index, val);
+        assert(ok && "JS_SetElement failed");
+        return JS_TRUE;
+      }
+      delete field;
+    }
+    else if (JSVAL_IS_STRING(id)) {
+      const char * str = spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(id));
+      if (SbName("length") == str) {
+        double number;
+        spidermonkey()->JS_ValueToNumber(cx, *val, &number);
+        if (number < 0) {
+          spidermonkey()->JS_ReportError(cx, "RangeError: invalid array length");
+        }
+        else {
+          resize(cx, JSVAL_TO_OBJECT(*array), (uint32_t)number);
+        }
+        return JS_TRUE;
+      }
+    }
+
+    return JS_FALSE;
+  }
+
+
+  static SbBool jsval2field(JSContext * cx, const jsval v, SoField * f)
+  {
+    if (JSVAL_IS_OBJECT(v) &&
+        spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(v), &desc->cls, NULL)) {
+      JSObject * obj = JSVAL_TO_OBJECT(v);
+      jsval * array = (jsval *)spidermonkey()->JS_GetPrivate(cx, obj);
+      assert(array != NULL);
+
+      jsval element;
+      uint32_t i;
+      uint32_t num;
+      JSBool ok = spidermonkey()->JS_GetArrayLength(cx, JSVAL_TO_OBJECT(*array), &num);
+
+      SFFieldClass * field = (SFFieldClass *)SFFieldClass::createInstance();
+
+      for (i=0; i<num; ++i) {
+        ok = spidermonkey()->JS_GetElement(cx, obj, i, &element);
+        assert(ok);
+
+        ok = SoJavaScriptEngine::getEngine(cx)->jsval2field(element, field);
+        assert(ok && "jsval2field failed");
+        ((MFFieldClass *)f)->set1Value(i, field->getValue());
+      }
+      delete field;
+      return TRUE;
+    }
+    return FALSE;
+  }
+
+  static void field2jsval(JSContext * cx, const SoField * f, jsval * v)
+  {
+    JSObject * obj = spidermonkey()->JS_NewObject(cx, &desc->cls, NULL, NULL);
+    spidermonkey()->JS_DefineFunctions(cx, obj, desc->functions);
+
+    int num = ((SoMField *)f)->getNum();
+    jsval * vals = new jsval[num];
+
+    MFFieldClass & mf = *(MFFieldClass *)f;
+
+    SFFieldClass * field = (SFFieldClass *)SFFieldClass::createInstance();
+    for (int i=0; i<num; ++i) {
+      field->setValue(mf[i]);
+      SbBool ok = SoJavaScriptEngine::getEngine(cx)->field2jsval(field, &vals[i]);
+      assert(ok && "field2jsval failed");
+    }
+
+    jsval rval;
+    constructor(cx, obj, num, vals, &rval);
+    *v = OBJECT_TO_JSVAL(obj);
+    delete field;
+    delete [] vals;
+  }
+};
+
+// *************************************************************************
+// constructors
+
+static JSBool SFRotationConstructor(JSContext * cx, JSObject * obj,
+                                    uintN argc, jsval * argv, jsval * rval)
+{
+  if (argc == 2) {
+    if (JSVAL_IS_SFVEC3F(cx, argv[0])) {
+      SbVec3f & vec =
+        *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+
+      SbVec4f * data = new SbVec4f();
+      spidermonkey()->JS_SetPrivate(cx, obj, data);
+      *rval = OBJECT_TO_JSVAL(obj);
+      // new SFRotation(SFVec3f fromVector, SFVec3f toVector)
+      if (JSVAL_IS_SFVEC3F(cx, argv[1])) {
+        SbVec3f & vec2 =
+          *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
+
+        SbRotation rot(vec, vec2);
+        SbVec3f axis;
+        float rad;
+        rot.getValue(axis, rad);
+
+        data->setValue(axis[0], axis[1], axis[2], rad);
+        return JS_TRUE;
+      }
+      // new SFRotation(SFVec3f axis, numeric angle)
+      else {
+        SbVec4f * data = new SbVec4f();
+        spidermonkey()->JS_SetPrivate(cx, obj, data);
+        *rval = OBJECT_TO_JSVAL(obj);
+
+        double number = 0.0;
+        spidermonkey()->JS_ValueToNumber(cx, argv[1], &number);
+
+        data->setValue(vec[0], vec[1], vec[2], (float)number);
+        return JS_TRUE;
+      }
+    }
+  }
+  // new SFRotation(numeric x, numeric y, numeric z, numeric angle)
+  // Missing values default to 0.0, except y, which defaults to 1.0.
+  //
+  // SbRotation will default to 0.0, 0.0, 1.0, when angle is 0.0
+  // So we use SbVec4f to hold values for SFRotation, since we need to support
+  // patterns like this:
+  // var colors = new MFColor();
+  // colors.length = 10;
+  // colors[0].x = 1
+  // colors[0].y = 0
+  // colors[0].z = 0
+  // colors[0].angle = 1.8
+  //
+  // This will not work when SbRotation holds the values. 20050714 erikgors.
+
+  return SFRotationHandler::constructor(cx, obj, argc, argv, rval);
+}
+
+// *************************************************************************
+// functions
+
+static JSBool SFNode_ref(JSContext * cx, JSObject * obj, uintN argc,
+                         jsval * argv, jsval * rval)
+{
+  // Check if the JS object has already been garbage collected. This
+  // must be done to prevent a Java script from crashing the
+  // application.
+  if (garbagecollectedobjects->find(obj) != -1) {
+    if (SoJavaScriptEngine::debug())
+      SoDebugError::postInfo("SFNode_ref", "WARNING! Trying to ref a deleted node.");
+    return JSVAL_FALSE;
+  }
+
+  SoNode & node = *(SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+  node.ref();
+  return JSVAL_TRUE;
+}
+
+static JSBool SFNode_unref(JSContext * cx, JSObject * obj, uintN argc,
+                           jsval * argv, jsval * rval)
+{
+  // Check if the JS object has already been garbage collected. This
+  // must be done to prevent a Java script from crashing the
+  // application.
+  if (garbagecollectedobjects->find(obj) != -1) {
+    if (SoJavaScriptEngine::debug())
+      SoDebugError::postInfo("SFNode_unref", "WARNING! Trying to unref an already deleted node.");
+    return JSVAL_FALSE;
+  }
+
+  SoNode & node = *(SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+  node.unref();
+  return JSVAL_TRUE;
+}
+
+static void *
+buffer_realloc(void * bufptr, size_t size)
+{
+  char *buffer = (char *)realloc(bufptr, size);
+  return buffer;
+}
+
+static JSBool SFNode_toString(JSContext * cx, JSObject * obj, uintN argc,
+                              jsval * argv, jsval * rval)
+{
+  // Check if the JS object has already been garbage collected. This
+  // must be done to prevent a Java script from crashing the
+  // application.
+  if (garbagecollectedobjects->find(obj) != -1) {
+    if (SoJavaScriptEngine::debug())
+      SoDebugError::postInfo("SFNode_toString", "WARNING! Trying to access "
+                             "an already deleted node.");
+    return JSVAL_FALSE;
+  }
+
+  SoNode *node = (SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  SoOutput out;
+  out.setHeaderString("#VRML V2.0 utf8");
+  size_t buffer_size = 1024;
+  void *buffer = (void *)malloc(buffer_size);
+  out.setBuffer(buffer, buffer_size, buffer_realloc);
+  
+  SoWriteAction wa(&out);
+  wa.apply(node);
+  
+  out.getBuffer(buffer, buffer_size);
+
+  *rval = STRING_TO_JSVAL(spidermonkey()->JS_NewStringCopyZ(cx, 
+    (char *)buffer));
+
+  free(buffer);
+
+  return JSVAL_TRUE;
+}
+
+static void SFNode_deleteCB(void * data, SoSensor * sensor)
+{
+  SoNode * node = ((SoNodeSensor *) sensor)->getAttachedNode();
+  void * tmp;
+  if(!CoinVrmlJs_sensorinfohash->get((unsigned long) node, tmp)) {
+    assert(FALSE && "Trying to delete an unregistered SoNodeSensor. Internal error.");
+    return;
+  }
+
+  CoinVrmlJs_SensorInfo * si = (CoinVrmlJs_SensorInfo *) tmp;
+
+  // Delete all JSObjects which were connected to this SoNode
+  while (si->objects.getLength()) {
+    JSObject * obj = si->objects[0];
+    garbagecollectedobjects->append(obj);
+    si->objects.removeFast(0);
+  }
+
+  // Store the sensor-pointer so that it can be properly deleted later
+  nodesensorstobedeleted->append((SoNodeSensor *) sensor);
+  CoinVrmlJs_sensorinfohash->remove((unsigned long) node);
+  delete si;
+}
+
+static void cleanupObsoleteNodeSensors(void)
+{
+  // Delete all SoNodeSensors which no longer have a node attached.
+  while(nodesensorstobedeleted->getLength() > 0) {
+    SoNodeSensor * ns = (SoNodeSensor *) (*nodesensorstobedeleted)[0];
+    nodesensorstobedeleted->removeItem(ns);
+    delete ns;
+  }
+}
+
+static JSBool SFVec2f_add(JSContext * cx, JSObject * obj, uintN argc,
+                          jsval * argv, jsval * rval)
+{
+  SbVec2f & vec1 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC2F(cx, argv[0])) {
+    SbVec2f & vec2 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec2f result = vec1 + vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec2fFactory(cx, result));
+    return JS_TRUE;
+  }
+
+  return JS_FALSE;
+}
+
+static JSBool SFVec3f_add(JSContext * cx, JSObject * obj, uintN argc,
+                          jsval * argv, jsval * rval)
+{
+  SbVec3f & vec1 = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3F(cx, argv[0])) {
+    SbVec3f & vec2 = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3f result = vec1 + vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, result));
+    return JS_TRUE;
+  }
+
+  return JS_FALSE;
+}
+
+static JSBool SFVec3d_add(JSContext * cx, JSObject * obj, uintN argc,
+                          jsval * argv, jsval * rval)
+{
+  SbVec3d & vec1 = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3D(cx, argv[0])) {
+    SbVec3d & vec2 = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3d result = vec1 + vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, result));
+    return JS_TRUE;
+  }
+
+  return JS_FALSE;
+}
+
+static JSBool SFVec2f_divide(JSContext * cx, JSObject * obj, uintN argc,
+                             jsval * argv, jsval * rval)
+{
+  SbVec2f & vec = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  double number;
+  if (argc >= 1 && jsval2double(cx, argv[0], number)) {
+    SbVec2f newVec = vec / (float)number;
+    *rval = OBJECT_TO_JSVAL(SFVec2fFactory(cx, newVec));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3f_divide(JSContext * cx, JSObject * obj, uintN argc,
+                             jsval * argv, jsval * rval)
+{
+  SbVec3f & vec = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  double number;
+  if (argc >= 1 && jsval2double(cx, argv[0], number)) {
+    SbVec3f newVec = vec / (float)number;
+    *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, newVec));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3d_divide(JSContext * cx, JSObject * obj, uintN argc,
+                             jsval * argv, jsval * rval)
+{
+  SbVec3d & vec = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  double number;
+  if (argc >= 1 && jsval2double(cx, argv[0], number)) {
+    SbVec3d newVec = vec / number;
+    *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, newVec));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec2f_dot(JSContext *cx, JSObject *obj, uintN argc,
+                          jsval *argv, jsval *rval)
+{
+  SbVec2f & vec1 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC2F(cx, argv[0])) {
+    SbVec2f & vec2 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+
+    float dot = vec1.dot(vec2);
+    JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, dot, rval);
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3f_dot(JSContext *cx, JSObject *obj, uintN argc,
+                          jsval *argv, jsval *rval)
+{
+  SbVec3f & vec = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3F(cx, argv[0])) {
+
+    SbVec3f & vec2 = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+
+    float dot = vec.dot(vec2);
+    JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, dot, rval);
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3d_dot(JSContext *cx, JSObject *obj, uintN argc,
+                          jsval *argv, jsval *rval)
+{
+  SbVec3d & vec = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3D(cx, argv[0])) {
+
+    SbVec3d & vec2 = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+
+    double dot = vec.dot(vec2);
+    JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, dot, rval);
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec2_length(JSContext * cx, JSObject * obj, uintN argc,
+                            jsval * argv, jsval * rval)
+{
+  SbVec2f * vec = (SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, vec->length(), rval);
+  return JS_TRUE;
+}
+
+static JSBool SFVec3f_length(JSContext * cx, JSObject * obj, uintN argc,
+                            jsval * argv, jsval * rval)
+{
+  SbVec3f * vec = (SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, vec->length(), rval);
+  return JS_TRUE;
+}
+
+static JSBool SFVec3d_length(JSContext * cx, JSObject * obj, uintN argc,
+                            jsval * argv, jsval * rval)
+{
+  SbVec3d * vec = (SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+  JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, vec->length(), rval);
+  return JS_TRUE;
+}
+
+static JSBool SFVec2f_multiply(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+
+  SbVec2f & vec = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_NUMBER(argv[0])) {
+    double number;
+    spidermonkey()->JS_ValueToNumber(cx, argv[0], &number);
+
+    SbVec2f newVec = vec * (float)number;
+
+    *rval = OBJECT_TO_JSVAL(SFVec2fFactory(cx, newVec));
+
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3f_multiply(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec3f & vec = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  double number;
+  if (argc >= 1 && jsval2double(cx, argv[0], number)) {
+    SbVec3f newVec = vec * (float)number;
+    *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, newVec));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3d_multiply(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec3d & vec = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  double number;
+  if (argc >= 1 && jsval2double(cx, argv[0], number)) {
+    SbVec3d newVec = vec * number;
+    *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, newVec));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec2f_normalize(JSContext * cx, JSObject * obj, uintN argc,
+                                jsval * argv, jsval * rval)
+{
+  SbVec2f vec = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  vec.normalize();
+  *rval = OBJECT_TO_JSVAL(SFVec2fFactory(cx, vec));
+  return JS_TRUE;
+}
+
+static JSBool SFVec3f_normalize(JSContext * cx, JSObject * obj, uintN argc,
+                                jsval * argv, jsval * rval)
+{
+  SbVec3f vec = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  vec.normalize();
+  *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, vec));
+  return JS_TRUE;
+}
+
+static JSBool SFVec3d_normalize(JSContext * cx, JSObject * obj, uintN argc,
+                                jsval * argv, jsval * rval)
+{
+  SbVec3d vec = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+  vec.normalize();
+  *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, vec));
+  return JS_TRUE;
+}
+
+static JSBool SFVec3f_negate(JSContext * cx, JSObject * obj, uintN argc,
+                                     jsval * argv, jsval * rval)
+{
+  SbVec3f vec = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  vec.negate();
+  *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, vec));
+  return JS_TRUE;
+}
+
+static JSBool SFVec3d_negate(JSContext * cx, JSObject * obj, uintN argc,
+                                     jsval * argv, jsval * rval)
+{
+  SbVec3d vec = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+  vec.negate();
+  *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, vec));
+  return JS_TRUE;
+}
+
+static JSBool SFVec2f_subtract(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec2f & vec1 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC2F(cx, argv[0])) {
+    SbVec2f & vec2 = *(SbVec2f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec2f result = vec1 - vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec2fFactory(cx, result));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFVec3f_subtract(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec3f & vec1 = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3F(cx, argv[0])) {
+    SbVec3f & vec2 = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3f result = vec1 - vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, result));
+    return JS_TRUE;
+  }
+
+  return JS_FALSE;
+}
+
+static JSBool SFVec3d_subtract(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec3d & vec1 = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3D(cx, argv[0])) {
+    SbVec3d & vec2 = *(SbVec3d *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3d result = vec1 - vec2;
+    *rval = OBJECT_TO_JSVAL(SFVec3dFactory(cx, result));
+    return JS_TRUE;
+  }
+
+  return JS_FALSE;
+}
+
+static JSBool SFColor_setHSV(JSContext * cx, JSObject * obj, uintN argc,
+                             jsval * argv, jsval * rval)
+{
+  if (argc != 3) {
+    return JS_FALSE;
+  }
+  SbColor & color = *(SbColor *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  float vals[3];
+  int i;
+
+  for (i=0; i<3; ++i) {
+    double number;
+    spidermonkey()->JS_ValueToNumber(cx, argv[i], &number);
+    vals[i] = (float)number;
+  }
+
+  color.setHSVValue(vals);
+
+  *rval = JSVAL_VOID;
+  return JS_TRUE;
+}
+
+static JSBool SFColor_getHSV(JSContext * cx, JSObject * obj, uintN argc,
+                             jsval * argv, jsval * rval)
+{
+  SbColor & color = *(SbColor *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  float vals[3];
+  color.getHSVValue(vals);
+
+  jsval vector[3];
+  for (int i=0; i<3; ++i) {
+    spidermonkey()->JS_NewDoubleValue(cx, vals[i], &vector[i]);
+  }
+
+  *rval = OBJECT_TO_JSVAL(spidermonkey()->JS_NewArrayObject(cx, 3, vector));
+
+  return JS_TRUE;
+}
+
+static JSBool SFRotation_getAxis(JSContext * cx, JSObject * obj, uintN argc,
+                                 jsval * argv, jsval * rval)
+{
+  SbVec4f & rot = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  SbVec3f axis(rot[0], rot[1], rot[2]);
+  *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, axis));
+  return JS_TRUE;
+}
+
+static JSBool SFRotation_inverse(JSContext * cx, JSObject * obj, uintN argc,
+                                 jsval * argv, jsval * rval)
+{
+  SbVec4f & rot = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  SbVec3f axis(rot[0], rot[1], rot[2]);
+  SbRotation newRot(axis, rot[3]);
+  newRot.invert();
+
+  *rval = OBJECT_TO_JSVAL(SFRotationFactory(cx, newRot));
+  return JS_TRUE;
+}
+
+static JSBool SFRotation_multiply(JSContext * cx, JSObject * obj, uintN argc,
+                                  jsval * argv, jsval * rval)
+{
+  SbVec4f & vec1 = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFROTATION(cx, argv[0])) {
+    SbVec4f & vec2 = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3f axis1(vec1[0], vec1[1], vec1[2]);
+    SbVec3f axis2(vec2[0], vec2[1], vec2[2]);
+    SbRotation result = SbRotation(axis1, vec1[3]) * SbRotation(axis2, vec2[3]);
+
+    *rval = OBJECT_TO_JSVAL(SFRotationFactory(cx, result));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFRotation_multVec(JSContext * cx, JSObject * obj, uintN argc,
+                                 jsval * argv, jsval * rval)
+{
+  SbVec4f & vec = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  SbVec3f axis(vec[0], vec[1], vec[2]);
+  SbRotation rot(axis, vec[3]);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3F(cx, argv[0])) {
+    SbVec3f & src = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3f dst;
+    rot.multVec(src, dst);
+
+    *rval = OBJECT_TO_JSVAL(SFVec3fFactory(cx, dst));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFRotation_setAxis(JSContext * cx, JSObject * obj, uintN argc,
+                                 jsval * argv, jsval * rval)
+{
+  SbVec4f & rot = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (argc >= 1 && JSVAL_IS_SFVEC3F(cx, argv[0])) {
+    SbVec3f & axis = *(SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    rot[0] = axis[0];
+    rot[1] = axis[1];
+    rot[2] = axis[2];
+
+    *rval = JSVAL_VOID;
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSBool SFRotation_slerp(JSContext * cx, JSObject * obj, uintN argc,
+                               jsval * argv, jsval * rval)
+{
+  SbVec4f & vec = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, obj);
+  SbVec3f axis(vec[0], vec[1], vec[2]);
+  SbRotation rot(axis, vec[3]);
+
+  double number;
+  if (argc >= 2 && JSVAL_IS_SFROTATION(cx, argv[0]) && jsval2double(cx, argv[1], number)) {
+    SbVec4f & vec2 = *(SbVec4f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
+    SbVec3f axis2(vec2[0], vec2[1], vec2[2]);
+    SbRotation dest(axis2, vec2[3]);
+
+    SbRotation result = SbRotation::slerp(rot, dest, (float)number);
+
+    *rval = OBJECT_TO_JSVAL(SFRotationFactory(cx, result));
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSFunctionSpec SFNodeFunctions[] = {
+  {"ref", SFNode_ref, 0, 0, 0},
+  {"unref", SFNode_unref, 0, 0, 0},
+  {"toString", SFNode_toString, 0, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSFunctionSpec SFVec2fFunctions[] = {
+  {"add", SFVec2f_add, 1, 0, 0},
+  {"divide", SFVec2f_divide, 1, 0, 0},
+  {"dot", SFVec2f_dot, 1, 0, 0},
+  {"length", SFVec2_length, 0, 0, 0},
+  {"multiply", SFVec2f_multiply, 1, 0, 0},
+  {"normalize", SFVec2f_normalize, 0, 0, 0},
+  {"subtract", SFVec2f_subtract, 1, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSFunctionSpec SFVec3fFunctions[] = {
+  {"add", SFVec3f_add, 1, 0, 0},
+  {"divide", SFVec3f_divide, 1, 0, 0},
+  {"dot", SFVec3f_dot, 1, 0, 0},
+  {"length", SFVec3f_length, 0, 0, 0},
+  {"multiply", SFVec3f_multiply, 1, 0, 0},
+  {"normalize", SFVec3f_normalize, 0, 0, 0},
+  {"negate", SFVec3f_negate, 0, 0, 0},
+  {"subtract", SFVec3f_subtract, 1, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSFunctionSpec SFVec3dFunctions[] = {
+  {"add", SFVec3d_add, 1, 0, 0},
+  {"divide", SFVec3d_divide, 1, 0, 0},
+  {"dot", SFVec3d_dot, 1, 0, 0},
+  {"length", SFVec3d_length, 0, 0, 0},
+  {"multiply", SFVec3d_multiply, 1, 0, 0},
+  {"normalize", SFVec3d_normalize, 0, 0, 0},
+  {"negate", SFVec3d_negate, 0, 0, 0},
+  {"subtract", SFVec3d_subtract, 1, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSFunctionSpec SFColorFunctions[] = {
+  {"setHSV", SFColor_setHSV, 3, 0, 0},
+  {"getHSV", SFColor_getHSV, 0, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+static JSFunctionSpec SFRotationFunctions[] = {
+  {"getAxis", SFRotation_getAxis, 0, 0, 0},
+  {"inverse", SFRotation_inverse, 0, 0, 0},
+  {"multiply", SFRotation_multiply, 1, 0, 0},
+  {"multVec", SFRotation_multVec, 1, 0, 0},
+  {"setAxis", SFRotation_setAxis, 1, 0, 0},
+  {"slerp", SFRotation_slerp, 2, 0, 0},
+  {NULL, NULL, 0, 0, 0}
+};
+
+// *************************************************************************
+// factory
+
+static JSObject * SFColorFactory(JSContext * cx, const SbColor & self)
+{
+  JSObject * obj =
+    spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFColor.cls, NULL, NULL);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFColorFunctions);
+
+  SbColor * color = new SbColor(self);
+  spidermonkey()->JS_SetPrivate(cx, obj, color);
+
+  return obj;
+}
+
+static JSObject * SFRotationFactory(JSContext * cx, const SbRotation & self)
+{
+  JSObject * obj =
+    spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFRotation.cls, NULL, NULL);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFRotationFunctions);
+
+  SbVec3f axis;
+  float angle;
+  self.getValue(axis, angle);
+  SbVec4f * data = new SbVec4f(axis[0], axis[1], axis[2], angle);
+  spidermonkey()->JS_SetPrivate(cx, obj, data);
+
+  return obj;
+}
+
+static JSObject * SFVec2fFactory(JSContext * cx, const SbVec2f & self)
+{
+  JSObject * obj =
+    spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec2f.cls, NULL, NULL);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFVec2fFunctions);
+
+  SbVec2f * data = new SbVec2f(self);
+  spidermonkey()->JS_SetPrivate(cx, obj, data);
+  return obj;
+}
+
+static JSObject * SFVec3fFactory(JSContext * cx, const SbVec3f & self)
+{
+  JSObject * obj =
+    spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec3f.cls, NULL, NULL);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFVec3fFunctions);
+
+  SbVec3f * data = new SbVec3f(self);
+  spidermonkey()->JS_SetPrivate(cx, obj, data);
+
+  return obj;
+}
+
+static JSObject * SFVec3dFactory(JSContext * cx, const SbVec3d & self)
+{
+  JSObject * obj =
+    spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFVec3d.cls, NULL, NULL);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFVec3dFunctions);
+
+  SbVec3d * data = new SbVec3d(self);
+  spidermonkey()->JS_SetPrivate(cx, obj, data);
+
+  return obj;
+}
+
+static JSObject * SFVec2f_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFVec2f.cls,
+                                      SFVec2fHandler::constructor, 0,
+                                      NULL, SFVec2fFunctions, NULL, NULL);
+}
+
+static JSObject * SFVec3f_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFVec3f.cls,
+                                      SFVec3fHandler::constructor, 0,
+                                      NULL, SFVec3fFunctions, NULL, NULL);
+}
+
+static JSObject * SFVec3d_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFVec3d.cls,
+                                      SFVec3dHandler::constructor, 0,
+                                      NULL, SFVec3dFunctions, NULL, NULL);
+}
+
+static JSObject * SFColor_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFColor.cls,
+                                      SFColorHandler::constructor, 0,
+                                      NULL, SFColorFunctions, NULL, NULL);
+}
+
+static JSObject * SFRotation_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFRotation.cls,
+                                      SFRotationConstructor, 0,
+                                      NULL, SFRotationFunctions, NULL, NULL);
+}
+
+// *************************************************************************
+// SFNode
+
+static JSBool SFNode_get(JSContext * cx, JSObject * obj, jsval id, jsval * rval)
+{
+
+  if (garbagecollectedobjects->find(obj) != -1) {
+    spidermonkey()->JS_ReportError(cx, "Trying to access an object with refcount=0.");
+    return JS_FALSE;
+  }
+
+  SoNode * container = (SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (container == NULL) {
+    // this will only happen when JS_NewObject calls "constructor"
+    // or the node is "undefined"
+
+    if (JSVAL_IS_STRING(id)) {
+      const char * str = spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(id));
+      if (SbName("constructor") == str) {
+        return JS_TRUE;
+      }
+    }
+    spidermonkey()->JS_ReportError(cx, "node is undefined");
+    return JS_FALSE;
+  }
+
+  if (JSVAL_IS_STRING(id)) {
+    SbString str(spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(id)));
+
+    SoField * out = container->getField(SbName(str));
+
+    int len = str.getLength();
+    static const char post[] = "_changed";
+    static const size_t postLen = sizeof(post) - 1;
+
+    if (out == NULL && len > (int)postLen &&
+        str.getSubString(len - postLen) == post) {
+      out = container->getField(SbName(str.getSubString(0, len - postLen - 1)));
+    }
+
+    if (out != NULL) {
+      SoJavaScriptEngine::getEngine(cx)->field2jsval(out, rval);
+      return JS_TRUE;
+    }
+  }
+
+  /* Note: If we're unable to find the field, we return JS_TRUE
+     instead of JS_FALSE, which might seem as the logical choice
+     for indicating a failure. If we return JS_FALSE, execution of
+     the script will halt. One side-effect of this is that it is not
+     possible to extend the SFNode JavaScript object by adding
+     properties, which can be very useful in some cases. This is also
+     more in line with the JavaScript philosophy that one can
+     dynamically add and remove properties for any object at any time.
+
+     2005-11-23 thammer.
+
+     Update: We should look more closely into the return values 
+     JS_TRUE / JS_FALSE for all getters and setters, and possibly for
+     other functions as well. It might be more robust to report the
+     error (using JS_ReportError) and return JS_TRUE to allow the
+     script to continue running than to abort the script.
+
+     2006-06-21 thammer.
+  */
+  return JS_TRUE;
+}
+
+static JSBool SFNode_set(JSContext * cx, JSObject * obj, jsval id, jsval * rval)
+{
+  SoNode * container = (SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+
+  if (container == NULL) {
+    spidermonkey()->JS_ReportError(cx, "node is undefined");
+    return JS_FALSE;
+  }
+
+  if (JSVAL_IS_STRING(id)) {
+    SbString str(spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(id)));
+
+    SoField * in = container->getField(SbName(str));
+
+    int len = str.getLength();
+    static const char pre[] = "set_";
+    static const size_t preLen = sizeof(pre) - 1;
+
+    if (in == NULL && len > (int)preLen &&
+        str.getSubString(0, preLen - 1) == pre) {
+      in = container->getField(SbName(str.getSubString(preLen)));
+    }
+
+    if (in != NULL) {
+      SoJavaScriptEngine::getEngine(cx)->jsval2field(*rval, in);
+      if (SoJavaScriptEngine::debug()) {
+        SoDebugError::postInfo("SFNode_set", "setting field %s", str.getString());
+      }
+    } else if (SoJavaScriptEngine::debug())
+      SoDebugError::postWarning("SFNode_set", "no such field %s", str.getString());
+  }
+
+  // See note in SFNode_get() about return value. 2005-11-23 thammer.
+  return JS_TRUE;
+}
+
+static void SFNodeDestructor(JSContext * cx, JSObject * obj)
+{
+  // Delete all SoNodeSensors which no longer has a node attached.
+  cleanupObsoleteNodeSensors();
+  if(garbagecollectedobjects->find(obj) != -1) { // Pointer is marked as garbage-collected
+    garbagecollectedobjects->removeItem(obj);
+  }
+
+  SoNode * container = (SoNode *)spidermonkey()->JS_GetPrivate(cx, obj);
+  // FIXME: We cannot assume this since the class object itself is an
+  // instance of this JSClass. kintel 20050804.
+  //  assert(container != NULL);
+  if (SoJavaScriptEngine::getEngine(cx)->getAutoNodeUnrefState())
+    if (container) container->unref();
+}
+
+// Called via coin_atexit() when Coin exits.
+static void deleteSensorInfoHash(void)
+{
+  CoinVrmlJs_sensorinfohash->clear();
+  delete CoinVrmlJs_sensorinfohash;
+}
+
+/*
+  Attach an SoNodeSensor to node. Adds a 'delete callback' to the
+  sensor which includes the 'obj' parameter.
+*/
+static void attachSensorToNode(SoNode * node, JSObject * obj)
+{
+  // Has the hash-table been initialized?
+  if (!CoinVrmlJs_sensorinfohash) {
+    CoinVrmlJs_sensorinfohash = new SbHash <void *, unsigned long>;
+    coin_atexit(deleteSensorInfoHash, CC_ATEXIT_NORMAL);
+  }
+
+  // Is a sensor already attached to this SoNode?
+  void * tmp;
+  if (CoinVrmlJs_sensorinfohash->get((unsigned long) node, tmp)) {
+    CoinVrmlJs_SensorInfo * si = (CoinVrmlJs_SensorInfo *) tmp;
+    si->objects.append(obj);
+  }
+  else {
+    SoNodeSensor * ns = new SoNodeSensor();
+    ns->setDeleteCallback(SFNode_deleteCB, obj);
+    ns->attach(node);
+    CoinVrmlJs_SensorInfo * si = new CoinVrmlJs_SensorInfo;
+    si->objects.append(obj);
+    CoinVrmlJs_sensorinfohash->put((unsigned long) node, si);
+  }
+}
+
+static JSObject * SFNodeFactory(JSContext * cx, SoNode * container)
+{
+  // Delete all SoNodeSensors which no longer has a node attached.
+  cleanupObsoleteNodeSensors();
+
+  JSObject * obj = spidermonkey()->JS_NewObject(cx, &CoinVrmlJs::SFNode.cls, NULL, NULL);
+
+  if(garbagecollectedobjects->find(obj) != -1) // Pointer has been used before. Remove from list.
+    garbagecollectedobjects->removeItem(obj);
+
+  spidermonkey()->JS_SetPrivate(cx, obj, container);
+  spidermonkey()->JS_DefineFunctions(cx, obj, SFNodeFunctions);
+
+  // FIXME: If the node has enums, define them here. 2007-03-08 thammer.
+
+  attachSensorToNode(container, obj);
+
+  if (SoJavaScriptEngine::getEngine(cx)->getAutoNodeUnrefState())
+    container->ref();
+
+  return obj;
+}
+
+static JSBool SFNodeConstructor(JSContext * cx, JSObject * obj,
+                                uintN argc, jsval * argv, jsval *rval)
+{
+  // Delete all SoNodeSensors which no longer has a node attached.
+  cleanupObsoleteNodeSensors();
+
+  // spidermonkey ignores the return value
+  if (argc >= 1 && JSVAL_IS_STRING(argv[0])) {
+    JSString * js = JSVAL_TO_STRING(argv[0]);
+    char * str = spidermonkey()->JS_GetStringBytes(js);
+    size_t len = spidermonkey()->JS_GetStringLength(js);
+
+    // FIXME: what about UTF8? 20050701 erikgors.
+
+    if (SoJavaScriptEngine::debug()) {
+      SoDebugError::postInfo("SFNodeConstructor",
+                             "creating new node with str = '%s'", str);
+    }
+
+    SoInput input;
+    const char * array[2];
+    array[0] = str;
+    array[1] = NULL;
+    input.setStringArray(array);
+
+    SoGroup * group;
+    
+    if (input.isFileVRML2())
+      group = SoDB::readAllVRML(&input);
+    else
+      group = SoDB::readAll(&input);
+
+    if (group == NULL) {
+      spidermonkey()->JS_ReportError(cx, "input is not legal VRML string");
+      return JS_FALSE;
+    }
+    if (group->getNumChildren() == 0) {
+      spidermonkey()->JS_ReportError(cx, "no top-level node, result is undefined");
+      *rval = JSVAL_VOID;
+      return JS_FALSE;
+    }
+
+    if(garbagecollectedobjects->find(obj) != -1) { // Pointer has been used before. Remove from list.
+      garbagecollectedobjects->removeItem(obj);
+    }
+
+    attachSensorToNode(group, obj);
+
+    if (SoJavaScriptEngine::getEngine(cx)->getAutoNodeUnrefState())
+      group->ref();
+
+    spidermonkey()->JS_SetPrivate(cx, obj, group);
+    spidermonkey()->JS_DefineFunctions(cx, obj, SFNodeFunctions);
+
+    return JS_TRUE;
+  }
+  return JS_FALSE;
+}
+
+static JSObject * SFNode_init(JSContext * cx, JSObject * obj)
+{
+  return spidermonkey()->JS_InitClass(cx, obj, NULL, &CoinVrmlJs::SFNode.cls,
+                                      SFNodeConstructor, 0,
+                                      NULL, NULL, NULL, NULL);
+}
+
+
+// *************************************************************************
+// jsval2field
+
+static SbBool SFBool_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_BOOLEAN(v)) {
+    const SbBool b = JSVAL_TO_BOOLEAN(v);
+    ((SoSFBool *)f)->setValue(b);
+    return TRUE;
+  }
+  else {
+    JSBool b;
+    if (spidermonkey()->JS_ValueToBoolean(cx, v, &b)) {
+      ((SoSFBool *)f)->setValue(b);
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+static SbBool SFColor_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_SFCOLOR(cx, v)) {
+    SbColor * color = (SbColor *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    assert(color != NULL);
+    ((SoSFColor *)f)->setValue(*color);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFFloat_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  double number;
+  if (jsval2double(cx, v, number)) {
+    ((SoSFFloat *)f)->setValue((float)number);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFInt32_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  int32_t val;
+  if (jsval2int(cx, v, val)) {
+    ((SoSFInt32 *)f)->setValue(val);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFEnum_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  int32_t val;
+  if (jsval2int(cx, v, val)) {
+    ((SoSFInt32 *)f)->setValue(val);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFNode_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_NULL(v)) {
+    ((SoSFNode *)f)->setValue(NULL);
+    return TRUE;
+  }
+  if (JSVAL_IS_OBJECT(v) &&
+      spidermonkey()->JS_InstanceOf(cx, JSVAL_TO_OBJECT(v), &CoinVrmlJs::SFNode.cls, NULL)) {
+    SoNode * node = (SoNode *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    ((SoSFNode *)f)->setValue(node);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFRotation_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_SFROTATION(cx, v)) {
+    SbVec4f * rot = (SbVec4f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    assert(rot != NULL);
+    SbVec3f axis((*rot)[0], (*rot)[1], (*rot)[2]);
+    ((SoSFRotation *)f)->setValue(SbRotation(axis, (*rot)[3]));
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFString_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_STRING(v)) {
+    const char * str = spidermonkey()->JS_GetStringBytes(JSVAL_TO_STRING(v));
+    ((SoSFString *)f)->setValue(str);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFTime_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  double number;
+  if (jsval2double(cx, v, number)) {
+    spidermonkey()->JS_ValueToNumber(cx, v, &number);
+    ((SoSFTime*)f)->setValue(SbTime(number));
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFVec2f_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_SFVEC2F(cx, v)) {
+    SbVec2f * vec = (SbVec2f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    assert(vec != NULL);
+    ((SoSFVec2f *)f)->setValue(*vec);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFVec3f_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_SFVEC3F(cx, v)) {
+    SbVec3f * vec = (SbVec3f *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    assert(vec != NULL);
+    ((SoSFVec3f *)f)->setValue(*vec);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static SbBool SFVec3d_jsval2field(JSContext * cx, const jsval v, SoField * f)
+{
+  if (JSVAL_IS_SFVEC3D(cx, v)) {
+    SbVec3d * vec = (SbVec3d *)spidermonkey()->JS_GetPrivate(cx, JSVAL_TO_OBJECT(v));
+    assert(vec != NULL);
+    ((SoSFVec3d *)f)->setValue(*vec);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+// *************************************************************************
+// field2jsval
+
+static void SFBool_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const SbBool val = ((SoSFBool *)f)->getValue();
+  *v = BOOLEAN_TO_JSVAL(val);
+}
+
+static void SFColor_field2jsval(JSContext * cx, const SoField * f, jsval *v)
+{
+  const SbColor & val = ((SoSFColor *)f)->getValue();
+  JSObject * obj = SFColorFactory(cx, val);
+  *v = OBJECT_TO_JSVAL(obj);
+}
+
+static void SFFloat_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const float val = ((SoSFFloat *)f)->getValue();
+  JSBool ok = spidermonkey()->JS_NewDoubleValue(cx, val, v);
+}
+
+static void SFInt32_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const int32_t val = ((SoSFInt32 *)f)->getValue();
+  *v = INT_TO_JSVAL(val);
+}
+
+static void SFEnum_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const int32_t val = ((SoSFInt32 *)f)->getValue();
+  *v = INT_TO_JSVAL(val);
+}
+
+static void SFNode_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  SoNode * node = ((SoSFNode *)f)->getValue();
+  if (node == NULL)
+    *v = JSVAL_NULL;
+  else {
+    JSObject * obj = SFNodeFactory(cx, node);
+    *v = OBJECT_TO_JSVAL(obj);
+  }
+}
+
+static void SFRotation_field2jsval(JSContext * cx, const SoField * f, jsval *v)
+{
+  const SbRotation & val = ((SoSFRotation *)f)->getValue();
+  JSObject * obj = SFRotationFactory(cx, val);
+  *v = OBJECT_TO_JSVAL(obj);
+}
+
+static void SFString_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const SbString & val = ((SoSFString *)f)->getValue();
+  JSString * str = spidermonkey()->JS_NewStringCopyZ(cx, val.getString());
+  *v = STRING_TO_JSVAL(str);
+}
+
+static void SFTime_field2jsval(JSContext * cx, const SoField * f, jsval * v)
+{
+  const SbTime & time = ((SoSFTime *)f)->getValue();
+  spidermonkey()->JS_NewDoubleValue(cx, time.getValue(), v);
+}
+
+static void SFVec2f_field2jsval(JSContext * cx, const SoField * f, jsval *v)
+{
+  const SbVec2f & val = ((SoSFVec2f *)f)->getValue();
+  JSObject * obj = SFVec2fFactory(cx, val);
+  *v = OBJECT_TO_JSVAL(obj);
+}
+
+static void SFVec3f_field2jsval(JSContext * cx, const SoField * f, jsval *v)
+{
+  const SbVec3f & val = ((SoSFVec3f *)f)->getValue();
+  JSObject * obj = SFVec3fFactory(cx, val);
+  *v = OBJECT_TO_JSVAL(obj);
+}
+
+static void SFVec3d_field2jsval(JSContext * cx, const SoField * f, jsval *v)
+{
+  const SbVec3d & val = ((SoSFVec3d *)f)->getValue();
+  JSObject * obj = SFVec3dFactory(cx, val);
+  *v = OBJECT_TO_JSVAL(obj);
+}
+
+// *************************************************************************
+// classes
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFColor = {
+  {
+    "SFColor", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFColorHandler::get, SFColorHandler::set,
+    NULL, NULL, NULL,
+    SFColorHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  SFColorFunctions
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFNode = {
+  {
+    "SFNode", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFNode_get, SFNode_set,
+    NULL, NULL, NULL,
+    SFNodeDestructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  NULL
+};
+
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFRotation = {
+  {
+    "SFRotation", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFRotationHandler::get, SFRotationHandler::set,
+    NULL, NULL, NULL,
+    SFRotationHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  SFRotationFunctions
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFVec2f = {
+  {
+    "SFVec2f", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFVec2fHandler::get, SFVec2fHandler::set,
+    NULL, NULL, NULL,
+    SFVec2fHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  SFVec2fFunctions
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFVec3f = {
+  {
+    "SFVec3f", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFVec3fHandler::get, SFVec3fHandler::set,
+    NULL, NULL, NULL,
+    SFVec3fHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  SFVec3fFunctions
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::SFVec3d = {
+  {
+    "SFVec3d", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    SFVec3dHandler::get, SFVec3dHandler::set,
+    NULL, NULL, NULL,
+    SFVec3dHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  SFVec3dFunctions
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFColor = {
+  {
+    "MFColor", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFColorHandler::get, MFColorHandler::set,
+    NULL, NULL, NULL,
+    MFColorHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFFloat = {
+  {
+    "MFFloat", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFFloatHandler::get, MFFloatHandler::set,
+    NULL, NULL, NULL,
+    MFFloatHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFInt32 = {
+  {
+    "MFInt32", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFInt32Handler::get, MFInt32Handler::set,
+    NULL, NULL, NULL,
+    MFInt32Handler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFNode = {
+  {
+    "MFNode", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFNodeHandler::get, MFNodeHandler::set,
+    NULL, NULL, NULL,
+    MFNodeHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFRotation = {
+  {
+    "MFRotation", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFRotationHandler::get, MFRotationHandler::set,
+    NULL, NULL, NULL,
+    MFRotationHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFString = {
+  {
+    "MFString", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFStringHandler::get, MFStringHandler::set,
+    NULL, NULL, NULL,
+    MFStringHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFTime = {
+  {
+    "MFTime", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFTimeHandler::get, MFTimeHandler::set,
+    NULL, NULL, NULL,
+    MFTimeHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFVec2f = {
+  {
+    "MFVec2f", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFVec2fHandler::get, MFVec2fHandler::set,
+    NULL, NULL, NULL,
+    MFVec2fHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFVec3f = {
+  {
+    "MFVec3f", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFVec3fHandler::get, MFVec3fHandler::set,
+    NULL, NULL, NULL,
+    MFVec3fHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+CoinVrmlJs::ClassDescriptor CoinVrmlJs::MFVec3d = {
+  {
+    "MFVec3d", JSCLASS_HAS_PRIVATE, NULL, NULL,
+    MFVec3dHandler::get, MFVec3dHandler::set,
+    NULL, NULL, NULL,
+    MFVec3dHandler::destructor,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+  },
+  MFFunctions,
+};
+
+
+CoinVrmlJs::ClassDescriptor * CLASSDESCRIPTORS[] = {
+  &CoinVrmlJs::SFColor, &CoinVrmlJs::SFNode, &CoinVrmlJs::SFRotation,
+  &CoinVrmlJs::SFVec2f, &CoinVrmlJs::SFVec3f, &CoinVrmlJs::SFVec3d, 
+  &CoinVrmlJs::MFColor, 
+  &CoinVrmlJs::MFFloat, &CoinVrmlJs::MFInt32, &CoinVrmlJs::MFNode,
+  &CoinVrmlJs::MFRotation, &CoinVrmlJs::MFString, &CoinVrmlJs::MFTime,
+  &CoinVrmlJs::MFVec2f, &CoinVrmlJs::MFVec3f, &CoinVrmlJs::MFVec3d
+};
+
+// *************************************************************************
+
+// cleans up static / one-off resource allocations
+static void
+js_vrmlclasses_cleanup(void)
+{
+  delete garbagecollectedobjects;
+  delete nodesensorstobedeleted;
+
+  garbagecollectedobjects = NULL;
+  nodesensorstobedeleted = NULL;
+}
+
+// *************************************************************************
+// helper function to add all classes to engine
+
+void
+JS_addVRMLclasses(SoJavaScriptEngine * engine)
+{
+  // init static data
+  if (garbagecollectedobjects == NULL) {
+    garbagecollectedobjects = new SbList <JSObject *>;
+    nodesensorstobedeleted = new SbList <SoNodeSensor *>;
+    coin_atexit((coin_atexit_f *)js_vrmlclasses_cleanup, CC_ATEXIT_NORMAL);
+
+    // set up default function stubs for Spidermonkey classes we
+    // make. must be done at run-time to avoid calling spidermonkey()
+    // early (i.e. not on demand).
+    const size_t NRELEMENTS = sizeof(CLASSDESCRIPTORS) / sizeof(CLASSDESCRIPTORS[0]);
+    for (size_t i=0; i < NRELEMENTS; i++) {
+      CoinVrmlJs::ClassDescriptor * desc = CLASSDESCRIPTORS[i];
+      desc->cls.addProperty = spidermonkey()->JS_PropertyStub;
+      desc->cls.delProperty = spidermonkey()->JS_PropertyStub;
+      desc->cls.enumerate = spidermonkey()->JS_EnumerateStub;
+      desc->cls.resolve = spidermonkey()->JS_ResolveStub;
+      desc->cls.convert = spidermonkey()->JS_ConvertStub;
+    }
+  }
+
+  // Bool
+  engine->addHandler(
+    SoSFBool::getClassTypeId(), NULL,
+    SFBool_field2jsval, SFBool_jsval2field);
+
+  // Color
+  engine->addHandler(
+    SoSFColor::getClassTypeId(), SFColor_init,
+    SFColor_field2jsval, SFColor_jsval2field);
+  engine->addHandler(
+    SoMFColor::getClassTypeId(),
+    MFColorHandler::init,
+    MFColorHandler::field2jsval,
+    MFColorHandler::jsval2field);
+
+  // Float
+  engine->addHandler(
+    SoSFFloat::getClassTypeId(), NULL,
+    SFFloat_field2jsval, SFFloat_jsval2field);
+  engine->addHandler(
+    SoMFFloat::getClassTypeId(),
+    MFFloatHandler::init,
+    MFFloatHandler::field2jsval,
+    MFFloatHandler::jsval2field);
+
+  // Int32
+  engine->addHandler(
+    SoSFInt32::getClassTypeId(), NULL,
+    SFInt32_field2jsval, SFInt32_jsval2field);
+  engine->addHandler(
+    SoMFInt32::getClassTypeId(),
+    MFInt32Handler::init,
+    MFInt32Handler::field2jsval,
+    MFInt32Handler::jsval2field);
+
+  // Enum 
+  engine->addHandler(
+    SoSFEnum::getClassTypeId(), NULL,
+    SFEnum_field2jsval, SFEnum_jsval2field);
+
+  // Node
+  engine->addHandler(
+    SoSFNode::getClassTypeId(), SFNode_init,
+    SFNode_field2jsval, SFNode_jsval2field);
+  engine->addHandler(
+    SoMFNode::getClassTypeId(),
+    MFNodeHandler::init,
+    MFNodeHandler::field2jsval,
+    MFNodeHandler::jsval2field);
+
+  // Rotation
+  engine->addHandler(
+    SoSFRotation::getClassTypeId(), SFRotation_init,
+    SFRotation_field2jsval, SFRotation_jsval2field);
+  engine->addHandler(
+    SoMFRotation::getClassTypeId(),
+    MFRotationHandler::init,
+    MFRotationHandler::field2jsval,
+    MFRotationHandler::jsval2field);
+
+  // String
+  engine->addHandler(
+    SoSFString::getClassTypeId(), NULL,
+    SFString_field2jsval, SFString_jsval2field);
+  engine->addHandler(
+    SoMFString::getClassTypeId(),
+    MFStringHandler::init,
+    MFStringHandler::field2jsval,
+    MFStringHandler::jsval2field);
+
+  // Time
+  engine->addHandler(
+    SoSFTime::getClassTypeId(), NULL,
+    SFTime_field2jsval, SFTime_jsval2field);
+  engine->addHandler(
+    SoMFTime::getClassTypeId(),
+    MFTimeHandler::init,
+    MFTimeHandler::field2jsval,
+    MFTimeHandler::jsval2field);
+
+  // Vec2f
+  engine->addHandler(
+    SoSFVec2f::getClassTypeId(), SFVec2f_init,
+    SFVec2f_field2jsval, SFVec2f_jsval2field);
+  engine->addHandler(
+    SoMFVec2f::getClassTypeId(),
+    MFVec2fHandler::init,
+    MFVec2fHandler::field2jsval,
+    MFVec2fHandler::jsval2field);
+
+  // Vec3f
+  engine->addHandler(
+    SoSFVec3f::getClassTypeId(), SFVec3f_init,
+    SFVec3f_field2jsval, SFVec3f_jsval2field);
+  engine->addHandler(
+    SoMFVec3f::getClassTypeId(),
+    MFVec3fHandler::init,
+    MFVec3fHandler::field2jsval,
+    MFVec3fHandler::jsval2field);
+
+  // Vec3d
+  engine->addHandler(
+    SoSFVec3d::getClassTypeId(), SFVec3d_init,
+    SFVec3d_field2jsval, SFVec3d_jsval2field);
+  engine->addHandler(
+    SoMFVec3d::getClassTypeId(),
+    MFVec3dHandler::init,
+    MFVec3dHandler::field2jsval,
+    MFVec3dHandler::jsval2field);
+}
+
+#endif // HAVE_VRML97

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tony Theodore <tonyt@logyst.com>
Date: Sat, 18 Nov 2017 20:45:31 +1100
Subject: [PATCH 2/2] gcc 4.7 fixes

This patch was taken from Gentoo:
https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/coin/files/coin-3.1.3-gcc-4.7.patch?id=17d7c853393ff83e3422e48e9ad2810f23889bbf

diff --git a/include/Inventor/SbBasic.h b/include/Inventor/SbBasic.h
index 1111111..2222222 100644
--- a/include/Inventor/SbBasic.h
+++ b/include/Inventor/SbBasic.h
@@ -24,6 +24,7 @@
  *
 \**************************************************************************/
 
+#include <Inventor/C/errors/debugerror.h>
 #include <Inventor/C/basic.h>
 
 /* ********************************************************************** */