diff options
Diffstat (limited to 'Source/Modules/directors.cxx')
-rw-r--r-- | Source/Modules/directors.cxx | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index a91d5fd9a..14e2e8466 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -4,7 +4,7 @@ * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. + * and at https://www.swig.org/legal.html. * * directors.cxx * @@ -97,7 +97,6 @@ String *Swig_director_declaration(Node *n) { String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { String *func; - int i = 0; int comma = 0; Parm *p = parms; SwigType *pt; @@ -115,7 +114,6 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { pname = Getattr(p, "name"); Printf(func, "%s", pname); comma = 1; - i++; } p = nextSibling(p); } @@ -160,7 +158,7 @@ String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_Strin SwigType *rettype_stripped = SwigType_strip_qualifiers(rettype); String *rtype = SwigType_str(rettype, 0); Append(result, rtype); - if (SwigType_issimple(rettype_stripped) && return_base_type) + if ((SwigType_issimple(rettype_stripped) && return_base_type) || SwigType_isqualifier(rettype)) Append(result, " "); Delete(rtype); Delete(rettype_stripped); @@ -175,10 +173,6 @@ String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_Strin if (qualifiers) Printv(result, " ", qualifiers, NIL); - // Reformat result to how it has been historically - Replaceall(result, ",", ", "); - Replaceall(result, "=", " = "); - Delete(args_string); Delete(popped_decl); Delete(qualifiers); @@ -239,3 +233,38 @@ void Swig_director_parms_fixup(ParmList *parms) { } } +/* ----------------------------------------------------------------------------- + * Swig_director_can_unwrap() + * + * Determine whether a function's return type can be returned as an existing + * target language object instead of creating a new target language object. + * Must be a director class and only for return by pointer or reference only + * (not by value or by pointer to pointer etc). + * ----------------------------------------------------------------------------- */ + +bool Swig_director_can_unwrap(Node *n) { + + // FIXME: this will not try to unwrap directors returned as non-director + // base class pointers! + + bool unwrap = false; + + String *type = Getattr(n, "type"); + SwigType *t = SwigType_typedef_resolve_all(type); + SwigType *t1 = SwigType_strip_qualifiers(t); + SwigType *prefix = SwigType_prefix(t1); + + if (Strcmp(prefix, "p.") == 0 || Strcmp(prefix, "r.") == 0) { + Node *parent = Swig_methodclass(n); + Node *module = Getattr(parent, "module"); + Node *target = Swig_directormap(module, t1); + if (target) + unwrap = true; + } + + Delete(prefix); + Delete(t1); + Delete(t); + + return unwrap; +} |