Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions inst/include/datatableAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/* This header file provides the interface used by other packages,
and should be included once per package. */

#ifndef _R_data_table_API_h_
#define _R_data_table_API_h_

/* number of R header files (possibly listing too many) */
#include <R.h>

#ifdef HAVE_VISIBILITY_ATTRIBUTE
# define attribute_hidden __attribute__ ((visibility ("hidden")))
#else
# define attribute_hidden
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* provided the interface for the function exported in
../src/init.c via R_RegisterCCallable() */

SEXP attribute_hidden DT_subsetDT(SEXP x, SEXP rows, SEXP cols) {
static SEXP(*fun)(SEXP, SEXP, SEXP) =
(SEXP(*)(SEXP,SEXP,SEXP)) R_GetCCallable("data.table", "CsubsetDT");
return fun(x,rows,cols);
Comment on lines +25 to +27
Copy link
Copy Markdown
Member

@jangorecki jangorecki Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddelbuettel is it necessary to create fun object here? couldn't this be a one liner to returning R_GetCCallable() call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: fun is what is invoked when you call. The static makes the assignment stick, and the R_GetCCallable() ges the identifier from the other package.

}

/* permit opt-in to redefine shorter identifiers */
#if defined(DATATABLE_REMAP_API)
#define subsetDT DT_subsetDT
#endif

#ifdef __cplusplus
}

/* add a namespace for C++ use */
namespace dt {
inline SEXP subsetDT(SEXP x, SEXP rows, SEXP cols) { return DT_subsetDT(x, rows, cols); }
}

#endif /* __cplusplus */

#endif /* _R_data_table_API_h_ */