9
9
* See the file LICENSE for information on usage and redistribution.
10
10
* ----------------------------------------------------------------------------- */
12
char cvsroot_symbol_c[] = "$Header: /cvsroot/SWIG/Source/Swig/symbol.c,v 1.7 2003/09/11 20:26:57 beazley Exp $";
12
char cvsroot_symbol_c[] = "$Header: /cvsroot/swig/SWIG/Source/Swig/symbol.c,v 1.10 2004/04/09 19:23:01 cheetah Exp $";
15
15
#include "swigwarn.h"
115
115
* These names are modeled after XML namespaces. In particular, every attribute
116
116
* pertaining to symbol table management is prefaced by the "sym:" prefix.
118
* An example dump of the parse tree showing symbol table entries for the
119
* following code should clarify this:
121
* namespace OuterNamespace {
122
* namespace InnerNamespace {
131
* +++ namespace ----------------------------------------
132
* | sym:name - "OuterNamespace"
133
* | symtab - 0xa064bf0
134
* | sym:symtab - 0xa041690
135
* | sym:overname - "__SWIG_0"
137
* +++ namespace ----------------------------------------
138
* | sym:name - "InnerNamespace"
139
* | symtab - 0xa064cc0
140
* | sym:symtab - 0xa064bf0
141
* | sym:overname - "__SWIG_0"
143
* +++ class ----------------------------------------
144
* | sym:name - "Class"
145
* | symtab - 0xa064d80
146
* | sym:symtab - 0xa064cc0
147
* | sym:overname - "__SWIG_0"
149
* +++ class ----------------------------------------
150
* | sym:name - "Struct"
151
* | symtab - 0xa064f00
152
* | sym:symtab - 0xa064cc0
153
* | sym:overname - "__SWIG_0"
155
* +++ cdecl ----------------------------------------
157
* | sym:symtab - 0xa064f00
158
* | sym:overname - "__SWIG_0"
162
* Each class and namespace has its own scope and thus a new symbol table (sym)
163
* is created. The sym attribute is only set for the first entry in the symbol
164
* table. The sym:symtab entry points to the symbol table in which the symbol
165
* exists, so for example, Struct is in the scope OuterNamespace::InnerNamespace
166
* so sym:symtab points to this symbol table (0xa064cc0).
117
168
* ----------------------------------------------------------------------------- */
119
170
static Hash *current = 0; /* The current symbol table hash */
122
173
static Hash *symtabs = 0; /* Hash of all symbol tables by fully-qualified name */
123
174
static Hash *global_scope = 0; /* Global scope */
178
Swig_symbol_dump_symtable() {
179
Printf(stdout, "DUMPING SYMTABLE start =======================================\n");
181
Hash* cst = Getattr(current_symtab, "csymtab");
182
Swig_print_tree(cst);
183
Printf(stdout, "DUMPING SYMTABLE middle =======================================\n");
184
Swig_print_tree(Getattr(cst, "NumSpace"));
186
Printf(stdout, "DUMPING SYMTABLE end =======================================\n");
125
190
/* -----------------------------------------------------------------------------
126
191
* Swig_symbol_new()
383
448
Setattr(ccurrent,name,n);
385
450
} else if (cn && (Strcmp(nodeType(cn),"templateparm") == 0)) {
386
Swig_error(Getfile(n),Getline(n),"Error. Declaration of '%s' shadows template parameter at %s:%d\n",
387
name,Getfile(cn),Getline(cn));
451
Swig_error(Getfile(n),Getline(n),
452
"Declaration of '%s' shadows template parameter,\n",
454
Swig_error(Getfile(cn),Getline(cn),
455
"previous template parameter declaration '%s'.\n",
648
717
/* -----------------------------------------------------------------------------
649
* symbol_lookup_qualified()
651
720
* Internal function to handle fully qualified symbol table lookups. This
652
721
* works from the symbol table supplied in symtab and unwinds its way out
776
/* -----------------------------------------------------------------------------
777
* symbol_lookup_qualified()
778
* ----------------------------------------------------------------------------- */
708
781
symbol_lookup_qualified(String_or_char *name, Symtab *symtab, String *prefix, int local, int (*checkfunc)(Node *n)) {
709
782
/* This is a little funky, we search by fully qualified names */
960
/* -----------------------------------------------------------------------------
961
* Swig_symbol_clookup_local()
962
* ----------------------------------------------------------------------------- */
888
965
Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
1003
/* -----------------------------------------------------------------------------
1004
* Swig_symbol_clookup_local_check()
1005
* ----------------------------------------------------------------------------- */
928
1008
Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc)(Node *)) {
1025
1105
Delattr(n,"sym:overloaded");
1029
1109
symtab = Getattr(n,"sym:symtab"); /* Get symbol table object */
1030
1110
symtab = Getattr(symtab,"csymtab"); /* Get actual hash table of symbols */
1031
1111
symprev = Getattr(n,"csym:previousSibling");