From 157f655be613d91ed78cd48094560aed7e34cbb5 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 2 Mar 2006 05:48:53 +0000 Subject: [PATCH] reduce the typedef reduce cases git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8924 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/CParse/parser.y | 8 ++++++-- SWIG/Source/Swig/stype.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/SWIG/Source/CParse/parser.y b/SWIG/Source/CParse/parser.y index d95dd6dfe..fb7a55943 100644 --- a/SWIG/Source/CParse/parser.y +++ b/SWIG/Source/CParse/parser.y @@ -2530,8 +2530,12 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va if (!value) { SwigType *ty = Getattr(p,k_type); if (ty) { - SwigType *rty = Swig_symbol_typedef_reduce(ty,tscope); - int reduce = template_reduce || SwigType_ispointer(rty) || SwigType_isarray(rty) || SwigType_isreference(rty); + SwigType *rty = 0; + int reduce = template_reduce; + if (reduce || !SwigType_ispointer(ty)) { + rty = Swig_symbol_typedef_reduce(ty,tscope); + if (!reduce) reduce = SwigType_ispointer(rty); + } ty = reduce ? Swig_symbol_type_qualify(rty,tscope) : Swig_symbol_type_qualify(ty,tscope); Setattr(p,k_type,ty); Delete(ty); diff --git a/SWIG/Source/Swig/stype.c b/SWIG/Source/Swig/stype.c index 456f610e6..0f1976e70 100644 --- a/SWIG/Source/Swig/stype.c +++ b/SWIG/Source/Swig/stype.c @@ -646,13 +646,22 @@ SwigType_ltype(SwigType *s) { } if (SwigType_issimple(tc)) { /* Resolve any typedef definitions */ - td = SwigType_typedef_resolve_all(tc); - if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) { - /* We need to use the typedef type */ + SwigType *tt = Copy(tc); + td = 0; + while ((td = SwigType_typedef_resolve(tt))) { + if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) { + /* We need to use the typedef type */ + Delete(tt); + tt = td; + break; + } else if (td) { + Delete(tt); + tt = td; + } + } + if (td) { Delete(tc); - tc = td; - } else if (td) { - Delete(td); + tc = td; } } elements = SwigType_split(tc);