Skip to content

Commit

Permalink
Add missing SWIGTYPE *const& typemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
wsfulton committed Oct 13, 2022
1 parent f13de56 commit 752b7e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.current
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Examples/test-suite/r/constant_pointers_runme.R
Original file line number Diff line number Diff line change
@@ -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")
9 changes: 7 additions & 2 deletions Lib/r/rtype.swg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"); %}

/*
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 752b7e8

Please sign in to comment.