Improve director unwrap detection for the return type
Resolve the return type to correctly determine if the type is a pointer or reference to a director class. SwigType_refptr_count_return() recently added as a simpler fix is no longer needed. The conventional approach of using the "type" rather than "decl" to analyse the return type is used instead too. Issue #1823
This commit is contained in:
parent
4a397869a2
commit
2f55379687
10 changed files with 76 additions and 90 deletions
|
|
@ -140,7 +140,6 @@ extern "C" {
|
|||
extern String *SwigType_pop(SwigType *t);
|
||||
extern void SwigType_push(SwigType *t, String *s);
|
||||
extern SwigType *SwigType_last(SwigType *t);
|
||||
extern int SwigType_refptr_count_return(const SwigType *t);
|
||||
extern List *SwigType_parmlist(const SwigType *p);
|
||||
extern String *SwigType_parm(const SwigType *p);
|
||||
extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
|
||||
|
|
|
|||
|
|
@ -249,49 +249,6 @@ SwigType *SwigType_last(SwigType *t) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_refptr_count_return()
|
||||
*
|
||||
* Returns the number of pointer and reference indirections found in the given
|
||||
* type. For functions this concerns the return type.
|
||||
* For example:
|
||||
* r.p. => 2
|
||||
* q(const).p. => 1
|
||||
* r.f(int).p.p. => 2
|
||||
* f().p.q(const).p. => 2
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_refptr_count_return(const SwigType *t) {
|
||||
char *c;
|
||||
char *last;
|
||||
int sz;
|
||||
int result = 0;
|
||||
|
||||
if (!t)
|
||||
return 0;
|
||||
|
||||
c = Char(t);
|
||||
last = c;
|
||||
while (*c) {
|
||||
last = c;
|
||||
sz = element_size(c);
|
||||
c = c + sz;
|
||||
if (*(c-1) == '.') {
|
||||
if (((last[0] == 'p') || (last[0] == 'r')) && (last[1] == '.')) {
|
||||
result++;
|
||||
} else if (strncmp(last, "f(", 2) == 0) {
|
||||
/* restart counter if this is a function type */
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
if (*c == '.') {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_parm()
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue