From 4138222abddecfd8a4ff65b35e0f3584cb94126f Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Thu, 20 Mar 2003 19:36:51 +0000 Subject: [PATCH] Fixed odd class scope bug. class Foo { public: int Foo::bar(int x); }; SWIG just drops the "Foo" prefix the method and continues (previously, the declaration was ignored entirely). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4591 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/CParse/parser.y | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/SWIG/Source/CParse/parser.y b/SWIG/Source/CParse/parser.y index bbf521fe0..f9da219f5 100644 --- a/SWIG/Source/CParse/parser.y +++ b/SWIG/Source/CParse/parser.y @@ -2088,8 +2088,22 @@ c_decl : storage_class type declarator initializer c_decl_tail { /* Look for "::" declarations (ignored) */ if (Strstr($3.id,"::")) { - Delete($$); - $$ = $5; + if (Namespaceprefix) { + /* This is a special case. If the scope name of the declaration exactly + matches that of the declaration, then we will allow it. Otherwise, delete. */ + String *p = Swig_scopename_prefix($3.id); + if (Strcmp(p,Namespaceprefix) == 0) { + Setattr($$,"name",Swig_scopename_last($3.id)); + set_nextSibling($$,$5); + } else { + Delete($$); + $$ = $5; + } + Delete(p); + } else { + Delete($$); + $$ = $5; + } } else { set_nextSibling($$,$5); }