-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set up registration forwarding * forward routine registraton from C to Rust * avoid reading Rinternals.h. * fix up examples (somewhat)
- Loading branch information
1 parent
6f738b0
commit 62d0c15
Showing
7 changed files
with
29 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
// We need to forward routine registration from C to Rust | ||
// to avoid the linker removing the static library. | ||
|
||
void R_init_data_extendr(void *dll); | ||
|
||
// Take the address of the wrap__hello stub function to avoid | ||
// the linker removing the static library. | ||
// | ||
// This will be removed in future versions with the module macro. | ||
void R_init_libdata(); | ||
|
||
void *__dummy = (void*)&R_init_libdata; | ||
|
||
void R_init_data(void *dll) { | ||
R_init_data_extendr(dll); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ Then in R: | |
|
||
> library(hello) | ||
> hello() | ||
hello | ||
NULL | ||
[1] "hello" | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
// We need to forward routine registration from C to Rust | ||
// to avoid the linker removing the static library. | ||
|
||
void R_init_hello_extendr(void *dll); | ||
|
||
// Take the address of the wrap__hello stub function to avoid | ||
// the linker removing the static library. | ||
// | ||
// This will be removed in future versions with the module macro. | ||
void R_init_libhello(); | ||
|
||
void *__dummy = (void*)&R_init_libhello; | ||
|
||
void R_init_hello(void *dll) { | ||
R_init_hello_extendr(dll); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,8 @@ | ||
/* | ||
// Take the address of the wrap__hello stub function to avoid | ||
// the linker removing the static library. | ||
// | ||
// This will be removed in future versions with the module macro. | ||
void wrap__hello(); | ||
// We need to forward routine registration from C to Rust | ||
// to avoid the linker removing the static library. | ||
|
||
void *x = (void*)&wrap__hello; | ||
*/ | ||
void R_init_extendrtests_extendr(void *dll); | ||
|
||
|
||
#define R_NO_REMAP | ||
#define STRICT_R_HEADERS | ||
#include <Rinternals.h> | ||
|
||
SEXP wrap__hello(); | ||
SEXP wrap__add_ints(); | ||
|
||
// Standard R package stuff | ||
static const R_CallMethodDef CallEntries[] = { | ||
{"wrap__hello", (DL_FUNC) &wrap__hello, 0}, | ||
{"wrap__add_ints", (DL_FUNC) &wrap__add_ints, 2}, | ||
{NULL, NULL, 0} | ||
}; | ||
|
||
void R_init_extendrtests(DllInfo *dll) { | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
void R_init_extendrtests(void *dll) { | ||
R_init_extendrtests_extendr(dll); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters