Overloading fixes for R and rtypecheck typemap
- Fix for special variable $argtype expansion in rtypecheck typemap. - Remove unnecessary () brackets when using rtypecheck typemap for single parameter functions. - Add rtypecheck typemaps for shared_ptr so that NULL can be used in overloaded functions taking shared_ptr.
This commit is contained in:
parent
f2da4f2ade
commit
d6d83f4df4
4 changed files with 26 additions and 13 deletions
|
|
@ -21,3 +21,7 @@ Version 4.2.0 (in progress)
|
||||||
Example of new improved error message:
|
Example of new improved error message:
|
||||||
Error in use_count(k) :
|
Error in use_count(k) :
|
||||||
cannot find overloaded function for use_count with argtypes (NULL)
|
cannot find overloaded function for use_count with argtypes (NULL)
|
||||||
|
|
||||||
|
2022-10-27: wsfulton
|
||||||
|
[R] Allow NULL to be used in overloaded functions taking shared_ptr.
|
||||||
|
Also fixes special variable $argtype expansion in rtypecheck typemaps.
|
||||||
|
|
|
||||||
|
|
@ -512,7 +512,7 @@ testSuite <- function() {
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
|
|
||||||
delete_MemberVariables(m); # m.delete();
|
delete_MemberVariables(m);
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
}
|
}
|
||||||
|
|
@ -532,7 +532,7 @@ testSuite <- function() {
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
|
|
||||||
delete_MemberVariables(m); # m.delete();
|
delete_MemberVariables(m);
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
}
|
}
|
||||||
|
|
@ -552,7 +552,7 @@ testSuite <- function() {
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
|
|
||||||
delete_MemberVariables(m); # m.delete();
|
delete_MemberVariables(m);
|
||||||
testSuite_verifyCount(1, kmember);
|
testSuite_verifyCount(1, kmember);
|
||||||
testSuite_verifyCount(1, k);
|
testSuite_verifyCount(1, k);
|
||||||
}
|
}
|
||||||
|
|
@ -570,7 +570,7 @@ testSuite <- function() {
|
||||||
k = m$SmartMemberValue;
|
k = m$SmartMemberValue;
|
||||||
if (!is.null(k))
|
if (!is.null(k))
|
||||||
stop("expected null");
|
stop("expected null");
|
||||||
testSuite_verifyCount(0, k); # this does not work for nulls
|
testSuite_verifyCount(0, k);
|
||||||
|
|
||||||
# plain by value
|
# plain by value
|
||||||
bNotCatched = F
|
bNotCatched = F
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,12 @@
|
||||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||||
"$typemap(rtype, TYPE)"
|
"$typemap(rtype, TYPE)"
|
||||||
|
|
||||||
|
%typemap(rtypecheck) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
|
||||||
|
"(extends($argtype, '$typemap(rtype, TYPE)') && length($arg) == 1) || is.null($arg)"
|
||||||
|
|
||||||
%typemap(scoercein) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
%typemap(scoercein) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||||
|
|
|
||||||
|
|
@ -1595,7 +1595,7 @@ void R::dispatchFunction(Node *n) {
|
||||||
first_compare = false;
|
first_compare = false;
|
||||||
}
|
}
|
||||||
Printv(f->code, "if (", NIL);
|
Printv(f->code, "if (", NIL);
|
||||||
for (p =pi, j = 0 ; j < num_arguments ; j++) {
|
for (p = pi, j = 0 ; j < num_arguments ; j++) {
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
Swig_print_node(p);
|
Swig_print_node(p);
|
||||||
}
|
}
|
||||||
|
|
@ -1606,21 +1606,24 @@ void R::dispatchFunction(Node *n) {
|
||||||
|
|
||||||
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
||||||
if (tmcheck) {
|
if (tmcheck) {
|
||||||
String *tmp = NewString("");
|
String *tmp_argtype = NewStringf("argtypes[%d]", j+1);
|
||||||
Printf(tmp, "argv[[%d]]", j+1);
|
Replaceall(tmcheck, "$argtype", tmp_argtype);
|
||||||
Replaceall(tmcheck, "$arg", tmp);
|
String *tmp_arg = NewStringf("argv[[%d]]", j+1);
|
||||||
Printf(tmp, "argtype[%d]", j+1);
|
Replaceall(tmcheck, "$arg", tmp_arg);
|
||||||
Replaceall(tmcheck, "$argtype", tmp);
|
|
||||||
if (tm) {
|
if (tm) {
|
||||||
Replaceall(tmcheck, "$rtype", tm);
|
Replaceall(tmcheck, "$rtype", tm);
|
||||||
}
|
}
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
||||||
}
|
}
|
||||||
Printf(f->code, "%s(%s)",
|
if (num_arguments == 1) {
|
||||||
j == 0 ? "" : " && ",
|
Printf(f->code, "%s", tmcheck);
|
||||||
tmcheck);
|
} else {
|
||||||
|
Printf(f->code, "%s(%s)", j == 0 ? "" : " && ", tmcheck);
|
||||||
|
}
|
||||||
p = Getattr(p, "tmap:in:next");
|
p = Getattr(p, "tmap:in:next");
|
||||||
|
Delete(tmp_arg);
|
||||||
|
Delete(tmp_argtype);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Below should be migrated into rtypecheck typemaps
|
// Below should be migrated into rtypecheck typemaps
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue