From 6d8ba96466830bd5150a7d34935de60f407c85a5 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 1 Dec 2004 00:47:10 +0000 Subject: [PATCH] fix protected constructor by using clean_overloaded to utils.cxx git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6801 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/swigmod.h | 1 + Source/Modules/typepass.cxx | 69 ----------------------------------- Source/Modules/utils.cxx | 71 +++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 69 deletions(-) diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index d67dacfcd..923fff796 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -343,6 +343,7 @@ void Wrapper_director_mode_set(int); void Wrapper_director_protected_mode_set(int); void Wrapper_template_extmode_set(int); +void clean_overloaded(Node *n); /* Contracts */ diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 6f6244c2b..a3d2b3c65 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -273,75 +273,6 @@ class TypePass : private Dispatcher { } } - /* Clean overloaded list. Removes templates, friends, ignored, and errors */ - - void clean_overloaded(Node *n) { - Node *nn = Getattr(n,"sym:overloaded"); - Node *first = 0; - int cnt = 0; - while (nn) { - if ((Strcmp(nodeType(nn),"template") == 0) || - (Getattr(nn,"feature:ignore")) || - (Getattr(nn,"error")) || - // (checkAttribute(nn,"storage","friend")) || - ((Strcmp(nodeType(nn),"using") == 0) && !firstChild(nn))) { - /* Remove from overloaded list */ - Node *ps = Getattr(nn,"sym:previousSibling"); - Node *ns = Getattr(nn,"sym:nextSibling"); - if (ps) { - Setattr(ps,"sym:nextSibling",ns); - } - if (ns) { - Setattr(ns,"sym:previousSibling",ps); - } - Delattr(nn,"sym:previousSibling"); - Delattr(nn,"sym:nextSibling"); - Delattr(nn,"sym:overloaded"); - nn = ns; - continue; - } else if ((Strcmp(nodeType(nn),"using") == 0)) { - /* A possibly dangerous parse tree hack. We're going to - cut the parse tree node out and stick in the resolved - using declarations */ - - Node *ps = Getattr(nn,"sym:previousSibling"); - Node *ns = Getattr(nn,"sym:nextSibling"); - Node *un = firstChild(nn); - Node *pn = un; - - if (!first) { - first = un; - } - while (pn) { - Node *ppn = Getattr(pn,"sym:nextSibling"); - Setattr(pn,"sym:overloaded",first); - Setattr(pn,"sym:overname", NewStringf("%s_%d", Getattr(nn,"sym:overname"), cnt++)); - if (ppn) pn = ppn; - else break; - } - if (ps) { - Setattr(ps,"sym:nextSibling",un); - Setattr(un,"sym:previousSibling",ps); - } - if (ns) { - Setattr(ns,"sym:previousSibling", pn); - Setattr(pn,"sym:nextSibling",ns); - } - if (!first) { - first = un; - Setattr(nn,"sym:overloaded",first); - } - } else { - if (!first) first = nn; - Setattr(nn,"sym:overloaded",first); - } - nn = Getattr(nn,"sym:nextSibling"); - } - if (!first || (first && !Getattr(first,"sym:nextSibling"))) { - Delattr(n,"sym:overloaded"); - } - } - /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx index 4594be848..cc8fbf0aa 100644 --- a/Source/Modules/utils.cxx +++ b/Source/Modules/utils.cxx @@ -40,3 +40,74 @@ int is_member_director(Node* member) { return is_member_director(Getattr(member, "parentNode"), member); } + + +/* Clean overloaded list. Removes templates, friends, ignored, and errors */ + +void clean_overloaded(Node *n) { + Node *nn = Getattr(n,"sym:overloaded"); + Node *first = 0; + int cnt = 0; + while (nn) { + if ((Strcmp(nodeType(nn),"template") == 0) || + (Getattr(nn,"feature:ignore")) || + (Getattr(nn,"error")) || + // (checkAttribute(nn,"storage","friend")) || + ((Strcmp(nodeType(nn),"using") == 0) && !firstChild(nn))) { + /* Remove from overloaded list */ + Node *ps = Getattr(nn,"sym:previousSibling"); + Node *ns = Getattr(nn,"sym:nextSibling"); + if (ps) { + Setattr(ps,"sym:nextSibling",ns); + } + if (ns) { + Setattr(ns,"sym:previousSibling",ps); + } + Delattr(nn,"sym:previousSibling"); + Delattr(nn,"sym:nextSibling"); + Delattr(nn,"sym:overloaded"); + nn = ns; + continue; + } else if ((Strcmp(nodeType(nn),"using") == 0)) { + /* A possibly dangerous parse tree hack. We're going to + cut the parse tree node out and stick in the resolved + using declarations */ + + Node *ps = Getattr(nn,"sym:previousSibling"); + Node *ns = Getattr(nn,"sym:nextSibling"); + Node *un = firstChild(nn); + Node *pn = un; + + if (!first) { + first = un; + } + while (pn) { + Node *ppn = Getattr(pn,"sym:nextSibling"); + Setattr(pn,"sym:overloaded",first); + Setattr(pn,"sym:overname", NewStringf("%s_%d", Getattr(nn,"sym:overname"), cnt++)); + if (ppn) pn = ppn; + else break; + } + if (ps) { + Setattr(ps,"sym:nextSibling",un); + Setattr(un,"sym:previousSibling",ps); + } + if (ns) { + Setattr(ns,"sym:previousSibling", pn); + Setattr(pn,"sym:nextSibling",ns); + } + if (!first) { + first = un; + Setattr(nn,"sym:overloaded",first); + } + } else { + if (!first) first = nn; + Setattr(nn,"sym:overloaded",first); + } + nn = Getattr(nn,"sym:nextSibling"); + } + if (!first || (first && !Getattr(first,"sym:nextSibling"))) { + Delattr(n,"sym:overloaded"); + } +} +