~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Source/Swig/symbol.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2005-01-10 09:48:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050110094852-axi555axhj1brbwq
Tags: 1.3.22-5ubuntu2
Build using python2.4 and pike7.6. Closes: #4146.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 * See the file LICENSE for information on usage and redistribution.
10
10
 * ----------------------------------------------------------------------------- */
11
11
 
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 $";
13
13
 
14
14
#include "swig.h"
15
15
#include "swigwarn.h"
114
114
 *
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.   
 
117
 *
 
118
 * An example dump of the parse tree showing symbol table entries for the 
 
119
 * following code should clarify this:
 
120
 *
 
121
 *   namespace OuterNamespace {
 
122
 *       namespace InnerNamespace {
 
123
 *           class Class {
 
124
 *           };
 
125
 *           struct Struct {
 
126
 *               int Var;
 
127
 *           };
 
128
 *       }
 
129
 *    }
 
130
 *
 
131
 *   +++ namespace ----------------------------------------
 
132
 *   | sym:name     - "OuterNamespace"
 
133
 *   | symtab       - 0xa064bf0
 
134
 *   | sym:symtab   - 0xa041690
 
135
 *   | sym:overname - "__SWIG_0"
 
136
 *  
 
137
 *         +++ namespace ----------------------------------------
 
138
 *         | sym:name     - "InnerNamespace"
 
139
 *         | symtab       - 0xa064cc0
 
140
 *         | sym:symtab   - 0xa064bf0
 
141
 *         | sym:overname - "__SWIG_0"
 
142
 *  
 
143
 *               +++ class ----------------------------------------
 
144
 *               | sym:name     - "Class"
 
145
 *               | symtab       - 0xa064d80
 
146
 *               | sym:symtab   - 0xa064cc0
 
147
 *               | sym:overname - "__SWIG_0"
 
148
 *               | 
 
149
 *               +++ class ----------------------------------------
 
150
 *               | sym:name     - "Struct"
 
151
 *               | symtab       - 0xa064f00
 
152
 *               | sym:symtab   - 0xa064cc0
 
153
 *               | sym:overname - "__SWIG_0"
 
154
 *  
 
155
 *                     +++ cdecl ----------------------------------------
 
156
 *                     | sym:name     - "Var"
 
157
 *                     | sym:symtab   - 0xa064f00
 
158
 *                     | sym:overname - "__SWIG_0"
 
159
 *                     | 
 
160
 *  
 
161
 *
 
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).
 
167
 *
117
168
 * ----------------------------------------------------------------------------- */
118
169
     
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 */
124
175
 
 
176
#if 0
 
177
void
 
178
Swig_symbol_dump_symtable() {
 
179
  Printf(stdout, "DUMPING SYMTABLE start =======================================\n");
 
180
  {
 
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"));
 
185
  }
 
186
  Printf(stdout, "DUMPING SYMTABLE end =======================================\n");
 
187
}
 
188
#endif
 
189
 
125
190
/* -----------------------------------------------------------------------------
126
191
 * Swig_symbol_new()
127
192
 *
383
448
    Setattr(ccurrent,name,n);
384
449
    append = cn;
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",
 
453
               name);
 
454
    Swig_error(Getfile(cn),Getline(cn),
 
455
               "previous template parameter declaration '%s'.\n",
 
456
               name);
388
457
    return;
389
458
  } else if (cn) {
390
459
    append = n;
646
715
}
647
716
 
648
717
/* -----------------------------------------------------------------------------
649
 
 * symbol_lookup_qualified()
 
718
 * symbol_lookup()
650
719
 *
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
704
773
  return 0;
705
774
}
706
775
 
 
776
/* -----------------------------------------------------------------------------
 
777
 * symbol_lookup_qualified()
 
778
 * ----------------------------------------------------------------------------- */
 
779
 
707
780
static Node *
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 */
884
957
  return s;
885
958
}
886
959
 
 
960
/* -----------------------------------------------------------------------------
 
961
 * Swig_symbol_clookup_local()
 
962
 * ----------------------------------------------------------------------------- */
 
963
 
887
964
Node *
888
965
Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
889
966
  Hash *h, *hsym;
923
1000
  return s;
924
1001
}
925
1002
 
 
1003
/* -----------------------------------------------------------------------------
 
1004
 * Swig_symbol_clookup_local_check()
 
1005
 * ----------------------------------------------------------------------------- */
926
1006
 
927
1007
Node *
928
1008
Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc)(Node *)) {
1025
1105
  Delattr(n,"sym:overloaded");
1026
1106
  return;
1027
1107
 
1028
 
 
 
1108
#if 0
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");
1050
1130
  Delattr(n,"sym:symtab");
1051
1131
  Delattr(n,"csym:previousSibling");
1052
1132
  Delattr(n,"csym:nextSibling");
1053
 
 
 
1133
#endif
1054
1134
}
1055
1135
 
1056
1136
/* -----------------------------------------------------------------------------