-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25c4083
commit dc72e6a
Showing
8 changed files
with
86 additions
and
0 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
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,2 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
useDynLib(vsexample, .registration = TRUE) |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Generated by cpp11: do not edit by hand | ||
|
||
buggy_init <- function(size) { | ||
.Call(`_vsexample_buggy_init`, size) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @useDynLib vsexample, .registration = TRUE | ||
## usethis namespace: end | ||
NULL |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.o | ||
*.so | ||
*.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <cpp11.hpp> | ||
|
||
void buggy_fill(cpp11::writable::doubles& x, double value) { | ||
R_xlen_t size = x.size(); | ||
|
||
for (R_xlen_t i = 1; i <= size; ++i) { | ||
x[i] = value; | ||
} | ||
} | ||
|
||
[[cpp11::register]] | ||
cpp11::writable::doubles buggy_init(cpp11::integers size) { | ||
R_xlen_t c_size = static_cast<R_xlen_t>(size[0]); | ||
cpp11::writable::doubles out(c_size); | ||
buggy_fill(out, 2); | ||
return out; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Generated by cpp11: do not edit by hand | ||
// clang-format off | ||
|
||
|
||
#include "cpp11/declarations.hpp" | ||
#include <R_ext/Visibility.h> | ||
|
||
// code.cpp | ||
cpp11::writable::doubles buggy_init(cpp11::integers size); | ||
extern "C" SEXP _vsexample_buggy_init(SEXP size) { | ||
BEGIN_CPP11 | ||
return cpp11::as_sexp(buggy_init(cpp11::as_cpp<cpp11::decay_t<cpp11::integers>>(size))); | ||
END_CPP11 | ||
} | ||
|
||
extern "C" { | ||
static const R_CallMethodDef CallEntries[] = { | ||
{"_vsexample_buggy_init", (DL_FUNC) &_vsexample_buggy_init, 1}, | ||
{NULL, NULL, 0} | ||
}; | ||
} | ||
|
||
extern "C" attribute_visible void R_init_vsexample(DllInfo* dll){ | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
R_forceSymbols(dll, TRUE); | ||
} |