Improve R wrapper error message calling overloaded methods
when incorrect types passed are passed to the overloaded methods.
Old unhelpful error message:
Error in f(...) : could not find function "f"
Example of new improved error message:
Error in use_count(k) :
cannot find overloaded function for use_count with argtypes (NULL)
This commit is contained in:
parent
9e7610f972
commit
f2da4f2ade
3 changed files with 18 additions and 6 deletions
|
|
@ -11,3 +11,13 @@ Version 4.2.0 (in progress)
|
||||||
[R] #2386 Fix memory leak in R shared_ptr wrappers.
|
[R] #2386 Fix memory leak in R shared_ptr wrappers.
|
||||||
Fix leak when a cast up a class inheritance chain is required.
|
Fix leak when a cast up a class inheritance chain is required.
|
||||||
|
|
||||||
|
2022-10-26: wsfulton
|
||||||
|
[R] Improve R wrapper error message when calling overloaded methods
|
||||||
|
when incorrect types passed are passed to the overloaded methods.
|
||||||
|
|
||||||
|
Old unhelpful error message:
|
||||||
|
Error in f(...) : could not find function "f"
|
||||||
|
|
||||||
|
Example of new improved error message:
|
||||||
|
Error in use_count(k) :
|
||||||
|
cannot find overloaded function for use_count with argtypes (NULL)
|
||||||
|
|
|
||||||
|
|
@ -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); # this does not work for nulls
|
||||||
|
|
||||||
# plain by value
|
# plain by value
|
||||||
bNotCatched = F
|
bNotCatched = F
|
||||||
|
|
|
||||||
|
|
@ -1566,7 +1566,8 @@ void R::dispatchFunction(Node *n) {
|
||||||
Printv(f->code,
|
Printv(f->code,
|
||||||
"argtypes <- mapply(class, list(...));\n",
|
"argtypes <- mapply(class, list(...));\n",
|
||||||
"argv <- list(...);\n",
|
"argv <- list(...);\n",
|
||||||
"argc <- length(argtypes);\n", NIL );
|
"argc <- length(argtypes);\n",
|
||||||
|
"f <- NULL;\n", NIL);
|
||||||
|
|
||||||
Printf(f->code, "# dispatch functions %d\n", nfunc);
|
Printf(f->code, "# dispatch functions %d\n", nfunc);
|
||||||
int cur_args = -1;
|
int cur_args = -1;
|
||||||
|
|
@ -1649,11 +1650,12 @@ void R::dispatchFunction(Node *n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cur_args != -1) {
|
if (cur_args != -1) {
|
||||||
Printf(f->code, "} else {\n"
|
Printf(f->code, "};\n");
|
||||||
"stop(\"cannot find overloaded function for %s with argtypes (\","
|
|
||||||
"toString(argtypes),\")\");\n"
|
|
||||||
"}", sfname);
|
|
||||||
}
|
}
|
||||||
|
Printf(f->code, "if (is.null(f)) {\n"
|
||||||
|
"stop(\"cannot find overloaded function for %s with argtypes (\","
|
||||||
|
"toString(argtypes),\")\");\n"
|
||||||
|
"}", sfname);
|
||||||
Printv(f->code, ";\nf(...)", NIL);
|
Printv(f->code, ";\nf(...)", NIL);
|
||||||
Printv(f->code, ";\n}", NIL);
|
Printv(f->code, ";\n}", NIL);
|
||||||
Wrapper_print(f, sfile);
|
Wrapper_print(f, sfile);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue