aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLPbufferImpl.java')
0 files changed, 0 insertions, 0 deletions
id='n84' href='#n84'>84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358
/*
 * Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * - Redistribution of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Redistribution in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * Neither the name of Sun Microsystems, Inc. or the names of
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * You acknowledge that this software is not designed or intended for use
 * in the design, construction, operation or maintenance of any nuclear
 * facility.
 *
 * Sun gratefully acknowledges that this software was originally authored
 * and developed by Kenneth Bradley Russell and Christopher John Kline.
 */

package com.jogamp.gluegen;

import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
import com.jogamp.gluegen.JavaEmitter.EmissionStyle;
import com.jogamp.gluegen.JavaEmitter.MethodAccess;
import com.jogamp.gluegen.Logging.LoggerIf;

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.regex.*;

import com.jogamp.gluegen.jgram.*;
import com.jogamp.gluegen.cgram.types.*;

import static java.util.logging.Level.*;
import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*;
import static com.jogamp.gluegen.JavaEmitter.EmissionStyle.*;

/** Parses and provides access to the contents of .cfg files for the
    JavaEmitter. */

public class JavaConfiguration {
    private int nestedReads;
    private String libraryOnLoadName;
    private String packageName;
    private String implPackageName;
    private String className;
    private String implClassName;

    protected final LoggerIf LOG;

    public static String NEWLINE = System.getProperty("line.separator");

    /**
     * Root directory for the hierarchy of generated java classes. Default is
     * working directory.
     */
    private String javaOutputDir = ".";

    /**
     * Top output root directory for all generated files. Default is null, ie not to use it.
     */
    private String outputRootDir = null;

    /**
     * Directory into which generated native JNI code will be written. Default
     * is current working directory.
     */
    private String nativeOutputDir = ".";

    /**
     * If true, then each native *.c and *.h file will be generated in the
     * directory nativeOutputDir/packageAsPath(packageName). Default is false.
     */
    private boolean nativeOutputUsesJavaHierarchy;

    /**
     * If true, then the comment of a native method binding will include a @native tag
     * to allow taglets to augment the javadoc with additional information regarding
     * the mapped C function. Defaults to false.
     */
    private boolean tagNativeBinding;

    /**
     * If true, {@link TypeConfig.SemanticEqualityOp#equalSemantics(TypeConfig.SemanticEqualityOp)}
     * will attempt to perform a relaxed semantic equality test, e.g. skip the {@code const} and {@code volatile} qualifiers.
     * Otherwise a full semantic equality test will be performed.
     */
    private boolean relaxedEqualSemanticsTest;

    /**
     * Style of code emission. Can emit everything into one class
     * (AllStatic), separate interface and implementing classes
     * (InterfaceAndImpl), only the interface (InterfaceOnly), or only
     * the implementation (ImplOnly).
     */
    private EmissionStyle emissionStyle = AllStatic;

    /**
     * List of imports to emit at the head of the output files.
     */
    private final List<String> imports = new ArrayList<String>();

    /**
     * The package in which the generated glue code expects to find its
     * run-time helper classes (Buffers, Platform,
     * StructAccessor). Defaults to "com.jogamp.gluegen.runtime".
     */
    private String gluegenRuntimePackage = "com.jogamp.gluegen.runtime";

    /**
     * The kind of exception raised by the generated code if run-time
     * checks fail. Defaults to RuntimeException.
     */
    private String runtimeExceptionType = "RuntimeException";
    private String unsupportedExceptionType = "UnsupportedOperationException";

    private final Map<String, MethodAccess> accessControl = new HashMap<String, MethodAccess>();
    private final Map<String, TypeInfo> typeInfoMap = new HashMap<String, TypeInfo>();
    private final Set<String> returnsString = new HashSet<String>();
    private final Set<String> returnsStringOnly = new HashSet<String>();
    private final Map<String, JavaType> returnsOpaqueJType = new HashMap<String, JavaType>();
    private final Map<String, String> returnedArrayLengths = new HashMap<String, String>();
    private final Set<String> maxOneElement = new HashSet<String>();

    /**
     * Key is function that has some byte[] or short[] arguments that should be
     * converted to String args; value is List of Integer argument indices
     */
    private final Map<String, List<Integer>> argumentsAreString = new HashMap<String, List<Integer>>();

    /** JavaCallback configuration definition (static) */
    public static class JavaCallbackDef {
      final String cbFuncTypeName;
      final int cbFuncUserParamIdx;
      final String setFuncName;
      final List<Integer> setFuncKeyIndices = new ArrayList<Integer>();
      final String setFuncKeyClassName; // optional
      JavaCallbackDef(final String cbFuncTypeName, final int cbFuncUserParamIdx, final String setFuncName, final String setFuncKeyClassName) {
          this.cbFuncTypeName = cbFuncTypeName;
          this.cbFuncUserParamIdx = cbFuncUserParamIdx;
          this.setFuncName = setFuncName;
          this.setFuncKeyClassName = setFuncKeyClassName;
      }
      @Override
      public String toString() {
          return String.format("JavaCallbackDef[cbFunc[type %s, userParamIdx %d], set[%s, keys %s, KeyClass %s]]",
                  cbFuncTypeName, cbFuncUserParamIdx, setFuncName, setFuncKeyIndices.toString(), setFuncKeyClassName);
      }
    }
    private final List<JavaCallbackDef> javaCallbackList = new ArrayList<JavaCallbackDef>();
    private final Map<String, JavaCallbackDef> javaCallbackSetFuncToDef = new HashMap<String, JavaCallbackDef>();

    private final Set<String> extendedIntfSymbolsIgnore = new HashSet<String>();
    private final Set<String> extendedIntfSymbolsOnly = new HashSet<String>();
    private final Set<String> extendedImplSymbolsIgnore = new HashSet<String>();
    private final Set<String> extendedImplSymbolsOnly = new HashSet<String>();
    private final Set<Pattern> ignores = new HashSet<Pattern>();
    private final Map<String, Pattern> ignoreMap = new HashMap<String, Pattern>();
    private final Set<Pattern> ignoreNots = new HashSet<Pattern>();
    private final Set<Pattern> unignores = new HashSet<Pattern>();
    private final Set<Pattern> unimplemented = new HashSet<Pattern>();
    private boolean forceUseNIOOnly4All = false;
    private final Set<String> useNIOOnly = new HashSet<String>();
    private boolean forceUseNIODirectOnly4All = false;
    private final Set<String> useNIODirectOnly = new HashSet<String>();
    private final Set<String> immutableAccessSymbols = new HashSet<String>();
    private final Set<String> manuallyImplement = new HashSet<String>();
    private final Map<String, String> delegatedImplementation = new HashMap<String, String>();
    private final Map<String, List<String>> customJavaCode = new HashMap<String, List<String>>();
    private final Map<String, List<String>> customJNICode = new HashMap<String, List<String>>();
    private final Map<String, List<String>> classJavadoc = new HashMap<String, List<String>>();
    private final Map<String, List<String>> methodJavadoc = new HashMap<String, List<String>>();
    private final Map<String, String> structPackages = new HashMap<String, String>();
    private final List<String> customCCode = new ArrayList<String>();
    private final List<String> forcedStructs = new ArrayList<String>();
    private final Map<String, String> structMachineDataInfoIndex = new HashMap<String, String>();
    private final Map<String, String> returnValueCapacities = new HashMap<String, String>();
    private final Map<String, String> returnValueLengths = new HashMap<String, String>();
    private final Map<String, List<String>> temporaryCVariableDeclarations = new HashMap<String, List<String>>();
    private final Map<String, List<String>> temporaryCVariableAssignments = new HashMap<String, List<String>>();
    private final Map<String, List<String>> extendedInterfaces = new HashMap<String, List<String>>();
    private final Map<String, List<String>> implementedInterfaces = new HashMap<String, List<String>>();
    private final Map<String, String> parentClass = new HashMap<String, String>();
    private final Map<String, String> javaTypeRenames = new HashMap<String, String>();
    private final Map<String, String> javaSymbolRenames = new HashMap<String, String>();
    private final Map<String, Set<String>> javaRenamedSymbols = new HashMap<String, Set<String>>();
    private final Map<String, List<String>> javaPrologues = new HashMap<String, List<String>>();
    private final Map<String, List<String>> javaEpilogues = new HashMap<String, List<String>>();

    public JavaConfiguration() {
        LOG = Logging.getLogger(JavaConfiguration.class.getPackage().getName(), JavaConfiguration.class.getSimpleName());
    }

  /** Reads the configuration file.
      @param filename path to file that should be read
  */
  public final void read(final String filename) throws  IOException {
    read(filename, null);
  }

  /** Reads the specified file, treating each line as if it started with the
      specified string.
      @param filename path to file that should be read
      @param linePrefix if not null, treat each line read as if it were
      prefixed with the specified string.
  */
  protected final void read(final String filename, final String linePrefix) throws IOException {
    final File file = new File(filename);
    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new FileReader(file));
    }
    catch (final FileNotFoundException fnfe) {
      throw new RuntimeException("Could not read file \"" + file + "\"", fnfe);
    }
    int lineNo = 0;
    String line = null;
    final boolean hasPrefix = linePrefix != null && linePrefix.length() > 0;
    try {
      ++nestedReads;
      while ((line = reader.readLine()) != null) {
        ++lineNo;
        if (hasPrefix)  {
          line = linePrefix + " " + line;
        }

        if (line.trim().startsWith("#")) {
          // comment line
          continue;
        }

        final StringTokenizer tok = new StringTokenizer(line);
        if (tok.hasMoreTokens()) {
          // always reset delimiters in case of CustomJavaCode, etc.
          final String cmd = tok.nextToken(" \t\n\r\f");

          dispatch(cmd, tok, file, filename, lineNo);
        }
      }
      reader.close();
    } finally {
      --nestedReads;
    }

    if (nestedReads == 0) {
      if (allStatic() && implClassName != null) {
        throw new IllegalStateException("Error in configuration file \"" + filename + "\": Cannot use " +
                                        "directive \"ImplJavaClass\" in conjunction with " +
                                        "\"Style AllStatic\"");
      }

      if (className == null && (emissionStyle() != ImplOnly)) {
//        throw new RuntimeException("Output class name was not specified in configuration file \"" + filename + "\"");
      }
      if (packageName == null && (emissionStyle() != ImplOnly)) {
        throw new RuntimeException("Output package name was not specified in configuration file \"" + filename + "\"");
      }

      if (allStatic()) {
        implClassName = className;
        // If we're using the "Style AllStatic" directive, then the
        // implPackageName is the same as the regular package name
        implPackageName = packageName;
      } else {
        if (implClassName == null) {
          // implClassName defaults to "<className>Impl" if ImplJavaClass
          // directive is not used
          if (className == null) {
            throw new RuntimeException("If ImplJavaClass is not specified, must specify JavaClass");
          }
          implClassName = className + "Impl";
        }
        if (implPackageName == null) {
          // implPackageName defaults to "<packageName>.impl" if ImplPackage
          // directive is not used
          if (packageName == null) {
            throw new RuntimeException("If ImplPackageName is not specified, must specify PackageName");
          }
          implPackageName = packageName + ".impl";
        }
      }
    }
  }

  public void setOutputRootDir(final String s) { outputRootDir=s; }

    /** Returns the library basename used to {@link CCodeUnit#emitJNIOnLoadJNIEnvCode(String)}. */
    public String libraryOnLoadName() {
        return libraryOnLoadName;
    }

    /** Returns the package name parsed from the configuration file. */
    public String packageName() {
        return packageName;
    }

    /** Returns the implementation package name parsed from the configuration file. */
    public String implPackageName() {
        return implPackageName;
    }

    /** Returns the class name parsed from the configuration file. */
    public String className() {
        return className;
    }

    /** Returns the implementation class name parsed from the configuration file. */
    public String implClassName() {
        return implClassName;
    }

    public boolean structsOnly() {
        return className == null && implClassName == null;
    }

    /** Returns the Java code output directory parsed from the configuration file. */
    public String javaOutputDir() {
        return (null != outputRootDir) ? (outputRootDir + "/" + javaOutputDir) : javaOutputDir;
    }

    /** Returns the native code output directory parsed from the configuration file. */
    public String nativeOutputDir() {
        return (null != outputRootDir) ? (outputRootDir + "/" + nativeOutputDir) : nativeOutputDir;
    }

    /** Returns whether the native code directory structure mirrors the Java hierarchy. */
    public boolean nativeOutputUsesJavaHierarchy() {
        return nativeOutputUsesJavaHierarchy;
    }

    /** Returns whether the comment of a native method binding should include a @native tag. */
    public boolean tagNativeBinding() {
        return tagNativeBinding;
    }

    /**
     * Returns whether {@link TypeConfig.SemanticEqualityOp#equalSemantics(TypeConfig.SemanticEqualityOp)}
     * shall attempt to perform a relaxed semantic equality test, e.g. skip the {@code const} and {@code volatile} qualifier
     * - or not.
     */
    public boolean relaxedEqualSemanticsTest() {
        return relaxedEqualSemanticsTest;
    }

    /** Returns the code emission style (constants in JavaEmitter) parsed from the configuration file. */
    public EmissionStyle emissionStyle() {
        return emissionStyle;
    }

    /**
     * Returns the access control for the given method-name
     * or fully qualified class-name.
     */
    public MethodAccess accessControl(final String name) {
        final MethodAccess ret = accessControl.get(name);
        if (ret != null) {
            return ret;
        }
        // Default access control is public
        return PUBLIC;
    }

    /** Returns the package in which the generated glue code expects to
    find its run-time helper classes (Buffers, Platform,
    StructAccessor). Defaults to "com.jogamp.gluegen.runtime". */
    public String gluegenRuntimePackage() {
        return gluegenRuntimePackage;
    }

    /** Returns the kind of exception to raise if run-time checks fail in the generated code. */
    public String runtimeExceptionType() {
        return runtimeExceptionType;
    }

    /** Returns the kind of exception to raise if run-time checks fail in the generated code. */
    public String unsupportedExceptionType() {
        return unsupportedExceptionType;
    }

    /** Returns the list of imports that should be emitted at the top of each .java file. */
    public List<String> imports() {
        return imports;
    }

  private static final boolean DEBUG_TYPE_INFO = false;

  /**
   * If the given {@code canonicalName} should be considered opaque,
   * returns the TypeInfo describing the replacement type.
   * <p>
   * Returns null if this type should not be considered opaque.
   * </p>
   * <p>
   * If symbol references a struct fields, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   */
  public TypeInfo canonicalNameOpaque(final String canonicalName) {
    return typeInfoMap.get(canonicalName);
  }

  /** If this type should be considered opaque, returns the TypeInfo
      describing the replacement type. Returns null if this type
      should not be considered opaque. */
  public TypeInfo typeInfo(Type type) {
    // Because typedefs of pointer types can show up at any point,
    // walk the pointer chain looking for a typedef name that is in
    // the TypeInfo map.
    if (DEBUG_TYPE_INFO)
      System.err.println("Incoming type = " + type + ", " + type.getDebugString());
    final int pointerDepth = type.pointerDepth();
    for (int i = 0; i <= pointerDepth; i++) {
      String name = type.getName();
      if (DEBUG_TYPE_INFO) {
        System.err.printf(" [%2d] Name = %s%n", i, name);
        System.err.printf(" [%2d] Type = %s, pointerDepth %d, %s%n", i, type, type.pointerDepth(), type.getDebugString());
      }
      if (name != null) {
        final TypeInfo info = closestTypeInfo(name, i + type.pointerDepth());
        if (info != null) {
          final TypeInfo res = promoteTypeInfo(info, i);
          if (DEBUG_TYPE_INFO) {
            System.err.printf(" [A][%2d] name %s%n", i, name);
            System.err.printf(" [A][%2d] info %s%n", i, info.toString());
            System.err.printf(" [A][%2d] res  %s%n", i, res.toString());
          }
          return res;
        }
      }

      if (type.isCompound()) {
        // Try struct name as well
        name = type.asCompound().getStructName();
        if (name != null) {
          final TypeInfo info = closestTypeInfo(name, i + type.pointerDepth());
          if (info != null) {
            final TypeInfo res = promoteTypeInfo(info, i);
            if (DEBUG_TYPE_INFO) {
              System.err.printf(" [A][%2d] name %s%n", i, name);
              System.err.printf(" [A][%2d] info %s%n", i, info.toString());
              System.err.printf(" [A][%2d] res  %s%n", i, res.toString());
            }
            return res;
          }
        }
      }

      if (type.isPointer()) {
        type = type.asPointer().getTargetType();
      }
    }
    if (DEBUG_TYPE_INFO) {
      System.err.println(" [X] NULL");
    }
    return null;
  }

  // Helper functions for above
  private TypeInfo closestTypeInfo(final String name, final int pointerDepth) {
    TypeInfo info = typeInfoMap.get(name);
    TypeInfo closest = null;
    while (info != null) {
      if (DEBUG_TYPE_INFO) {
        System.err.println("  Checking TypeInfo for " + name + " at pointerDepth " + pointerDepth);
      }
      if (info.pointerDepth() <= pointerDepth && (closest == null || info.pointerDepth() > closest.pointerDepth())) {
        if (DEBUG_TYPE_INFO) {
          System.err.println("   Accepted");
        }
        closest = info;
      }
      info = info.next();
    }
    return closest;
  }

  // Promotes a TypeInfo to a higher pointer type (if necessary)
  private TypeInfo promoteTypeInfo(final TypeInfo info, final int numPointersStripped) {
    final int pd = info.pointerDepth();
    int diff = numPointersStripped - pd;
    if (diff == 0) {
      return info;
    }

    if (diff < 0) {
      throw new RuntimeException("TypeInfo for " + info.name() + " and pointerDepth " +
                                 info.pointerDepth() + " should not have matched for depth " +
                                 numPointersStripped);
    }

    Class<?> c = info.javaType().getJavaClass();

    // Handle single-pointer stripping for types compatible with C
    // integral and floating-point types specially so we end up
    // generating NIO variants for these
    if (diff == 1) {
      JavaType jt = null;
      if      (c == Boolean.TYPE) jt = JavaType.createForCCharPointer();
      else if (c == Byte.TYPE)    jt = JavaType.createForCCharPointer();
      else if (c == Short.TYPE)   jt = JavaType.createForCShortPointer();
      else if (c == Integer.TYPE) jt = JavaType.createForCInt32Pointer();
      else if (c == Long.TYPE)    jt = JavaType.createForCInt64Pointer();
      else if (c == Float.TYPE)   jt = JavaType.createForCFloatPointer();
      else if (c == Double.TYPE)  jt = JavaType.createForCDoublePointer();

      if (jt != null)
        return new TypeInfo(info.name(), numPointersStripped, jt);
    }

    while (diff > 0) {
      c = Array.newInstance(c, 0).getClass();
      --diff;
    }

    return new TypeInfo(info.name(),
                        numPointersStripped,
                        JavaType.createForClass(c));
  }

  /** Indicates whether the given function (which returns a
      <code>char*</code> in C) should be translated as returning a
      <code>java.lang.String</code>. */
  public boolean returnsString(final String functionName) {
    return returnsString.contains(functionName);
  }
  /** Indicates whether the given function (which returns a
      <code>char*</code> in C) should be translated as returning a
      <code>java.lang.String</code>. */
  public boolean returnsString(final AliasedSymbol symbol) {
      return returnsString.contains( symbol.getName() ) ||
             oneInSet(returnsString, symbol.getAliasedNames());
  }

  /** Indicates whether the given function (which returns a
      <code>char*</code> in C) should be translated as returning a
      <code>java.lang.String</code> only. Excluding other variants for struct field access. */
  public boolean returnsStringOnly(final String functionName) {
    return returnsStringOnly.contains(functionName);
  }

  /** Returns the list of all configured JavaCallback definitions. */
  public List<JavaCallbackDef> getJavaCallbackList() {
    return javaCallbackList;
  }

  /** Returns the configured JavaCallback definition mapped to the JavaCallback-Set-Function name. */
  public JavaCallbackDef javaCallbackSetFuncToDef(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      JavaCallbackDef res = javaCallbackSetFuncToDef.get(name);
      if( null == res ) {
          res = oneInMap(javaCallbackSetFuncToDef, aliases);
      }
      return res;
  }

  /**
   * Returns a MessageFormat string of the Java expression calculating
   * the number of elements in the returned array from the specified function
   * name or struct-field array-size. The literal <code>1</code> indicates a constant single object.
   * <p>
   * If symbol references a struct fields, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   * <p>
   * In case of struct fields, this array length will also be used
   * for the native C function, i.e. multiplied w/ <code>sizeof(C-Type)</code>
   * and passed down to native code, <b>if</b> not overriden by
   * either {@link #returnValueCapacity(String)} or {@link #returnValueLength(String)}!
   * </p>
   */
  public String returnedArrayLength(final String symbol) {
    return returnedArrayLengths.get(symbol);
  }

  /**
   * Indicates whether the given symbol covers no or one single object.
   * This is useful for struct-field pointer, indicating a null value
   * holding no object or at most referincing memory for one single object.
   */
  public boolean maxOneElement(final String symbol) {
    return maxOneElement.contains(symbol);
  }

  /** Returns a list of <code>Integer</code>s which are the indices of <code>const char*</code>
      arguments that should be converted to <code>String</code>s. Returns null if there are no
      such hints for the given function name. */
  public List<Integer> stringArguments(final String functionName) {
    return argumentsAreString.get(functionName);
  }

  /** Returns a list of <code>Integer</code>s which are the indices of <code>const char*</code>
      arguments that should be converted to <code>String</code>s. Returns null if there are no
      such hints for the given function alias symbol. */
  public List<Integer> stringArguments(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      List<Integer> res = argumentsAreString.get(name);
      if( null == res ) {
          res = oneInMap(argumentsAreString, aliases);
          if( null == res ) {
              return null;
          }
      }
      LOG.log(INFO, getASTLocusTag(symbol), "ArgumentsAreString: {0} -> {1}", symbol, res);
      return res;
  }

  public boolean isForceUsingNIOOnly4All() { return forceUseNIOOnly4All; }

  public void addUseNIOOnly(final String fname ) {
      useNIOOnly.add(fname);
  }
  /** Returns true if the given function should only create a java.nio
      variant, and no array variants, for <code>void*</code> and other
      C primitive pointers. NIO only still allows usage of array backed not direct Buffers. */
  public boolean useNIOOnly(final String functionName) {
    return useNIODirectOnly(functionName) || forceUseNIOOnly4All || useNIOOnly.contains(functionName);
  }

  public void addUseNIODirectOnly(final String fname ) {
      useNIODirectOnly.add(fname);
  }
  /** Returns true if the given function should only create a java.nio
      variant, and no array variants, for <code>void*</code> and other
      C primitive pointers. NIO direct only does only allow direct Buffers.
      Implies useNIOOnly !
   */
  public boolean useNIODirectOnly(final String functionName) {
    return forceUseNIODirectOnly4All || useNIODirectOnly.contains(functionName);
  }

  /** Returns a list of Strings containing user-implemented code for
      the given Java type name (not fully-qualified, only the class
      name); returns either null or an empty list if there is no
      custom code for the class. */
  public List<String> customJavaCodeForClass(final String className) {
    List<String> res = customJavaCode.get(className);
    if (res == null) {
      res = new ArrayList<String>();
      customJavaCode.put(className, res);
    }
    return res;
  }

  /** Returns a list of Strings containing user-implemented JNI code for
      the given Java type name (not fully-qualified, only the class
      name); returns either null or an empty list if there is no
      custom code for the class. */
  public List<String> customJNICodeForClass(final String className) {
    List<String> res = customJNICode.get(className);
    if (res == null) {
      res = new ArrayList<String>();
      customJNICode.put(className, res);
    }
    return res;
  }

  public List<String> javadocForMethod(final String methodName) {
    List<String> res = methodJavadoc.get(methodName);
    if (res == null) {
      res = new ArrayList<String>();
      methodJavadoc.put(methodName, res);
    }
    return res;
  }

  /** Returns a list of Strings containing Javadoc documentation for
      the given Java type name (not fully-qualified, only the class
      name); returns either null or an empty list if there is no
      Javadoc documentation for the class. */
  public List<String> javadocForClass(final String className) {
    List<String> res = classJavadoc.get(className);
    if (res == null) {
      res = new ArrayList<String>();
      classJavadoc.put(className, res);
    }
    return res;
  }

  /** Returns the package into which to place the glue code for
      accessing the specified struct. Defaults to emitting into the
      regular package (i.e., the result of {@link #packageName}). */
  public String packageForStruct(final String structName) {
    String res = structPackages.get(structName);
    if (res == null) {
      res = packageName;
    }
    return res;
  }

  /** Returns, as a List of Strings, the custom C code to be emitted
      along with the glue code for the main class. */
  public List<String> customCCode() {
    return customCCode;
  }

  /** Returns, as a List of Strings, the structs for which glue code
      emission should be forced. */
  public List<String> forcedStructs() {
    return forcedStructs;
  }

  /**
   * Returns a MessageFormat string of the Java code defining {@code mdIdx},
   * i.e. the index of the static MachineDescriptor index for structs.
   * <p>
   * If undefined, code generation uses the default expression:
   * <pre>
   *     private static final int mdIdx = MachineDataInfoRuntime.getStatic().ordinal();
   * </pre>
   * </p>
   */
  public String returnStructMachineDataInfoIndex(final String structName) {
    return structMachineDataInfoIndex.get(structName);
  }

  /**
   * Returns a MessageFormat string of the C expression calculating
   * the capacity of the java.nio.ByteBuffer being returned from a
   * native method, or null if no expression has been specified.
   * <p>
   * If symbol references a struct fields, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   */
  public String returnValueCapacity(final String functionName) {
    return returnValueCapacities.get(functionName);
  }

  /**
   * Returns a MessageFormat string of the C expression calculating
   * the length of the array being returned from a native method.
   * <p>
   * If symbol references a struct fields, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   */
  public String returnValueLength(final String symbol) {
    return returnValueLengths.get(symbol);
  }

  /** Returns a List of Strings of expressions declaring temporary C
      variables in the glue code for the specified function. */
  public List<String> temporaryCVariableDeclarations(final String functionName) {
    return temporaryCVariableDeclarations.get(functionName);
  }

  /** Returns a List of Strings of expressions containing assignments
      to temporary C variables in the glue code for the specified
      function. */
  public List<String> temporaryCVariableAssignments(final String functionName) {
    return temporaryCVariableAssignments.get(functionName);
  }

  /** Returns a List of Strings indicating the interfaces the passed
      interface should declare it extends. May return null or a list
      of zero length if there are none. */
  public List<String> extendedInterfaces(final String interfaceName) {
    List<String> res = extendedInterfaces.get(interfaceName);
    if (res == null) {
      res = new ArrayList<String>();
      extendedInterfaces.put(interfaceName, res);
    }
    return res;
  }

  /** Returns a List of Strings indicating the interfaces the passed
      class should declare it implements. May return null or a list
      of zero length if there are none. */
  public List<String> implementedInterfaces(final String className) {
    List<String> res = implementedInterfaces.get(className);
    if (res == null) {
      res = new ArrayList<String>();
      implementedInterfaces.put(className, res);
    }
    return res;
  }

  /** Returns a List of Strings indicating the interfaces the passed
      class should declare it implements. May return null or a list
      of zero length if there are none. */
  public String extendedParentClass(final String className) {
    return parentClass.get(className);
  }

  public void logIgnoresOnce() {
    if(!loggedIgnores) {
        loggedIgnores = true;
        logIgnores();
    }
  }
  private static boolean loggedIgnores = false;

  public void logIgnores() {
    LOG.log(INFO, "Extended Intf: {0}", extendedIntfSymbolsIgnore.size());
    for (final String str : extendedIntfSymbolsIgnore) {
        LOG.log(INFO, "\t{0}", str);
    }
    LOG.log(INFO, "Extended Impl: {0}", extendedImplSymbolsIgnore.size());
    for (final String str : extendedImplSymbolsIgnore) {
        LOG.log(INFO, "\t{0}", str);
    }
    LOG.log(INFO, "Ignores (All): {0}", ignores.size());
    for (final Pattern pattern : ignores) {
        LOG.log(INFO, "\t{0}", pattern);
    }
  }

  public void logRenamesOnce() {
    if(!loggedRenames) {
        loggedRenames = true;
        logRenames();
    }
  }
  private static boolean loggedRenames = false;

  public void logRenames() {
    LOG.log(INFO, "Symbol Renames: {0}", javaSymbolRenames.size());
    for (final String key : javaSymbolRenames.keySet()) {
        LOG.log(INFO, "\t{0} -> {1}", key, javaSymbolRenames.get(key));
    }

    LOG.log(INFO, "Symbol Aliasing (through renaming): {0}", javaSymbolRenames.size());
    for(final String newName : javaSymbolRenames.values()) {
        final Set<String> origNames = javaRenamedSymbols.get(newName);
        if(null!=origNames) {
            LOG.log(INFO, "\t{0} <- {1}", newName, origNames);
        }
    }
  }

  public static <K,V> V oneInMap(final Map<K, V> map, final Set<K> symbols) {
      if( null != map && map.size() > 0 &&
          null != symbols && symbols.size() > 0 ) {
          for(final K sym : symbols) {
              final V v = map.get(sym);
              if( null != v ) {
                  return v;
              }
          }
      }
      return null;
  }
  public static <K> boolean oneInSet(final Set<K> set1, final Set<K> set2) {
      if( null != set1 && set1.size() > 0 &&
          null != set2 && set2.size() > 0 ) {
          for(final K sym : set2) {
              if( set1.contains( sym ) ) {
                  return true;
              }
          }
      }
      return false;
  }
  private static boolean onePatternMatch(final Pattern ignoreRegexp, final Set<String> set) {
      if( null != ignoreRegexp && null != set && set.size() > 0 ) {
          for(final String sym : set) {
              final Matcher matcher = ignoreRegexp.matcher(sym);
              if (matcher.matches()) {
                  return true;
              }
          }
      }
      return false;
  }
  protected static ASTLocusTag getASTLocusTag(final AliasedSymbol s) {
      if( s instanceof ASTLocusTagProvider ) {
          return ((ASTLocusTagProvider)s).getASTLocusTag();
      } else {
          return null;
      }
  }

  /**
   * Returns the canonical configuration name for a struct field name,
   * i.e. 'struct-name'.'field-name'
   */
  public static String canonicalStructFieldSymbol(final String structName, final String fieldName) {
      return structName+"."+fieldName;
  }

  /**
   * Returns true if the glue code for the given aliased symbol
   * shall produce code for immutable access only.
   * <p>
   * This is implemented for whole struct-type symbols or struct-field names,
   * where no setter methods will be produced if marked immutable.
   * </p>
   */
  public final boolean immutableAccess(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      if ( immutableAccessSymbols.contains( name ) ||
           oneInSet(immutableAccessSymbols, aliases)
         )
      {
          LOG.log(INFO, getASTLocusTag(symbol), "Immutable access: {0}", symbol);
          return true;
      }
      return false;
  }
  /**
   * Returns true if the glue code for the given symbol
   * shall produce code for immutable access only.
   * <p>
   * This is implemented for whole struct-type symbols or struct-field names,
   * where no setter methods will be produced if marked immutable.
   * </p>
   */
  public final boolean immutableAccess(final String symbol) {
      if ( immutableAccessSymbols.contains( symbol ) ) {
          LOG.log(INFO, "Immutable access: {0}", symbol);
          return true;
      }
      return false;
  }

  /**
   * Variant of {@link #manuallyImplement(AliasedSymbol)},
   * where this method only considers the {@link AliasedSymbol#getName() current-name}
   * of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}.
   */
  public boolean manuallyImplement(final String functionName) {
      if( manuallyImplement.contains(functionName) ) {
          LOG.log(INFO, "ManuallyImplement: \"{0}\"", functionName);
          return true;
      } else {
          return false;
      }
  }

  /**
   * Returns true if the glue code for the given aliased function will be
   * manually implemented by the end user.
   * <p>
   * Both, the {@link AliasedSymbol#getName() current-name}
   * and all {@link AliasedSymbol#getAliasedNames() aliases} shall be considered.
   * </p>
   * <p>
   * If symbol references a struct field or method, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   * @see #manuallyImplement(String)
   */
  public boolean manuallyImplement(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      if ( manuallyImplement.contains( name ) ||
           oneInSet(manuallyImplement, aliases)
         )
      {
          LOG.log(INFO, getASTLocusTag(symbol), "ManuallyImplement: {0}", symbol);
          return true;
      } else {
          return false;
      }
  }

  /**
   * Variant of {@link #getDelegatedImplementation(AliasedSymbol)},
   * where this method only considers the {@link AliasedSymbol#getName() current-name}
   * of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}.
   */
  public String getDelegatedImplementation(final String functionName) {
      final String res = delegatedImplementation.get(functionName);
      if( null == res ) {
          return null;
      }
      LOG.log(INFO, "DelegatedImplementation: {0} -> {1}", functionName, res);
      return res;
  }

  /**
   * Returns the {@code RENAMED-IMPL-SYMBOL} if the implementation of the glue code
   * of the given function shall be manually delegated by the end user.
   * <p>
   * {@code DelegateImplementation <ORIG-SYMBOL> <RENAMED-IMPL-SYMBOL>}
   * </p>
   * <p>
   * The interface is emitted unchanged.
   * </p>
   * <p>
   * The Java and native-code implementation is renamed to {@code RENAMED-IMPL-SYMBOL}.
   * The user's manual implementation of {@code ORIG-SYMBOL}
   * may delegate to {@code RENAMED-IMPL-SYMBOL}.
   * </p>
   * <p>
   * If symbol references a struct field or method, see {@link #canonicalStructFieldSymbol(String, String)},
   * it describes field's array-length or element-count referenced by a pointer.
   * </p>
   */
  public String getDelegatedImplementation(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      String res = delegatedImplementation.get(name);
      if( null == res ) {
          res = oneInMap(delegatedImplementation, aliases);
          if( null == res ) {
              return null;
          }
      }
      LOG.log(INFO, getASTLocusTag(symbol), "DelegatedImplementation: {0} -> {1}", symbol, res);
      return res;
  }

  /**
   * Variant of {@link #getOpaqueReturnType(AliasedSymbol)},
   * where this method only considers the {@link AliasedSymbol#getName() current-name}
   * of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}.
   */
  public JavaType getOpaqueReturnType(final String functionName) {
      final JavaType res = returnsOpaqueJType.get(functionName);
      if( null == res ) {
          return null;
      }
      LOG.log(INFO, "ReturnsOpaque: {0} -> {1}", functionName, res);
      return res;
  }

  /**
   * Returns the opaque {@link JavaType} for the given function {@link AliasedSymbol}
   * or {@code null} if not opaque.
   * <p>
   * {@code ReturnsOpaque <Primitive Java Type> <Function Name>}
   * </p>
   */
  public JavaType getOpaqueReturnType(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();
      JavaType res = returnsOpaqueJType.get(name);
      if( null == res ) {
          res = oneInMap(returnsOpaqueJType, aliases);
          if( null == res ) {
              return null;
          }
      }
      LOG.log(INFO, getASTLocusTag(symbol), "ReturnsOpaque: {0} -> {1}", symbol, res);
      return res;
  }

  /**
   * Variant of {@link #shouldIgnoreInInterface(AliasedSymbol)},
   * where this method only considers the {@link AliasedSymbol#getName() current-name}
   * of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}.
   */
  public final boolean shouldIgnoreInInterface(final String symbol) {
      return shouldIgnoreInInterface( new AliasedSymbol.NoneAliasedSymbol(symbol) );
  }
  /**
   * Returns true if this aliased symbol should be ignored
   * during glue code generation of interfaces and implementation.
   * <p>
   * Both, the {@link AliasedSymbol#getName() current-name}
   * and all {@link AliasedSymbol#getAliasedNames() aliases} shall be considered.
   * </p>
   * <p>
   * Implementation calls {@link #shouldIgnoreInInterface_Int(AliasedSymbol)}
   * and overriding implementations shall ensure its being called as well!
   * </p>
   * @param symbol the symbolic aliased name to check for exclusion
   */
  public boolean shouldIgnoreInInterface(final AliasedSymbol symbol) {
      return shouldIgnoreInInterface_Int(symbol);
  }

  protected final boolean shouldIgnoreInInterface_Int(final AliasedSymbol symbol) {
      if( GlueGen.debug() ) {
          logIgnoresOnce();
      }
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      // Simple case-1; the symbol (orig or renamed) is in the interface ignore table
      if ( extendedIntfSymbolsIgnore.contains( name ) ||
           oneInSet(extendedIntfSymbolsIgnore, aliases)
         )
      {
          LOG.log(INFO, getASTLocusTag(symbol), "Ignore Intf ignore (one): {0}", symbol);
          return true;
      }
      // Simple case-2; the entire symbol (orig and renamed) is _not_ in the not-empty interface only table
      if ( !extendedIntfSymbolsOnly.isEmpty() &&
           !extendedIntfSymbolsOnly.contains( name ) &&
           !oneInSet(extendedIntfSymbolsOnly, aliases) ) {
          LOG.log(INFO, getASTLocusTag(symbol), "Ignore Intf !extended (all): {0}", symbol);
          return true;
      }
      return shouldIgnoreInImpl_Int(symbol);
  }

  /**
   * Returns true if this aliased symbol should be ignored
   * during glue code generation of implementation only.
   * <p>
   * Both, the {@link AliasedSymbol#getName() current-name}
   * and all {@link AliasedSymbol#getAliasedNames() aliases} shall be considered.
   * </p>
   * <p>
   * Implementation calls {@link #shouldIgnoreInImpl_Int(AliasedSymbol)}
   * and overriding implementations shall ensure its being called as well!
   * </p>
   * @param symbol the symbolic aliased name to check for exclusion
   */
  public boolean shouldIgnoreInImpl(final AliasedSymbol symbol) {
    return shouldIgnoreInImpl_Int(symbol);
  }

  protected final boolean shouldIgnoreInImpl_Int(final AliasedSymbol symbol) {
      final String name = symbol.getName();
      final Set<String> aliases = symbol.getAliasedNames();

      // Simple case-1; the symbol (orig or renamed) is in the interface ignore table
      if ( extendedImplSymbolsIgnore.contains( name ) ||
           oneInSet(extendedImplSymbolsIgnore, aliases)
         )
      {
          LOG.log(INFO, getASTLocusTag(symbol), "Ignore Impl ignore (one): {0}", symbol);
          return true;
      }
      // Simple case-2; the entire symbol (orig and renamed) is _not_ in the not-empty interface only table
      if ( !extendedImplSymbolsOnly.isEmpty() &&
           !extendedImplSymbolsOnly.contains( name ) &&
           !oneInSet(extendedImplSymbolsOnly, aliases) ) {
          LOG.log(INFO, getASTLocusTag(symbol), "Ignore Impl !extended (all): {0}", symbol);
          return true;
      }

      // Ok, the slow case. We need to check the entire table, in case the table
      // contains an regular expression that matches the symbol.
      for (final Pattern ignoreRegexp : ignores) {
          final Matcher matcher = ignoreRegexp.matcher(name);
          if ( matcher.matches() || onePatternMatch(ignoreRegexp, aliases) ) {
              LOG.log(INFO, getASTLocusTag(symbol), "Ignore Impl RegEx: {0}", symbol);
              return true;
          }
      }

      // Check negated ignore table if not empty
      if (ignoreNots.size() > 0) {
          // Ok, the slow case. We need to check the entire table, in case the table
          // contains an regular expression that matches the symbol.
          for (final Pattern ignoreNotRegexp : ignoreNots) {
              final Matcher matcher = ignoreNotRegexp.matcher(name);
              if ( !matcher.matches() && !onePatternMatch(ignoreNotRegexp, aliases) ) {
                  // Special case as this is most often likely to be the case.
                  // Unignores are not used very often.
                  if(unignores.isEmpty()) {
                      LOG.log(INFO, getASTLocusTag(symbol), "Ignore Impl unignores==0: {0} -> {1}", symbol, name);
                      return true;
                  }
                  boolean unignoreFound = false;
                  for (final Pattern unignoreRegexp : unignores) {
                      final Matcher unignoreMatcher = unignoreRegexp.matcher(name);
                      if ( unignoreMatcher.matches() || onePatternMatch(unignoreRegexp, aliases) ) {
                          unignoreFound = true;
                          break;
                      }
                  }

                  if (!unignoreFound) {
                      LOG.log(INFO, getASTLocusTag(symbol), "Ignore Impl !unignore: {0} -> {1}", symbol, name);
                      return true;
                  }
              }
          }
      }
      return false;
  }

  /** Returns true if this function should be given a body which
      throws a run-time exception with an "unimplemented" message
      during glue code generation. */
  public boolean isUnimplemented(final AliasedSymbol symbol) {
      // Ok, the slow case. We need to check the entire table, in case the table
      // contains an regular expression that matches the symbol.
      for (final Pattern unimplRegexp : unimplemented) {
          final Matcher matcher = unimplRegexp.matcher(symbol.getName());
          if ( matcher.matches() || onePatternMatch(unimplRegexp, symbol.getAliasedNames()) ) {
              return true;
          }
      }
      return false;
  }


  /**
   * Return a set of aliased-name for comment in docs.
   * <p>
   * This is usually {@link AliasedSymbol#addAliasedName(String)},
   * however an implementation may choose otherwise.
   * </p>
   * @param symbol the aliased symbol to retrieve the aliases
   * @return set of aliased-names or {@code null}.
   */
  public Set<String> getAliasedDocNames(final AliasedSymbol symbol) {
      return symbol.getAliasedNames();
  }

  /** Returns a replacement name for this type, which should be the
      name of a Java wrapper class for a C struct, or the name
      unchanged if no RenameJavaType directive was specified for this
      type. */
  public String renameJavaType(final String javaTypeName) {
    final String rename = javaTypeRenames.get(javaTypeName);
    if (rename != null) {
      return rename;
    }
    return javaTypeName;
  }

  /** Returns a replacement name for this function or definition which
      should be used as the Java name for the bound method or
      constant. If a function, it still calls the originally-named C
      function under the hood. Returns null if this symbol has not
      been explicitly renamed. */
  public String getJavaSymbolRename(final String origName) {
    if( LOG.isLoggable(INFO) ) {
        logRenamesOnce();
    }
    return javaSymbolRenames.get(origName);
  }

  /** Returns a set of replaced names to the given <code>aliasedName</code>. */
  public Set<String> getRenamedJavaSymbols(final String aliasedName) {
    return javaRenamedSymbols.get(aliasedName);
  }

  /** Programmatically adds a rename directive for the given symbol. */
  public void addJavaSymbolRename(final String origName, final String newName) {
    LOG.log(INFO, "\tRename {0} -> {1}", origName, newName);
    final String prevValue = javaSymbolRenames.put(origName, newName);
    if(null != prevValue && !prevValue.equals(newName)) {
        throw new RuntimeException("Rename-Override Attampt: "+origName+" -> "+newName+
                                   ", but "+origName+" -> "+prevValue+" already exist. Run in 'debug' mode to analyze!");
    }
    Set<String> origNames = javaRenamedSymbols.get(newName);
    if(null == origNames) {
        origNames = new HashSet<String>();
        javaRenamedSymbols.put(newName, origNames);
    }
    origNames.add(origName);
  }

  /** Programmatically adds a delegate implementation directive for the given symbol. */
  public void addDelegateImplementation(final String origName, final String renamedImpl) {
    LOG.log(INFO, "\tDelegateImplementation {0} -> {1}", origName, renamedImpl);
    final String prevValue = delegatedImplementation.put(origName, renamedImpl);
    if(null != prevValue && !prevValue.equals(renamedImpl)) {
        throw new RuntimeException("Rename-Override Attampt: "+origName+" -> "+renamedImpl+
                                   ", but "+origName+" -> "+prevValue+" already exist. Run in 'debug' mode to analyze!");
    }
  }

  /** Returns true if the emission style is AllStatic. */
  public boolean allStatic() {
    return emissionStyle == AllStatic;
  }

  /** Returns true if an interface should be emitted during glue code generation. */
  public boolean emitInterface() {
    return emissionStyle() == InterfaceAndImpl || emissionStyle() == InterfaceOnly;
  }

  /** Returns true if an implementing class should be emitted during glue code generation. */
  public boolean emitImpl() {
    return emissionStyle() == AllStatic || emissionStyle() == InterfaceAndImpl || emissionStyle() == ImplOnly;
  }

  /** Returns a list of Strings which should be emitted as a prologue
      to the body for the Java-side glue code for the given method.
      Returns null if no prologue was specified. */
  public List<String> javaPrologueForMethod(final MethodBinding binding,
                                                final boolean forImplementingMethodCall,