12
12
* ----------------------------------------------------------------------------- */
13
13
14
14
#include "swig.h"
15
- #include "swigwarn .h"
15
+ #include "cparse .h"
16
16
#include <ctype.h>
17
17
18
18
/* #define SWIG_DEBUG*/
@@ -382,29 +382,6 @@ String *Swig_symbol_qualified_language_scopename(Symtab *n) {
382
382
return result ;
383
383
}
384
384
385
- /* -----------------------------------------------------------------------------
386
- * Swig_symbol_add_using()
387
- *
388
- * Adds a node to the C symbol table for a using declaration.
389
- * Used for using-declarations within classes/structs.
390
- * ----------------------------------------------------------------------------- */
391
-
392
- void Swig_symbol_add_using (String * name , String * uname , Node * n ) {
393
- Hash * h ;
394
- h = Swig_symbol_clookup (uname , 0 );
395
- if (h && (checkAttribute (h , "kind" , "class" ) || checkAttribute (h , "kind" , "struct" ))) {
396
- String * qcurrent = Swig_symbol_qualifiedscopename (0 );
397
- if (qcurrent ) {
398
- Append (qcurrent , "::" );
399
- Append (qcurrent , name );
400
- } else {
401
- qcurrent = NewString (name );
402
- }
403
- Setattr (symtabs , qcurrent , n );
404
- Delete (qcurrent );
405
- }
406
- }
407
-
408
385
/* -----------------------------------------------------------------------------
409
386
* Swig_symbol_newscope()
410
387
*
@@ -664,10 +641,11 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
664
641
665
642
{
666
643
Node * td = n ;
667
- while (td && Checkattr ( td , "nodeType" , " cdecl" ) && Checkattr (td , "storage" , "typedef" )) {
644
+ while (td && (( Equal ( nodeType ( td ) , "cdecl" ) && Checkattr (td , "storage" , "typedef" )) || ( Equal ( nodeType ( td ), "using" ) && ! Getattr ( n , "namespace" )) )) {
668
645
SwigType * type ;
669
646
Node * td1 ;
670
- type = Copy (Getattr (td , "type" ));
647
+ int using_not_typedef = Equal (nodeType (td ), "using" );
648
+ type = Copy (Getattr (td , using_not_typedef ? "uname" : "type" ));
671
649
SwigType_push (type , Getattr (td , "decl" ));
672
650
td1 = Swig_symbol_clookup (type , 0 );
673
651
@@ -688,9 +666,13 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
688
666
ie, when Foo -> FooBar -> Foo, jump one scope up when possible.
689
667
690
668
*/
691
- if (td1 && Checkattr ( td1 , "storage" , "typedef" ) ) {
692
- String * st = Getattr ( td1 , "type" ) ;
669
+ if (td1 ) {
670
+ String * st = 0 ;
693
671
String * sn = Getattr (td , "name" );
672
+ if (Equal (nodeType (td1 ), "cdecl" ) && Checkattr (td1 , "storage" , "typedef" ))
673
+ st = Getattr (td1 , "type" );
674
+ else if (Equal (nodeType (td1 ), "using" ) && !Getattr (td1 , "namespace" ))
675
+ st = Getattr (td1 , "uname" );
694
676
if (st && sn && Equal (st , sn )) {
695
677
Symtab * sc = Getattr (current_symtab , "parentNode" );
696
678
if (sc )
@@ -1097,19 +1079,7 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt
1097
1079
Delete (qalloc );
1098
1080
return st ;
1099
1081
}
1100
- if (checkAttribute (st , "nodeType" , "using" )) {
1101
- String * uname = Getattr (st , "uname" );
1102
- if (uname ) {
1103
- st = Getattr (symtabs , uname );
1104
- if (st ) {
1105
- n = symbol_lookup (name , st , checkfunc );
1106
- } else {
1107
- fprintf (stderr , "Error: Found corrupt 'using' node\n" );
1108
- }
1109
- }
1110
- } else if (Getattr (st , "csymtab" )) {
1111
- n = symbol_lookup (name , st , checkfunc );
1112
- }
1082
+ n = symbol_lookup (name , st , checkfunc );
1113
1083
}
1114
1084
if (qalloc )
1115
1085
Delete (qalloc );
@@ -1212,7 +1182,9 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
1212
1182
Symtab * un = Getattr (s , "sym:symtab" );
1213
1183
Node * ss = (!Equal (name , uname ) || (un != n )) ? Swig_symbol_clookup (uname , un ) : 0 ; /* avoid infinity loop */
1214
1184
if (!ss ) {
1185
+ SWIG_WARN_NODE_BEGIN (s );
1215
1186
Swig_warning (WARN_PARSE_USING_UNDEF , Getfile (s ), Getline (s ), "Nothing known about '%s'.\n" , SwigType_namestr (Getattr (s , "uname" )));
1187
+ SWIG_WARN_NODE_END (s );
1216
1188
}
1217
1189
s = ss ;
1218
1190
}
@@ -1284,7 +1256,9 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
1284
1256
Node * ss ;
1285
1257
ss = Swig_symbol_clookup (Getattr (s , "uname" ), Getattr (s , "sym:symtab" ));
1286
1258
if (!ss && !checkfunc ) {
1259
+ SWIG_WARN_NODE_BEGIN (s );
1287
1260
Swig_warning (WARN_PARSE_USING_UNDEF , Getfile (s ), Getline (s ), "Nothing known about '%s'.\n" , SwigType_namestr (Getattr (s , "uname" )));
1261
+ SWIG_WARN_NODE_END (s );
1288
1262
}
1289
1263
s = ss ;
1290
1264
}
@@ -1335,7 +1309,9 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
1335
1309
while (s && Checkattr (s , "nodeType" , "using" )) {
1336
1310
Node * ss = Swig_symbol_clookup_local (Getattr (s , "uname" ), Getattr (s , "sym:symtab" ));
1337
1311
if (!ss ) {
1312
+ SWIG_WARN_NODE_BEGIN (s );
1338
1313
Swig_warning (WARN_PARSE_USING_UNDEF , Getfile (s ), Getline (s ), "Nothing known about '%s'.\n" , SwigType_namestr (Getattr (s , "uname" )));
1314
+ SWIG_WARN_NODE_END (s );
1339
1315
}
1340
1316
s = ss ;
1341
1317
}
@@ -1383,7 +1359,9 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
1383
1359
while (s && Checkattr (s , "nodeType" , "using" )) {
1384
1360
Node * ss = Swig_symbol_clookup_local_check (Getattr (s , "uname" ), Getattr (s , "sym:symtab" ), checkfunc );
1385
1361
if (!ss && !checkfunc ) {
1362
+ SWIG_WARN_NODE_BEGIN (s );
1386
1363
Swig_warning (WARN_PARSE_USING_UNDEF , Getfile (s ), Getline (s ), "Nothing known about '%s'.\n" , SwigType_namestr (Getattr (s , "uname" )));
1364
+ SWIG_WARN_NODE_END (s );
1387
1365
}
1388
1366
s = ss ;
1389
1367
}
0 commit comments