-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from paleolimbot/more-c
Drop cpp11 dependency
- Loading branch information
Showing
19 changed files
with
564 additions
and
211 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,3 +1,2 @@ | ||
inst/include/wk | ||
src/cpp11.cpp | ||
src/fast_float/fast_float.h | ||
src/internal/fast_float/fast_float.h |
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
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
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,56 @@ | ||
|
||
|
||
library(tidyverse) | ||
|
||
src_files <- list.files("src", "\\.(c|cpp)$", full.names = TRUE) | ||
src_sources <- src_files %>% set_names() %>% map_chr(readr::read_file) | ||
|
||
defs <- tibble( | ||
def = src_sources %>% | ||
str_extract_all(regex("SEXP wk_c_[^\\)]+\\)\\s+", multiline = TRUE)) %>% | ||
unlist() %>% | ||
str_replace_all("\\s+", " ") %>% | ||
str_trim(), | ||
name = def %>% str_extract("wk_c_[^\\(]+"), | ||
return_type = "SEXP", | ||
args = def %>% | ||
str_remove("SEXP wk_c_[^\\(]+\\(") %>% | ||
str_remove("\\)$") %>% | ||
str_split("\\s*,\\s*") %>% | ||
map(~{if(identical(.x, "")) character(0) else .x}), | ||
n_args = map(args, length) | ||
) | ||
|
||
call_headers <- paste0( | ||
"extern ", defs$def, ";", | ||
collapse = "\n" | ||
) | ||
call_entries <- paste0( | ||
' {"', defs$name, '", (DL_FUNC) &', defs$name, ', ', defs$n_args, "},", | ||
collapse = "\n" | ||
) | ||
|
||
header <- glue::glue(' | ||
/* generated by data-raw/make_callentries.R */ | ||
{call_headers} | ||
static const R_CallMethodDef CallEntries[] = {{ | ||
{call_entries} | ||
{{NULL, NULL, 0}} | ||
}}; | ||
/* end generated by data-raw/make_callentries.R */ | ||
') | ||
|
||
# rewrite relevant portion of init.c | ||
init <- read_file("src/init.c") | ||
pattern <- regex( | ||
"\n/\\* generated by data-raw/make_callentries\\.R \\*/.*?/\\* end generated by data-raw/make_callentries\\.R \\*/", | ||
multiline = TRUE, | ||
dotall = TRUE | ||
) | ||
|
||
stopifnot(str_detect(init, pattern)) | ||
init %>% | ||
str_replace(pattern, header) %>% | ||
write_file("src/init.c") |
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
File renamed without changes.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.