From cb963a14401b05af36a58a2b76eba3f368354ffd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Feb 2022 13:30:58 +0000 Subject: [PATCH] Using declarations fix in symbol tables Implementation is very similar to typedef implementation. Issue #655 and closes #1488. Testcase using_member.i. Better implementation to that reverted in previous commit 3f36157b. Symbol tables shown with -debug-csymbols and -debug-symbols now correct and are similar to when using a typedef. --- Source/Swig/symbol.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index aacaf24be..74b4c698d 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -641,10 +641,11 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { { Node *td = n; - while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) { + while (td && ((Equal(nodeType(td), "cdecl") && Checkattr(td, "storage", "typedef")) || (Equal(nodeType(td), "using") && !Getattr(n, "namespace")))) { SwigType *type; Node *td1; - type = Copy(Getattr(td, "type")); + int using_not_typedef = Equal(nodeType(td), "using"); + type = Copy(Getattr(td, using_not_typedef ? "uname" : "type")); SwigType_push(type, Getattr(td, "decl")); td1 = Swig_symbol_clookup(type, 0); @@ -665,9 +666,13 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { ie, when Foo -> FooBar -> Foo, jump one scope up when possible. */ - if (td1 && Checkattr(td1, "storage", "typedef")) { - String *st = Getattr(td1, "type"); + if (td1) { + String *st = 0; String *sn = Getattr(td, "name"); + if (Equal(nodeType(td1), "cdecl") && Checkattr(td1, "storage", "typedef")) + st = Getattr(td1, "type"); + else if (Equal(nodeType(td1), "using") && !Getattr(td1, "namespace")) + st = Getattr(td1, "uname"); if (st && sn && Equal(st, sn)) { Symtab *sc = Getattr(current_symtab, "parentNode"); if (sc)