[R] Fix CopyToR() generated for struct in namespace

Fixes https://sourceforge.net/p/swig/bugs/1147/
This commit is contained in:
Olly Betts 2022-01-31 12:05:09 +13:00
commit 7813793511
5 changed files with 25 additions and 1 deletions

View file

@ -315,6 +315,7 @@ CPP_TEST_CASES += \
namespace_forward_declaration \
namespace_nested \
namespace_spaces \
namespace_struct \
namespace_template \
namespace_typedef_class \
namespace_typemap \

View file

@ -0,0 +1,8 @@
%module namespace_struct
%inline %{
// SWIG/R generated bad code for copyToR for a struct in a namespace in SWIG < 4.1.0
namespace X { struct Y { int x, y; }; }
%}

View file

@ -0,0 +1,11 @@
clargs <- commandArgs(trailing=TRUE)
source(file.path(clargs[1], "unittest.R"))
dyn.load(paste("namespace_struct", .Platform$dynlib.ext, sep=""))
source("namespace_struct.R")
cacheMetaData(1)
xy = Y()
xy$x = as.integer(2)
xy$y = as.integer(4)
copyToR(xy)