1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
|
/* -----------------------------------------------------------------------------
* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
*
* symbol.c
*
* This file implements the SWIG symbol table. See details below.
* ----------------------------------------------------------------------------- */
#include "swig.h"
#include "swigwarn.h"
#include <ctype.h>
/* #define SWIG_DEBUG*/
/* -----------------------------------------------------------------------------
* Synopsis
*
* This module provides symbol table management for all of SWIG. In previous
* releases, the management of symbols was rather haphazard. This module tries
* to correct that.
*
* All symbols are associated with simple identifiers. For example, here are some
* declarations that generate symbol table entries:
*
* decl symbol
* -------------- ------------
* void foo(int); foo
* int x; x
* typedef int *blah; blah
*
* Associated with each symbol is a Hash table that can contain any set of
* attributes that make sense for that object. For example:
*
* typedef int *blah; ----> "name" : 'blah'
* "type" : 'int'
* "decl" : 'p.'
* "storage" : 'typedef'
*
* In some cases, the symbol table needs to manage overloaded entries. For instance,
* overloaded functions. In this case, a linked list is built. The "sym:nextSibling"
* attribute is reserved to hold a link to the next entry. For example:
*
* int foo(int); --> "name" : "foo" "name" : "foo"
* int foo(int,double); "type" : "int" "type" : "int"
* "decl" : "f(int)." "decl" : "f(int,double)."
* ... ...
* "sym:nextSibling" : --------> "sym:nextSibling": --------> ...
*
* When more than one symbol has the same name, the symbol declarator is
* used to detect duplicates. For example, in the above case, foo(int) and
* foo(int,double) are different because their "decl" attribute is different.
* However, if a third declaration "foo(int)" was made, it would generate a
* conflict (due to having a declarator that matches a previous entry).
*
* Structures and classes:
*
* C/C++ symbol tables are normally managed in a few different spaces. The
* most visible namespace is reserved for functions, variables, typedef, enum values
* and such. In C, a separate tag-space is reserved for 'struct name', 'class name',
* and 'union name' declarations. In SWIG, a single namespace is used for everything
* this means that certain incompatibilities will arise with some C programs. For instance:
*
* struct Foo {
* ...
* }
*
* int Foo(); // Error. Name clash. Works in C though
*
* Due to the unified namespace for structures, special handling is performed for
* the following:
*
* typedef struct Foo {
*
* } Foo;
*
* In this case, the symbol table contains an entry for the structure itself. The
* typedef is left out of the symbol table.
*
* Target language vs C:
*
* The symbol tables are normally managed *in the namespace of the target language*.
* This means that name-collisions can be resolved using %rename and related
* directives. A quirk of this is that sometimes the symbol tables need to
* be used for C type resolution as well. To handle this, each symbol table
* also has a C-symbol table lurking behind the scenes. This is used to locate
* symbols in the C namespace. However, this symbol table is not used for error
* reporting nor is it used for anything else during code generation.
*
* Symbol table structure:
*
* Symbol tables themselves are a special kind of node that is organized just like
* a normal parse tree node. Symbol tables are organized in a tree that can be
* traversed using the SWIG-DOM API. The following attributes names are reserved.
*
* name -- Name of the scope defined by the symbol table (if any)
* This name is the C-scope name and is not affected by
* %renaming operations
* symtab -- Hash table mapping identifiers to nodes.
* csymtab -- Hash table mapping C identifiers to nodes.
*
* Reserved attributes on symbol objects:
*
* When a symbol is placed in the symbol table, the following attributes
* are set:
*
* sym:name -- Symbol name
* sym:nextSibling -- Next symbol (if overloaded)
* sym:previousSibling -- Previous symbol (if overloaded)
* sym:symtab -- Symbol table object holding the symbol
* sym:overloaded -- Set to the first symbol if overloaded
*
* These names are modeled after XML namespaces. In particular, every attribute
* pertaining to symbol table management is prefaced by the "sym:" prefix.
*
* An example dump of the parse tree showing symbol table entries for the
* following code should clarify this:
*
* namespace OuterNamespace {
* namespace InnerNamespace {
* class Class {
* };
* struct Struct {
* int Var;
* };
* }
* }
*
* +++ namespace ----------------------------------------
* | sym:name - "OuterNamespace"
* | symtab - 0xa064bf0
* | sym:symtab - 0xa041690
* | sym:overname - "__SWIG_0"
*
* +++ namespace ----------------------------------------
* | sym:name - "InnerNamespace"
* | symtab - 0xa064cc0
* | sym:symtab - 0xa064bf0
* | sym:overname - "__SWIG_0"
*
* +++ class ----------------------------------------
* | sym:name - "Class"
* | symtab - 0xa064d80
* | sym:symtab - 0xa064cc0
* | sym:overname - "__SWIG_0"
* |
* +++ class ----------------------------------------
* | sym:name - "Struct"
* | symtab - 0xa064f00
* | sym:symtab - 0xa064cc0
* | sym:overname - "__SWIG_0"
*
* +++ cdecl ----------------------------------------
* | sym:name - "Var"
* | sym:symtab - 0xa064f00
* | sym:overname - "__SWIG_0"
* |
*
*
* Each class and namespace has its own scope and thus a new symbol table (sym)
* is created. The sym attribute is only set for the first entry in the symbol
* table. The sym:symtab entry points to the symbol table in which the symbol
* exists, so for example, Struct is in the scope OuterNamespace::InnerNamespace
* so sym:symtab points to this symbol table (0xa064cc0).
*
* ----------------------------------------------------------------------------- */
static Hash *current = 0; /* The current symbol table hash */
static Hash *ccurrent = 0; /* The current c symbol table hash */
static Hash *current_symtab = 0; /* Current symbol table node */
static Hash *symtabs = 0; /* Hash of all symbol tables by fully-qualified name */
static Hash *global_scope = 0; /* Global scope */
static int use_inherit = 1;
/* common attribute keys, to avoid calling find_key all the times */
/* -----------------------------------------------------------------------------
* Swig_symbol_print_tables()
*
* Debug display of symbol tables
* ----------------------------------------------------------------------------- */
void Swig_symbol_print_tables(Symtab *symtab) {
if (!symtab)
symtab = current_symtab;
Printf(stdout, "SYMBOL TABLES start =======================================\n");
Swig_print_tree(symtab);
Printf(stdout, "SYMBOL TABLES finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_print_tables_summary()
*
* Debug summary display of all symbol tables by fully-qualified name
* ----------------------------------------------------------------------------- */
void Swig_symbol_print_tables_summary(void) {
Printf(stdout, "SYMBOL TABLES SUMMARY start =======================================\n");
Swig_print_node(symtabs);
Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* symbol_print_symbols()
* ----------------------------------------------------------------------------- */
static void symbol_print_symbols(const char *symboltabletype) {
Node *table = symtabs;
Iterator ki = First(table);
while (ki.key) {
String *k = ki.key;
Printf(stdout, "===================================================\n");
Printf(stdout, "%s -\n", k);
{
Symtab *symtab = Getattr(Getattr(table, k), symboltabletype);
Iterator it = First(symtab);
while (it.key) {
String *symname = it.key;
Printf(stdout, " %s (%s)\n", symname, nodeType(it.item));
/*
Printf(stdout, " %s - %p (%s)\n", symname, it.item, Getattr(it.item, "name"));
*/
it = Next(it);
}
}
ki = Next(ki);
}
}
/* -----------------------------------------------------------------------------
* Swig_symbol_print_symbols()
*
* Debug display of all the target language symbols
* ----------------------------------------------------------------------------- */
void Swig_symbol_print_symbols(void) {
Printf(stdout, "SYMBOLS start =======================================\n");
symbol_print_symbols("symtab");
Printf(stdout, "SYMBOLS finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_print_csymbols()
*
* Debug display of all the C symbols
* ----------------------------------------------------------------------------- */
void Swig_symbol_print_csymbols(void) {
Printf(stdout, "CSYMBOLS start =======================================\n");
symbol_print_symbols("csymtab");
Printf(stdout, "CSYMBOLS finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_init()
*
* Create a new symbol table object
* ----------------------------------------------------------------------------- */
void Swig_symbol_init(void) {
current = NewHash();
current_symtab = NewHash();
ccurrent = NewHash();
set_nodeType(current_symtab, "symboltable");
Setattr(current_symtab, "symtab", current);
Delete(current);
Setattr(current_symtab, "csymtab", ccurrent);
Delete(ccurrent);
/* Set the global scope */
symtabs = NewHash();
Setattr(symtabs, "", current_symtab);
Delete(current_symtab);
global_scope = current_symtab;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_setscopename()
*
* Set the C scopename of the current symbol table.
* ----------------------------------------------------------------------------- */
void Swig_symbol_setscopename(const_String_or_char_ptr name) {
String *qname;
/* assert(!Getattr(current_symtab,"name")); */
Setattr(current_symtab, "name", name);
/* Set nested scope in parent */
qname = Swig_symbol_qualifiedscopename(current_symtab);
/* Save a reference to this scope */
Setattr(symtabs, qname, current_symtab);
Delete(qname);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_getscopename()
*
* Get the C scopename of the current symbol table
* ----------------------------------------------------------------------------- */
String *Swig_symbol_getscopename(void) {
return Getattr(current_symtab, "name");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_getscope()
*
* Given a fully qualified C scopename, this function returns a symbol table
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) {
if (!symtabs)
return 0;
if (Equal("::", (const_String_or_char_ptr ) name))
name = "";
return Getattr(symtabs, name);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_qualifiedscopename()
*
* Get the fully qualified C scopename of a symbol table. Note, this only pertains
* to the C/C++ scope name. It is not affected by renaming.
* ----------------------------------------------------------------------------- */
String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
String *result = 0;
Hash *parent;
String *name;
if (!symtab)
symtab = current_symtab;
parent = Getattr(symtab, "parentNode");
if (parent) {
result = Swig_symbol_qualifiedscopename(parent);
}
name = Getattr(symtab, "name");
if (name) {
if (!result) {
result = NewStringEmpty();
}
if (Len(result)) {
Printv(result, "::", name, NIL);
} else {
Append(result, name);
}
}
return result;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_qualified_language_scopename()
*
* Get the fully qualified C scopename of a symbol table but using a language
* specific separator for the scopenames. Basically the same as
* Swig_symbol_qualifiedscopename() but using the different separator.
* ----------------------------------------------------------------------------- */
String *Swig_symbol_qualified_language_scopename(Symtab *n) {
/* TODO: fix for %rename to work */
String *result = Swig_symbol_qualifiedscopename(n);
Replaceall(result, "::", NSPACE_SEPARATOR);
return result;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_newscope()
*
* Create a new scope. Returns the newly created scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_newscope(void) {
Hash *n;
Hash *hsyms, *h;
hsyms = NewHash();
h = NewHash();
set_nodeType(h, "symboltable");
Setattr(h, "symtab", hsyms);
Delete(hsyms);
set_parentNode(h, current_symtab);
n = lastChild(current_symtab);
if (!n) {
set_firstChild(current_symtab, h);
} else {
set_nextSibling(n, h);
Delete(h);
}
set_lastChild(current_symtab, h);
current = hsyms;
ccurrent = NewHash();
Setattr(h, "csymtab", ccurrent);
Delete(ccurrent);
current_symtab = h;
return h;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_setscope()
*
* Set the current scope. Returns the previous current scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_setscope(Symtab *sym) {
Symtab *ret = current_symtab;
current_symtab = sym;
current = Getattr(sym, "symtab");
assert(current);
ccurrent = Getattr(sym, "csymtab");
assert(ccurrent);
return ret;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_popscope()
*
* Pop out of the current scope. Returns the popped scope and sets the
* scope to the parent scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_popscope(void) {
Hash *h = current_symtab;
current_symtab = Getattr(current_symtab, "parentNode");
assert(current_symtab);
current = Getattr(current_symtab, "symtab");
assert(current);
ccurrent = Getattr(current_symtab, "csymtab");
assert(ccurrent);
return h;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_global_scope()
*
* Return the symbol table for the global scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_global_scope(void) {
return global_scope;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_current()
*
* Return the current symbol table.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_current(void) {
return current_symtab;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_alias()
*
* Makes an alias for a symbol in the global symbol table.
* Primarily for namespace aliases such as 'namespace X = Y;'.
* ----------------------------------------------------------------------------- */
void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) {
String *qname = Swig_symbol_qualifiedscopename(current_symtab);
if (qname) {
Printf(qname, "::%s", aliasname);
} else {
qname = NewString(aliasname);
}
if (!Getattr(symtabs, qname)) {
Setattr(symtabs, qname, s);
}
Delete(qname);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_inherit()
*
* Inherit symbols from another scope. Primarily for C++ inheritance and
* for using directives, such as 'using namespace X;'
* but not for using declarations, such as 'using A;'.
* ----------------------------------------------------------------------------- */
void Swig_symbol_inherit(Symtab *s) {
int i, ilen;
List *inherit = Getattr(current_symtab, "inherit");
if (!inherit) {
inherit = NewList();
Setattr(current_symtab, "inherit", inherit);
Delete(inherit);
}
if (s == current_symtab) {
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(s), Getline(s), "Recursive scope inheritance of '%s'.\n", Getattr(s, "name"));
return;
}
assert(s != current_symtab);
ilen = Len(inherit);
for (i = 0; i < ilen; i++) {
Node *n = Getitem(inherit, i);
if (n == s)
return; /* Already inherited */
}
Append(inherit, s);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_cadd()
*
* Adds a node to the C symbol table only.
* ----------------------------------------------------------------------------- */
void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
Node *append = 0;
Node *cn;
/* There are a few options for weak symbols. A "weak" symbol
is any symbol that can be replaced by another symbol in the C symbol
table. An example would be a forward class declaration. A forward
class sits in the symbol table until a real class declaration comes along.
Certain symbols are marked as "sym:typename". These are important
symbols related to the C++ type-system and take precedence in the C
symbol table. An example might be code like this:
template<class T> T foo(T x);
int foo(int);
In this case, the template is marked with "sym:typename" so that it
stays in the C symbol table (so that it can be expanded using %template).
*/
if (!name)
return;
if (SwigType_istemplate(name)) {
String *cname = NewString(name);
String *dname = Swig_symbol_template_deftype(cname, 0);
if (!Equal(dname, name)) {
Swig_symbol_cadd(dname, n);
}
Delete(dname);
Delete(cname);
}
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_cadd %s %p\n", name, n);
#endif
cn = Getattr(ccurrent, name);
if (cn && (Getattr(cn, "sym:typename"))) {
/* The node in the C symbol table is a typename. Do nothing */
/* We might append the symbol at the end */
append = n;
} else if (cn && (Getattr(cn, "sym:weak"))) {
/* The node in the symbol table is weak. Replace it */
if (checkAttribute(cn, "nodeType", "template")
&& checkAttribute(cn, "templatetype", "classforward")) {
/* The node is a template classforward declaration, and the
default template parameters here take precedence. */
ParmList *pc = Getattr(cn, "templateparms");
ParmList *pn = Getattr(n, "templateparms");
#ifdef SWIG_DEBUG
Printf(stderr, "found template classforward %s\n", Getattr(cn, "name"));
#endif
while (pc && pn) {
String *value = Getattr(pc, "value");
if (value) {
#ifdef SWIG_DEBUG
Printf(stderr, "add default template value %s %s\n", Getattr(pc, "name"), value);
#endif
Setattr(pn, "value", value);
}
pc = nextSibling(pc);
pn = nextSibling(pn);
}
Setattr(n, "templateparms", Getattr(cn, "templateparms"));
}
Setattr(ccurrent, name, n);
} else if (cn && (Getattr(n, "sym:weak"))) {
/* The node being added is weak. Don't worry about it */
} else if (cn && (Getattr(n, "sym:typename"))) {
/* The node being added is a typename. We definitely add it */
Setattr(ccurrent, name, n);
append = cn;
} else if (cn && (Checkattr(cn, "nodeType", "templateparm"))) {
Swig_error(Getfile(n), Getline(n), "Declaration of '%s' shadows template parameter,\n", name);
Swig_error(Getfile(cn), Getline(cn), "previous template parameter declaration '%s'.\n", name);
return;
} else if (cn) {
append = n;
} else if (!cn) {
/* No conflict. Add the symbol */
Setattr(ccurrent, name, n);
}
/* Multiple entries in the C symbol table. We append to to the symbol table */
if (append) {
Node *fn, *pn = 0;
cn = Getattr(ccurrent, name);
fn = cn;
while (fn) {
pn = fn;
if (fn == append) {
/* already added. Bail */
return;
}
fn = Getattr(fn, "csym:nextSibling");
}
if (pn) {
Setattr(pn, "csym:nextSibling", append);
}
}
/* Special typedef handling. When a typedef node is added to the symbol table, we
might have to add a type alias. This would occur if the typedef mapped to another
scope in the system. For example:
class Foo {
};
typedef Foo OtherFoo;
In this case, OtherFoo becomes an alias for Foo. */
{
Node *td = n;
while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) {
SwigType *type;
Node *td1;
type = Copy(Getattr(td, "type"));
SwigType_push(type, Getattr(td, "decl"));
td1 = Swig_symbol_clookup(type, 0);
/* Fix pathetic case #1214313:
class Foo
{
};
typedef Foo FooBar;
class CBaz
{
public:
typedef FooBar Foo;
};
ie, when Foo -> FooBar -> Foo, jump one scope up when possible.
*/
if (td1 && Checkattr(td1, "storage", "typedef")) {
String *st = Getattr(td1, "type");
String *sn = Getattr(td, "name");
if (st && sn && Equal(st, sn)) {
Symtab *sc = Getattr(current_symtab, "parentNode");
if (sc)
td1 = Swig_symbol_clookup(type, sc);
}
}
Delete(type);
if (td1 == td)
break;
td = td1;
if (td) {
Symtab *st = Getattr(td, "symtab");
if (st) {
Swig_symbol_alias(Getattr(n, "name"), st);
break;
}
}
}
}
}
/* -----------------------------------------------------------------------------
* Swig_symbol_add()
*
* Adds a node to the symbol table. Returns the node itself if successfully
* added. Otherwise, it returns the symbol table entry of the conflicting node.
*
* Also places the symbol in a behind-the-scenes C symbol table. This is needed
* for namespace support, type resolution, and other issues.
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) {
Hash *c, *cn, *cl = 0;
SwigType *decl, *ndecl;
String *cstorage, *nstorage;
int nt = 0, ct = 0;
int pn = 0;
int u1 = 0, u2 = 0;
String *name, *overname;
/* See if the node has a name. If so, we place in the C symbol table for this
scope. We don't worry about overloading here---the primary purpose of this
is to record information for type/name resolution for later. Conflicts
in C namespaces are errors, but these will be caught by the C++ compiler
when compiling the wrapper code */
/* There are a few options for weak symbols. A "weak" symbol
is any symbol that can be replaced by another symbol in the C symbol
table. An example would be a forward class declaration. A forward
class sits in the symbol table until a real class declaration comes along.
Certain symbols are marked as "sym:typename". These are important
symbols related to the C++ type-system and take precedence in the C
symbol table. An example might be code like this:
template<class T> T foo(T x);
int foo(int);
In this case, the template is marked with "sym:typename" so that it
stays in the C symbol table (so that it can be expanded using %template).
*/
name = Getattr(n, "name");
if (name && Len(name)) {
Swig_symbol_cadd(name, n);
}
/* No symbol name defined. We return. */
if (!symname) {
Setattr(n, "sym:symtab", current_symtab);
return n;
}
/* If node is ignored. We don't proceed any further */
if (GetFlag(n, "feature:ignore"))
return n;
/* See if the symbol already exists in the table */
c = Getattr(current, symname);
/* Check for a weak symbol. A weak symbol is allowed to be in the
symbol table, but is silently overwritten by other symbols. An example
would be a forward class declaration. For instance:
class Foo;
In this case, "Foo" sits in the symbol table. However, the
definition of Foo would replace the entry if it appeared later. */
if (c && Getattr(c, "sym:weak")) {
c = 0;
}
if (c) {
/* There is a symbol table conflict. There are a few cases to consider here:
(1) A conflict between a class/enum and a typedef declaration is okay.
In this case, the symbol table entry is set to the class/enum declaration
itself, not the typedef.
(2) A conflict between namespaces is okay--namespaces are open
(3) Otherwise, overloading is only allowed for functions
*/
/* Check for namespaces */
String *ntype = Getattr(n, "nodeType");
if ((Equal(ntype, Getattr(c, "nodeType"))) && ((Equal(ntype, "namespace")))) {
Node *cl, *pcl = 0;
cl = c;
while (cl) {
pcl = cl;
cl = Getattr(cl, "sym:nextSibling");
}
Setattr(pcl, "sym:nextSibling", n);
Setattr(n, "sym:symtab", current_symtab);
Setattr(n, "sym:name", symname);
Setattr(n, "sym:previousSibling", pcl);
return n;
}
if (Getattr(n, "allows_typedef"))
nt = 1;
if (Getattr(c, "allows_typedef"))
ct = 1;
if (nt || ct) {
Node *td, *other;
String *s;
/* At least one of the nodes allows typedef overloading. Make sure that
both don't--this would be a conflict */
if (nt && ct)
return c;
/* Figure out which node allows the typedef */
if (nt) {
td = n;
other = c;
} else {
td = c;
other = n;
}
/* Make sure the other node is a typedef */
s = Getattr(other, "storage");
if (!s || (!Equal(s, "typedef")))
return c; /* No. This is a conflict */
/* Hmmm. This appears to be okay. Make sure the symbol table refers to the allow_type node */
if (td != c) {
Setattr(current, symname, td);
Setattr(td, "sym:symtab", current_symtab);
Setattr(td, "sym:name", symname);
}
return n;
}
decl = Getattr(c, "decl");
ndecl = Getattr(n, "decl");
{
String *nt1, *nt2;
nt1 = Getattr(n, "nodeType");
if (Equal(nt1, "template"))
nt1 = Getattr(n, "templatetype");
nt2 = Getattr(c, "nodeType");
if (Equal(nt2, "template"))
nt2 = Getattr(c, "templatetype");
if (Equal(nt1, "using"))
u1 = 1;
if (Equal(nt2, "using"))
u2 = 1;
if ((!Equal(nt1, nt2)) && !(u1 || u2))
return c;
}
if (!(u1 || u2)) {
if ((!SwigType_isfunction(decl)) || (!SwigType_isfunction(ndecl))) {
/* Symbol table conflict */
return c;
}
}
/* Hmmm. Declarator seems to indicate that this is a function */
/* Look at storage class to see if compatible */
cstorage = Getattr(c, "storage");
nstorage = Getattr(n, "storage");
/* If either one is declared as typedef, forget it. We're hosed */
if (Cmp(cstorage, "typedef") == 0) {
return c;
}
if (Cmp(nstorage, "typedef") == 0) {
return c;
}
/* Okay. Walk down the list of symbols and see if we get a declarator match */
{
String *nt = Getattr(n, "nodeType");
int n_template = Equal(nt, "template") && Checkattr(n, "templatetype", "cdecl");
int n_plain_cdecl = Equal(nt, "cdecl");
cn = c;
pn = 0;
while (cn) {
decl = Getattr(cn, "decl");
if (!(u1 || u2)) {
if (Cmp(ndecl, decl) == 0) {
/* Declarator conflict */
/* Now check we don't have a non-templated function overloaded by a templated function with same params,
* eg void foo(); template<typename> void foo(); */
String *cnt = Getattr(cn, "nodeType");
int cn_template = Equal(cnt, "template") && Checkattr(cn, "templatetype", "cdecl");
int cn_plain_cdecl = Equal(cnt, "cdecl");
if (!((n_template && cn_plain_cdecl) || (cn_template && n_plain_cdecl))) {
/* found a conflict */
return cn;
}
}
}
cl = cn;
cn = Getattr(cn, "sym:nextSibling");
pn++;
}
}
/* Well, we made it this far. Guess we can drop the symbol in place */
Setattr(n, "sym:symtab", current_symtab);
Setattr(n, "sym:name", symname);
/* Printf(stdout,"%s %p\n", Getattr(n,"sym:overname"), current_symtab); */
assert(!Getattr(n, "sym:overname"));
overname = NewStringf("__SWIG_%d", pn);
Setattr(n, "sym:overname", overname);
/*Printf(stdout,"%s %s %s\n", symname, Getattr(n,"decl"), Getattr(n,"sym:overname")); */
Setattr(cl, "sym:nextSibling", n);
Setattr(n, "sym:previousSibling", cl);
Setattr(cl, "sym:overloaded", c);
Setattr(n, "sym:overloaded", c);
Delete(overname);
return n;
}
/* No conflict. Just add it */
Setattr(n, "sym:symtab", current_symtab);
Setattr(n, "sym:name", symname);
/* Printf(stdout,"%s\n", Getattr(n,"sym:overname")); */
overname = NewStringf("__SWIG_%d", pn);
Setattr(n, "sym:overname", overname);
Delete(overname);
/* Printf(stdout,"%s %s %s\n", symname, Getattr(n,"decl"), Getattr(n,"sym:overname")); */
Setattr(current, symname, n);
return n;
}
/* -----------------------------------------------------------------------------
* symbol_lookup()
*
* Internal function to handle fully qualified symbol table lookups. This
* works from the symbol table supplied in symtab and unwinds its way out
* towards the global scope.
*
* This function operates in the C namespace, not the target namespace.
*
* The check function is an optional callback that can be used to verify a particular
* symbol match. This is only used in some of the more exotic parts of SWIG. For instance,
* verifying that a class hierarchy implements all pure virtual methods.
* ----------------------------------------------------------------------------- */
static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) {
Node *n;
List *inherit;
Hash *sym = Getattr(symtab, "csymtab");
if (Getmark(symtab))
return 0;
Setmark(symtab, 1);
n = Getattr(sym, name);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_look %s %p %p %s\n", name, n, symtab, Getattr(symtab, "name"));
#endif
if (n) {
/* if a check-function is defined. Call it to determine a match */
if (check) {
int c = check(n);
if (c == 1) {
Setmark(symtab, 0);
return n;
}
if (c < 0) {
/* Terminate the search right away */
Setmark(symtab, 0);
return 0;
}
} else {
Setmark(symtab, 0);
return n;
}
}
if (!n && SwigType_istemplate(name)) {
String *dname = 0;
Setmark(symtab, 0);
dname = Swig_symbol_template_deftype(name, symtab);
if (!Equal(dname, name)) {
n = _symbol_lookup(dname, symtab, check);
}
Delete(dname);
if (n)
return n;
Setmark(symtab, 1);
}
inherit = Getattr(symtab, "inherit");
if (inherit && use_inherit) {
int i, len;
len = Len(inherit);
for (i = 0; i < len; i++) {
n = _symbol_lookup(name, Getitem(inherit, i), check);
if (n) {
Setmark(symtab, 0);
return n;
}
}
}
Setmark(symtab, 0);
return 0;
}
static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) {
Node *n = 0;
if (DohCheck(name)) {
n = _symbol_lookup(name, symtab, check);
} else {
String *sname = NewString(name);
n = _symbol_lookup(sname, symtab, check);
Delete(sname);
}
return n;
}
/* -----------------------------------------------------------------------------
* symbol_lookup_qualified()
* ----------------------------------------------------------------------------- */
static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) {
/* This is a little funky, we search by fully qualified names */
if (!symtab)
return 0;
if (!prefix) {
Node *n;
String *bname;
String *prefix;
Swig_scopename_split(name, &prefix, &bname);
n = symbol_lookup_qualified(bname, symtab, prefix, local, checkfunc);
Delete(bname);
Delete(prefix);
return n;
} else {
Symtab *st;
Node *n = 0;
/* Make qualified name of current scope */
String *qalloc = 0;
String *qname = Swig_symbol_qualifiedscopename(symtab);
const String *cqname;
if (qname) {
if (Len(qname)) {
if (prefix && Len(prefix)) {
Printv(qname, "::", prefix, NIL);
}
} else {
Append(qname, prefix);
}
qalloc = qname;
cqname = qname;
} else {
cqname = prefix;
}
st = Getattr(symtabs, cqname);
/* Found a scope match */
if (st) {
if (!name) {
if (qalloc)
Delete(qalloc);
return st;
}
n = symbol_lookup(name, st, checkfunc);
}
if (qalloc)
Delete(qalloc);
if (!n) {
if (!local) {
Node *pn = Getattr(symtab, "parentNode");
if (pn)
n = symbol_lookup_qualified(name, pn, prefix, local, checkfunc);
/* Check inherited scopes */
if (!n) {
List *inherit = Getattr(symtab, "inherit");
if (inherit && use_inherit) {
int i, len;
len = Len(inherit);
for (i = 0; i < len; i++) {
Node *prefix_node = symbol_lookup(prefix, Getitem(inherit, i), checkfunc);
if (prefix_node) {
Node *prefix_symtab = Getattr(prefix_node, "symtab");
if (prefix_symtab) {
n = symbol_lookup(name, prefix_symtab, checkfunc);
break;
}
}
}
}
}
} else {
n = 0;
}
}
return n;
}
}
/* -----------------------------------------------------------------------------
* Swig_symbol_clookup()
*
* Look up a symbol in the symbol table. This uses the C name, not scripting
* names. Note: If we come across a using declaration, we follow it to
* to get the real node. Any using directives are also followed (but this is
* implemented in symbol_lookup()).
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
Hash *hsym = 0;
Node *s = 0;
if (!n) {
hsym = current_symtab;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
if (n) {
hsym = n;
}
}
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0);
} else {
s = symbol_lookup(nname, global_scope, 0);
}
Delete(nname);
} else {
String *prefix = Swig_scopename_prefix(name);
if (prefix) {
s = symbol_lookup_qualified(name, hsym, 0, 0, 0);
Delete(prefix);
if (!s) {
return 0;
}
}
}
}
if (!s) {
while (hsym) {
s = symbol_lookup(name, hsym, 0);
if (s)
break;
hsym = Getattr(hsym, "parentNode");
if (!hsym)
break;
}
}
if (!s) {
return 0;
}
/* Check if s is a 'using' node */
while (s && Checkattr(s, "nodeType", "using")) {
String *uname = Getattr(s, "uname");
Symtab *un = Getattr(s, "sym:symtab");
Node *ss = (!Equal(name, uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */
if (!ss) {
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
return s;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_clookup_check()
*
* This function is identical to Swig_symbol_clookup() except that it
* accepts a callback function that is invoked to determine a symbol match.
* The purpose of this function is to support complicated algorithms that need
* to examine multiple definitions of the same symbol that might appear in an
* inheritance hierarchy.
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) {
Hash *hsym = 0;
Node *s = 0;
if (!n) {
hsym = current_symtab;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
if (n) {
hsym = n;
}
}
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc);
} else {
s = symbol_lookup(nname, global_scope, checkfunc);
}
Delete(nname);
} else {
String *prefix = Swig_scopename_prefix(name);
if (prefix) {
s = symbol_lookup_qualified(name, hsym, 0, 0, checkfunc);
Delete(prefix);
if (!s) {
return 0;
}
}
}
}
if (!s) {
while (hsym) {
s = symbol_lookup(name, hsym, checkfunc);
if (s)
break;
hsym = Getattr(hsym, "parentNode");
if (!hsym)
break;
}
}
if (!s) {
return 0;
}
/* Check if s is a 'using' node */
while (s && Checkattr(s, "nodeType", "using")) {
Node *ss;
ss = Swig_symbol_clookup(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
if (!ss && !checkfunc) {
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
return s;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_clookup_local()
*
* Same as Swig_symbol_clookup but parent nodes are not searched, that is, just
* this symbol table is searched.
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
Hash *hsym;
Node *s = 0;
if (!n) {
hsym = current_symtab;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
hsym = n;
}
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0);
} else {
s = symbol_lookup(nname, global_scope, 0);
}
Delete(nname);
} else {
s = symbol_lookup_qualified(name, hsym, 0, 0, 0);
}
}
if (!s) {
s = symbol_lookup(name, hsym, 0);
}
if (!s)
return 0;
/* Check if s is a 'using' node */
while (s && Checkattr(s, "nodeType", "using")) {
Node *ss = Swig_symbol_clookup_local(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
if (!ss) {
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
return s;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_clookup_local_check()
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
Hash *hsym;
Node *s = 0;
if (!n) {
hsym = current_symtab;
} else {
if (!Checkattr(n, "nodeType", "symboltable")) {
n = Getattr(n, "sym:symtab");
}
assert(n);
hsym = n;
}
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0) {
String *nname = NewString(cname + 2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc);
} else {
s = symbol_lookup(nname, global_scope, checkfunc);
}
Delete(nname);
} else {
s = symbol_lookup_qualified(name, hsym, 0, 0, checkfunc);
}
}
if (!s) {
s = symbol_lookup(name, hsym, checkfunc);
}
if (!s)
return 0;
/* Check if s is a 'using' node */
while (s && Checkattr(s, "nodeType", "using")) {
Node *ss = Swig_symbol_clookup_local_check(Getattr(s, "uname"), Getattr(s, "sym:symtab"), checkfunc);
if (!ss && !checkfunc) {
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
}
s = ss;
}
return s;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_clookup_no_inherit()
*
* Symbol lookup like Swig_symbol_clookup but does not follow using declarations.
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_clookup_no_inherit(const_String_or_char_ptr name, Symtab *n) {
Node *s = 0;
assert(use_inherit==1);
use_inherit = 0;
s = Swig_symbol_clookup(name, n);
use_inherit = 1;
return s;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_cscope()
*
* Look up a scope name.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0)
return symbol_lookup_qualified(0, global_scope, name, 0, 0);
return symbol_lookup_qualified(0, symtab, name, 0, 0);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_remove()
*
* Remove a symbol. If the symbol is an overloaded function and the symbol removed
* is not the last in the list of overloaded functions, then the overloaded
* names (sym:overname attribute) are changed to start from zero, eg __SWIG_0.
* ----------------------------------------------------------------------------- */
void Swig_symbol_remove(Node *n) {
Symtab *symtab;
String *symname;
String *overname;
Node *symprev;
Node *symnext;
Node *fixovername = 0;
symtab = Getattr(n, "sym:symtab"); /* Get symbol table object */
symtab = Getattr(symtab, "symtab"); /* Get actual hash table of symbols */
symname = Getattr(n, "sym:name");
symprev = Getattr(n, "sym:previousSibling");
symnext = Getattr(n, "sym:nextSibling");
/* If previous symbol, just fix the links */
if (symprev) {
if (symnext) {
Setattr(symprev, "sym:nextSibling", symnext);
fixovername = symprev; /* fix as symbol to remove is somewhere in the middle of the linked list */
} else {
Delattr(symprev, "sym:nextSibling");
}
} else {
/* If no previous symbol, see if there is a next symbol */
if (symnext) {
Setattr(symtab, symname, symnext);
fixovername = symnext; /* fix as symbol to remove is at head of linked list */
} else {
if (symname)
Delattr(symtab, symname);
}
}
if (symnext) {
if (symprev) {
Setattr(symnext, "sym:previousSibling", symprev);
} else {
Delattr(symnext, "sym:previousSibling");
}
}
Delattr(n, "sym:symtab");
Delattr(n, "sym:previousSibling");
Delattr(n, "sym:nextSibling");
Delattr(n, "csym:nextSibling");
Delattr(n, "sym:overname");
Delattr(n, "csym:previousSibling");
Delattr(n, "sym:overloaded");
n = 0;
if (fixovername) {
Node *nn = fixovername;
Node *head = fixovername;
int pn = 0;
/* find head of linked list */
while (nn) {
head = nn;
nn = Getattr(nn, "sym:previousSibling");
}
/* adjust all the sym:overname strings to start from 0 and increment by one */
nn = head;
while (nn) {
assert(Getattr(nn, "sym:overname"));
Delattr(nn, "sym:overname");
overname = NewStringf("__SWIG_%d", pn);
Setattr(nn, "sym:overname", overname);
Delete(overname);
pn++;
nn = Getattr(nn, "sym:nextSibling");
}
}
}
/* -----------------------------------------------------------------------------
* Swig_symbol_qualified()
*
* Return the qualified name of a symbol
* ----------------------------------------------------------------------------- */
String *Swig_symbol_qualified(Node *n) {
Hash *symtab;
if (Checkattr(n, "nodeType", "symboltable")) {
symtab = n;
} else {
symtab = Getattr(n, "sym:symtab");
}
if (!symtab)
return NewStringEmpty();
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_qscope %s %p %s\n", Getattr(n, "name"), symtab, Getattr(symtab, "name"));
#endif
return Swig_symbol_qualifiedscopename(symtab);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_isoverloaded()
*
* Check if a symbol is overloaded. Returns the first symbol if so.
* ----------------------------------------------------------------------------- */
Node *Swig_symbol_isoverloaded(Node *n) {
return Getattr(n, "sym:overloaded");
}
/* -----------------------------------------------------------------------------
* symbol_template_qualify()
*
* Internal function to create a fully qualified type name for templates
* ----------------------------------------------------------------------------- */
/* This cache produces problems with OSS, don't active it */
/* #define SWIG_TEMPLATE_QUALIFY_CACHE */
static SwigType *symbol_template_qualify(const SwigType *e, Symtab *st) {
String *tprefix, *tsuffix;
SwigType *qprefix;
List *targs;
Node *tempn;
Symtab *tscope;
Iterator ti;
#ifdef SWIG_TEMPLATE_QUALIFY_CACHE
static Hash *qualify_cache = 0;
String *scopetype = st ? NewStringf("%s::%s", Getattr(st, "name"), e)
: NewStringf("%s::%s", Swig_symbol_getscopename(), e);
if (!qualify_cache) {
qualify_cache = NewHash();
}
if (scopetype) {
String *cres = Getattr(qualify_cache, scopetype);
if (cres) {
Delete(scopetype);
return Copy(cres);
}
}
#endif
tprefix = SwigType_templateprefix(e);
tsuffix = SwigType_templatesuffix(e);
qprefix = Swig_symbol_type_qualify(tprefix, st);
targs = SwigType_parmlist(e);
tempn = Swig_symbol_clookup_local(tprefix, st);
tscope = tempn ? Getattr(tempn, "sym:symtab") : 0;
Append(qprefix, "<(");
for (ti = First(targs); ti.item;) {
String *vparm;
String *qparm = Swig_symbol_type_qualify(ti.item, st);
if (tscope && (tscope != st)) {
String *ty = Swig_symbol_type_qualify(qparm, tscope);
Delete(qparm);
qparm = ty;
}
vparm = Swig_symbol_template_param_eval(qparm, st);
Append(qprefix, vparm);
ti = Next(ti);
if (ti.item) {
Putc(',', qprefix);
}
Delete(qparm);
Delete(vparm);
}
Append(qprefix, ")>");
Append(qprefix, tsuffix);
Delete(tprefix);
Delete(tsuffix);
Delete(targs);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_temp_qual %s %s\n", e, qprefix);
#endif
#ifdef SWIG_TEMPLATE_QUALIFY_CACHE
Setattr(qualify_cache, scopetype, qprefix);
Delete(scopetype);
#endif
return qprefix;
}
static int symbol_no_constructor(Node *n) {
return !Checkattr(n, "nodeType", "constructor");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_type_qualify()
*
* Create a fully qualified type name
* Note: Does not resolve a constructor if passed in as the 'type'.
* ----------------------------------------------------------------------------- */
SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
List *elements;
String *result = NewStringEmpty();
int i, len;
char *c = Char(t);
if (strncmp(c, "::", 2) == 0) {
Append(result, t);
return result;
}
elements = SwigType_split(t);
len = Len(elements);
for (i = 0; i < len; i++) {
String *e = Getitem(elements, i);
if (SwigType_issimple(e)) {
/* Note: the unary scope operator (::) is being removed from the template parameters here. */
Node *n = Swig_symbol_clookup_check(e, st, symbol_no_constructor);
if (n) {
String *name = Getattr(n, "name");
Clear(e);
Append(e, name);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_qual_ei %d %s %s %p\n", i, name, e, st);
#endif
if (!Swig_scopename_check(name)) {
String *qname = Swig_symbol_qualified(n);
if (qname && Len(qname)) {
Insert(e, 0, "::");
Insert(e, 0, qname);
}
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_qual_sc %d %s %s %p\n", i, qname, e, st);
#endif
Delete(qname);
}
} else if (SwigType_istemplate(e)) {
SwigType *ty = symbol_template_qualify(e, st);
Clear(e);
Append(e, ty);
Delete(ty);
}
if (strncmp(Char(e), "::", 2) == 0) {
Delitem(e, 0);
Delitem(e, 0);
}
Append(result, e);
} else if (SwigType_isfunction(e)) {
List *parms = SwigType_parmlist(e);
String *s = NewString("f(");
Iterator pi = First(parms);
while (pi.item) {
String *pf = Swig_symbol_type_qualify(pi.item, st);
Append(s, pf);
pi = Next(pi);
if (pi.item) {
Append(s, ",");
}
Delete(pf);
}
Append(s, ").");
Append(result, s);
Delete(parms);
Delete(s);
} else {
Append(result, e);
}
}
Delete(elements);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_qualify %s %s %p %s\n", t, result, st, st ? Getattr(st, "name") : 0);
#endif
return result;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_template_reduce()
* Resolves template parameter types
* For example:
* typedef int Int;
* typedef Int Integer;
* with input:
* Foo<(Int,Integer)>
* returns:
* Foo<(int,int)>
* ----------------------------------------------------------------------------- */
static
SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
Parm *p;
String *templateargs = SwigType_templateargs(qt);
List *parms = SwigType_parmlist(templateargs);
Iterator pi = First(parms);
String *tprefix = SwigType_templateprefix(qt);
String *tsuffix = SwigType_templatesuffix(qt);
String *qprefix = SwigType_typedef_qualified(tprefix);
Append(qprefix, "<(");
while ((p = pi.item)) {
String *np;
String *tp = Swig_symbol_typedef_reduce(p, ntab);
String *qp = Swig_symbol_type_qualify(tp, ntab);
Node *n = Swig_symbol_clookup(qp, ntab);
if (n) {
String *qual = Swig_symbol_qualified(n);
np = Copy(Getattr(n, "name"));
Delete(tp);
tp = np;
if (qual && Len(qual)) {
Insert(np, 0, "::");
Insert(np, 0, qual);
}
Delete(qual);
} else {
np = qp;
}
Append(qprefix, np);
pi = Next(pi);
if (pi.item) {
Append(qprefix, ",");
}
Delete(qp);
Delete(tp);
}
Append(qprefix, ")>");
Append(qprefix, tsuffix);
Delete(parms);
Delete(tprefix);
Delete(tsuffix);
Delete(templateargs);
return qprefix;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_typedef_reduce()
*
* Chase a typedef through symbol tables looking for a match.
* ----------------------------------------------------------------------------- */
SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
SwigType *prefix, *base;
Node *n;
String *nt;
base = SwigType_base(ty);
prefix = SwigType_prefix(ty);
n = Swig_symbol_clookup(base, tab);
if (!n) {
if (SwigType_istemplate(ty)) {
SwigType *qt = Swig_symbol_template_reduce(base, tab);
Append(prefix, qt);
Delete(qt);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_reduce (a) %s %s\n", ty, prefix);
#endif
Delete(base);
return prefix;
} else {
Delete(prefix);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_reduce (b) %s %s\n", ty, ty);
#endif
return Copy(ty);
}
}
nt = Getattr(n, "nodeType");
if (Equal(nt, "using")) {
String *uname = Getattr(n, "uname");
if (uname) {
n = Swig_symbol_clookup(base, Getattr(n, "sym:symtab"));
if (!n) {
Delete(base);
Delete(prefix);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_reduce (c) %s %s\n", ty, ty);
#endif
return Copy(ty);
}
}
}
if (Equal(nt, "cdecl")) {
String *storage = Getattr(n, "storage");
if (storage && (Equal(storage, "typedef"))) {
SwigType *decl;
SwigType *rt;
SwigType *qt;
Symtab *ntab;
SwigType *nt = Copy(Getattr(n, "type"));
/* Fix for case 'typedef struct Hello hello;' */
{
const char *dclass[3] = { "struct ", "union ", "class " };
int i;
char *c = Char(nt);
for (i = 0; i < 3; i++) {
if (strstr(c, dclass[i]) == c) {
Replace(nt, dclass[i], "", DOH_REPLACE_FIRST);
}
}
}
decl = Getattr(n, "decl");
if (decl) {
SwigType_push(nt, decl);
}
SwigType_push(nt, prefix);
Delete(base);
Delete(prefix);
ntab = Getattr(n, "sym:symtab");
rt = Swig_symbol_typedef_reduce(nt, ntab);
qt = Swig_symbol_type_qualify(rt, ntab);
if (SwigType_istemplate(qt)) {
SwigType *qtr = Swig_symbol_template_reduce(qt, ntab);
Delete(qt);
qt = qtr;
}
Delete(nt);
Delete(rt);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_reduce (d) %s %s\n", qt, ty);
#endif
return qt;
}
}
Delete(base);
Delete(prefix);
#ifdef SWIG_DEBUG
Printf(stderr, "symbol_reduce (e) %s %s\n", ty, ty);
#endif
return Copy(ty);
}
/* -----------------------------------------------------------------------------
* Swig_symbol_string_qualify()
*
* This function takes a string and looks for identifiers. Identifiers are
* then qualified according to scope rules. This function is used in a number
* of settings including expression evaluation, scoping of conversion operators,
* and so forth.
* ----------------------------------------------------------------------------- */
String *Swig_symbol_string_qualify(String *s, Symtab *st) {
int have_id = 0;
String *id = NewStringEmpty();
String *r = NewStringEmpty();
char *c = Char(s);
int first_char = 1;
while (*c) {
if (isalpha((int) *c) || (*c == '_') || (*c == ':') || (*c == '~' && first_char) || (isdigit((int) *c) && !first_char)) {
Putc(*c, id);
have_id = 1;
} else {
if (have_id) {
String *qid = Swig_symbol_type_qualify(id, st);
Append(r, qid);
Clear(id);
Delete(qid);
have_id = 0;
}
Putc(*c, r);
}
first_char = (*c == ':');
c++;
}
if (have_id) {
String *qid = Swig_symbol_type_qualify(id, st);
Append(r, qid);
Delete(qid);
}
Delete(id);
return r;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_template_defargs()
*
* Apply default arg from generic template default args
* Returns a parameter list which contains missing default arguments (if any)
* Note side effects: parms will also contain the extra parameters in its list
* (but only if non-zero).
* ----------------------------------------------------------------------------- */
ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl) {
ParmList *expandedparms = parms;
if (Len(parms) < Len(targs)) {
Parm *lp = parms;
Parm *p = lp;
Parm *tp = targs;
while (p && tp) {
p = nextSibling(p);
tp = nextSibling(tp);
if (p)
lp = p;
}
while (tp) {
String *value = Getattr(tp, "value");
if (value) {
Parm *cp;
Parm *ta = targs;
Parm *p = parms;
SwigType *nt = Swig_symbol_string_qualify(value, tsdecl);
SwigType *ntq = 0;
#ifdef SWIG_DEBUG
Printf(stderr, "value %s %s %s\n", value, nt, tsdecl ? Getattr(tsdecl, "name") : tsdecl);
#endif
while (p && ta) {
String *name = Getattr(ta, "name");
String *pvalue = Getattr(p, "value");
String *value = pvalue ? pvalue : Getattr(p, "type");
String *ttq = Swig_symbol_type_qualify(value, tscope);
/* value = SwigType_typedef_resolve_all(value); */
Replaceid(nt, name, ttq);
p = nextSibling(p);
ta = nextSibling(ta);
Delete(ttq);
}
ntq = Swig_symbol_type_qualify(nt, tsdecl);
if (SwigType_istemplate(ntq)) {
String *ty = Swig_symbol_template_deftype(ntq, tscope);
Delete(ntq);
ntq = ty;
}
cp = NewParmWithoutFileLineInfo(ntq, 0);
if (lp) {
set_nextSibling(lp, cp);
Delete(cp);
} else {
expandedparms = cp;
}
lp = cp;
tp = nextSibling(tp);
Delete(nt);
Delete(ntq);
} else {
tp = 0;
}
}
}
return expandedparms;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_template_deftype()
*
* Apply default args to generic template type
* ----------------------------------------------------------------------------- */
#define SWIG_TEMPLATE_DEFTYPE_CACHE
SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
String *result = NewStringEmpty();
List *elements = SwigType_split(type);
int len = Len(elements);
int i;
#ifdef SWIG_TEMPLATE_DEFTYPE_CACHE
static Hash *s_cache = 0;
Hash *scope_cache;
/* The lookup depends on the current scope and potential namespace qualification.
Looking up x in namespace y is not the same as looking up x::y in outer scope.
-> we use a 2-level hash: first scope and then symbol. */
String *scope_name = tscope
? Swig_symbol_qualifiedscopename(tscope)
: Swig_symbol_qualifiedscopename(current_symtab);
String *type_name = tscope
? NewStringf("%s::%s", Getattr(tscope, "name"), type)
: NewStringf("%s::%s", Swig_symbol_getscopename(), type);
if (!scope_name) scope_name = NewString("::");
if (!s_cache) {
s_cache = NewHash();
}
scope_cache = Getattr(s_cache, scope_name);
if (scope_cache) {
String *cres = Getattr(scope_cache, type_name);
if (cres) {
Append(result, cres);
#ifdef SWIG_DEBUG
Printf(stderr, "cached deftype %s(%s) -> %s\n", type, scope_name, result);
#endif
Delete(type_name);
Delete(scope_name);
return result;
}
} else {
scope_cache = NewHash();
Setattr(s_cache, scope_name, scope_cache);
Delete(scope_name);
}
#endif
#ifdef SWIG_DEBUG
Printf(stderr, "finding deftype %s\n", type);
#endif
for (i = 0; i < len; i++) {
String *e = Getitem(elements, i);
if (SwigType_isfunction(e)) {
String *s = NewString("f(");
List *parms = SwigType_parmlist(e);
Iterator pi = First(parms);
while (pi.item) {
String *pf = SwigType_istemplate(e) ? Swig_symbol_template_deftype(pi.item, tscope)
: Swig_symbol_type_qualify(pi.item, tscope);
Append(s, pf);
pi = Next(pi);
if (pi.item) {
Append(s, ",");
}
Delete(pf);
}
Append(s, ").");
Append(result, s);
Delete(s);
Delete(parms);
} else if (SwigType_istemplate(e)) {
String *prefix = SwigType_prefix(e);
String *base = SwigType_base(e);
String *tprefix = SwigType_templateprefix(base);
String *targs = SwigType_templateargs(base);
String *tsuffix = SwigType_templatesuffix(base);
ParmList *tparms = SwigType_function_parms(targs, 0);
Node *tempn = Swig_symbol_clookup_local(tprefix, tscope);
if (!tempn && tsuffix && Len(tsuffix)) {
tempn = Swig_symbol_clookup(tprefix, 0);
}
#ifdef SWIG_DEBUG
Printf(stderr, "deftype type %s %s %d\n", e, tprefix, (long) tempn);
#endif
if (tempn) {
ParmList *tnargs = Getattr(tempn, "templateparms");
ParmList *expandedparms;
Parm *p;
Symtab *tsdecl = Getattr(tempn, "sym:symtab");
#ifdef SWIG_DEBUG
Printf(stderr, "deftype type %s %s %s\n", tprefix, targs, tsuffix);
#endif
Append(tprefix, "<(");
expandedparms = Swig_symbol_template_defargs(tparms, tnargs, tscope, tsdecl);
p = expandedparms;
tscope = tsdecl;
while (p) {
SwigType *ptype = Getattr(p, "type");
SwigType *ttr = ptype ? ptype : Getattr(p, "value");
SwigType *ttf = Swig_symbol_type_qualify(ttr, tscope);
SwigType *ttq = Swig_symbol_template_param_eval(ttf, tscope);
#ifdef SWIG_DEBUG
Printf(stderr, "arg type %s\n", ttq);
#endif
if (SwigType_istemplate(ttq)) {
SwigType *ttd = Swig_symbol_template_deftype(ttq, tscope);
Delete(ttq);
ttq = ttd;
#ifdef SWIG_DEBUG
Printf(stderr, "arg deftype %s\n", ttq);
#endif
}
Append(tprefix, ttq);
p = nextSibling(p);
if (p)
Putc(',', tprefix);
Delete(ttf);
Delete(ttq);
}
Append(tprefix, ")>");
Append(tprefix, tsuffix);
Append(prefix, tprefix);
#ifdef SWIG_DEBUG
Printf(stderr, "deftype %s %s \n", type, tprefix);
#endif
Append(result, prefix);
} else {
Append(result, e);
}
Delete(prefix);
Delete(base);
Delete(tprefix);
Delete(tsuffix);
Delete(targs);
Delete(tparms);
} else {
Append(result, e);
}
}
Delete(elements);
#ifdef SWIG_TEMPLATE_DEFTYPE_CACHE
Setattr(scope_cache, type_name, result);
Delete(type_name);
#endif
return result;
}
SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab) {
String *value = Copy(p);
Node *lastnode = 0;
while (1) {
Node *n = Swig_symbol_clookup(value, symtab);
if (n == lastnode)
break;
lastnode = n;
if (n) {
String *nt = Getattr(n, "nodeType");
if (Equal(nt, "enumitem")) {
/* An enum item. Generate a fully qualified name */
String *qn = Swig_symbol_qualified(n);
if (qn && Len(qn)) {
Append(qn, "::");
Append(qn, Getattr(n, "name"));
Delete(value);
value = qn;
continue;
} else {
Delete(qn);
break;
}
} else if ((Equal(nt, "cdecl"))) {
String *nv = Getattr(n, "value");
if (nv) {
Delete(value);
value = Copy(nv);
continue;
}
}
}
break;
}
return value;
}
|