Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automatically register init functions for RcppModules (closes #704)#705

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eddelbuettel merged 2 commits intomasterfromfeature/module-routine-registraiton
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes fromall 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
5 changes: 5 additions & 0 deletionsChangeLog
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
2017-06-02 JJ Allaire <jj@rstudio.com>

* src/attributes.cpp: Automatically register init functions for RcppModules
* R/Rcpp.package.skeleton.R: compileAttributes only after all code is generated

2017-06-01 JJ Allaire <jj@rstudio.com>

* src/attributes.cpp: Fix registration for exports with name attribute.
Expand Down
10 changes: 5 additions & 5 deletionsR/Rcpp.package.skeleton.R
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,18 +138,13 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
file.copy(file, src)
message(" >> copied ", file, " to src directory" )
}
compileAttributes(root)
}

if (example_code) {
if (isTRUE(attributes)) {
file.copy(file.path( skeleton, "rcpp_hello_world_attributes.cpp"),
file.path( src, "rcpp_hello_world.cpp"))
message(" >> added example src file using Rcpp attributes")
compileAttributes(root)
message(" >> compiled Rcpp attributes")
message(" >> do NOT modify by hand either RcppExports.cpp or ",
"RcppExports.R")
} else {
header <- readLines(file.path(skeleton, "rcpp_hello_world.h"))
header <- gsub("@PKG@", name, header, fixed = TRUE)
Expand DownExpand Up@@ -218,6 +213,11 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
rm("rcpp_hello_world", envir = env)
}

if (attributes) {
compileAttributes(root)
message(" >> compiled Rcpp attributes ")
}

Copy link
Member

@eddelbuetteleddelbuettelJun 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

Maybe I am short of coffee butif (attributes) { relies onattributes==TRUE. We could have a case ofmodules=TRUE (as in#704)and alsoattributes=FALSE, no? Needless complication?

invisible(NULL)
}

Expand Down
1 change: 1 addition & 0 deletionsinst/NEWS.Rd
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@
or newer (Elias Pipping in \ghpr{698}).
\item Fix native registration for exports with name attribute (\ghpr{703}
addressing \ghit{702}).
\item Automatically register init functions for RcppModules.
}
}
}
Expand Down
20 changes: 18 additions & 2 deletionssrc/attributes.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -675,8 +675,11 @@ namespace attributes {
// for generating C++ interfaces
std::vector<Attribute> cppExports_;

// for generating native routine registration
// for generatingRcpp::exportnative routine registration
std::vector<Attribute> nativeRoutines_;

// for generating module native routine registration
std::vector<std::string> modules_;
};

// Class which manages generating PackageName_RcppExports.h header file
Expand DownExpand Up@@ -1888,6 +1891,9 @@ namespace attributes {
}
} // #nocov end

// record modules
const std::vector<std::string>& modules = attributes.modules();
modules_.insert(modules_.end(), modules.begin(), modules.end());

// verbose if requested
if (verbose) {// #nocov start
Expand DownExpand Up@@ -1955,7 +1961,7 @@ namespace attributes {
}

// write native routines
if (!hasPackageInit && !nativeRoutines_.empty()) {
if (!hasPackageInit &&(!nativeRoutines_.empty() || !modules_.empty())) {

// build list of routines we will register
std::vector<std::string> routineNames;
Expand All@@ -1965,6 +1971,11 @@ namespace attributes {
routineNames.push_back(package() + "_" + attr.function().name());
routineArgs.push_back(attr.function().arguments().size());
}
std::string kRcppModuleBoot = "_rcpp_module_boot_";
for (std::size_t i=0;i<modules_.size(); i++) {
routineNames.push_back(kRcppModuleBoot + modules_[i]);
routineArgs.push_back(0);
}
if (hasCppInterface()) {
routineNames.push_back(registerCCallableExportedName());
routineArgs.push_back(0);
Expand All@@ -1976,6 +1987,11 @@ namespace attributes {
std::vector<std::string> declarations = extraRoutines["declarations"];
std::vector<std::string> callEntries = extraRoutines["call_entries"];

// add declarations for modules
for (std::size_t i=0;i<modules_.size(); i++) {
declarations.push_back("RcppExport SEXP " + kRcppModuleBoot + modules_[i] + "();");
}

// generate declarations
if (declarations.size() > 0) {
ostr() << std::endl;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp