-
Notifications
You must be signed in to change notification settings - Fork 8
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
Register C Callable #24
Comments
All grand by me, but with one caveat: The number of exposed functions is actually pretty huge: extern SEXP R_cheap(SEXP);
extern SEXP R_cheap_paired(SEXP, SEXP);
extern SEXP R_cheap_paired_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_cheap_range(SEXP);
extern SEXP R_cheap_seq(SEXP);
extern SEXP R_cheap_seq_range(SEXP);
extern SEXP R_cheap_seq_vec(SEXP, SEXP);
extern SEXP R_cheap_vec(SEXP, SEXP);
extern SEXP R_cheap_xy(SEXP, SEXP);
extern SEXP R_cheap_xy_range(SEXP, SEXP);
extern SEXP R_cheap_xy_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_geodesic(SEXP);
extern SEXP R_geodesic_paired(SEXP, SEXP);
extern SEXP R_geodesic_paired_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_geodesic_range(SEXP);
extern SEXP R_geodesic_seq(SEXP);
extern SEXP R_geodesic_seq_range(SEXP);
extern SEXP R_geodesic_seq_vec(SEXP, SEXP);
extern SEXP R_geodesic_vec(SEXP, SEXP);
extern SEXP R_geodesic_xy(SEXP, SEXP);
extern SEXP R_geodesic_xy_range(SEXP, SEXP);
extern SEXP R_geodesic_xy_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_haversine(SEXP);
extern SEXP R_haversine_paired(SEXP, SEXP);
extern SEXP R_haversine_paired_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_haversine_range(SEXP);
extern SEXP R_haversine_seq(SEXP);
extern SEXP R_haversine_seq_range(SEXP);
extern SEXP R_haversine_seq_vec(SEXP, SEXP);
extern SEXP R_haversine_vec(SEXP, SEXP);
extern SEXP R_haversine_xy(SEXP, SEXP);
extern SEXP R_haversine_xy_range(SEXP, SEXP);
extern SEXP R_haversine_xy_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_vincenty(SEXP);
extern SEXP R_vincenty_paired(SEXP, SEXP);
extern SEXP R_vincenty_paired_vec(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_vincenty_range(SEXP);
extern SEXP R_vincenty_seq(SEXP);
extern SEXP R_vincenty_seq_range(SEXP);
extern SEXP R_vincenty_seq_vec(SEXP, SEXP);
extern SEXP R_vincenty_vec(SEXP, SEXP);
extern SEXP R_vincenty_xy(SEXP, SEXP);
extern SEXP R_vincenty_xy_range(SEXP, SEXP);
extern SEXP R_vincenty_xy_vec(SEXP, SEXP, SEXP, SEXP); Each one is a particular combination of input params. Exposing those would induce some safety compromises, as the code currently relies very strongly on the R-side per-processing to ensure the appropriate C routine is called. That means the code does no checking of arguments at all in any C routine. Direct passing of arbitrary inputs would almost certainly raise problems, and at the least, I'd first have to implement a bunch of C-level code to ensure sane inputs, and doing that would likely slow calculations down somewhat, so there would also be potential disadvantages there. Note also that some I don't mean to be obstructive here, and i definitely do think this is a good idea, but would be interested to first have your insights into some of these concerns? |
(All interesting stuff for me, just went through my first example and learnt heaps thanks both) |
An alternative would be for me to write a C-level meta-wrapper around all of those internal functions. The latter could then be left so, and the exposed bit used to funnel the right combinations of |
You bring up some valid concerns for sure. And I think your suggested C-level API would be an easier solution. But, having brought up this issue, I have no real need for it yet, so don't feel like you're required to do this :) |
I'm happy to leave this issue open for a while. I'll attend to some others first, and then slowly come around to this. Thanks for the impetus! |
Inspired by recent discussions and progress in other libraries, and by
data.table
exposing their C functions, would you consider exposing the C functions fromgeodist
so they can be called by otherC
/C++
code?I've made a very quick prototype here, where all that was needed was to register a function as
R_RegisterCCallable()
Which then makes it availabel to other C/C++ code, for example
And a quick check, using the example from
?geodist
The text was updated successfully, but these errors were encountered: