diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in index a7ed48e11..f7325c100 100644 --- a/Examples/test-suite/c/Makefile.in +++ b/Examples/test-suite/c/Makefile.in @@ -107,14 +107,11 @@ cpp11_default_delete.cpptest: SWIG_NOCXX = -nocxx # Assignment operator and r-va cpp11_explicit_conversion_operators.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type. cpp11_noexcept.cpptest: SWIG_NOCXX = -nocxx # Assignment operator. default_constructor.cpptest: SWIG_NOCXX = -nocxx # Something weird with OSRSpatialReferenceShadow. -director_classes.cpptest: SWIG_NOCXX = -nocxx # Ref to pointer director_conversion_operators.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type. director_frob.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type. extend_template_method.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name. features.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type not handled specially. global_namespace.cpptest: SWIG_NOCXX = -nocxx # Const const reference type. -li_boost_shared_ptr_director.cpptest: SWIG_NOCXX = -nocxx # Ref to pointer -li_std_vector_ptr.cpptest: SWIG_NOCXX = -nocxx # Ref to pointer member_template.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name. multiple_inheritance_abstract.cpptest: SWIG_NOCXX = -nocxx # Multiple inheritance not supported. multiple_inheritance_interfaces.cpptest: SWIG_NOCXX = -nocxx diff --git a/Lib/c/c.swg b/Lib/c/c.swg index 081955d51..806ca5f11 100644 --- a/Lib/c/c.swg +++ b/Lib/c/c.swg @@ -119,6 +119,7 @@ same_macro_all_primitive_types_but_void(cref_as_value,ctype); // objects %typemap(ctype) SWIGTYPE "$&resolved_type*" %typemap(ctype) SWIGTYPE * "$resolved_type*" +%typemap(ctype) SWIGTYPE * const & "$resolved_type*" %typemap(ctype) SWIGTYPE & "$*resolved_type*" %typemap(ctype) SWIGTYPE [ANY] "$resolved_type*" %typemap(ctype) SWIGTYPE * [ANY] "$resolved_type**" diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index ec18d2520..78d24ad7b 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -719,7 +719,16 @@ private: } else { String* classname; if (Node* const class_node = Language::instance()->classLookup(type)) { - typestr = SwigType_str(resolved_type, 0); + // Special case: if this is a pointer passed by (const) reference, we return just the pointer directly because we don't have any pointer-valued variable + // to give out a reference to. + if (typeKind == Type_Ptr && strncmp(Char(resolved_type), "r.q(const).", 11) == 0) { + scoped_dohptr deref_type(Copy(resolved_type)); + Delslice(deref_type, 0, 11); + typestr = SwigType_str(deref_type, 0); + } else { + typestr = SwigType_str(resolved_type, 0); + } + classname = Getattr(class_node, "sym:name"); // We don't use namespaces, but the type may contain them, so get rid of them by replacing the base type name, which is fully qualified, with just the