Unwrap director classes only when returning a pointer or reference to an object

This involves properly counting the number of references and pointers in the return
type of a function and only generate unwrapping code if this number is 1.
For template instances some post-processing code is added to fix the 'decl' and
'type' attributes of functions if changed in an unfavorable way during template
expansion.
This commit fixes swig#1811.
This commit is contained in:
Thomas Reitmayr 2020-06-09 21:58:47 +02:00
commit 01277d700c
9 changed files with 369 additions and 6 deletions

View file

@ -1893,9 +1893,7 @@ public:
*/
bool unwrap = false;
String *decl = Getattr(n, "decl");
int is_pointer = SwigType_ispointer_return(decl);
int is_reference = SwigType_isreference_return(decl);
if (is_pointer || is_reference) {
if (SwigType_refptr_count_return(decl) == 1) {
String *type = Getattr(n, "type");
Node *parent = Swig_methodclass(n);
Node *modname = Getattr(parent, "module");