Resolve prefix when resolving typedef

This commit is contained in:
Yann Diorcet 2013-06-03 15:41:54 +02:00 • committed by William S Fulton
commit c319ad9dd6

View file

@ -602,7 +602,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
Typetab *s; Typetab *s;
Hash *ttab; Hash *ttab;
String *namebase = 0; String *namebase = 0;
String *nameprefix = 0; String *nameprefix = 0, *rnameprefix = 0;
int newtype = 0; int newtype = 0;
resolved_scope = 0; resolved_scope = 0;
@ -647,51 +647,66 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
Printf(stdout, "nameprefix = '%s'\n", nameprefix); Printf(stdout, "nameprefix = '%s'\n", nameprefix);
#endif #endif
if (nameprefix) { if (nameprefix) {
/* Name had a prefix on it. See if we can locate the proper scope for it */ rnameprefix = SwigType_typedef_resolve(nameprefix);
String *rnameprefix = template_parameters_resolve(nameprefix); if(rnameprefix != NULL) {
nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
Delete(rnameprefix);
s = SwigType_find_scope(s, nameprefix);
/* Couldn't locate a scope for the type. */
if (!s) {
Delete(base);
Delete(namebase);
Delete(nameprefix);
r = 0;
goto return_result;
}
/* Try to locate the name starting in the scope */
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout, "namebase = '%s'\n", namebase); Printf(stdout, "nameprefix '%s' is a typedef to '%s'\n", nameprefix, rnameprefix);
#endif #endif
type = typedef_resolve(s, namebase); type = Copy(namebase);
if (type && resolved_scope) { Insert(type, 0, "::");
/* we need to look for the resolved type, this will also Insert(type, 0, rnameprefix);
fix the resolved_scope if 'type' and 'namebase' are if (strncmp(Char(type), "::", 2) == 0) {
declared in different scopes */ Delitem(type, 0);
String *rtype = 0; Delitem(type, 0);
rtype = typedef_resolve(resolved_scope, type); }
if (rtype) newtype = 1;
type = rtype; } else {
} /* Name had a prefix on it. See if we can locate the proper scope for it */
#ifdef SWIG_DEBUG String *rnameprefix = template_parameters_resolve(nameprefix);
Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type); nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
#endif Delete(rnameprefix);
if (type && (!Swig_scopename_check(type)) && resolved_scope) { s = SwigType_find_scope(s, nameprefix);
Typetab *rtab = resolved_scope;
String *qname = Getattr(resolved_scope, "qname"); /* Couldn't locate a scope for the type. */
/* If qualified *and* the typename is defined from the resolved scope, we qualify */ if (!s) {
if ((qname) && typedef_resolve(resolved_scope, type)) { Delete(base);
type = Copy(type); Delete(namebase);
Insert(type, 0, "::"); Delete(nameprefix);
Insert(type, 0, qname); r = 0;
#ifdef SWIG_DEBUG goto return_result;
Printf(stdout, "qual %s \n", type); }
#endif /* Try to locate the name starting in the scope */
newtype = 1; #ifdef SWIG_DEBUG
Printf(stdout, "namebase = '%s'\n", namebase);
#endif
type = typedef_resolve(s, namebase);
if (type && resolved_scope) {
/* we need to look for the resolved type, this will also
fix the resolved_scope if 'type' and 'namebase' are
declared in different scopes */
String *rtype = 0;
rtype = typedef_resolve(resolved_scope, type);
if (rtype)
type = rtype;
}
#ifdef SWIG_DEBUG
Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type);
#endif
if ((type) && (!Swig_scopename_check(type)) && resolved_scope) {
Typetab *rtab = resolved_scope;
String *qname = Getattr(resolved_scope, "qname");
/* If qualified *and* the typename is defined from the resolved scope, we qualify */
if ((qname) && typedef_resolve(resolved_scope, type)) {
type = Copy(type);
Insert(type, 0, "::");
Insert(type, 0, qname);
#ifdef SWIG_DEBUG
Printf(stdout, "qual %s \n", type);
#endif
newtype = 1;
}
resolved_scope = rtab;
} }
resolved_scope = rtab;
} }
} else { } else {
/* Name is unqualified. */ /* Name is unqualified. */