Fixes for SWIG_TypeQuery and templates/typedefs,
before the swig_type_info fields 'str' and 'name'
where not consistent, one was fully resolved (name),
the other not, therefore
typedef int Int;
template <class C> struct Class {};
SWIG_TypeQuery($descriptor(Class<int>*))
wasn't necessary the same that
typedef int Int;
template <class C> struct Class {};
SWIG_TypeQuery("Class<int> *")
the problem was visible only when the latter form was used,
like in a static auxiliar function outside a typemap.
also, relax type name comparison with blanks, ie
SWIG_TypeQuery("Class<int> *") := SWIG_TypeQuery("Class<int > *")
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5703 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8f7e15900e
commit
d3caa4eefc
2 changed files with 100 additions and 55 deletions
|
|
@ -167,12 +167,33 @@ SWIG_TypeName(const swig_type_info *ty) {
|
|||
return ty->name;
|
||||
}
|
||||
|
||||
/*
|
||||
Compare two type names skipping the space characters, therefore
|
||||
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
|
||||
|
||||
Return 0 when the two name types are equivalent, as in
|
||||
strncmp, but skipping ' '.
|
||||
*/
|
||||
static int
|
||||
SWIG_TypeNameComp(const char *name1, const char *name2) {
|
||||
register size_t s1 = strlen(name1);
|
||||
register size_t s2 = strlen(name2);
|
||||
register size_t i1 = 0;
|
||||
register size_t i2 = 0;
|
||||
for( ; (i1 < s1) && (i2 < s2); ++i1, ++i2) {
|
||||
while ((name1[i1] == ' ') && (i1 < s1)) ++i1;
|
||||
while ((name2[i2] == ' ') && (i2 < s2)) ++i2;
|
||||
if (name1[i1] != name2[i2]) return name1[i1] - name2[i2];
|
||||
}
|
||||
return (s1 - i1) - (s2 - i2);
|
||||
}
|
||||
|
||||
/* Search for a swig_type_info structure */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeQuery(const char *name) {
|
||||
swig_type_info *ty = swig_type_list;
|
||||
while (ty) {
|
||||
if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
|
||||
if (ty->str && (SWIG_TypeNameComp(name,ty->str) == 0)) return ty;
|
||||
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
|
||||
ty = ty->prev;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue