|
Re: Typedefs of template instantiations not recognized properly?: msg#00140programming.swig
Zachary Pincus wrote: I get the following error: I had a very similar problem with partial specialization, and created the attached patch. (Hopefully it will apply cleanly; it's actually in the middle of a series of patches I have applied to my swig 1.3.21.) When looking for a matching template, it tries matching both the unqualified name you provided and the namespace-qualified name. Note that I don't really understand what I'm doing here, but it works for me. Index: Source/CParse/templ.c =================================================================== RCS file: /usr/local/cvs/Imports/SWIG-1.3.21/Source/CParse/templ.c,v retrieving revision 1.1 diff -u -u -r1.1 templ.c --- Source/CParse/templ.c 19 May 2004 19:11:27 -0000 1.1 +++ Source/CParse/templ.c 24 May 2004 17:17:03 -0000 @@ -387,7 +387,7 @@ Node * Swig_cparse_template_locate(String *name, Parm *tparms) { Node *n; - String *tname, *rname = 0; + String *tname, *qualname, *rname = 0; Node *templ; List *mpartials = 0; Parm *p; @@ -415,24 +415,27 @@ /* Search for an exact specialization. Example: template<> class name<int> { ... } */ - { - if (template_debug) { - Printf(stdout," searching: '%s' (exact specialization)\n", tname); - } - n = Swig_symbol_clookup_local(tname,0); - if (n) { - Node *tn; - if (Strcmp(nodeType(n),"template") == 0) goto success; - tn = Getattr(n,"template"); - if (tn) { - n = tn; - goto success; /* Previously wrapped by a template return that */ - } - Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n)); - Delete(tname); - Delete(parms); - return 0; /* Found a match, but it's not a template of any kind. */ - } + if (template_debug) { + Printf(stdout," searching: '%s' (exact specialization)\n", tname); + } + n = Swig_symbol_clookup_local(tname,0); + qualname = Copy(Swig_symbol_getscopename()); + Append(qualname, "::"); + Append(qualname, tname); + if (!n) n = Swig_symbol_clookup_local(qualname,0); + if (n) { + Node *tn; + if (Strcmp(nodeType(n),"template") == 0) goto success; + tn = Getattr(n,"template"); + if (tn) { + n = tn; + goto success; /* Previously wrapped by a template return that */ + } + Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n)); + Delete(tname); + Delete(parms); + Delete(qualname); + return 0; /* Found a match, but it's not a template of any kind. */ } /* Search for generic template */ @@ -499,8 +502,11 @@ } if (template_debug) { Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, pi.item); + Printf(stdout," %s eq %s\n", ss, tname); + Printf(stdout," %s eq %s\n", ss, rname); + Printf(stdout," %s eq %s\n", ss, qualname); } - if ((Strcmp(ss,tname) == 0) || (Strcmp(ss,rname) == 0)) { + if ((Strcmp(ss,tname) == 0) || (Strcmp(ss,rname) == 0) || (Strcmp(ss,qualname) == 0)) { Append(mpartials,pi.item); } Delete(ss); @@ -535,6 +541,7 @@ success: Delete(tname); Delete(rname); + Delete(qualname); Delete(mpartials); if ((template_debug) && (n)) { Printf(stdout,"Node: %x\n", n); |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: renaming the .so in C->python: 00140, William . Fulton |
|---|---|
| Next by Date: | [PATCH] assortment of problems: 00140, Steve Fink |
| Previous by Thread: | Typedefs of template instantiations not recognized properly?i: 00140, David Beazley |
| Next by Thread: | Re: Typedefs of template instantiations not recognized properly?: 00140, Marcelo Matus |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |