summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-10-13 22:22:18 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-10-13 22:22:18 +0100
commit752b7e82cd61a80eb0f5dd80f134ba80bcae4973 (patch)
tree4136d47b645e4a728455b8d1eeb9fa2736ee55ad
parentf13de56e5f88aaed94a2fe143ee766755ee82cf1 (diff)
downloadswig-752b7e82cd61a80eb0f5dd80f134ba80bcae4973.tar.gz
Add missing SWIGTYPE *const& typemaps
-rw-r--r--CHANGES.current4
-rw-r--r--Examples/test-suite/r/constant_pointers_runme.R13
-rw-r--r--Lib/r/rtype.swg9
3 files changed, 24 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 4a94edca2..d0246156b 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
+2022-10-13: wsfulton
+ [R] Add missing SWIGTYPE *const& typemaps for supporting pointers
+ by const reference.
+
2022-10-10: wsfulton
#2160 Fix compile error when using templates with more than one template
parameter and used as an input parameter in a virtual method in a
diff --git a/Examples/test-suite/r/constant_pointers_runme.R b/Examples/test-suite/r/constant_pointers_runme.R
new file mode 100644
index 000000000..d6f1c945d
--- /dev/null
+++ b/Examples/test-suite/r/constant_pointers_runme.R
@@ -0,0 +1,13 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+
+dyn.load(paste("constant_pointers", .Platform$dynlib.ext, sep=""))
+source("constant_pointers.R")
+cacheMetaData(1)
+
+myb <- B()
+bret = bar(myb)
+bret2 = cbar(myb)
+bret3 = bar(bret2)
+
+q(save="no")
diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg
index 41f0affe1..a9c067589 100644
--- a/Lib/r/rtype.swg
+++ b/Lib/r/rtype.swg
@@ -14,12 +14,13 @@
%typemap("rtype") bool, bool * "logical"
%typemap("rtype") enum SWIGTYPE "character"
%typemap("rtype") enum SWIGTYPE * "character"
-%typemap("rtype") enum SWIGTYPE *const "character"
+%typemap("rtype") enum SWIGTYPE *const& "character"
%typemap("rtype") enum SWIGTYPE & "character"
%typemap("rtype") const enum SWIGTYPE & "character"
%typemap("rtype") enum SWIGTYPE && "character"
%typemap("rtype") SWIGTYPE * "$R_class"
%typemap("rtype") SWIGTYPE *const "$R_class"
+%typemap("rtype") SWIGTYPE *const& "$*R_class"
%typemap("rtype") SWIGTYPE & "$R_class"
%typemap("rtype") SWIGTYPE && "$R_class"
%typemap("rtype") SWIGTYPE "$&R_class"
@@ -93,7 +94,7 @@
%typemap(scoercein) enum SWIGTYPE *const
%{ $input = enumToInteger($input, "$R_class"); %}
-%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&
+%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE *const&, SWIGTYPE &, SWIGTYPE &&
%{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref"); %}
/*
@@ -172,6 +173,10 @@ string &, std::string &
%{ $result <- if (is.null($result)) $result
else new("$R_class", ref=$result); %}
+%typemap(scoerceout) SWIGTYPE *const&
+ %{ $result <- if (is.null($result)) $result
+ else new("$*R_class", ref=$result); %}
+
/* Override the SWIGTYPE * above. */
%typemap(scoerceout) char,