-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is__module_object leads to error when checking non-module object #380
Comments
|
Directly check won't work, since that object is a S4, and I guess we need to check type of env.get(".cppclass") |
See the code below, I think it is what you want.
|
Yap :) However, I think this may be something that should be solved by |
But edd@don:~/git/rcpp(master)$ ag NDArray
edd@don:~/git/rcpp(master)$ ie |
Sorry for confusion, Discussed with @thirdwing , seems it is indeed a logical error in current is. Can be fixed by either check if object is S4 here Lines 38 to 43 in 0a43747
check if return value of env.get is R_NilValue here Rcpp/inst/include/Rcpp/api/meat/is.h Line 153 in 0a43747
|
In current code, say if MyClass is exported by RCPP_EXPORT_CLASS. And we check is<MyClass>(some INTEXP ) It dispatches to Rcpp/inst/include/Rcpp/api/meat/is.h Line 151 in 0a43747
So instead of return a false, it throws an Error saying things cannot be converted to XPtr |
To fix this, we can check if the return type of env.get(".cppclass") is External Ptr here, and simply return false if it is not. |
If you want/need special behaviour for your class, can you not write a function in your library to deal with it? I do not plan to rapid-fire change things in Rcpp without clearer motivation. |
To be clear, this is not special behavior? As the I suppose that the check |
I may still misunderstand the issue but I think you expect Rcpp Modules to do more than it does, and apart from you nobody has brought such expectations forward in the five years we used Rcpp Modules. So my intuitive feeling is that maybe you need to adjust your expectations. Rcpp Modules is not a parser of your class or library code. It does some things well enough, and things that are missing ... will be missing until someone (you ?) contributes them. But posting issue after issue "it should do this or that" will not get us there. Sorry. Again, I may be missing something obvious too. But maybe you can start by package-local code in your package, and then try to convince us that some generic code is general enough to be moved over into Rcpp itself? |
Thanks Dirk, Yes. I think we will do it in this way. I am opening the issue to suggest solutions(as in my previous post) and see if it makes sense. I guess writing it out will make it more clear. |
created a PR #381 on this |
Fixed in #381 |
Strictly speaking we don't know yet as the tests are not yet done :) But appreciate the close nonetheless. And we will get back to your gist and work down the issue tickets. Promised. |
Sorry for this. [Edited] Maybe not very clear in this morning. I thought you have tested before merging. |
It is more work to get a neutral branch to build from so I just merged and am testing now ... |
Looks good -- it just finished and we have what appears to be no new issue. Just the usual problem of tests failing when |
If we call check from R's side by passing in a non-module object. It will report error "External pointer is expected", instead of returning false.
The problem is here
Rcpp/inst/include/Rcpp/api/meat/is.h
Line 153 in 0a43747
Maybe need a explicit check of ext ptr type first before converting to XPtr
The text was updated successfully, but these errors were encountered: