Typemap matching rules enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time starting with the left most qualifier.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12007 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
58a7e2c3d6
commit
efd200ffe2
10 changed files with 398 additions and 38 deletions
|
|
@ -1125,3 +1125,62 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
|||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_strip_single_qualifier()
|
||||
*
|
||||
* If the type contains a qualifier, strip one qualifier and return a new type.
|
||||
* The left most qualifier is stripped first (when viewed as C source code) but
|
||||
* this is the equivalent to the right most qualifier using SwigType notation.
|
||||
* Example:
|
||||
* r.q(const).p.q(const).int => r.q(const).p.int
|
||||
* r.q(const).p.int => r.p.int
|
||||
* r.p.int => r.p.int
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_single_qualifier(SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
int numitems;
|
||||
|
||||
if (!memoize_stripped)
|
||||
memoize_stripped = NewHash();
|
||||
r = Getattr(memoize_stripped, t);
|
||||
if (r)
|
||||
return Copy(r);
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 2) {
|
||||
int item;
|
||||
/* iterate backwards from last but one item */
|
||||
for (item = numitems - 2; item >= 0; --item) {
|
||||
String *subtype = Getitem(l, item);
|
||||
if (SwigType_isqualifier(subtype)) {
|
||||
Iterator it;
|
||||
Delitem(l, item);
|
||||
r = NewStringEmpty();
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!r)
|
||||
r = Copy(t);
|
||||
|
||||
Delete(l);
|
||||
{
|
||||
String *key, *value;
|
||||
key = Copy(t);
|
||||
value = Copy(r);
|
||||
Setattr(memoize_stripped, key, value);
|
||||
Delete(key);
|
||||
Delete(value);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue